@@ -862,7 +862,7 @@ bool SPIRVInstructionSelector::spvSelect(Register ResVReg,
862
862
.addUse (GV);
863
863
return MIB.constrainAllUses (TII, TRI, RBI) &&
864
864
BuildMI (BB, I, I.getDebugLoc (),
865
- TII.get (STI.isVulkanEnv ()
865
+ TII.get (STI.isLogicalSPIRV ()
866
866
? SPIRV::OpInBoundsAccessChain
867
867
: SPIRV::OpInBoundsPtrAccessChain))
868
868
.addDef (ResVReg)
@@ -1036,7 +1036,7 @@ bool SPIRVInstructionSelector::selectUnOp(Register ResVReg,
1036
1036
const SPIRVType *ResType,
1037
1037
MachineInstr &I,
1038
1038
unsigned Opcode) const {
1039
- if (STI.isOpenCLEnv () && I.getOperand (1 ).isReg ()) {
1039
+ if (! STI.isLogicalSPIRV () && I.getOperand (1 ).isReg ()) {
1040
1040
Register SrcReg = I.getOperand (1 ).getReg ();
1041
1041
bool IsGV = false ;
1042
1042
for (MachineRegisterInfo::def_instr_iterator DefIt =
@@ -2069,7 +2069,7 @@ bool SPIRVInstructionSelector::selectDot4AddPackedExpansion(
2069
2069
auto ExtractOp =
2070
2070
Signed ? SPIRV::OpBitFieldSExtract : SPIRV::OpBitFieldUExtract;
2071
2071
2072
- bool ZeroAsNull = STI.isOpenCLEnv ();
2072
+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
2073
2073
// Extract the i8 element, multiply and add it to the accumulator
2074
2074
for (unsigned i = 0 ; i < 4 ; i++) {
2075
2075
// A[i]
@@ -2209,7 +2209,7 @@ bool SPIRVInstructionSelector::selectWaveOpInst(Register ResVReg,
2209
2209
.addDef (ResVReg)
2210
2210
.addUse (GR.getSPIRVTypeID (ResType))
2211
2211
.addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I,
2212
- IntTy, TII, STI.isOpenCLEnv ()));
2212
+ IntTy, TII, ! STI.isLogicalSPIRV ()));
2213
2213
2214
2214
for (unsigned J = 2 ; J < I.getNumOperands (); J++) {
2215
2215
BMI.addUse (I.getOperand (J).getReg ());
@@ -2233,7 +2233,7 @@ bool SPIRVInstructionSelector::selectWaveActiveCountBits(
2233
2233
.addDef (ResVReg)
2234
2234
.addUse (GR.getSPIRVTypeID (ResType))
2235
2235
.addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy,
2236
- TII, STI.isOpenCLEnv ()))
2236
+ TII, ! STI.isLogicalSPIRV ()))
2237
2237
.addImm (SPIRV::GroupOperation::Reduce)
2238
2238
.addUse (BallotReg)
2239
2239
.constrainAllUses (TII, TRI, RBI);
@@ -2264,7 +2264,7 @@ bool SPIRVInstructionSelector::selectWaveReduceMax(Register ResVReg,
2264
2264
.addDef (ResVReg)
2265
2265
.addUse (GR.getSPIRVTypeID (ResType))
2266
2266
.addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy, TII,
2267
- STI.isOpenCLEnv ()))
2267
+ ! STI.isLogicalSPIRV ()))
2268
2268
.addImm (SPIRV::GroupOperation::Reduce)
2269
2269
.addUse (I.getOperand (2 ).getReg ())
2270
2270
.constrainAllUses (TII, TRI, RBI);
@@ -2291,7 +2291,7 @@ bool SPIRVInstructionSelector::selectWaveReduceSum(Register ResVReg,
2291
2291
.addDef (ResVReg)
2292
2292
.addUse (GR.getSPIRVTypeID (ResType))
2293
2293
.addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy, TII,
2294
- STI.isOpenCLEnv ()))
2294
+ ! STI.isLogicalSPIRV ()))
2295
2295
.addImm (SPIRV::GroupOperation::Reduce)
2296
2296
.addUse (I.getOperand (2 ).getReg ());
2297
2297
}
@@ -2513,7 +2513,7 @@ bool SPIRVInstructionSelector::selectFCmp(Register ResVReg,
2513
2513
Register SPIRVInstructionSelector::buildZerosVal (const SPIRVType *ResType,
2514
2514
MachineInstr &I) const {
2515
2515
// OpenCL uses nulls for Zero. In HLSL we don't use null constants.
2516
- bool ZeroAsNull = STI.isOpenCLEnv ();
2516
+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
2517
2517
if (ResType->getOpcode () == SPIRV::OpTypeVector)
2518
2518
return GR.getOrCreateConstVector (0UL , I, ResType, TII, ZeroAsNull);
2519
2519
return GR.getOrCreateConstInt (0 , I, ResType, TII, ZeroAsNull);
@@ -2522,7 +2522,7 @@ Register SPIRVInstructionSelector::buildZerosVal(const SPIRVType *ResType,
2522
2522
Register SPIRVInstructionSelector::buildZerosValF (const SPIRVType *ResType,
2523
2523
MachineInstr &I) const {
2524
2524
// OpenCL uses nulls for Zero. In HLSL we don't use null constants.
2525
- bool ZeroAsNull = STI.isOpenCLEnv ();
2525
+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
2526
2526
APFloat VZero = getZeroFP (GR.getTypeForSPIRVType (ResType));
2527
2527
if (ResType->getOpcode () == SPIRV::OpTypeVector)
2528
2528
return GR.getOrCreateConstVector (VZero, I, ResType, TII, ZeroAsNull);
@@ -2532,7 +2532,7 @@ Register SPIRVInstructionSelector::buildZerosValF(const SPIRVType *ResType,
2532
2532
Register SPIRVInstructionSelector::buildOnesValF (const SPIRVType *ResType,
2533
2533
MachineInstr &I) const {
2534
2534
// OpenCL uses nulls for Zero. In HLSL we don't use null constants.
2535
- bool ZeroAsNull = STI.isOpenCLEnv ();
2535
+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
2536
2536
APFloat VOne = getOneFP (GR.getTypeForSPIRVType (ResType));
2537
2537
if (ResType->getOpcode () == SPIRV::OpTypeVector)
2538
2538
return GR.getOrCreateConstVector (VOne, I, ResType, TII, ZeroAsNull);
@@ -2720,10 +2720,10 @@ bool SPIRVInstructionSelector::selectConst(Register ResVReg,
2720
2720
Reg = GR.getOrCreateConstNullPtr (MIRBuilder, ResType);
2721
2721
} else if (Opcode == TargetOpcode::G_FCONSTANT) {
2722
2722
Reg = GR.getOrCreateConstFP (I.getOperand (1 ).getFPImm ()->getValue (), I,
2723
- ResType, TII, STI.isOpenCLEnv ());
2723
+ ResType, TII, ! STI.isLogicalSPIRV ());
2724
2724
} else {
2725
2725
Reg = GR.getOrCreateConstInt (I.getOperand (1 ).getCImm ()->getZExtValue (), I,
2726
- ResType, TII, STI.isOpenCLEnv ());
2726
+ ResType, TII, ! STI.isLogicalSPIRV ());
2727
2727
}
2728
2728
return Reg == ResVReg ? true : BuildCOPY (ResVReg, Reg, I);
2729
2729
}
@@ -2803,7 +2803,7 @@ bool SPIRVInstructionSelector::selectGEP(Register ResVReg,
2803
2803
// OpAccessChain could be used for OpenCL, but the SPIRV-LLVM Translator only
2804
2804
// relies on PtrAccessChain, so we'll try not to deviate. For Vulkan however,
2805
2805
// we have to use Op[InBounds]AccessChain.
2806
- const unsigned Opcode = STI.isVulkanEnv ()
2806
+ const unsigned Opcode = STI.isLogicalSPIRV ()
2807
2807
? (IsGEPInBounds ? SPIRV::OpInBoundsAccessChain
2808
2808
: SPIRV::OpAccessChain)
2809
2809
: (IsGEPInBounds ? SPIRV::OpInBoundsPtrAccessChain
@@ -3483,7 +3483,7 @@ bool SPIRVInstructionSelector::selectFirstBitSet64Overflow(
3483
3483
3484
3484
// On odd component counts we need to handle one more component
3485
3485
if (CurrentComponent != ComponentCount) {
3486
- bool ZeroAsNull = STI.isOpenCLEnv ();
3486
+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
3487
3487
Register FinalElemReg = MRI->createVirtualRegister (GR.getRegClass (I64Type));
3488
3488
Register ConstIntLastIdx = GR.getOrCreateConstInt (
3489
3489
ComponentCount - 1 , I, BaseType, TII, ZeroAsNull);
@@ -3513,7 +3513,7 @@ bool SPIRVInstructionSelector::selectFirstBitSet64(
3513
3513
Register SrcReg, unsigned BitSetOpcode, bool SwapPrimarySide) const {
3514
3514
unsigned ComponentCount = GR.getScalarOrVectorComponentCount (ResType);
3515
3515
SPIRVType *BaseType = GR.retrieveScalarOrVectorIntType (ResType);
3516
- bool ZeroAsNull = STI.isOpenCLEnv ();
3516
+ bool ZeroAsNull = ! STI.isLogicalSPIRV ();
3517
3517
Register ConstIntZero =
3518
3518
GR.getOrCreateConstInt (0 , I, BaseType, TII, ZeroAsNull);
3519
3519
Register ConstIntOne =
@@ -3715,7 +3715,10 @@ bool SPIRVInstructionSelector::selectAllocaArray(Register ResVReg,
3715
3715
.addUse (GR.getSPIRVTypeID (ResType))
3716
3716
.addUse (I.getOperand (2 ).getReg ())
3717
3717
.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 ()) {
3719
3722
unsigned Alignment = I.getOperand (3 ).getImm ();
3720
3723
buildOpDecorate (ResVReg, I, TII, SPIRV::Decoration::Alignment, {Alignment});
3721
3724
}
@@ -3734,7 +3737,10 @@ bool SPIRVInstructionSelector::selectFrameIndex(Register ResVReg,
3734
3737
.addUse (GR.getSPIRVTypeID (ResType))
3735
3738
.addImm (static_cast <uint32_t >(SPIRV::StorageClass::Function))
3736
3739
.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 ()) {
3738
3744
unsigned Alignment = I.getOperand (2 ).getImm ();
3739
3745
buildOpDecorate (ResVReg, *It, TII, SPIRV::Decoration::Alignment,
3740
3746
{Alignment});
0 commit comments