[llvm] 638abc2 - [RISCV] Make 'c.addi x0, imm' an alias for 'c.nop imm'.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 6 07:26:07 PST 2023
Author: Craig Topper
Date: 2023-02-06T07:25:56-08:00
New Revision: 638abc270db27a1709890fcdca394bad26f9432b
URL: https://github.com/llvm/llvm-project/commit/638abc270db27a1709890fcdca394bad26f9432b
DIFF: https://github.com/llvm/llvm-project/commit/638abc270db27a1709890fcdca394bad26f9432b.diff
LOG: [RISCV] Make 'c.addi x0, imm' an alias for 'c.nop imm'.
Instead of making it an AsmParserOnly instruction, make it an alias.
This makes printing consistent with disassembly.
Reviewed By: luismarques
Differential Revision: https://reviews.llvm.org/D143362
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfoC.td
llvm/test/MC/RISCV/rvc-hints-valid.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
index bcca73377a335..7475bba9faf0d 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
@@ -614,16 +614,6 @@ def C_NOP_HINT : RVInst16CI<0b000, 0b01, (outs), (ins simm6nonzero:$imm),
let DecoderMethod = "decodeRVCInstrSImm";
}
-// Just a
diff erent syntax for the c.nop hint: c.addi x0, simm6 vs c.nop simm6.
-def C_ADDI_HINT_X0 : RVInst16CI<0b000, 0b01, (outs GPRX0:$rd_wb),
- (ins GPRX0:$rd, simm6nonzero:$imm),
- "c.addi", "$rd, $imm">,
- Sched<[WriteIALU, ReadIALU]> {
- let Constraints = "$rd = $rd_wb";
- let Inst{6-2} = imm{4-0};
- let isAsmParserOnly = 1;
-}
-
def C_ADDI_HINT_IMM_ZERO : RVInst16CI<0b000, 0b01, (outs GPRNoX0:$rd_wb),
(ins GPRNoX0:$rd, immzero:$imm),
"c.addi", "$rd, $imm">,
@@ -712,6 +702,11 @@ def C_SRAI64_HINT : RVInst16CI<0b100, 0b01, (outs GPRC:$rd_wb),
// Assembler Pseudo Instructions
//===----------------------------------------------------------------------===//
+let Predicates = [HasStdExtCOrZca, HasRVCHints] in {
+// Just a
diff erent syntax for the c.nop hint: c.addi x0, simm6 vs c.nop simm6.
+def : InstAlias<"c.addi x0, $imm", (C_NOP_HINT simm6nonzero:$imm), 0>;
+}
+
let Predicates = [HasStdExtC, HasRVCHints, HasStdExtZihintntl] in {
def : InstAlias<"c.ntl.p1", (C_ADD_HINT X0, X2)>;
def : InstAlias<"c.ntl.pall", (C_ADD_HINT X0, X3)>;
diff --git a/llvm/test/MC/RISCV/rvc-hints-valid.s b/llvm/test/MC/RISCV/rvc-hints-valid.s
index 52d3589b10403..ce7bb254b1e98 100644
--- a/llvm/test/MC/RISCV/rvc-hints-valid.s
+++ b/llvm/test/MC/RISCV/rvc-hints-valid.s
@@ -4,21 +4,20 @@
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c < %s \
# RUN: | llvm-objdump -M no-aliases -d -r - \
-# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c < %s \
# RUN: | llvm-objdump -M no-aliases -d -r - \
-# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c < %s \
# RUN: | llvm-objdump -d -r - \
-# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck -check-prefixes=CHECK-ASM-AND-OBJ %s
# CHECK-ASM-AND-OBJ: c.nop 8
# CHECK-ASM: encoding: [0x21,0x00]
c.nop 8
-# CHECK-ASM: c.addi zero, 7
+# CHECK-ASM-AND-OBJ: c.nop 7
# CHECK-ASM: encoding: [0x1d,0x00]
-# CHECK-OBJ: c.nop 7
c.addi x0, 7
# CHECK-ASM-AND-OBJ: c.addi a0, 0
More information about the llvm-commits
mailing list