[llvm] [AMDGPU] Fix decoder for BF16 inline constants (PR #82276)
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 19 13:05:14 PST 2024
================
@@ -1108,24 +1108,34 @@ class RegOrImmOperand <RegisterClass RegClass, string OperandTypeName>
let ParserMatchClass = RegImmMatcher<!subst("_Deferred", "", NAME)>;
}
+// Should be in sync with the OperandSematics defined in SIDefines.h
+def OperandSematics {
+ int INT = 0;
+ int FP16 = 1;
+ int BF16 = 2;
+ int FP32 = 3;
+ int FP64 = 4;
+}
+
//===----------------------------------------------------------------------===//
// SSrc_* Operands with an SGPR or a 32-bit immediate
//===----------------------------------------------------------------------===//
class SrcRegOrImm9<RegisterClass regClass, string opWidth, string operandType,
- int immWidth> : RegOrImmOperand<regClass, operandType> {
+ int immWidth, int OperandSematics>
+ : RegOrImmOperand<regClass, operandType> {
let DecoderMethod = "decodeSrcRegOrImm9<AMDGPUDisassembler::" # opWidth #
- ", " # immWidth # ">";
+ ", " # immWidth # ", " # OperandSematics # ">";
}
-def SSrc_b16 : SrcRegOrImm9 <SReg_32, "OPW32", "OPERAND_REG_IMM_INT16", 16>;
-def SSrc_bf16: SrcRegOrImm9 <SReg_32, "OPW32", "OPERAND_REG_IMM_BF16", 16>;
-def SSrc_f16 : SrcRegOrImm9 <SReg_32, "OPW32", "OPERAND_REG_IMM_FP16", 16>;
-def SSrc_b32 : SrcRegOrImm9 <SReg_32, "OPW32", "OPERAND_REG_IMM_INT32", 32>;
-def SSrc_f32 : SrcRegOrImm9 <SReg_32, "OPW32", "OPERAND_REG_IMM_FP32", 32>;
-def SSrc_b64 : SrcRegOrImm9 <SReg_64, "OPW64", "OPERAND_REG_IMM_INT64", 64>;
+def SSrc_b16 : SrcRegOrImm9 <SReg_32, "OPW32", "OPERAND_REG_IMM_INT16", 16, OperandSematics.INT>;
----------------
rampitec wrote:
Yes. All ints have the same semantics - 2-complement. No need to create more template specializations. The real problem is to distinguish f16 and bf16.
https://github.com/llvm/llvm-project/pull/82276
More information about the llvm-commits
mailing list