@@ -1157,23 +1157,6 @@ class NamedMatchClass<string CName, bit Optional = 1> : AsmOperandClass {
1157
1157
let DefaultMethod = !if(Optional, "default"#CName, ?);
1158
1158
}
1159
1159
1160
- class NamedOperandBit<string Name, AsmOperandClass MatchClass> : Operand<i1> {
1161
- let PrintMethod = "print"#Name;
1162
- let ParserMatchClass = MatchClass;
1163
- }
1164
-
1165
- class NamedOperandBit_0<string Name, AsmOperandClass MatchClass> :
1166
- OperandWithDefaultOps<i1, (ops (i1 0))> {
1167
- let PrintMethod = "print"#Name;
1168
- let ParserMatchClass = MatchClass;
1169
- }
1170
-
1171
- class NamedOperandBit_1<string Name, AsmOperandClass MatchClass> :
1172
- OperandWithDefaultOps<i1, (ops (i1 1))> {
1173
- let PrintMethod = "print"#Name;
1174
- let ParserMatchClass = MatchClass;
1175
- }
1176
-
1177
1160
class CustomOperandClass<string CName, bit Optional> : AsmOperandClass {
1178
1161
let Name = CName;
1179
1162
let PredicateMethod = "is"#CName;
@@ -1183,23 +1166,43 @@ class CustomOperandClass<string CName, bit Optional> : AsmOperandClass {
1183
1166
let DefaultMethod = "default"#CName;
1184
1167
}
1185
1168
1169
+ class CustomOperandProps<bit Optional = 0, string Name = NAME,
1170
+ AsmOperandClass Class = CustomOperandClass<Name, Optional>> {
1171
+ string PrintMethod = "print"#Name;
1172
+ AsmOperandClass ParserMatchClass = Class;
1173
+ }
1174
+
1186
1175
class CustomOperand<ValueType Type, bit Optional = 0, string Name = NAME,
1187
1176
AsmOperandClass Class = CustomOperandClass<Name, Optional>>
1188
- : Operand<Type> {
1189
- let PrintMethod = "print"#Name;
1190
- let ParserMatchClass = Class;
1177
+ : Operand<Type>, CustomOperandProps<Optional, Name, Class>;
1178
+
1179
+ class NamedIntOperandClass<string Prefix, string Name, string ConvertMethod>
1180
+ : CustomOperandClass<Name, 1> {
1181
+ string ImmTy = "AMDGPUOperand::ImmTy"#Name;
1182
+ let ParserMethod =
1183
+ "[this](OperandVector &Operands) -> OperandMatchResultTy { "#
1184
+ "return parseIntWithPrefix(\""#Prefix#"\", Operands, "#ImmTy#", "#
1185
+ ConvertMethod#"); }";
1191
1186
}
1192
1187
1193
- class NamedIntOperandClass<string Prefix, string Name>
1188
+ class NamedIntOperand<ValueType Type, string Prefix, string Name = NAME,
1189
+ string ConvertMethod = "nullptr">
1190
+ : CustomOperand<Type, 1, Name, NamedIntOperandClass<Prefix, Name, ConvertMethod>>;
1191
+
1192
+ class BitOperandClass<string Id, string Name>
1194
1193
: CustomOperandClass<Name, 1> {
1195
1194
string ImmTy = "AMDGPUOperand::ImmTy"#Name;
1196
1195
let ParserMethod =
1197
1196
"[this](OperandVector &Operands) -> OperandMatchResultTy { "#
1198
- "return parseIntWithPrefix (\""#Prefix #"\", Operands, "#ImmTy#"); }";
1197
+ "return parseNamedBit (\""#Id #"\", Operands, "#ImmTy#"); }";
1199
1198
}
1200
1199
1201
- class NamedIntOperand<ValueType Type, string Prefix, string Name = NAME>
1202
- : CustomOperand<Type, 1, Name, NamedIntOperandClass<Prefix, Name>>;
1200
+ class NamedBitOperand<string Id, string Name = NAME>
1201
+ : CustomOperand<i1, 1, Name, BitOperandClass<Id, Name>>;
1202
+
1203
+ class DefaultOperand_0<CustomOperand Op>
1204
+ : OperandWithDefaultOps<Op.Type, (ops (Op.Type 0))>,
1205
+ CustomOperandProps<1, Op.ParserMatchClass.Name, Op.ParserMatchClass>;
1203
1206
1204
1207
class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> {
1205
1208
let PrintMethod = "print"#Name;
@@ -1231,33 +1234,33 @@ def offset : NamedIntOperand<i16, "offset", "Offset">;
1231
1234
def offset0 : NamedIntOperand<i8, "offset0", "Offset0">;
1232
1235
def offset1 : NamedIntOperand<i8, "offset1", "Offset1">;
1233
1236
1234
- def gds : NamedOperandBit<"GDS ", NamedMatchClass< "GDS"> >;
1237
+ def gds : NamedBitOperand<"gds ", "GDS">;
1235
1238
1236
1239
def omod : NamedOperandU32<"OModSI", NamedMatchClass<"OModSI">>;
1237
1240
def omod0 : NamedOperandU32_0<"OModSI", NamedMatchClass<"OModSI">>;
1238
1241
1239
1242
// We need to make the cases with a default of 0 distinct from no
1240
1243
// default to help deal with some cases where the operand appears
1241
1244
// before a mandatory operand.
1242
- def clampmod : NamedOperandBit<"ClampSI ", NamedMatchClass< "ClampSI"> >;
1243
- def clampmod0 : NamedOperandBit_0<"ClampSI", NamedMatchClass<"ClampSI"> >;
1244
- def highmod : NamedOperandBit<"High ", NamedMatchClass< "High"> >;
1245
+ def clampmod : NamedBitOperand<"clamp ", "ClampSI">;
1246
+ def clampmod0 : DefaultOperand_0<clampmod >;
1247
+ def highmod : NamedBitOperand<"high ", "High">;
1245
1248
1246
1249
def CPol : NamedOperandU32<"CPol", NamedMatchClass<"CPol">>;
1247
1250
def CPol_0 : NamedOperandU32Default0<"CPol", NamedMatchClass<"CPol">>;
1248
1251
def CPol_GLC1 : NamedOperandU32Default1<"CPol", NamedMatchClass<"CPol">>;
1249
1252
1250
- def TFE : NamedOperandBit<"TFE", NamedMatchClass<"TFE"> >;
1251
- def SWZ : NamedOperandBit<"SWZ", NamedMatchClass<"SWZ"> >;
1252
- def SWZ_0 : NamedOperandBit_0<" SWZ", NamedMatchClass<"SWZ"> >;
1253
- def UNorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm"> >;
1254
- def DA : NamedOperandBit<"DA", NamedMatchClass<"DA"> >;
1255
- def R128A16 : NamedOperandBit<"R128A16", NamedMatchClass<"R128A16"> >;
1256
- def A16 : NamedOperandBit<"A16", NamedMatchClass<"A16"> >;
1257
- def D16 : NamedOperandBit<"D16", NamedMatchClass<"D16"> >;
1258
- def LWE : NamedOperandBit<"LWE", NamedMatchClass<"LWE"> >;
1259
- def exp_compr : NamedOperandBit<"ExpCompr ", NamedMatchClass< "ExpCompr"> >;
1260
- def exp_vm : NamedOperandBit<"ExpVM ", NamedMatchClass< "ExpVM"> >;
1253
+ def TFE : NamedBitOperand<"tfe" >;
1254
+ def SWZ : NamedBitOperand<"swz" >;
1255
+ def SWZ_0 : DefaultOperand_0< SWZ>;
1256
+ def UNorm : NamedBitOperand<"unorm" >;
1257
+ def DA : NamedBitOperand<"da" >;
1258
+ def R128A16 : CustomOperand<i1, 1 >;
1259
+ def A16 : NamedBitOperand<"a16" >;
1260
+ def D16 : NamedBitOperand<"d16" >;
1261
+ def LWE : NamedBitOperand<"lwe" >;
1262
+ def exp_compr : NamedBitOperand<"compr ", "ExpCompr">;
1263
+ def exp_vm : NamedBitOperand<"vm ", "ExpVM">;
1261
1264
1262
1265
def FORMAT : CustomOperand<i8>;
1263
1266
@@ -1279,7 +1282,7 @@ def dpp_ctrl : NamedOperandU32<"DPPCtrl", NamedMatchClass<"DPPCtrl", 0>>;
1279
1282
1280
1283
def row_mask : NamedOperandU32<"RowMask", NamedMatchClass<"RowMask">>;
1281
1284
def bank_mask : NamedOperandU32<"BankMask", NamedMatchClass<"BankMask">>;
1282
- def bound_ctrl : NamedOperandBit<"BoundCtrl ", NamedMatchClass<"BoundCtrl"> >;
1285
+ def bound_ctrl : NamedIntOperand<i1, "bound_ctrl ", "DppBoundCtrl", "ConvertDppBoundCtrl" >;
1283
1286
def FI : NamedOperandU32<"FI", NamedMatchClass<"FI">>;
1284
1287
1285
1288
def blgp : NamedOperandU32<"BLGP", NamedMatchClass<"BLGP">>;
0 commit comments