[llvm] 07d1996 - [VE] Support register aliases in llvm-mc
Kazushi Marukawa via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 29 07:28:42 PDT 2020
Author: Kazushi (Jam) Marukawa
Date: 2020-10-29T23:28:32+09:00
New Revision: 07d199660104b3e2e5e6e3f06412cfe66f9a6b61
URL: https://github.com/llvm/llvm-project/commit/07d199660104b3e2e5e6e3f06412cfe66f9a6b61
DIFF: https://github.com/llvm/llvm-project/commit/07d199660104b3e2e5e6e3f06412cfe66f9a6b61.diff
LOG: [VE] Support register aliases in llvm-mc
Support register aliases in MC layer to compile existing assembly
files with clang and integrated assembler.
Reviewed By: simoll
Differential Revision: https://reviews.llvm.org/D90383
Added:
llvm/test/MC/VE/register.s
Modified:
llvm/lib/Target/VE/VERegisterInfo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/VE/VERegisterInfo.td b/llvm/lib/Target/VE/VERegisterInfo.td
index 312796143b2f..4e0efc302b48 100644
--- a/llvm/lib/Target/VE/VERegisterInfo.td
+++ b/llvm/lib/Target/VE/VERegisterInfo.td
@@ -112,10 +112,21 @@ foreach I = 0-63 in
DwarfRegNum<[I]>;
// Generic integer registers - 64 bits wide
-let SubRegIndices = [sub_i32, sub_f32], CoveredBySubRegs = 1 in
-foreach I = 0-63 in
- def SX#I : VEReg<I, "s"#I, [!cast<VEReg>("SW"#I), !cast<VEReg>("SF"#I)],
- ["s"#I]>, DwarfRegNum<[I]>;
+let SubRegIndices = [sub_i32, sub_f32], CoveredBySubRegs = 1 in {
+ // Several registers have specific names, so add them to one of aliases.
+ def SX8 : VEReg<8, "s8", [SW8, SF8], ["s8", "sl"]>, DwarfRegNum<[8]>;
+ def SX9 : VEReg<9, "s9", [SW9, SF9], ["s9", "fp"]>, DwarfRegNum<[9]>;
+ def SX10 : VEReg<10, "s10", [SW10, SF10], ["s10", "lr"]>, DwarfRegNum<[10]>;
+ def SX11 : VEReg<11, "s11", [SW11, SF11], ["s11", "sp"]>, DwarfRegNum<[11]>;
+ def SX14 : VEReg<14, "s14", [SW14, SF14], ["s14", "tp"]>, DwarfRegNum<[14]>;
+ def SX15 : VEReg<15, "s15", [SW15, SF15], ["s15", "got"]>, DwarfRegNum<[15]>;
+ def SX16 : VEReg<16, "s16", [SW16, SF16], ["s16", "plt"]>, DwarfRegNum<[16]>;
+
+ // Other generic registers.
+ foreach I = { 0-7, 12-13, 17-63 } in
+ def SX#I : VEReg<I, "s"#I, [!cast<VEReg>("SW"#I), !cast<VEReg>("SF"#I)],
+ ["s"#I]>, DwarfRegNum<[I]>;
+}
// Aliases of the S* registers used to hold 128-bit for values (long doubles).
// Following foreach represents something like:
diff --git a/llvm/test/MC/VE/register.s b/llvm/test/MC/VE/register.s
new file mode 100644
index 000000000000..f2451785b72f
--- /dev/null
+++ b/llvm/test/MC/VE/register.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc -triple=ve %s -o - | FileCheck %s
+# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
+# RUN: | FileCheck %s --check-prefixes=CHECK-INST
+
+### Test registers with specific names like "%sp"
+
+ subu.l %fp, %sp, %s0
+ brge.l.t %sp, %sl, 1f
+ ld %s63, 0x18(,%tp)
+1:
+ or %got, 0, %plt
+ b.l (,%lr)
+
+
+# CHECK: subu.l %s9, %s11, %s0
+# CHECK-NEXT: brge.l.t %s11, %s8, .Ltmp0
+# CHECK-NEXT: ld %s63, 24(, %s14)
+# CHECK-NEXT: .Ltmp0:
+# CHECK-NEXT: or %s15, 0, %s16
+# CHECK-NEXT: b.l (, %s10)
+
+# CHECK-INST: subu.l %s9, %s11, %s0
+# CHECK-INST-NEXT: brge.l.t %s11, %s8, 16
+# CHECK-INST-NEXT: ld %s63, 24(, %s14)
+# CHECK-INST-NEXT: or %s15, 0, %s16
+# CHECK-INST-NEXT: b.l (, %s10)
More information about the llvm-commits
mailing list