Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame^] | 1 | From c2b64f2f7a06231d8da0a53c6761939583ac56da Mon Sep 17 00:00:00 2001 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
| 3 | Date: Tue, 17 Jan 2017 18:07:24 +0530 |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame^] | 4 | Subject: [PATCH 24/63] [PATCH] microblaze.md: Improve 'adddi3' and 'subdi3' |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 5 | insn definitions Change adddi3 to handle DI immediates as the second operand, |
| 6 | this requires modification to the output template however reduces the need to |
| 7 | specify seperate templates for 16-bit positive/negative immediate operands. |
| 8 | The use of 32-bit immediates for the addi and addic instructions is handled |
| 9 | by the assembler, which will emit the imm instructions when required. This |
| 10 | conveniently handles the optimizable cases where the immediate constant value |
| 11 | does not need the higher half words of the operands upper/lower words. |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 12 | |
| 13 | Change the constraints of the subdi3 instruction definition such that it |
| 14 | does not match the second operand as an immediate value. This is because |
| 15 | there is no definition to handle this case nor is it possible to |
| 16 | implement purely with instructions as microblaze does not provide an |
| 17 | instruction to perform a forward arithmetic subtraction (it only |
| 18 | provides reverse 'rD = IMM - rA'). |
| 19 | |
| 20 | Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 21 | --- |
| 22 | gcc/config/microblaze/microblaze.md | 13 ++++++------- |
| 23 | 1 file changed, 6 insertions(+), 7 deletions(-) |
| 24 | |
| 25 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame^] | 26 | index 1fb5582..216219b 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 27 | --- a/gcc/config/microblaze/microblaze.md |
| 28 | +++ b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame^] | 29 | @@ -502,17 +502,16 @@ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 30 | ;; Adding 2 DI operands in register or reg/imm |
| 31 | |
| 32 | (define_insn "adddi3" |
| 33 | - [(set (match_operand:DI 0 "register_operand" "=d,d,d") |
| 34 | - (plus:DI (match_operand:DI 1 "register_operand" "%d,d,d") |
| 35 | - (match_operand:DI 2 "arith_operand32" "d,P,N")))] |
| 36 | + [(set (match_operand:DI 0 "register_operand" "=d,d") |
| 37 | + (plus:DI (match_operand:DI 1 "register_operand" "%d,d") |
| 38 | + (match_operand:DI 2 "arith_operand" "d,i")))] |
| 39 | "" |
| 40 | "@ |
| 41 | add\t%L0,%L1,%L2\;addc\t%M0,%M1,%M2 |
| 42 | - addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0 |
| 43 | - addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0\;addi\t%M0,%M0,-1" |
| 44 | + addi\t%L0,%L1,%j2\;addic\t%M0,%M1,%h2" |
| 45 | [(set_attr "type" "darith") |
| 46 | (set_attr "mode" "DI") |
| 47 | - (set_attr "length" "8,8,12")]) |
| 48 | + (set_attr "length" "8,8")]) |
| 49 | |
| 50 | ;;---------------------------------------------------------------- |
| 51 | ;; Subtraction |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame^] | 52 | @@ -549,7 +548,7 @@ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 53 | (define_insn "subdi3" |
| 54 | [(set (match_operand:DI 0 "register_operand" "=&d") |
| 55 | (minus:DI (match_operand:DI 1 "register_operand" "d") |
| 56 | - (match_operand:DI 2 "arith_operand32" "d")))] |
| 57 | + (match_operand:DI 2 "register_operand" "d")))] |
| 58 | "" |
| 59 | "rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1" |
| 60 | [(set_attr "type" "darith") |
| 61 | -- |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 62 | 2.7.4 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 63 | |