@@ -862,7 +862,7 @@ bool SPIRVInstructionSelector::spvSelect(Register ResVReg,
862862 .addUse (GV);
863863 return MIB.constrainAllUses (TII, TRI, RBI) &&
864864 BuildMI (BB, I, I.getDebugLoc (),
865- TII.get (STI.isVulkanEnv ()
865+ TII.get (STI.isLogicalSPIRV ()
866866 ? SPIRV::OpInBoundsAccessChain
867867 : SPIRV::OpInBoundsPtrAccessChain))
868868 .addDef (ResVReg)
@@ -1036,7 +1036,7 @@ bool SPIRVInstructionSelector::selectUnOp(Register ResVReg,
10361036 const SPIRVType *ResType,
10371037 MachineInstr &I,
10381038 unsigned Opcode) const {
1039- if (STI.isOpenCLEnv () && I.getOperand (1 ).isReg ()) {
1039+ if (! STI.isLogicalSPIRV () && I.getOperand (1 ).isReg ()) {
10401040 Register SrcReg = I.getOperand (1 ).getReg ();
10411041 bool IsGV = false ;
10421042 for (MachineRegisterInfo::def_instr_iterator DefIt =
@@ -2069,7 +2069,7 @@ bool SPIRVInstructionSelector::selectDot4AddPackedExpansion(
20692069 auto ExtractOp =
20702070 Signed ? SPIRV::OpBitFieldSExtract : SPIRV::OpBitFieldUExtract;
20712071
2072- bool ZeroAsNull = STI.isOpenCLEnv ();
2072+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
20732073 // Extract the i8 element, multiply and add it to the accumulator
20742074 for (unsigned i = 0 ; i < 4 ; i++) {
20752075 // A[i]
@@ -2209,7 +2209,7 @@ bool SPIRVInstructionSelector::selectWaveOpInst(Register ResVReg,
22092209 .addDef (ResVReg)
22102210 .addUse (GR.getSPIRVTypeID (ResType))
22112211 .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I,
2212- IntTy, TII, STI.isOpenCLEnv ()));
2212+ IntTy, TII, ! STI.isLogicalSPIRV ()));
22132213
22142214 for (unsigned J = 2 ; J < I.getNumOperands (); J++) {
22152215 BMI.addUse (I.getOperand (J).getReg ());
@@ -2233,7 +2233,7 @@ bool SPIRVInstructionSelector::selectWaveActiveCountBits(
22332233 .addDef (ResVReg)
22342234 .addUse (GR.getSPIRVTypeID (ResType))
22352235 .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy,
2236- TII, STI.isOpenCLEnv ()))
2236+ TII, ! STI.isLogicalSPIRV ()))
22372237 .addImm (SPIRV::GroupOperation::Reduce)
22382238 .addUse (BallotReg)
22392239 .constrainAllUses (TII, TRI, RBI);
@@ -2264,7 +2264,7 @@ bool SPIRVInstructionSelector::selectWaveReduceMax(Register ResVReg,
22642264 .addDef (ResVReg)
22652265 .addUse (GR.getSPIRVTypeID (ResType))
22662266 .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy, TII,
2267- STI.isOpenCLEnv ()))
2267+ ! STI.isLogicalSPIRV ()))
22682268 .addImm (SPIRV::GroupOperation::Reduce)
22692269 .addUse (I.getOperand (2 ).getReg ())
22702270 .constrainAllUses (TII, TRI, RBI);
@@ -2291,7 +2291,7 @@ bool SPIRVInstructionSelector::selectWaveReduceSum(Register ResVReg,
22912291 .addDef (ResVReg)
22922292 .addUse (GR.getSPIRVTypeID (ResType))
22932293 .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy, TII,
2294- STI.isOpenCLEnv ()))
2294+ ! STI.isLogicalSPIRV ()))
22952295 .addImm (SPIRV::GroupOperation::Reduce)
22962296 .addUse (I.getOperand (2 ).getReg ());
22972297}
@@ -2513,7 +2513,7 @@ bool SPIRVInstructionSelector::selectFCmp(Register ResVReg,
25132513Register SPIRVInstructionSelector::buildZerosVal (const SPIRVType *ResType,
25142514 MachineInstr &I) const {
25152515 // OpenCL uses nulls for Zero. In HLSL we don't use null constants.
2516- bool ZeroAsNull = STI.isOpenCLEnv ();
2516+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
25172517 if (ResType->getOpcode () == SPIRV::OpTypeVector)
25182518 return GR.getOrCreateConstVector (0UL , I, ResType, TII, ZeroAsNull);
25192519 return GR.getOrCreateConstInt (0 , I, ResType, TII, ZeroAsNull);
@@ -2522,7 +2522,7 @@ Register SPIRVInstructionSelector::buildZerosVal(const SPIRVType *ResType,
25222522Register SPIRVInstructionSelector::buildZerosValF (const SPIRVType *ResType,
25232523 MachineInstr &I) const {
25242524 // OpenCL uses nulls for Zero. In HLSL we don't use null constants.
2525- bool ZeroAsNull = STI.isOpenCLEnv ();
2525+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
25262526 APFloat VZero = getZeroFP (GR.getTypeForSPIRVType (ResType));
25272527 if (ResType->getOpcode () == SPIRV::OpTypeVector)
25282528 return GR.getOrCreateConstVector (VZero, I, ResType, TII, ZeroAsNull);
@@ -2532,7 +2532,7 @@ Register SPIRVInstructionSelector::buildZerosValF(const SPIRVType *ResType,
25322532Register SPIRVInstructionSelector::buildOnesValF (const SPIRVType *ResType,
25332533 MachineInstr &I) const {
25342534 // OpenCL uses nulls for Zero. In HLSL we don't use null constants.
2535- bool ZeroAsNull = STI.isOpenCLEnv ();
2535+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
25362536 APFloat VOne = getOneFP (GR.getTypeForSPIRVType (ResType));
25372537 if (ResType->getOpcode () == SPIRV::OpTypeVector)
25382538 return GR.getOrCreateConstVector (VOne, I, ResType, TII, ZeroAsNull);
@@ -2720,10 +2720,10 @@ bool SPIRVInstructionSelector::selectConst(Register ResVReg,
27202720 Reg = GR.getOrCreateConstNullPtr (MIRBuilder, ResType);
27212721 } else if (Opcode == TargetOpcode::G_FCONSTANT) {
27222722 Reg = GR.getOrCreateConstFP (I.getOperand (1 ).getFPImm ()->getValue (), I,
2723- ResType, TII, STI.isOpenCLEnv ());
2723+ ResType, TII, ! STI.isLogicalSPIRV ());
27242724 } else {
27252725 Reg = GR.getOrCreateConstInt (I.getOperand (1 ).getCImm ()->getZExtValue (), I,
2726- ResType, TII, STI.isOpenCLEnv ());
2726+ ResType, TII, ! STI.isLogicalSPIRV ());
27272727 }
27282728 return Reg == ResVReg ? true : BuildCOPY (ResVReg, Reg, I);
27292729}
@@ -2803,7 +2803,7 @@ bool SPIRVInstructionSelector::selectGEP(Register ResVReg,
28032803 // OpAccessChain could be used for OpenCL, but the SPIRV-LLVM Translator only
28042804 // relies on PtrAccessChain, so we'll try not to deviate. For Vulkan however,
28052805 // we have to use Op[InBounds]AccessChain.
2806- const unsigned Opcode = STI.isVulkanEnv ()
2806+ const unsigned Opcode = STI.isLogicalSPIRV ()
28072807 ? (IsGEPInBounds ? SPIRV::OpInBoundsAccessChain
28082808 : SPIRV::OpAccessChain)
28092809 : (IsGEPInBounds ? SPIRV::OpInBoundsPtrAccessChain
@@ -3483,7 +3483,7 @@ bool SPIRVInstructionSelector::selectFirstBitSet64Overflow(
34833483
34843484 // On odd component counts we need to handle one more component
34853485 if (CurrentComponent != ComponentCount) {
3486- bool ZeroAsNull = STI.isOpenCLEnv ();
3486+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
34873487 Register FinalElemReg = MRI->createVirtualRegister (GR.getRegClass (I64Type));
34883488 Register ConstIntLastIdx = GR.getOrCreateConstInt (
34893489 ComponentCount - 1 , I, BaseType, TII, ZeroAsNull);
@@ -3513,7 +3513,7 @@ bool SPIRVInstructionSelector::selectFirstBitSet64(
35133513 Register SrcReg, unsigned BitSetOpcode, bool SwapPrimarySide) const {
35143514 unsigned ComponentCount = GR.getScalarOrVectorComponentCount (ResType);
35153515 SPIRVType *BaseType = GR.retrieveScalarOrVectorIntType (ResType);
3516- bool ZeroAsNull = STI.isOpenCLEnv ();
3516+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
35173517 Register ConstIntZero =
35183518 GR.getOrCreateConstInt (0 , I, BaseType, TII, ZeroAsNull);
35193519 Register ConstIntOne =
@@ -3715,7 +3715,10 @@ bool SPIRVInstructionSelector::selectAllocaArray(Register ResVReg,
37153715 .addUse (GR.getSPIRVTypeID (ResType))
37163716 .addUse (I.getOperand (2 ).getReg ())
37173717 .constrainAllUses (TII, TRI, RBI);
3718- if (!STI.isVulkanEnv ()) {
3718+ // FIXME: Alignment requires Kernel Capabilities, so we only emit it if we are
3719+ // in OpenCL env. However, that is not good enough at the moment, so we use
3720+ // `!isLogicalSPIRV()` instead.
3721+ if (!STI.isLogicalSPIRV ()) {
37193722 unsigned Alignment = I.getOperand (3 ).getImm ();
37203723 buildOpDecorate (ResVReg, I, TII, SPIRV::Decoration::Alignment, {Alignment});
37213724 }
@@ -3734,7 +3737,10 @@ bool SPIRVInstructionSelector::selectFrameIndex(Register ResVReg,
37343737 .addUse (GR.getSPIRVTypeID (ResType))
37353738 .addImm (static_cast <uint32_t >(SPIRV::StorageClass::Function))
37363739 .constrainAllUses (TII, TRI, RBI);
3737- if (!STI.isVulkanEnv ()) {
3740+ // FIXME: Alignment requires Kernel Capabilities, so we only emit it if we are
3741+ // in OpenCL env. However, that is not good enough at the moment, so we use
3742+ // `!isLogicalSPIRV()` instead.
3743+ if (!STI.isLogicalSPIRV ()) {
37383744 unsigned Alignment = I.getOperand (2 ).getImm ();
37393745 buildOpDecorate (ResVReg, *It, TII, SPIRV::Decoration::Alignment,
37403746 {Alignment});
0 commit comments