[PATCH] D52005: [RISCV][MC] Reject bare symbols for the simm6 and simm6nonzero operand types
Ana Pazos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 13 11:40:27 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342160: [RISCV][MC] Reject bare symbols for the simm6 and simm6nonzero operand types (authored by apazos, committed by ).
Herald added subscribers: llvm-commits, jrtc27.
Changed prior to commit:
https://reviews.llvm.org/D52005?vs=165338&id=165339#toc
Repository:
rL LLVM
https://reviews.llvm.org/D52005
Files:
llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/trunk/test/MC/RISCV/rv32c-invalid.s
llvm/trunk/test/MC/RISCV/rv64c-invalid.s
Index: llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===================================================================
--- llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -326,29 +326,19 @@
return false;
RISCVMCExpr::VariantKind VK;
int64_t Imm;
- bool IsValid;
bool IsConstantImm = evaluateConstantImm(Imm, VK);
- if (!IsConstantImm)
- IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
- else
- IsValid = isInt<6>(Imm);
- return IsValid &&
- (VK == RISCVMCExpr::VK_RISCV_None || VK == RISCVMCExpr::VK_RISCV_LO);
+ return IsConstantImm && isInt<6>(Imm) &&
+ VK == RISCVMCExpr::VK_RISCV_None;
}
bool isSImm6NonZero() const {
if (!isImm())
return false;
RISCVMCExpr::VariantKind VK;
int64_t Imm;
- bool IsValid;
bool IsConstantImm = evaluateConstantImm(Imm, VK);
- if (!IsConstantImm)
- IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
- else
- IsValid = ((Imm != 0) && isInt<6>(Imm));
- return IsValid &&
- (VK == RISCVMCExpr::VK_RISCV_None || VK == RISCVMCExpr::VK_RISCV_LO);
+ return IsConstantImm && isInt<6>(Imm) && (Imm != 0) &&
+ VK == RISCVMCExpr::VK_RISCV_None;
}
bool isCLUIImm() const {
Index: llvm/trunk/test/MC/RISCV/rv32c-invalid.s
===================================================================
--- llvm/trunk/test/MC/RISCV/rv32c-invalid.s
+++ llvm/trunk/test/MC/RISCV/rv32c-invalid.s
@@ -45,12 +45,21 @@
## simm6
c.li t0, 128 # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31]
+c.li t0, foo # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31]
+c.li t0, %lo(foo) # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31]
+c.li t0, %hi(foo) # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-32, 31]
c.andi a0, -33 # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31]
+c.andi a0, foo # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31]
+c.andi a0, %lo(foo) # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31]
+c.andi a0, %hi(foo) # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31]
## simm6nonzero
c.addi t0, 0 # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
c.addi t0, -33 # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
c.addi t0, 32 # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
+c.addi t0, foo # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
+c.addi t0, %lo(foo) # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
+c.addi t0, %hi(foo) # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
## c_lui_imm
c.lui t0, 0 # CHECK: :[[@LINE]]:11: error: immediate must be in [0xfffe0, 0xfffff] or [1, 31]
Index: llvm/trunk/test/MC/RISCV/rv64c-invalid.s
===================================================================
--- llvm/trunk/test/MC/RISCV/rv64c-invalid.s
+++ llvm/trunk/test/MC/RISCV/rv64c-invalid.s
@@ -20,6 +20,9 @@
## 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]
+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]
## uimm9_lsb000
c.ldsp ra, 512(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 8 bytes in the range [0, 504]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52005.165339.patch
Type: text/x-patch
Size: 4003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180913/d7f12949/attachment-0001.bin>
More information about the llvm-commits
mailing list