Luis Marques | c3bf3d1 | 2019-08-21 14:00:58 +0000 | [diff] [blame] | 1 | # RUN: not llvm-mc -triple=riscv32 -mattr=+c -mattr=-rvc-hints < %s 2>&1 \ |
| 2 | # RUN: | FileCheck %s |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 3 | |
| 4 | ## GPRC |
Alex Bradbury | f8f4b90 | 2017-12-07 13:19:57 +0000 | [diff] [blame] | 5 | .LBB: |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 6 | c.lw ra, 4(sp) # CHECK: :[[@LINE]]:7: error: invalid operand for instruction |
| 7 | c.sw sp, 4(sp) # CHECK: :[[@LINE]]:7: error: invalid operand for instruction |
Alex Bradbury | f8f4b90 | 2017-12-07 13:19:57 +0000 | [diff] [blame] | 8 | c.beqz t0, .LBB # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
| 9 | c.bnez s8, .LBB # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 10 | c.addi4spn s4, sp, 12 # CHECK: :[[@LINE]]:13: error: invalid operand for instruction |
| 11 | c.srli s7, 12 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
| 12 | c.srai t0, 12 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
| 13 | c.andi t1, 12 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
| 14 | c.and t1, a0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction |
| 15 | c.or a0, s8 # CHECK: :[[@LINE]]:12: error: invalid operand for instruction |
| 16 | c.xor t2, a0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction |
| 17 | c.sub a0, s8 # CHECK: :[[@LINE]]:12: error: invalid operand for instruction |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 18 | |
| 19 | ## GPRNoX0 |
| 20 | c.lwsp x0, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
| 21 | c.lwsp zero, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
Alex Bradbury | f8f4b90 | 2017-12-07 13:19:57 +0000 | [diff] [blame] | 22 | c.jr x0 # CHECK: :[[@LINE]]:7: error: invalid operand for instruction |
| 23 | c.jalr zero # CHECK: :[[@LINE]]:9: error: invalid operand for instruction |
Luis Marques | c3bf3d1 | 2019-08-21 14:00:58 +0000 | [diff] [blame] | 24 | c.addi x0, x0, 1 # CHECK: :[[@LINE]]:13: error: immediate must be zero |
Simon Cook | a6e50e4 | 2019-12-10 16:44:48 +0000 | [diff] [blame] | 25 | c.li zero, 2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions |
Luis Marques | c3bf3d1 | 2019-08-21 14:00:58 +0000 | [diff] [blame] | 26 | c.slli zero, zero, 4 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction |
Simon Cook | a6e50e4 | 2019-12-10 16:44:48 +0000 | [diff] [blame] | 27 | c.mv zero, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 28 | c.mv ra, x0 # CHECK: :[[@LINE]]:11: error: invalid operand for instruction |
| 29 | c.add ra, ra, x0 # CHECK: :[[@LINE]]:16: error: invalid operand for instruction |
Luis Marques | c3bf3d1 | 2019-08-21 14:00:58 +0000 | [diff] [blame] | 30 | c.add zero, zero, sp # CHECK: :[[@LINE]]:14: error: invalid operand for instruction |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 31 | |
| 32 | ## GPRNoX0X2 |
Simon Cook | a6e50e4 | 2019-12-10 16:44:48 +0000 | [diff] [blame] | 33 | c.lui x0, 4 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 34 | c.lui x2, 4 # CHECK: :[[@LINE]]:7: error: invalid operand for instruction |
| 35 | |
| 36 | ## SP |
| 37 | c.addi4spn a0, a0, 12 # CHECK: :[[@LINE]]:17: error: invalid operand for instruction |
| 38 | c.addi16sp t0, 16 # CHECK: :[[@LINE]]:13: error: invalid operand for instruction |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 39 | |
| 40 | # Out of range immediates |
| 41 | |
Alex Bradbury | 0ad4c26 | 2017-12-15 10:20:51 +0000 | [diff] [blame] | 42 | ## uimmlog2xlennonzero |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 43 | c.slli t0, 64 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 31] |
| 44 | c.srli a0, 32 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 31] |
| 45 | c.srai a0, 0 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 31] |
| 46 | |
| 47 | ## simm6 |
| 48 | c.li t0, 128 # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31] |
Ana Pazos | 065b088 | 2018-09-13 18:37:23 +0000 | [diff] [blame] | 49 | c.li t0, foo # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31] |
| 50 | c.li t0, %lo(foo) # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31] |
| 51 | c.li t0, %hi(foo) # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31] |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 52 | c.andi a0, -33 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31] |
Ana Pazos | 065b088 | 2018-09-13 18:37:23 +0000 | [diff] [blame] | 53 | c.andi a0, foo # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31] |
| 54 | c.andi a0, %lo(foo) # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31] |
| 55 | c.andi a0, %hi(foo) # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31] |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 56 | |
Shiva Chen | b22c1d2 | 2018-02-02 02:43:23 +0000 | [diff] [blame] | 57 | ## simm6nonzero |
Simon Cook | a6e50e4 | 2019-12-10 16:44:48 +0000 | [diff] [blame] | 58 | c.addi t0, 0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions |
Shiva Chen | b22c1d2 | 2018-02-02 02:43:23 +0000 | [diff] [blame] | 59 | c.addi t0, -33 # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31] |
| 60 | c.addi t0, 32 # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31] |
Ana Pazos | 065b088 | 2018-09-13 18:37:23 +0000 | [diff] [blame] | 61 | c.addi t0, foo # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31] |
| 62 | c.addi t0, %lo(foo) # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31] |
| 63 | c.addi t0, %hi(foo) # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31] |
Shiva Chen | b22c1d2 | 2018-02-02 02:43:23 +0000 | [diff] [blame] | 64 | |
Shiva Chen | 7c17242 | 2018-02-22 15:02:28 +0000 | [diff] [blame] | 65 | ## c_lui_imm |
| 66 | c.lui t0, 0 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31] |
| 67 | c.lui t0, 32 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31] |
| 68 | c.lui t0, 0xffffdf # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31] |
| 69 | c.lui t0, 0x1000000 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31] |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 70 | |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 71 | ## uimm8_lsb00 |
| 72 | c.lwsp ra, 256(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 4 bytes in the range [0, 252] |
| 73 | c.swsp ra, -4(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 4 bytes in the range [0, 252] |
| 74 | ## uimm7_lsb00 |
| 75 | c.lw s0, -4(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 4 bytes in the range [0, 124] |
| 76 | c.sw s0, 128(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 4 bytes in the range [0, 124] |
Alex Bradbury | f8f4b90 | 2017-12-07 13:19:57 +0000 | [diff] [blame] | 77 | |
| 78 | ## simm9_lsb0 |
| 79 | c.bnez s1, -258 # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 2 bytes in the range [-256, 254] |
| 80 | c.beqz a0, 256 # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 2 bytes in the range [-256, 254] |
| 81 | |
| 82 | ## simm12_lsb0 |
| 83 | c.j 2048 # CHECK: :[[@LINE]]:5: error: immediate must be a multiple of 2 bytes in the range [-2048, 2046] |
| 84 | c.jal -2050 # CHECK: :[[@LINE]]:7: error: immediate must be a multiple of 2 bytes in the range [-2048, 2046] |
Alex Bradbury | 60714f9 | 2017-12-13 09:32:55 +0000 | [diff] [blame] | 85 | |
| 86 | ## uimm10_lsb00nonzero |
| 87 | c.addi4spn a0, sp, 0 # CHECK: :[[@LINE]]:21: error: immediate must be a multiple of 4 bytes in the range [4, 1020] |
| 88 | c.addi4spn a0, sp, 1024 # CHECK: :[[@LINE]]:21: error: immediate must be a multiple of 4 bytes in the range [4, 1020] |
| 89 | |
Shiva Chen | b22c1d2 | 2018-02-02 02:43:23 +0000 | [diff] [blame] | 90 | ## simm10_lsb0000nonzero |
| 91 | c.addi16sp sp, -528 # CHECK: :[[@LINE]]:17: error: immediate must be a multiple of 16 bytes and non-zero in the range [-512, 496] |
| 92 | c.addi16sp sp, 512 # CHECK: :[[@LINE]]:17: error: immediate must be a multiple of 16 bytes and non-zero in the range [-512, 496] |
| 93 | c.addi16sp sp, 0 # CHECK: :[[@LINE]]:17: error: immediate must be a multiple of 16 bytes and non-zero in the range [-512, 496] |