Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 1 | From 341bf8ad4e55693d00d4d8c916f4c347e7186dd4 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 3 | Date: Wed, 18 Jan 2017 12:14:51 +0530 |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 4 | Subject: [PATCH 29/58] [Patch, microblaze]: Add new bit-field instructions |
| 5 | |
| 6 | This patches adds new bsefi and bsifi instructions. |
| 7 | BSEFI- The instruction shall extract a bit field from a |
| 8 | register and place it right-adjusted in the destination register. |
| 9 | The other bits in the destination register shall be set to zero |
| 10 | BSIFI- The instruction shall insert a right-adjusted bit field |
| 11 | from a register at another position in the destination register. |
| 12 | The rest of the bits in the destination register shall be unchanged |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 13 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 14 | Signed-off-by :Nagaraju Mekala <nmekala@xilix.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 15 | |
| 16 | ChangeLog: |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 17 | 2016-02-03 Nagaraju Mekala <nmekala@xilix.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 18 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 19 | *microblaze.md (Update): Added new patterns |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 20 | --- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 21 | gcc/config/microblaze/microblaze.h | 2 + |
| 22 | gcc/config/microblaze/microblaze.md | 73 +++++++++++++++++++++++++++++ |
| 23 | 2 files changed, 75 insertions(+) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 24 | |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 25 | diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h |
| 26 | index 8b0db2c1718..b5b7b22cec9 100644 |
| 27 | --- a/gcc/config/microblaze/microblaze.h |
| 28 | +++ b/gcc/config/microblaze/microblaze.h |
| 29 | @@ -44,6 +44,7 @@ extern int microblaze_dbx_regno[]; |
| 30 | |
| 31 | extern int microblaze_no_unsafe_delay; |
| 32 | extern int microblaze_has_clz; |
| 33 | +extern int microblaze_has_bitfield; |
| 34 | extern enum pipeline_type microblaze_pipe; |
| 35 | |
| 36 | #define OBJECT_FORMAT_ELF |
| 37 | @@ -62,6 +63,7 @@ extern enum pipeline_type microblaze_pipe; |
| 38 | |
| 39 | /* Do we have CLZ? */ |
| 40 | #define TARGET_HAS_CLZ (TARGET_PATTERN_COMPARE && microblaze_has_clz) |
| 41 | +#define TARGET_HAS_BITFIELD (TARGET_BARREL_SHIFT && microblaze_has_bitfield) |
| 42 | |
| 43 | /* The default is to support PIC. */ |
| 44 | #define TARGET_SUPPORTS_PIC 1 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 45 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 46 | index c407a81c51e..fa6aabdb9d4 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 47 | --- a/gcc/config/microblaze/microblaze.md |
| 48 | +++ b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 49 | @@ -982,6 +982,8 @@ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 50 | (set_attr "mode" "DI") |
| 51 | (set_attr "length" "20,20,20")]) |
| 52 | |
| 53 | + |
| 54 | + |
| 55 | ;;---------------------------------------------------------------- |
| 56 | ;; Data movement |
| 57 | ;;---------------------------------------------------------------- |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 58 | @@ -1776,6 +1778,7 @@ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 59 | (set_attr "length" "28")] |
| 60 | ) |
| 61 | |
| 62 | + |
| 63 | ;;---------------------------------------------------------------- |
| 64 | ;; Setting a register from an integer comparison. |
| 65 | ;;---------------------------------------------------------------- |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 66 | @@ -2489,4 +2492,74 @@ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 67 | DONE; |
| 68 | }") |
| 69 | |
| 70 | +(define_expand "extvsi" |
| 71 | + [(set (match_operand:SI 0 "register_operand" "r") |
| 72 | + (zero_extract:SI (match_operand:SI 1 "register_operand" "r") |
| 73 | + (match_operand:SI 2 "immediate_operand" "I") |
| 74 | + (match_operand:SI 3 "immediate_operand" "I")))] |
| 75 | +"TARGET_HAS_BITFIELD" |
| 76 | +" |
| 77 | +{ |
| 78 | + unsigned HOST_WIDE_INT len = UINTVAL (operands[2]); |
| 79 | + unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]); |
| 80 | + |
| 81 | + if ((len == 0) || (pos + len > 32) ) |
| 82 | + FAIL; |
| 83 | + |
| 84 | + ;;if (!register_operand (operands[1], VOIDmode)) |
| 85 | + ;; FAIL; |
| 86 | + if (operands[0] == operands[1]) |
| 87 | + FAIL; |
| 88 | + if (GET_CODE (operands[1]) == ASHIFT) |
| 89 | + FAIL; |
| 90 | +;; operands[2] = GEN_INT(INTVAL(operands[2])+1 ); |
| 91 | + emit_insn (gen_extv_32 (operands[0], operands[1], |
| 92 | + operands[2], operands[3])); |
| 93 | + DONE; |
| 94 | +}") |
| 95 | + |
| 96 | +(define_insn "extv_32" |
| 97 | + [(set (match_operand:SI 0 "register_operand" "=r") |
| 98 | + (zero_extract:SI (match_operand:SI 1 "register_operand" "r") |
| 99 | + (match_operand:SI 2 "immediate_operand" "I") |
| 100 | + (match_operand:SI 3 "immediate_operand" "I")))] |
| 101 | + "TARGET_HAS_BITFIELD && (UINTVAL (operands[2]) > 0) |
| 102 | + && ((UINTVAL (operands[2]) + UINTVAL (operands[3])) <= 32)" |
| 103 | + "bsefi %0,%1,%2,%3" |
| 104 | + [(set_attr "type" "bshift") |
| 105 | + (set_attr "length" "4")]) |
| 106 | + |
| 107 | +(define_expand "insvsi" |
| 108 | + [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r") |
| 109 | + (match_operand:SI 1 "immediate_operand" "I") |
| 110 | + (match_operand:SI 2 "immediate_operand" "I")) |
| 111 | + (match_operand:SI 3 "register_operand" "r"))] |
| 112 | + "TARGET_HAS_BITFIELD" |
| 113 | + " |
| 114 | +{ |
| 115 | + unsigned HOST_WIDE_INT len = UINTVAL (operands[1]); |
| 116 | + unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]); |
| 117 | + |
| 118 | + if (len <= 0 || pos + len > 32) |
| 119 | + FAIL; |
| 120 | + |
| 121 | + ;;if (!register_operand (operands[0], VOIDmode)) |
| 122 | + ;; FAIL; |
| 123 | + |
| 124 | + emit_insn (gen_insv_32 (operands[0], operands[1], |
| 125 | + operands[2], operands[3])); |
| 126 | + DONE; |
| 127 | +}") |
| 128 | + |
| 129 | +(define_insn "insv_32" |
| 130 | + [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r") |
| 131 | + (match_operand:SI 1 "immediate_operand" "I") |
| 132 | + (match_operand:SI 2 "immediate_operand" "I")) |
| 133 | + (match_operand:SI 3 "register_operand" "r"))] |
| 134 | + "TARGET_HAS_BITFIELD && UINTVAL (operands[1]) > 0 |
| 135 | + && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32" |
| 136 | + "bsifi %0, %3, %1, %2" |
| 137 | + [(set_attr "type" "bshift") |
| 138 | + (set_attr "length" "4")]) |
| 139 | + |
| 140 | (include "sync.md") |
| 141 | -- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 142 | 2.17.1 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 143 | |