2017-12-07 12:50:32 +00:00
|
|
|
# RUN: not llvm-mc -triple=riscv64 -mattr=+c < %s 2>&1 | FileCheck %s
|
|
|
|
|
|
|
|
## GPRC
|
|
|
|
c.ld ra, 4(sp) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction
|
|
|
|
c.sd sp, 4(sp) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction
|
2017-12-13 09:32:55 +00:00
|
|
|
c.addw a0, a7 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
|
|
|
|
c.subw a0, a6 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
|
2017-12-07 12:50:32 +00:00
|
|
|
|
|
|
|
## GPRNoX0
|
|
|
|
c.ldsp x0, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
|
|
|
|
c.ldsp zero, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
|
|
|
|
|
|
|
|
# Out of range immediates
|
|
|
|
|
2017-12-15 10:20:51 +00:00
|
|
|
## uimmlog2xlennonzero
|
|
|
|
c.slli t0, 64 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
|
|
|
|
c.srli a0, -1 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
|
|
|
|
c.srai a0, 0 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [1, 63]
|
|
|
|
|
2017-12-13 09:32:55 +00:00
|
|
|
## simm6
|
|
|
|
c.addiw t0, -33 # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
|
|
|
|
c.addiw t0, 32 # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
|
[RISCV][MC] Reject bare symbols for the simm6 and simm6nonzero operand types
Summary:
Fixed assertions due to invalid fixup when encoding compressed instructions
(c.addi, c.addiw, c.li, c.andi) with bare symbols with/without modifiers.
This matches GAS behavior as well.
This bug was uncovered by a LLVM MC Disassembler Protocol Buffer Fuzzer
for the RISC-V assembly language.
Reviewers: asb
Reviewed By: asb
Subscribers: rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, asb
Differential Revision: https://reviews.llvm.org/D52005
llvm-svn: 342160
2018-09-13 18:37:23 +00:00
|
|
|
c.addiw t0, foo # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
|
|
|
|
c.addiw t0, %lo(foo) # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
|
|
|
|
c.addiw t0, %hi(foo) # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [-32, 31]
|
2017-12-13 09:32:55 +00:00
|
|
|
|
2017-12-07 12:50:32 +00:00
|
|
|
## uimm9_lsb000
|
|
|
|
c.ldsp ra, 512(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 8 bytes in the range [0, 504]
|
|
|
|
c.sdsp ra, -8(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 8 bytes in the range [0, 504]
|
|
|
|
## uimm8_lsb000
|
|
|
|
c.ld s0, -8(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 8 bytes in the range [0, 248]
|
|
|
|
c.sd s0, 256(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 8 bytes in the range [0, 248]
|