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