Skip to content

Commit

Permalink
[RISCV] Allow parsing dot '.' in assembly
Browse files Browse the repository at this point in the history
Summary:
Useful for jumps, such as `j .`.

I am not sure who should review this. Do not hesitate to change the reviewers if needed.

Reviewers: asb, jrtc27, lenary

Reviewed By: lenary

Subscribers: MaskRay, lenary, hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63669

Patch by John LLVM (JohnLLVM)

llvm-svn: 365881
  • Loading branch information
lenary committed Jul 12, 2019
1 parent 4a9a772 commit fafec51
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Expand Up @@ -1119,6 +1119,7 @@ OperandMatchResultTy RISCVAsmParser::parseImmediate(OperandVector &Operands) {
default:
return MatchOperand_NoMatch;
case AsmToken::LParen:
case AsmToken::Dot:
case AsmToken::Minus:
case AsmToken::Plus:
case AsmToken::Exclaim:
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/MC/RISCV/rv32i-aliases-invalid.s
Expand Up @@ -19,5 +19,7 @@ sll x2, x3, -1 # CHECK: :[[@LINE]]:13: error: immediate must be an integer in t
srl x2, x3, -2 # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [0, 31]
sra x2, x3, -3 # CHECK: :[[@LINE]]:13: error: immediate must be an integer in the range [0, 31]

addi x1, . # CHECK: :[[@LINE]]:10: error: invalid operand for instruction

foo:
.space 4
3 changes: 3 additions & 0 deletions llvm/test/MC/RISCV/rv32i-valid.s
Expand Up @@ -90,6 +90,9 @@ jal s0, (0)
# CHECK-ASM-AND-OBJ: jal s0, 156
# CHECK-ASM: encoding: [0x6f,0x04,0xc0,0x09]
jal s0, (0xff-99)
# CHECK-ASM: encoding: [0x6f,0bAAAA0000,A,A]
# CHECK-OBJ: jal zero, 0
jal zero, .

# CHECK-ASM-AND-OBJ: jalr a0, a1, -2048
# CHECK-ASM: encoding: [0x67,0x85,0x05,0x80]
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/MC/RISCV/rvi-aliases-valid.s
Expand Up @@ -117,6 +117,13 @@ j foo
# CHECK-OBJ: j 0
# CHECK-OBJ: R_RISCV_JAL a0
j a0
# CHECK-S-NOALIAS: [[LABEL:.L[[:alnum:]_]+]]:
# CHECK-S-NOALIAS-NEXT: jal zero, [[LABEL]]
# CHECK-S: [[LABEL:.L[[:alnum:]_]+]]:
# CHECK-S-NEXT: j [[LABEL]]
# CHECK-OBJ-NOALIAS: jal zero, 0
# CHECK-OBJ: j 0
j .
# CHECK-S-OBJ-NOALIAS: jal ra, 2040
# CHECK-S-OBJ: jal 2040
jal 2040
Expand Down

0 comments on commit fafec51

Please sign in to comment.