Skip to content

Commit 7deb8ce

Browse files
committed
[mips] Joint MipsMemSimmXXXAsmOperand into the single template class. NFC
1 parent 2fcf3e9 commit 7deb8ce

File tree

2 files changed

+14
-60
lines changed

2 files changed

+14
-60
lines changed

llvm/lib/Target/Mips/MicroMipsInstrInfo.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ def mem_mm_9 : Operand<i32> {
116116
let PrintMethod = "printMemOperand";
117117
let MIOperandInfo = (ops ptr_rc, simm9);
118118
let EncoderMethod = "getMemEncodingMMImm9";
119-
let ParserMatchClass = MipsMemSimm9AsmOperand;
119+
let ParserMatchClass = MipsMemSimmAsmOperand<9>;
120120
let OperandType = "OPERAND_MEMORY";
121121
}
122122

123123
def mem_mm_11 : Operand<i32> {
124124
let PrintMethod = "printMemOperand";
125125
let MIOperandInfo = (ops GPR32, simm11);
126126
let EncoderMethod = "getMemEncodingMMImm11";
127-
let ParserMatchClass = MipsMemSimm11AsmOperand;
127+
let ParserMatchClass = MipsMemSimmAsmOperand<11>;
128128
let OperandType = "OPERAND_MEMORY";
129129
}
130130

@@ -141,7 +141,7 @@ def mem_mm_16 : Operand<i32> {
141141
let MIOperandInfo = (ops ptr_rc, simm16);
142142
let EncoderMethod = "getMemEncodingMMImm16";
143143
let DecoderMethod = "DecodeMemMMImm16";
144-
let ParserMatchClass = MipsMemSimm16AsmOperand;
144+
let ParserMatchClass = MipsMemSimmAsmOperand<16>;
145145
let OperandType = "OPERAND_MEMORY";
146146
}
147147

llvm/lib/Target/Mips/MipsInstrInfo.td

Lines changed: 11 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,59 +1086,14 @@ def MipsMemAsmOperand : AsmOperandClass {
10861086
let ParserMethod = "parseMemOperand";
10871087
}
10881088

1089-
def MipsMemSimm9AsmOperand : AsmOperandClass {
1090-
let Name = "MemOffsetSimm9";
1089+
class MipsMemSimmAsmOperand<int Width, int Shift = 0> : AsmOperandClass {
1090+
let Name = "MemOffsetSimm" # Width # "_" # Shift;
10911091
let SuperClasses = [MipsMemAsmOperand];
10921092
let RenderMethod = "addMemOperands";
10931093
let ParserMethod = "parseMemOperand";
1094-
let PredicateMethod = "isMemWithSimmOffset<9>";
1095-
let DiagnosticType = "MemSImm9";
1096-
}
1097-
1098-
def MipsMemSimm10AsmOperand : AsmOperandClass {
1099-
let Name = "MemOffsetSimm10";
1100-
let SuperClasses = [MipsMemAsmOperand];
1101-
let RenderMethod = "addMemOperands";
1102-
let ParserMethod = "parseMemOperand";
1103-
let PredicateMethod = "isMemWithSimmOffset<10>";
1104-
let DiagnosticType = "MemSImm10";
1105-
}
1106-
1107-
def MipsMemSimm12AsmOperand : AsmOperandClass {
1108-
let Name = "MemOffsetSimm12";
1109-
let SuperClasses = [MipsMemAsmOperand];
1110-
let RenderMethod = "addMemOperands";
1111-
let ParserMethod = "parseMemOperand";
1112-
let PredicateMethod = "isMemWithSimmOffset<12>";
1113-
let DiagnosticType = "MemSImm12";
1114-
}
1115-
1116-
foreach I = {1, 2, 3} in
1117-
def MipsMemSimm10Lsl # I # AsmOperand : AsmOperandClass {
1118-
let Name = "MemOffsetSimm10_" # I;
1119-
let SuperClasses = [MipsMemAsmOperand];
1120-
let RenderMethod = "addMemOperands";
1121-
let ParserMethod = "parseMemOperand";
1122-
let PredicateMethod = "isMemWithSimmOffset<10, " # I # ">";
1123-
let DiagnosticType = "MemSImm10Lsl" # I;
1124-
}
1125-
1126-
def MipsMemSimm11AsmOperand : AsmOperandClass {
1127-
let Name = "MemOffsetSimm11";
1128-
let SuperClasses = [MipsMemAsmOperand];
1129-
let RenderMethod = "addMemOperands";
1130-
let ParserMethod = "parseMemOperand";
1131-
let PredicateMethod = "isMemWithSimmOffset<11>";
1132-
let DiagnosticType = "MemSImm11";
1133-
}
1134-
1135-
def MipsMemSimm16AsmOperand : AsmOperandClass {
1136-
let Name = "MemOffsetSimm16";
1137-
let SuperClasses = [MipsMemAsmOperand];
1138-
let RenderMethod = "addMemOperands";
1139-
let ParserMethod = "parseMemOperand";
1140-
let PredicateMethod = "isMemWithSimmOffset<16>";
1141-
let DiagnosticType = "MemSImm16";
1094+
let PredicateMethod = "isMemWithSimmOffset<" # Width # ", " # Shift # ">";
1095+
let DiagnosticType = !if(!eq(Shift, 0), "MemSImm" # Width,
1096+
"MemSImm" # Width # "Lsl" # Shift);
11421097
}
11431098

11441099
def MipsMemSimmPtrAsmOperand : AsmOperandClass {
@@ -1188,39 +1143,38 @@ def simm12 : Operand<i32> {
11881143
def mem_simm9 : mem_generic {
11891144
let MIOperandInfo = (ops ptr_rc, simm9);
11901145
let EncoderMethod = "getMemEncoding";
1191-
let ParserMatchClass = MipsMemSimm9AsmOperand;
1146+
let ParserMatchClass = MipsMemSimmAsmOperand<9>;
11921147
}
11931148

11941149
def mem_simm10 : mem_generic {
11951150
let MIOperandInfo = (ops ptr_rc, simm10);
11961151
let EncoderMethod = "getMemEncoding";
1197-
let ParserMatchClass = MipsMemSimm10AsmOperand;
1152+
let ParserMatchClass = MipsMemSimmAsmOperand<10>;
11981153
}
11991154

12001155
foreach I = {1, 2, 3} in
12011156
def mem_simm10_lsl # I : mem_generic {
12021157
let MIOperandInfo = (ops ptr_rc, !cast<Operand>("simm10_lsl" # I));
12031158
let EncoderMethod = "getMemEncoding<" # I # ">";
1204-
let ParserMatchClass =
1205-
!cast<AsmOperandClass>("MipsMemSimm10Lsl" # I # "AsmOperand");
1159+
let ParserMatchClass = MipsMemSimmAsmOperand<10, I>;
12061160
}
12071161

12081162
def mem_simm11 : mem_generic {
12091163
let MIOperandInfo = (ops ptr_rc, simm11);
12101164
let EncoderMethod = "getMemEncoding";
1211-
let ParserMatchClass = MipsMemSimm11AsmOperand;
1165+
let ParserMatchClass = MipsMemSimmAsmOperand<11>;
12121166
}
12131167

12141168
def mem_simm12 : mem_generic {
12151169
let MIOperandInfo = (ops ptr_rc, simm12);
12161170
let EncoderMethod = "getMemEncoding";
1217-
let ParserMatchClass = MipsMemSimm12AsmOperand;
1171+
let ParserMatchClass = MipsMemSimmAsmOperand<12>;
12181172
}
12191173

12201174
def mem_simm16 : mem_generic {
12211175
let MIOperandInfo = (ops ptr_rc, simm16);
12221176
let EncoderMethod = "getMemEncoding";
1223-
let ParserMatchClass = MipsMemSimm16AsmOperand;
1177+
let ParserMatchClass = MipsMemSimmAsmOperand<16>;
12241178
}
12251179

12261180
def mem_simmptr : mem_generic {

0 commit comments

Comments
 (0)