diff options
author | Martyn Capewell <martyn.capewell@arm.com> | 2020-07-01 11:01:51 +0100 |
---|---|---|
committer | Jacob Bramley <jacob.bramley@arm.com> | 2020-07-13 20:05:18 +0000 |
commit | 960606b686f59d468f97dfa93b5dba5b2b38cc8f (patch) | |
tree | 3948abaa2c6f91c5259c81ddb1262f662474034f /test | |
parent | 4635261c9edcf4b056f9e1b26052b5612dee61ba (diff) | |
download | vixl-960606b686f59d468f97dfa93b5dba5b2b38cc8f.tar.gz |
Emit pairs of add/sub for larger immediates
For immediates between 12 and 24 bits in size, a pair of add or sub instructions
can be used instead of mov, avoiding the need to allocate a temporary.
Change-Id: I114b4667dcc1bda094652e01d88069d012249dca
Diffstat (limited to 'test')
-rw-r--r-- | test/aarch64/test-disasm-aarch64.cc | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/test/aarch64/test-disasm-aarch64.cc b/test/aarch64/test-disasm-aarch64.cc index 0051d0c7..625ceefb 100644 --- a/test/aarch64/test-disasm-aarch64.cc +++ b/test/aarch64/test-disasm-aarch64.cc @@ -2758,24 +2758,61 @@ TEST(add_sub_macro) { SETUP(); // Add and Sub use their destination register as a scratch if they can. - COMPARE_MACRO(Add(x0, x1, 0x4242), + COMPARE_MACRO(Add(x0, x1, 0x42424242), "mov x0, #0x4242\n" + "movk x0, #0x4242, lsl #16\n" "add x0, x1, x0"); - COMPARE_MACRO(Add(x0, x0, 0x4242), + COMPARE_MACRO(Add(x0, x0, 0x42424242), "mov x16, #0x4242\n" + "movk x16, #0x4242, lsl #16\n" "add x0, x0, x16"); + COMPARE_MACRO(Adds(x0, x1, 0x4242), + "mov x0, #0x4242\n" + "adds x0, x1, x0"); + COMPARE_MACRO(Adds(x0, x0, 0x4242), + "mov x16, #0x4242\n" + "adds x0, x0, x16"); COMPARE_MACRO(Adds(x0, xzr, Operand(w1, SXTW)), "sxtw x0, w1\n" "adds x0, xzr, x0"); - COMPARE_MACRO(Sub(x0, x1, 0x4242), + COMPARE_MACRO(Subs(x0, x1, 0x42424242), "mov x0, #0x4242\n" - "sub x0, x1, x0"); - COMPARE_MACRO(Sub(x0, x0, 0x4242), + "movk x0, #0x4242, lsl #16\n" + "subs x0, x1, x0"); + COMPARE_MACRO(Subs(x0, x0, 0x42424242), "mov x16, #0x4242\n" - "sub x0, x0, x16"); + "movk x16, #0x4242, lsl #16\n" + "subs x0, x0, x16"); + COMPARE_MACRO(Subs(x0, x1, 0x4242), + "mov x0, #0x4242\n" + "subs x0, x1, x0"); + COMPARE_MACRO(Subs(x0, x0, 0x4242), + "mov x16, #0x4242\n" + "subs x0, x0, x16"); COMPARE_MACRO(Subs(x0, xzr, Operand(w1, SXTW)), "sxtw x0, w1\n" "negs x0, x0"); + + // Add and Sub for immediates between 12 and 24 bits emits a pair of + // instructions. + COMPARE_MACRO(Add(x0, x0, 0x4242), + "add x0, x0, #0x242 (578)\n" + "add x0, x0, #0x4000 (16384)"); + COMPARE_MACRO(Add(x0, x1, 0x4242), + "add x0, x1, #0x242 (578)\n" + "add x0, x0, #0x4000 (16384)"); + COMPARE_MACRO(Add(x0, x0, 0xffffff), + "add x0, x0, #0xfff (4095)\n" + "add x0, x0, #0xfff000 (16773120)"); + COMPARE_MACRO(Sub(x0, x0, 0x4242), + "sub x0, x0, #0x242 (578)\n" + "sub x0, x0, #0x4000 (16384)"); + COMPARE_MACRO(Sub(x0, x1, 0x4242), + "sub x0, x1, #0x242 (578)\n" + "sub x0, x0, #0x4000 (16384)"); + COMPARE_MACRO(Sub(x0, x0, 0xffffff), + "sub x0, x0, #0xfff (4095)\n" + "sub x0, x0, #0xfff000 (16773120)"); } TEST(adc_sbc_macro) { |