diff options
author | Jozef Lawrynowicz <jozef.l@mittosystems.com> | 2019-06-16 21:24:56 +0000 |
---|---|---|
committer | Jozef Lawrynowicz <jozefl@gcc.gnu.org> | 2019-06-16 21:24:56 +0000 |
commit | 0fcc78f79e85b816480e0425cc8d7c496e739e88 (patch) | |
tree | 588d5986dd2a505d0fff820371c546025752c25e /libgcc | |
parent | 1409f3b0f39baa489d4cc467a3489dfe78653ec4 (diff) | |
download | gcc-0fcc78f79e85b816480e0425cc8d7c496e739e88.zip gcc-0fcc78f79e85b816480e0425cc8d7c496e739e88.tar.gz gcc-0fcc78f79e85b816480e0425cc8d7c496e739e88.tar.bz2 |
MSP430: Implement 64-bit shifts in assembly code
gcc/ChangeLog:
2019-06-16 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* config/msp430/msp430.c (msp430_expand_helper): Setup arguments which
describe how to perform MSPABI compliant 64-bit shift.
* config/msp430/msp430.md (ashldi3): New define_expand.
(ashrdi3): New define_expand.
(lshrdi3): New define_expand.
libgcc/ChangeLog:
2019-06-16 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* config/msp430/slli.S (__mspabi_sllll): New library function for
performing a logical left shift of a 64-bit value.
* config/msp430/srai.S (__mspabi_srall): New library function for
performing a arithmetic right shift of a 64-bit value.
* config/msp430/srll.S (__mspabi_srlll): New library function for
performing a logical right shift of a 64-bit value.
gcc/testsuite/ChangeLog:
2019-06-16 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc.target/msp430/mspabi_sllll.c: New test.
* gcc.target/msp430/mspabi_srall.c: New test.
* gcc.target/msp430/mspabi_srlll.c: New test.
* gcc.c-torture/execute/shiftdi-2.c: New test.
From-SVN: r272360
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/ChangeLog | 9 | ||||
-rw-r--r-- | libgcc/config/msp430/slli.S | 33 | ||||
-rw-r--r-- | libgcc/config/msp430/srai.S | 34 | ||||
-rw-r--r-- | libgcc/config/msp430/srli.S | 35 |
4 files changed, 111 insertions, 0 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 959776d..fee8b38 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,12 @@ +2019-06-16 Jozef Lawrynowicz <jozef.l@mittosystems.com> + + * config/msp430/slli.S (__mspabi_sllll): New library function for + performing a logical left shift of a 64-bit value. + * config/msp430/srai.S (__mspabi_srall): New library function for + performing a arithmetic right shift of a 64-bit value. + * config/msp430/srll.S (__mspabi_srlll): New library function for + performing a logical right shift of a 64-bit value. + 2019-06-14 Matt Thomas <matt@3am-software.com> Matthew Green <mrg@eterna.com.au> Nick Hudson <skrll@netbsd.org> diff --git a/libgcc/config/msp430/slli.S b/libgcc/config/msp430/slli.S index 89ca35a..9210fe6 100644 --- a/libgcc/config/msp430/slli.S +++ b/libgcc/config/msp430/slli.S @@ -110,3 +110,36 @@ __mspabi_slll: RET #endif +/* Logical Left Shift - R8:R11 -> R12:R15 + A 64-bit argument would normally be passed in R12:R15, but __mspabi_sllll has + special conventions, so the 64-bit value to shift is passed in R8:R11. + According to the MSPABI, the shift amount is a 64-bit value in R12:R15, but + we only use the low word in R12. */ + + .section .text.__mspabi_sllll + .global __mspabi_sllll +__mspabi_sllll: + MOV R11, R15 ; Free up R11 first + MOV R12, R11 ; Save the shift amount in R11 + MOV R10, R14 + MOV R9, R13 + MOV R8, R12 + CMP #0,R11 + JNZ 1f +#ifdef __MSP430X_LARGE__ + RETA +#else + RET +#endif +1: + RLA R12 + RLC R13 + RLC R14 + RLC R15 + ADD #-1,R11 + JNZ 1b +#ifdef __MSP430X_LARGE__ + RETA +#else + RET +#endif diff --git a/libgcc/config/msp430/srai.S b/libgcc/config/msp430/srai.S index 564f798..ed5c6a5 100644 --- a/libgcc/config/msp430/srai.S +++ b/libgcc/config/msp430/srai.S @@ -108,3 +108,37 @@ __mspabi_sral: #else RET #endif + +/* Arithmetic Right Shift - R8:R11 -> R12:R15 + A 64-bit argument would normally be passed in R12:R15, but __mspabi_srall has + special conventions, so the 64-bit value to shift is passed in R8:R11. + According to the MSPABI, the shift amount is a 64-bit value in R12:R15, but + we only use the low word in R12. */ + + .section .text.__mspabi_srall + .global __mspabi_srall +__mspabi_srall: + MOV R11, R15 ; Free up R11 first + MOV R12, R11 ; Save the shift amount in R11 + MOV R10, R14 + MOV R9, R13 + MOV R8, R12 + CMP #0, R11 + JNZ 1f +#ifdef __MSP430X_LARGE__ + RETA +#else + RET +#endif +1: + RRA R15 + RRC R14 + RRC R13 + RRC R12 + ADD #-1,R11 + JNZ 1b +#ifdef __MSP430X_LARGE__ + RETA +#else + RET +#endif diff --git a/libgcc/config/msp430/srli.S b/libgcc/config/msp430/srli.S index 4dd32ea..bc1b034 100644 --- a/libgcc/config/msp430/srli.S +++ b/libgcc/config/msp430/srli.S @@ -112,3 +112,38 @@ __mspabi_srll: #else RET #endif + +/* Logical Right Shift - R8:R11 -> R12:R15 + A 64-bit argument would normally be passed in R12:R15, but __mspabi_srlll has + special conventions, so the 64-bit value to shift is passed in R8:R11. + According to the MSPABI, the shift amount is a 64-bit value in R12:R15, but + we only use the low word in R12. */ + + .section .text.__mspabi_srlll + .global __mspabi_srlll +__mspabi_srlll: + MOV R11, R15 ; Free up R11 first + MOV R12, R11 ; Save the shift amount in R11 + MOV R10, R14 + MOV R9, R13 + MOV R8, R12 + CMP #0,R11 + JNZ 1f +#ifdef __MSP430X_LARGE__ + RETA +#else + RET +#endif +1: + CLRC + RRC R15 + RRC R14 + RRC R13 + RRC R12 + ADD #-1,R11 + JNZ 1b +#ifdef __MSP430X_LARGE__ + RETA +#else + RET +#endif |