Skip to content

Commit b79c33e

Browse files
author
Jim Grosbach
committed
ARM: More InstAlias refactors to use #NAME#.
llvm-svn: 161220
1 parent 99fc2e1 commit b79c33e

File tree

1 file changed

+27
-42
lines changed

1 file changed

+27
-42
lines changed

llvm/lib/Target/ARM/ARMInstrThumb2.td

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,7 @@ multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
803803

804804
/// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
805805
// rotate operation that produces a value.
806-
multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, PatFrag opnode,
807-
string baseOpc> {
806+
multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, PatFrag opnode> {
808807
// 5-bit imm
809808
def ri : T2sTwoRegShiftImm<
810809
(outs rGPR:$Rd), (ins rGPR:$Rm, ty:$imm), IIC_iMOVsi,
@@ -829,41 +828,35 @@ multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, PatFrag opnode,
829828

830829
// Optional destination register
831830
def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"),
832-
(!cast<Instruction>(!strconcat(baseOpc, "ri")) rGPR:$Rdn, rGPR:$Rdn,
833-
ty:$imm, pred:$p,
834-
cc_out:$s)>;
831+
(!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
832+
cc_out:$s)>;
835833
def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"),
836-
(!cast<Instruction>(!strconcat(baseOpc, "rr")) rGPR:$Rdn, rGPR:$Rdn,
837-
rGPR:$Rm, pred:$p,
838-
cc_out:$s)>;
834+
(!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
835+
cc_out:$s)>;
839836

840837
// Assembler aliases w/o the ".w" suffix.
841838
def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $imm"),
842-
(!cast<Instruction>(!strconcat(baseOpc, "ri")) rGPR:$Rd, rGPR:$Rn,
843-
ty:$imm, pred:$p,
844-
cc_out:$s)>;
839+
(!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, ty:$imm, pred:$p,
840+
cc_out:$s)>;
845841
def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
846-
(!cast<Instruction>(!strconcat(baseOpc, "rr")) rGPR:$Rd, rGPR:$Rn,
847-
rGPR:$Rm, pred:$p,
848-
cc_out:$s)>;
842+
(!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
843+
cc_out:$s)>;
849844

850845
// and with the optional destination operand, too.
851846
def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $imm"),
852-
(!cast<Instruction>(!strconcat(baseOpc, "ri")) rGPR:$Rdn, rGPR:$Rdn,
853-
ty:$imm, pred:$p,
854-
cc_out:$s)>;
847+
(!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
848+
cc_out:$s)>;
855849
def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
856-
(!cast<Instruction>(!strconcat(baseOpc, "rr")) rGPR:$Rdn, rGPR:$Rdn,
857-
rGPR:$Rm, pred:$p,
858-
cc_out:$s)>;
850+
(!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
851+
cc_out:$s)>;
859852
}
860853

861854
/// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
862855
/// patterns. Similar to T2I_bin_irs except the instruction does not produce
863856
/// a explicit result, only implicitly set CPSR.
864857
multiclass T2I_cmp_irs<bits<4> opcod, string opc,
865858
InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
866-
PatFrag opnode, string baseOpc> {
859+
PatFrag opnode> {
867860
let isCompare = 1, Defs = [CPSR] in {
868861
// shifted imm
869862
def ri : T2OneRegCmpImm<
@@ -908,12 +901,9 @@ let isCompare = 1, Defs = [CPSR] in {
908901
// No alias here for 'rr' version as not all instantiations of this
909902
// multiclass want one (CMP in particular, does not).
910903
def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $imm"),
911-
(!cast<Instruction>(!strconcat(baseOpc, "ri")) GPRnopc:$Rn,
912-
t2_so_imm:$imm, pred:$p)>;
904+
(!cast<Instruction>(NAME#"ri") GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
913905
def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $shift"),
914-
(!cast<Instruction>(!strconcat(baseOpc, "rs")) GPRnopc:$Rn,
915-
t2_so_reg:$shift,
916-
pred:$p)>;
906+
(!cast<Instruction>(NAME#"rs") GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
917907
}
918908

919909
/// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
@@ -2147,13 +2137,13 @@ def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
21472137
//
21482138

21492139
defm t2LSL : T2I_sh_ir<0b00, "lsl", imm0_31,
2150-
BinOpFrag<(shl node:$LHS, node:$RHS)>, "t2LSL">;
2140+
BinOpFrag<(shl node:$LHS, node:$RHS)>>;
21512141
defm t2LSR : T2I_sh_ir<0b01, "lsr", imm_sr,
2152-
BinOpFrag<(srl node:$LHS, node:$RHS)>, "t2LSR">;
2142+
BinOpFrag<(srl node:$LHS, node:$RHS)>>;
21532143
defm t2ASR : T2I_sh_ir<0b10, "asr", imm_sr,
2154-
BinOpFrag<(sra node:$LHS, node:$RHS)>, "t2ASR">;
2144+
BinOpFrag<(sra node:$LHS, node:$RHS)>>;
21552145
defm t2ROR : T2I_sh_ir<0b11, "ror", imm0_31,
2156-
BinOpFrag<(rotr node:$LHS, node:$RHS)>, "t2ROR">;
2146+
BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
21572147

21582148
// (rotr x, (and y, 0x...1f)) ==> (ROR x, y)
21592149
def : T2Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)),
@@ -2871,7 +2861,7 @@ def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
28712861
//
28722862
defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
28732863
IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
2874-
BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>, "t2CMP">;
2864+
BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
28752865

28762866
def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_imm:$imm),
28772867
(t2CMPri GPRnopc:$lhs, t2_so_imm:$imm)>;
@@ -2925,13 +2915,10 @@ let isCompare = 1, Defs = [CPSR] in {
29252915
// Assembler aliases w/o the ".w" suffix.
29262916
// No alias here for 'rr' version as not all instantiations of this multiclass
29272917
// want one (CMP in particular, does not).
2928-
def : t2InstAlias<!strconcat("cmn", "${p}", " $Rn, $imm"),
2929-
(!cast<Instruction>(!strconcat("t2CMN", "ri")) GPRnopc:$Rn,
2930-
t2_so_imm:$imm, pred:$p)>;
2931-
def : t2InstAlias<!strconcat("cmn", "${p}", " $Rn, $shift"),
2932-
(!cast<Instruction>(!strconcat("t2CMNz", "rs")) GPRnopc:$Rn,
2933-
t2_so_reg:$shift,
2934-
pred:$p)>;
2918+
def : t2InstAlias<"cmn${p} $Rn, $imm",
2919+
(t2CMNri GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
2920+
def : t2InstAlias<"cmn${p} $Rn, $shift",
2921+
(t2CMNzrs GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
29352922

29362923
def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
29372924
(t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
@@ -2941,12 +2928,10 @@ def : T2Pat<(ARMcmpZ GPRnopc:$src, t2_so_imm_neg:$imm),
29412928

29422929
defm t2TST : T2I_cmp_irs<0b0000, "tst",
29432930
IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
2944-
BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>,
2945-
"t2TST">;
2931+
BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>>;
29462932
defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
29472933
IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
2948-
BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>,
2949-
"t2TEQ">;
2934+
BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>>;
29502935

29512936
// Conditional moves
29522937
// FIXME: should be able to write a pattern for ARMcmov, but can't use

0 commit comments

Comments
 (0)