Skip to content

Commit

Permalink
[RISCV] Fix InsnCI register type (llvm#100113)
Browse files Browse the repository at this point in the history
According to the spec the CI type instructions can take any of the 32
RVI registers.

Fixes llvm#100112
  • Loading branch information
svs-quic authored Jul 23, 2024
1 parent 25952ec commit 1ebfc81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Target/RISCV/RISCVInstrInfoC.td
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,9 @@ def InsnCR : DirectiveInsnCR<(outs AnyReg:$rd), (ins uimm2_opcode:$opcode,
uimm4:$funct4,
AnyReg:$rs2),
"$opcode, $funct4, $rd, $rs2">;
def InsnCI : DirectiveInsnCI<(outs AnyRegC:$rd), (ins uimm2_opcode:$opcode,
uimm3:$funct3,
simm6:$imm6),
def InsnCI : DirectiveInsnCI<(outs AnyReg:$rd), (ins uimm2_opcode:$opcode,
uimm3:$funct3,
simm6:$imm6),
"$opcode, $funct3, $rd, $imm6">;
def InsnCIW : DirectiveInsnCIW<(outs AnyRegC:$rd), (ins uimm2_opcode:$opcode,
uimm3:$funct3,
Expand Down Expand Up @@ -818,7 +818,7 @@ def : InstAlias<".insn_cr $opcode, $funct4, $rd, $rs2",
(InsnCR AnyReg:$rd, uimm2_opcode:$opcode, uimm4:$funct4,
AnyReg:$rs2)>;
def : InstAlias<".insn_ci $opcode, $funct3, $rd, $imm6",
(InsnCI AnyRegC:$rd, uimm2_opcode:$opcode, uimm3:$funct3,
(InsnCI AnyReg:$rd, uimm2_opcode:$opcode, uimm3:$funct3,
simm6:$imm6)>;
def : InstAlias<".insn_ciw $opcode, $funct3, $rd, $imm8",
(InsnCIW AnyRegC:$rd, uimm2_opcode:$opcode, uimm3:$funct3,
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/MC/RISCV/insn_c.s
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ target:
# CHECK-OBJ: c.addi a0, 0xd
.insn ci C1, 0, a0, 13

# CHECK-ASM: .insn ci 1, 0, a6, 13
# CHECK-ASM: encoding: [0x35,0x08]
# CHECK-OBJ: c.addi a6, 0xd
.insn ci 1, 0, a6, 13

# CHECK-ASM: .insn ci 1, 0, a6, 13
# CHECK-ASM: encoding: [0x35,0x08]
# CHECK-OBJ: c.addi a6, 0xd
.insn ci C1, 0, a6, 13

# CHECK-ASM: .insn ciw 0, 0, a0, 13
# CHECK-ASM: encoding: [0xa8,0x01]
# CHECK-OBJ: c.addi4spn a0, sp, 0xc8
Expand Down

0 comments on commit 1ebfc81

Please sign in to comment.