Skip to content

Commit 032810c

Browse files
committed
FIX:
print the symbolic operand for opcode the operation OpSpecConstantOp
1 parent f46cea5 commit 032810c

File tree

12 files changed

+114
-16
lines changed

12 files changed

+114
-16
lines changed

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category,
6868
Category != SPIRV::OperandCategory::FunctionControlOperand &&
6969
Category != SPIRV::OperandCategory::MemorySemanticsOperand &&
7070
Category != SPIRV::OperandCategory::MemoryOperandOperand &&
71-
Category != SPIRV::OperandCategory::KernelProfilingInfoOperand)
71+
Category != SPIRV::OperandCategory::KernelProfilingInfoOperand &&
72+
Category != SPIRV::OperandCategory::SpecConstantOpOperandsOperand)
7273
return "UNKNOWN";
7374
// Value that encodes many enum values (one bit per enum value).
7475
std::string Name;

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ namespace CooperativeMatrixOperands {
217217
#include "SPIRVGenTables.inc"
218218
} // namespace CooperativeMatrixOperands
219219

220+
namespace SpecConstantOpOperands {
221+
#define GET_SpecConstantOpOperands_DECL
222+
#include "SPIRVGenTables.inc"
223+
} // namespace SpecConstantOpOperands
224+
220225
struct ExtendedBuiltin {
221226
StringRef Name;
222227
InstructionSet::InstructionSet Set;

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ void SPIRVInstPrinter::printInst(const MCInst *MI, uint64_t Address,
242242
}
243243
break;
244244
}
245+
245246
default:
246247
printRemainingVariableOps(MI, NumFixedOps, OS);
247248
break;

llvm/lib/Target/SPIRV/SPIRVInstrInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def OpSpecConstantComposite: Op<51, (outs ID:$res), (ins TYPE:$type, variable_op
245245
"$res = OpSpecConstantComposite $type">;
246246
def OpSpecConstantCompositeContinuedINTEL: Op<6092, (outs), (ins variable_ops),
247247
"OpSpecConstantCompositeContinuedINTEL">;
248-
def OpSpecConstantOp: Op<52, (outs ID:$res), (ins TYPE:$t, i32imm:$c, ID:$o, variable_ops),
248+
def OpSpecConstantOp: Op<52, (outs ID:$res), (ins TYPE:$t, SpecConstantOpOperands:$c, ID:$o, variable_ops),
249249
"$res = OpSpecConstantOp $t $c $o">;
250250

251251
// 3.42.8 Memory Instructions

llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def KernelProfilingInfoOperand : OperandCategory;
172172
def OpcodeOperand : OperandCategory;
173173
def CooperativeMatrixLayoutOperand : OperandCategory;
174174
def CooperativeMatrixOperandsOperand : OperandCategory;
175+
def SpecConstantOpOperandsOperand : OperandCategory;
175176

176177
//===----------------------------------------------------------------------===//
177178
// Multiclass used to define Extesions enum values and at the same time
@@ -1743,3 +1744,93 @@ defm MatrixAAndBTF32ComponentsINTEL : CooperativeMatrixOperandsOperand<0x20, [SP
17431744
defm MatrixAAndBBFloat16ComponentsINTEL : CooperativeMatrixOperandsOperand<0x40, [SPV_INTEL_joint_matrix], [CooperativeMatrixBFloat16ComponentTypeINTEL]>;
17441745
defm MatrixCBFloat16ComponentsINTEL : CooperativeMatrixOperandsOperand<0x80, [SPV_INTEL_joint_matrix], [CooperativeMatrixBFloat16ComponentTypeINTEL]>;
17451746
defm MatrixResultBFloat16ComponentsINTEL : CooperativeMatrixOperandsOperand<0x100, [SPV_INTEL_joint_matrix], [CooperativeMatrixBFloat16ComponentTypeINTEL]>;
1747+
1748+
//===----------------------------------------------------------------------===//
1749+
// Multiclass used to define SpecConstant Operands enum values and at the
1750+
// same time SymbolicOperand entries with string mnemonics, extensions and
1751+
// capabilities.
1752+
//===----------------------------------------------------------------------===//
1753+
1754+
def SpecConstantOpOperands : GenericEnum, Operand<i32> {
1755+
let FilterClass = "SpecConstantOpOperands";
1756+
let NameField = "Name";
1757+
let ValueField = "Value";
1758+
let PrintMethod = !strconcat("printSymbolicOperand<OperandCategory::", FilterClass, "Operand>");
1759+
}
1760+
1761+
class SpecConstantOpOperands<string name, bits<32> value> {
1762+
string Name = name;
1763+
bits<32> Value = value;
1764+
}
1765+
1766+
multiclass SpecConstantOpOperandsOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
1767+
def : SpecConstantOpOperands<NAME, value>;
1768+
defm : SymbolicOperandWithRequirements<SpecConstantOpOperandsOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities>;
1769+
}
1770+
1771+
// Conversion
1772+
defm SConvert : SpecConstantOpOperandsOperand<114, [], []>;
1773+
defm FConvert : SpecConstantOpOperandsOperand<115, [], []>;
1774+
defm ConvertFToS : SpecConstantOpOperandsOperand<110, [], [Kernel]>;
1775+
defm ConvertSToF : SpecConstantOpOperandsOperand<111, [], [Kernel]>;
1776+
defm ConvertFToU : SpecConstantOpOperandsOperand<109, [], [Kernel]>;
1777+
defm ConvertUToF : SpecConstantOpOperandsOperand<112, [], [Kernel]>;
1778+
defm UConvert : SpecConstantOpOperandsOperand<113, [], [Kernel]>;
1779+
defm ConvertPtrToU : SpecConstantOpOperandsOperand<117, [], [Kernel]>;
1780+
defm ConvertUToPtr : SpecConstantOpOperandsOperand<120, [], [Kernel]>;
1781+
defm GenericCastToPtr : SpecConstantOpOperandsOperand<122, [], [Kernel]>;
1782+
defm PtrCastToGeneric : SpecConstantOpOperandsOperand<121, [], [Kernel]>;
1783+
defm Bitcast : SpecConstantOpOperandsOperand<124, [], []>;
1784+
defm QuantizeToF16 : SpecConstantOpOperandsOperand<116, [], [Shader]>;
1785+
// Arithmetic
1786+
defm SNegate : SpecConstantOpOperandsOperand<126, [], []>;
1787+
defm Not : SpecConstantOpOperandsOperand<200, [], []>;
1788+
defm IAdd : SpecConstantOpOperandsOperand<128, [], []>;
1789+
defm ISub : SpecConstantOpOperandsOperand<130, [], []>;
1790+
defm IMul : SpecConstantOpOperandsOperand<132, [], []>;
1791+
defm UDiv : SpecConstantOpOperandsOperand<134, [], []>;
1792+
defm SDiv : SpecConstantOpOperandsOperand<135, [], []>;
1793+
defm UMod : SpecConstantOpOperandsOperand<137, [], []>;
1794+
defm SRem : SpecConstantOpOperandsOperand<138, [], []>;
1795+
defm SMod : SpecConstantOpOperandsOperand<139, [], []>;
1796+
defm ShiftRightLogical : SpecConstantOpOperandsOperand<194, [], []>;
1797+
defm ShiftRightArithmetic : SpecConstantOpOperandsOperand<195, [], []>;
1798+
defm ShiftLeftLogical : SpecConstantOpOperandsOperand<196, [], []>;
1799+
defm BitwiseOr : SpecConstantOpOperandsOperand<197, [], []>;
1800+
defm BitwiseAnd : SpecConstantOpOperandsOperand<199, [], []>;
1801+
defm BitwiseXor : SpecConstantOpOperandsOperand<198, [], []>;
1802+
defm FNegate : SpecConstantOpOperandsOperand<127, [], [Kernel]>;
1803+
defm FAdd : SpecConstantOpOperandsOperand<129, [], [Kernel]>;
1804+
defm FSub : SpecConstantOpOperandsOperand<131, [], [Kernel]>;
1805+
defm FMul : SpecConstantOpOperandsOperand<133, [], [Kernel]>;
1806+
defm FDiv : SpecConstantOpOperandsOperand<136, [], [Kernel]>;
1807+
defm FRem : SpecConstantOpOperandsOperand<140, [], [Kernel]>;
1808+
defm FMod : SpecConstantOpOperandsOperand<141, [], [Kernel]>;
1809+
// Composite;
1810+
defm VectorShuffle : SpecConstantOpOperandsOperand<79, [], []>;
1811+
defm CompositeExtract : SpecConstantOpOperandsOperand<81, [], []>;
1812+
defm CompositeInsert : SpecConstantOpOperandsOperand<82, [], []>;
1813+
// Logical;
1814+
defm LogicalOr : SpecConstantOpOperandsOperand<166, [], []>;
1815+
defm LogicalAnd : SpecConstantOpOperandsOperand<167, [], []>;
1816+
defm LogicalNot : SpecConstantOpOperandsOperand<168, [], []>;
1817+
defm LogicalEqual : SpecConstantOpOperandsOperand<164, [], []>;
1818+
defm LogicalNotEqual : SpecConstantOpOperandsOperand<165, [], []>;
1819+
defm Select : SpecConstantOpOperandsOperand<169, [], []>;
1820+
// Comparison;
1821+
defm IEqual : SpecConstantOpOperandsOperand<170, [], []>;
1822+
defm INotEqual : SpecConstantOpOperandsOperand<171, [], []>;
1823+
defm ULessThan : SpecConstantOpOperandsOperand<176, [], []>;
1824+
defm SLessThan : SpecConstantOpOperandsOperand<177, [], []>;
1825+
defm UGreaterThan : SpecConstantOpOperandsOperand<172, [], []>;
1826+
defm SGreaterThan : SpecConstantOpOperandsOperand<173, [], []>;
1827+
defm ULessThanEqual : SpecConstantOpOperandsOperand<176, [], []>;
1828+
defm SLessThanEqual : SpecConstantOpOperandsOperand<178, [], []>;
1829+
defm UGreaterThanEqual : SpecConstantOpOperandsOperand<174, [], []>;
1830+
defm SGreaterThanEqual : SpecConstantOpOperandsOperand<175, [], []>;
1831+
// Memory SpecConstantOpOperandsOperand<0, [], []>;
1832+
defm AccessChain : SpecConstantOpOperandsOperand<65, [], [Kernel]>;
1833+
defm InBoundsAccessChain : SpecConstantOpOperandsOperand<66, [], [Kernel]>;
1834+
defm PtrAccessChain : SpecConstantOpOperandsOperand<67, [], [Kernel]>;
1835+
defm InBoundsPtrAccessChain : SpecConstantOpOperandsOperand<70, [], [Kernel]>;
1836+
defm CooperativeMatrixLengthKHR : SpecConstantOpOperandsOperand<4460, [], []>;

llvm/test/CodeGen/SPIRV/const-nested-vecs.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
; CHECK-SPIRV-DAG: %[[#IntZero:]] = OpConstantNull %[[#IntTy]]
2626
; CHECK-SPIRV-DAG: %[[#LongZero:]] = OpConstantNull %[[#LongTy]]
2727
; CHECK-SPIRV64-DAG: %[[#ConstLong2:]] = OpConstant %[[#LongTy]] 2
28-
; CHECK-SPIRV64-DAG: %[[#PvarInit:]] = OpSpecConstantOp %[[#PtrCharTy]] 70 %[[#VarV2Char:]] %[[#IntZero]] %[[#ConstLong2]]
29-
; CHECK-SPIRV32-DAG: %[[#PvarInit:]] = OpSpecConstantOp %[[#PtrCharTy]] 70 %[[#VarV2Char:]] %[[#IntZero]] %[[#Const2]]
28+
; CHECK-SPIRV64-DAG: %[[#PvarInit:]] = OpSpecConstantOp %[[#PtrCharTy]] InBoundsPtrAccessChain %[[#VarV2Char:]] %[[#IntZero]] %[[#ConstLong2]]
29+
; CHECK-SPIRV32-DAG: %[[#PvarInit:]] = OpSpecConstantOp %[[#PtrCharTy]] InBoundsPtrAccessChain %[[#VarV2Char:]] %[[#IntZero]] %[[#Const2]]
3030
; CHECK-SPIRV-DAG: %[[#PtrPtrCharTy:]] = OpTypePointer CrossWorkgroup %[[#PtrCharTy]]
3131
; CHECK-SPIRV-DAG: %[[#AVar]] = OpVariable %[[#PtrArr2V2CharTy]] CrossWorkgroup %[[#Arr2V2Char]]
3232
; CHECK-SPIRV-DAG: %[[#PVar]] = OpVariable %[[#PtrPtrCharTy]] CrossWorkgroup %[[#PvarInit]]

llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - --spirv-ext=+SPV_INTEL_function_pointers | FileCheck %s
66
; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
77

8-
; CHECK-COUNT-3: %[[#]] = OpSpecConstantOp %[[#]] 121 %[[#]]
8+
; CHECK-COUNT-3: %[[#]] = OpSpecConstantOp %[[#]] PtrCastToGeneric %[[#]]
99
; CHECK-COUNT-3: OpPtrCastToGeneric
1010

1111
@G1 = addrspace(1) constant { [3 x ptr addrspace(4)] } { [3 x ptr addrspace(4)] [ptr addrspace(4) null, ptr addrspace(4) addrspacecast (ptr @foo to ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr @bar to ptr addrspace(4))] }

llvm/test/CodeGen/SPIRV/opencl/basic/progvar_prog_scope_init.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
; CHECK-DAG: %[[#pt2:]] = OpTypePointer CrossWorkgroup %[[#arr2]]
1111
; CHECK-DAG: %[[#pt3:]] = OpTypePointer CrossWorkgroup %[[#pt1]]
1212
; CHECK-DAG: %[[#a_var]] = OpVariable %[[#pt2]] CrossWorkgroup
13-
; CHECK-DAG: %[[#const:]] = OpSpecConstantOp %[[#pt1]] 70 %[[#a_var]]
13+
; CHECK-DAG: %[[#const:]] = OpSpecConstantOp %[[#pt1]] InBoundsPtrAccessChain %[[#a_var]]
1414
; CHECK-DAG: %[[#p_var]] = OpVariable %[[#pt3]] CrossWorkgroup %[[#const]]
1515
@var = addrspace(1) global i8 0, align 1
1616
@g_var = addrspace(1) global i8 1, align 1

llvm/test/CodeGen/SPIRV/opt-gepoperator-of-gvar.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
; CHECK-DAG: %[[#PtrStruct:]] = OpTypePointer CrossWorkgroup %[[#Struct]]
1515
; CHECK-DAG: %[[#Var:]] = OpVariable %[[#PtrStruct]] CrossWorkgroup %[[#VarInit]]
1616
; CHECK-DAG: %[[#Bytes:]] = OpVariable %[[#PtrChar]] CrossWorkgroup %[[#]]
17-
; CHECK-DAG: %[[#BytesGEP:]] = OpSpecConstantOp %[[#PtrChar]] 70 %[[#Bytes]] %[[#C648]]
17+
; CHECK-DAG: %[[#BytesGEP:]] = OpSpecConstantOp %[[#PtrChar]] InBoundsPtrAccessChain %[[#Bytes]] %[[#C648]]
1818

1919
; CHECK: OpFunction
2020
; CHECK: %[[#]] = OpFunctionParameter %[[#]]

llvm/test/CodeGen/SPIRV/pointers/PtrCast-in-OpSpecConstantOp.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
; CHECK-DAG: %[[WPtr:.*]] = OpTypePointer Workgroup %[[Int]]
2424

2525
; CHECK-DAG: %[[F]] = OpVariable %[[CWPtr]] CrossWorkgroup %[[#]]
26-
; CHECK-DAG: %[[GenF:.*]] = OpSpecConstantOp %[[GenPtrChar]] 121 %[[F]]
26+
; CHECK-DAG: %[[GenF:.*]] = OpSpecConstantOp %[[GenPtrChar]] PtrCastToGeneric %[[F]]
2727
; CHECK-DAG: %[[B]] = OpVariable %[[CWPtr]] CrossWorkgroup %[[#]]
28-
; CHECK-DAG: %[[GenB:.*]] = OpSpecConstantOp %[[GenPtrChar]] 121 %[[B]]
28+
; CHECK-DAG: %[[GenB:.*]] = OpSpecConstantOp %[[GenPtrChar]] PtrCastToGeneric %[[B]]
2929
; CHECK-DAG: %[[GenFB:.*]] = OpConstantComposite %[[Arr2]] %[[GenF]] %[[GenB]]
3030
; CHECK-DAG: %[[GenBF:.*]] = OpConstantComposite %[[Arr2]] %[[GenB]] %[[GenF]]
3131
; CHECK-DAG: %[[CG1:.*]] = OpConstantComposite %[[Struct2]] %[[GenFB]]
3232
; CHECK-DAG: %[[CG2:.*]] = OpConstantComposite %[[Struct2]] %[[GenBF]]
3333

3434
; CHECK-DAG: %[[X]] = OpVariable %[[WPtr]] Workgroup %[[#]]
35-
; CHECK-DAG: %[[GenX:.*]] = OpSpecConstantOp %[[GenPtr]] 121 %[[X]]
36-
; CHECK-DAG: %[[CWX:.*]] = OpSpecConstantOp %[[CWPtrChar]] 122 %[[GenX]]
35+
; CHECK-DAG: %[[GenX:.*]] = OpSpecConstantOp %[[GenPtr]] PtrCastToGeneric %[[X]]
36+
; CHECK-DAG: %[[CWX:.*]] = OpSpecConstantOp %[[CWPtrChar]] GenericCastToPtr %[[GenX]]
3737
; CHECK-DAG: %[[Y]] = OpVariable %[[WPtr]] Workgroup %[[#]]
38-
; CHECK-DAG: %[[GenY:.*]] = OpSpecConstantOp %[[GenPtr]] 121 %[[Y]]
39-
; CHECK-DAG: %[[CWY:.*]] = OpSpecConstantOp %[[CWPtrChar]] 122 %[[GenY]]
38+
; CHECK-DAG: %[[GenY:.*]] = OpSpecConstantOp %[[GenPtr]] PtrCastToGeneric %[[Y]]
39+
; CHECK-DAG: %[[CWY:.*]] = OpSpecConstantOp %[[CWPtrChar]] GenericCastToPtr %[[GenY]]
4040
; CHECK-DAG: %[[CWXY:.*]] = OpConstantComposite %[[Arr1]] %[[CWX]] %[[CWY]]
4141
; CHECK-DAG: %[[CWYX:.*]] = OpConstantComposite %[[Arr1]] %[[CWY]] %[[CWX]]
4242
; CHECK-DAG: %[[CG3:.*]] = OpConstantComposite %[[Struct1]] %[[CWXY]]

llvm/test/CodeGen/SPIRV/pointers/global-ptrtoint.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
; CHECK-DAG: %[[TyStruct:.*]] = OpTypeStruct %[[TyI64]] %[[TyI64]]
1212
; CHECK-DAG: %[[Const128:.*]] = OpConstant %[[TyI64]] 128
1313
; CHECK-DAG: %[[GlobalValue]] = OpVariable
14-
; CHECK-DAG: %[[PtrToInt:.*]] = OpSpecConstantOp %[[TyI64]] 117 %[[GlobalValue]]
14+
; CHECK-DAG: %[[PtrToInt:.*]] = OpSpecConstantOp %[[TyI64]] ConvertPtrToU %[[GlobalValue]]
1515
; TODO: The following bitcast line looks unneeded and we may expect it to be removed in future
16-
; CHECK-DAG: %[[UseGlobalValue:.*]] = OpSpecConstantOp %[[TyI64]] 124 %[[PtrToInt]]
16+
; CHECK-DAG: %[[UseGlobalValue:.*]] = OpSpecConstantOp %[[TyI64]] Bitcast %[[PtrToInt]]
1717
; CHECK-DAG: %[[ConstComposite:.*]] = OpConstantComposite %[[TyStruct]] %[[Const128]] %[[UseGlobalValue]]
1818
; CHECK-DAG: %[[TyPtrStruct:.*]] = OpTypePointer CrossWorkgroup %[[TyStruct]]
1919
; CHECK: OpVariable %[[TyPtrStruct]] CrossWorkgroup %[[ConstComposite]]

llvm/test/CodeGen/SPIRV/pointers/irtrans-added-int-const-32-64.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
; CHECK-SPIRV64-DAG: %[[#IntTy:]] = OpTypeInt 64 0
1313
; CHECK-SPIRV32-DAG: %[[#IntTy:]] = OpTypeInt 32 0
1414
; CHECK-SPIRV-DAG: %[[#Const2:]] = OpConstant %[[#IntTy]] 2
15-
; CHECK-SPIRV-DAG: %[[#]] = OpSpecConstantOp %[[#]] 70 %[[#]] %[[#]] %[[#Const2]]
15+
; CHECK-SPIRV-DAG: %[[#]] = OpSpecConstantOp %[[#]] InBoundsPtrAccessChain %[[#]] %[[#]] %[[#Const2]]
1616
; CHECK-SPIRV: OpFunction
1717

1818
@a_var = addrspace(1) global [2 x i8] [i8 1, i8 1]

0 commit comments

Comments
 (0)