bool isFORMAT() const { return isImmTy(ImmTyFORMAT) && isUInt<7>(getImm()); }
bool isBankMask() const { return isImmTy(ImmTyDppBankMask); }
bool isRowMask() const { return isImmTy(ImmTyDppRowMask); }
- bool isBoundCtrl() const { return isImmTy(ImmTyDppBoundCtrl); }
+ bool isDppBoundCtrl() const { return isImmTy(ImmTyDppBoundCtrl); }
bool isFI() const { return isImmTy(ImmTyDppFi); }
bool isSDWADstSel() const { return isImmTy(ImmTySdwaDstSel); }
bool isSDWASrc0Sel() const { return isImmTy(ImmTySdwaSrc0Sel); }
OperandMatchResultTy parseSymbolicOrNumericFormat(int64_t &Format);
OperandMatchResultTy parseNumericFormat(int64_t &Format);
OperandMatchResultTy parseFlatOffset(OperandVector &Operands);
+ OperandMatchResultTy parseR128A16(OperandVector &Operands);
bool tryParseFmt(const char *Pref, int64_t MaxVal, int64_t &Val);
bool matchDfmtNfmt(int64_t &Dfmt, int64_t &Nfmt, StringRef FormatStr, SMLoc Loc);
int64_t parseDPPCtrlPerm();
AMDGPUOperand::Ptr defaultRowMask() const;
AMDGPUOperand::Ptr defaultBankMask() const;
- AMDGPUOperand::Ptr defaultBoundCtrl() const;
+ AMDGPUOperand::Ptr defaultDppBoundCtrl() const;
AMDGPUOperand::Ptr defaultFI() const;
void cvtDPP(MCInst &Inst, const OperandVector &Operands, bool IsDPP8 = false);
void cvtDPP8(MCInst &Inst, const OperandVector &Operands) {
return Res;
}
+OperandMatchResultTy AMDGPUAsmParser::parseR128A16(OperandVector &Operands) {
+ OperandMatchResultTy Res =
+ parseNamedBit("r128", Operands, AMDGPUOperand::ImmTyR128A16);
+ if (Res == MatchOperand_NoMatch)
+ Res = parseNamedBit("a16", Operands, AMDGPUOperand::ImmTyA16);
+ return Res;
+}
+
//===----------------------------------------------------------------------===//
// ds
//===----------------------------------------------------------------------===//
// Both bound_ctrl:0 and bound_ctrl:1 are encoded as 1.
// This is intentional and ensures compatibility with sp3.
// See bug 35397 for details.
-static bool ConvertBoundCtrl(int64_t &BoundCtrl) {
+static bool ConvertDppBoundCtrl(int64_t &BoundCtrl) {
if (BoundCtrl == 0 || BoundCtrl == 1) {
BoundCtrl = 1;
return true;
return AMDGPUOperand::CreateImm(this, 0xf, SMLoc(), AMDGPUOperand::ImmTyDppBankMask);
}
-AMDGPUOperand::Ptr AMDGPUAsmParser::defaultBoundCtrl() const {
+AMDGPUOperand::Ptr AMDGPUAsmParser::defaultDppBoundCtrl() const {
return AMDGPUOperand::CreateImm(this, 0, SMLoc(), AMDGPUOperand::ImmTyDppBoundCtrl);
}
}
return Res;
}
- case MCK_ImmBoundCtrl:
- return parseIntWithPrefix("bound_ctrl", Operands,
- AMDGPUOperand::ImmTyDppBoundCtrl,
- ConvertBoundCtrl);
case MCK_ImmCBSZ:
return parseIntWithPrefix("cbsz", Operands, AMDGPUOperand::ImmTyCBSZ);
- case MCK_ImmClampSI:
- return parseNamedBit("clamp", Operands, AMDGPUOperand::ImmTyClampSI);
case MCK_ImmCPol:
return parseCPol(Operands);
- case MCK_ImmD16:
- return parseNamedBit("d16", Operands, AMDGPUOperand::ImmTyD16);
- case MCK_ImmDA:
- return parseNamedBit("da", Operands, AMDGPUOperand::ImmTyDA);
- case MCK_ImmExpCompr:
- return parseNamedBit("compr", Operands, AMDGPUOperand::ImmTyExpCompr);
- case MCK_ImmExpVM:
- return parseNamedBit("vm", Operands, AMDGPUOperand::ImmTyExpVM);
case MCK_ImmFI:
return parseIntWithPrefix("fi", Operands, AMDGPUOperand::ImmTyDppFi);
case MCK_gds:
- case MCK_ImmGDS:
return parseNamedBit("gds", Operands, AMDGPUOperand::ImmTyGDS);
- case MCK_ImmA16:
- return parseNamedBit("a16", Operands, AMDGPUOperand::ImmTyA16);
- case MCK_ImmHigh:
- return parseNamedBit("high", Operands, AMDGPUOperand::ImmTyHigh);
- case MCK_ImmLWE:
- return parseNamedBit("lwe", Operands, AMDGPUOperand::ImmTyLWE);
case MCK_ImmNegHi:
return parseOperandArrayWithPrefix("neg_hi", Operands,
AMDGPUOperand::ImmTyNegHi);
case MCK_ImmOpSelHi:
return parseOperandArrayWithPrefix("op_sel_hi", Operands,
AMDGPUOperand::ImmTyOpSelHi);
- case MCK_ImmR128A16: {
- OperandMatchResultTy Res =
- parseNamedBit("r128", Operands, AMDGPUOperand::ImmTyR128A16);
- if (Res == MatchOperand_NoMatch)
- Res = parseNamedBit("a16", Operands, AMDGPUOperand::ImmTyA16);
- return Res;
- }
case MCK_ImmRowMask:
return parseIntWithPrefix("row_mask", Operands,
AMDGPUOperand::ImmTyDppRowMask);
return parseSDWASel(Operands, "src0_sel", AMDGPUOperand::ImmTySdwaSrc0Sel);
case MCK_ImmSDWASrc1Sel:
return parseSDWASel(Operands, "src1_sel", AMDGPUOperand::ImmTySdwaSrc1Sel);
- case MCK_ImmSWZ:
- return parseNamedBit("swz", Operands, AMDGPUOperand::ImmTySWZ);
case MCK_tfe:
- case MCK_ImmTFE:
return parseNamedBit("tfe", Operands, AMDGPUOperand::ImmTyTFE);
- case MCK_ImmUNorm:
- return parseNamedBit("unorm", Operands, AMDGPUOperand::ImmTyUNorm);
}
return tryCustomParseOperand(Operands, MCK);
}
case MCK_offen:
return Operand.isOffen() ? Match_Success : Match_InvalidOperand;
case MCK_tfe:
- case MCK_ImmTFE:
return Operand.isTFE() ? Match_Success : Match_InvalidOperand;
case MCK_SSrcB32:
// When operands have expression values, they will return true for isToken,
let DefaultMethod = !if(Optional, "default"#CName, ?);
}
-class NamedOperandBit<string Name, AsmOperandClass MatchClass> : Operand<i1> {
- let PrintMethod = "print"#Name;
- let ParserMatchClass = MatchClass;
-}
-
-class NamedOperandBit_0<string Name, AsmOperandClass MatchClass> :
- OperandWithDefaultOps<i1, (ops (i1 0))> {
- let PrintMethod = "print"#Name;
- let ParserMatchClass = MatchClass;
-}
-
-class NamedOperandBit_1<string Name, AsmOperandClass MatchClass> :
- OperandWithDefaultOps<i1, (ops (i1 1))> {
- let PrintMethod = "print"#Name;
- let ParserMatchClass = MatchClass;
-}
-
class CustomOperandClass<string CName, bit Optional> : AsmOperandClass {
let Name = CName;
let PredicateMethod = "is"#CName;
let DefaultMethod = "default"#CName;
}
+class CustomOperandProps<bit Optional = 0, string Name = NAME,
+ AsmOperandClass Class = CustomOperandClass<Name, Optional>> {
+ string PrintMethod = "print"#Name;
+ AsmOperandClass ParserMatchClass = Class;
+}
+
class CustomOperand<ValueType Type, bit Optional = 0, string Name = NAME,
AsmOperandClass Class = CustomOperandClass<Name, Optional>>
- : Operand<Type> {
- let PrintMethod = "print"#Name;
- let ParserMatchClass = Class;
+ : Operand<Type>, CustomOperandProps<Optional, Name, Class>;
+
+class NamedIntOperandClass<string Prefix, string Name, string ConvertMethod>
+ : CustomOperandClass<Name, 1> {
+ string ImmTy = "AMDGPUOperand::ImmTy"#Name;
+ let ParserMethod =
+ "[this](OperandVector &Operands) -> OperandMatchResultTy { "#
+ "return parseIntWithPrefix(\""#Prefix#"\", Operands, "#ImmTy#", "#
+ ConvertMethod#"); }";
}
-class NamedIntOperandClass<string Prefix, string Name>
+class NamedIntOperand<ValueType Type, string Prefix, string Name = NAME,
+ string ConvertMethod = "nullptr">
+ : CustomOperand<Type, 1, Name, NamedIntOperandClass<Prefix, Name, ConvertMethod>>;
+
+class BitOperandClass<string Id, string Name>
: CustomOperandClass<Name, 1> {
string ImmTy = "AMDGPUOperand::ImmTy"#Name;
let ParserMethod =
"[this](OperandVector &Operands) -> OperandMatchResultTy { "#
- "return parseIntWithPrefix(\""#Prefix#"\", Operands, "#ImmTy#"); }";
+ "return parseNamedBit(\""#Id#"\", Operands, "#ImmTy#"); }";
}
-class NamedIntOperand<ValueType Type, string Prefix, string Name = NAME>
- : CustomOperand<Type, 1, Name, NamedIntOperandClass<Prefix, Name>>;
+class NamedBitOperand<string Id, string Name = NAME>
+ : CustomOperand<i1, 1, Name, BitOperandClass<Id, Name>>;
+
+class DefaultOperand_0<CustomOperand Op>
+ : OperandWithDefaultOps<Op.Type, (ops (Op.Type 0))>,
+ CustomOperandProps<1, Op.ParserMatchClass.Name, Op.ParserMatchClass>;
class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> {
let PrintMethod = "print"#Name;
def offset0 : NamedIntOperand<i8, "offset0", "Offset0">;
def offset1 : NamedIntOperand<i8, "offset1", "Offset1">;
-def gds : NamedOperandBit<"GDS", NamedMatchClass<"GDS">>;
+def gds : NamedBitOperand<"gds", "GDS">;
def omod : NamedOperandU32<"OModSI", NamedMatchClass<"OModSI">>;
def omod0 : NamedOperandU32_0<"OModSI", NamedMatchClass<"OModSI">>;
// We need to make the cases with a default of 0 distinct from no
// default to help deal with some cases where the operand appears
// before a mandatory operand.
-def clampmod : NamedOperandBit<"ClampSI", NamedMatchClass<"ClampSI">>;
-def clampmod0 : NamedOperandBit_0<"ClampSI", NamedMatchClass<"ClampSI">>;
-def highmod : NamedOperandBit<"High", NamedMatchClass<"High">>;
+def clampmod : NamedBitOperand<"clamp", "ClampSI">;
+def clampmod0 : DefaultOperand_0<clampmod>;
+def highmod : NamedBitOperand<"high", "High">;
def CPol : NamedOperandU32<"CPol", NamedMatchClass<"CPol">>;
def CPol_0 : NamedOperandU32Default0<"CPol", NamedMatchClass<"CPol">>;
def CPol_GLC1 : NamedOperandU32Default1<"CPol", NamedMatchClass<"CPol">>;
-def TFE : NamedOperandBit<"TFE", NamedMatchClass<"TFE">>;
-def SWZ : NamedOperandBit<"SWZ", NamedMatchClass<"SWZ">>;
-def SWZ_0 : NamedOperandBit_0<"SWZ", NamedMatchClass<"SWZ">>;
-def UNorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm">>;
-def DA : NamedOperandBit<"DA", NamedMatchClass<"DA">>;
-def R128A16 : NamedOperandBit<"R128A16", NamedMatchClass<"R128A16">>;
-def A16 : NamedOperandBit<"A16", NamedMatchClass<"A16">>;
-def D16 : NamedOperandBit<"D16", NamedMatchClass<"D16">>;
-def LWE : NamedOperandBit<"LWE", NamedMatchClass<"LWE">>;
-def exp_compr : NamedOperandBit<"ExpCompr", NamedMatchClass<"ExpCompr">>;
-def exp_vm : NamedOperandBit<"ExpVM", NamedMatchClass<"ExpVM">>;
+def TFE : NamedBitOperand<"tfe">;
+def SWZ : NamedBitOperand<"swz">;
+def SWZ_0 : DefaultOperand_0<SWZ>;
+def UNorm : NamedBitOperand<"unorm">;
+def DA : NamedBitOperand<"da">;
+def R128A16 : CustomOperand<i1, 1>;
+def A16 : NamedBitOperand<"a16">;
+def D16 : NamedBitOperand<"d16">;
+def LWE : NamedBitOperand<"lwe">;
+def exp_compr : NamedBitOperand<"compr", "ExpCompr">;
+def exp_vm : NamedBitOperand<"vm", "ExpVM">;
def FORMAT : CustomOperand<i8>;
def row_mask : NamedOperandU32<"RowMask", NamedMatchClass<"RowMask">>;
def bank_mask : NamedOperandU32<"BankMask", NamedMatchClass<"BankMask">>;
-def bound_ctrl : NamedOperandBit<"BoundCtrl", NamedMatchClass<"BoundCtrl">>;
+def bound_ctrl : NamedIntOperand<i1, "bound_ctrl", "DppBoundCtrl", "ConvertDppBoundCtrl">;
def FI : NamedOperandU32<"FI", NamedMatchClass<"FI">>;
def blgp : NamedOperandU32<"BLGP", NamedMatchClass<"BLGP">>;