Skip to content

Commit 9e0a5a1

Browse files
add Decoration for SPV_INTEL_float_controls2; fix postlegalizer
1 parent 8cf4bd9 commit 9e0a5a1

File tree

4 files changed

+21
-30
lines changed

4 files changed

+21
-30
lines changed

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ SPIRVType *SPIRVGlobalRegistry::getOpTypeInt(unsigned Width,
126126
Width = adjustOpTypeIntWidth(Width);
127127
const SPIRVSubtarget &ST =
128128
cast<SPIRVSubtarget>(MIRBuilder.getMF().getSubtarget());
129-
if (ST.canUseExtension(
130-
SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers)) {
131-
MIRBuilder.buildInstr(SPIRV::OpExtension)
132-
.addImm(SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers);
133-
MIRBuilder.buildInstr(SPIRV::OpCapability)
134-
.addImm(SPIRV::Capability::ArbitraryPrecisionIntegersINTEL);
135-
}
136129
return createOpType(MIRBuilder, [&](MachineIRBuilder &MIRBuilder) {
130+
if (ST.canUseExtension(
131+
SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers)) {
132+
MIRBuilder.buildInstr(SPIRV::OpExtension)
133+
.addImm(SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers);
134+
MIRBuilder.buildInstr(SPIRV::OpCapability)
135+
.addImm(SPIRV::Capability::ArbitraryPrecisionIntegersINTEL);
136+
}
137137
return MIRBuilder.buildInstr(SPIRV::OpTypeInt)
138138
.addDef(createTypeVReg(MIRBuilder))
139139
.addImm(Width)

llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using namespace llvm;
2424
using namespace llvm::LegalizeActions;
2525
using namespace llvm::LegalityPredicates;
2626

27+
// clang-format off
2728
static const std::set<unsigned> TypeFoldingSupportingOpcs = {
2829
TargetOpcode::G_ADD,
2930
TargetOpcode::G_FADD,
@@ -54,6 +55,7 @@ static const std::set<unsigned> TypeFoldingSupportingOpcs = {
5455
TargetOpcode::G_SELECT,
5556
TargetOpcode::G_EXTRACT_VECTOR_ELT,
5657
};
58+
// clang-format on
5759

5860
bool isTypeFoldingSupported(unsigned Opcode) {
5961
return TypeFoldingSupportingOpcs.count(Opcode) > 0;

llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ extern void processInstr(MachineInstr &MI, MachineIRBuilder &MIB,
5555
MachineRegisterInfo &MRI, SPIRVGlobalRegistry *GR);
5656
} // namespace llvm
5757

58-
static bool isMetaInstr(unsigned Opcode) {
59-
return Opcode == SPIRV::GET_ID || Opcode == SPIRV::GET_fID ||
60-
Opcode == SPIRV::GET_pID || Opcode == SPIRV::GET_vID ||
61-
Opcode == SPIRV::GET_vfID || Opcode == SPIRV::GET_vpID ||
62-
Opcode == SPIRV::ASSIGN_TYPE;
63-
}
64-
6558
static bool mayBeInserted(unsigned Opcode) {
6659
switch (Opcode) {
6760
case TargetOpcode::G_SMAX:
@@ -112,27 +105,20 @@ static void processNewInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR,
112105
// registers, we must decorate them as if they were introduced in a
113106
// non-automatic way
114107
Register ResVReg = I.getOperand(0).getReg();
115-
SPIRVType *ResVType = GR->getSPIRVTypeForVReg(ResVReg);
116108
// Check if the register defined by the instruction is newly generated
117109
// or already processed
118-
if (!ResVType) {
119-
// Set type of the defined register
120-
ResVType = GR->getSPIRVTypeForVReg(I.getOperand(1).getReg());
121-
// Check if we have type defined for operands of the new instruction
122-
if (!ResVType)
123-
continue;
124-
// Set type & class
125-
setRegClassType(ResVReg, ResVType, GR, &MRI, *GR->CurMF, true);
126-
}
110+
if (MRI.getRegClassOrNull(ResVReg))
111+
continue;
112+
assert(GR->getSPIRVTypeForVReg(ResVReg) == nullptr);
113+
// Check if we have type defined for operands of the new instruction
114+
SPIRVType *ResVType = GR->getSPIRVTypeForVReg(I.getOperand(1).getReg());
115+
if (!ResVType)
116+
continue;
117+
// Set type & class
118+
setRegClassType(ResVReg, ResVType, GR, &MRI, *GR->CurMF, true);
127119
// If this is a simple operation that is to be reduced by TableGen
128120
// definition we must apply some of pre-legalizer rules here
129121
if (isTypeFoldingSupported(Opcode)) {
130-
// Check if the instruction newly generated or already processed
131-
MachineInstr *NextMI = I.getNextNode();
132-
if (NextMI && isMetaInstr(NextMI->getOpcode()))
133-
continue;
134-
// Restore usual instructions pattern for the newly inserted
135-
// instruction
136122
insertAssignInstr(ResVReg, nullptr, ResVType, GR, MIB, MRI);
137123
processInstr(I, MIB, MRI, GR);
138124
}

llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,9 @@ defm CacheControlStoreINTEL : DecorationOperand<6443, 0, 0, [], [CacheControlsIN
12501250
defm HostAccessINTEL : DecorationOperand<6188, 0, 0, [], [GlobalVariableHostAccessINTEL]>;
12511251
defm InitModeINTEL : DecorationOperand<6190, 0, 0, [], [GlobalVariableFPGADecorationsINTEL]>;
12521252
defm ImplementInRegisterMapINTEL : DecorationOperand<6191, 0, 0, [], [GlobalVariableFPGADecorationsINTEL]>;
1253+
defm FunctionRoundingModeINTEL : DecorationOperand<5822, 0, 0, [], [FunctionFloatControlINTEL]>;
1254+
defm FunctionDenormModeINTEL : DecorationOperand<5823, 0, 0, [], [FunctionFloatControlINTEL]>;
1255+
defm FunctionFloatingPointModeINTEL : DecorationOperand<6080, 0, 0, [], [FunctionFloatControlINTEL]>;
12531256

12541257
//===----------------------------------------------------------------------===//
12551258
// Multiclass used to define BuiltIn enum values and at the same time

0 commit comments

Comments
 (0)