Skip to content

Commit 05093e2

Browse files
authored
[Spirv][HLSL] Add OpAll lowering and float vec support (#87952)
The main point of this change was to add support for HLSL's all intrinsic. In the process of doing that I found a few issues around creating an `OpConstantComposite` via `buildZerosVal`. First the current code didn't support floats so the process of adding `buildZerosValF` meant I needed a float version of `getOrCreateIntConstVector`. After doing so I renamed both versions to `getOrCreateConstVector`. That meant I needed to create a float type version of `getOrCreateIntCompositeOrNull`. Luckily the type information was low for this function so was able to split it out into a helpwe and rename `getOrCreateIntCompositeOrNull` to `getOrCreateCompositeOrNull` With the exception of type handling differences of the code and Null vs 0 Constant Op codes these functions should be identical. To handle scalar floats I could not use `buildConstantFP` like this PR did: 0a2aaab5aba46#diff-733a189c5a8c3211f3a04fd6e719952a3fa231eadd8a7f11e6ecf1e584d57411R1603 because that would create too many superfluous registers (that causes problems in the validator), I had to create a float version of `getOrCreateConstInt` which I called `getOrCreateConstFP`. similar problems with doing it like this: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp#L1540. `buildZerosValF` also has a use of a function `getZeroFP`. This is because half, float, and double scalar values of 0 would collide in `SPIRVDuplicatesTracker<Constant> CT` if you use `APFloat(0.0f)`. `getORCreateConstFP` needed its own version of `getOrCreateConstIntReg` which I called `getOrCreateConstFloatReg` The one difference in this function is `getOrCreateConstFloatReg` returns a bit width so we don't have to call `getScalarOrVectorBitWidth` twice ie when it is used again in `getOrCreateConstFP` for `OpConstantF` `addNumImm`. `getOrCreateConstFloatReg` needed an `assignFloatTypeToVReg` helper which called a `getOrCreateSPIRVFloatType` helper. There was no equivalent IntegerType::get for floats so I handled this with a switch statement on bit widths to get the right LLVM float type. Finally, there is the use of `bool ZeroAsNull = STI.isOpenCLEnv();` This is partly a cosmetic change. When Zeros are treated as nulls, we don't create `OpConstantComposite` vectors which is something we do in the DXCs SPIRV backend. The DXC SPIRV backend also does not use `OpConstantNull`. Finally, I needed a means to test the behavior of the OpConstantNull and `OpConstantComposite` changes and this was one way I could do that via the same tests.
1 parent d347235 commit 05093e2

File tree

4 files changed

+506
-39
lines changed

4 files changed

+506
-39
lines changed

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp

Lines changed: 191 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
#include "SPIRVSubtarget.h"
2121
#include "SPIRVTargetMachine.h"
2222
#include "SPIRVUtils.h"
23+
#include "llvm/ADT/APInt.h"
24+
#include "llvm/IR/Constants.h"
25+
#include "llvm/IR/Type.h"
2326
#include "llvm/IR/TypedPointerType.h"
27+
#include "llvm/Support/Casting.h"
28+
#include <cassert>
2429

2530
using namespace llvm;
2631
SPIRVGlobalRegistry::SPIRVGlobalRegistry(unsigned PointerSize)
@@ -35,6 +40,15 @@ SPIRVType *SPIRVGlobalRegistry::assignIntTypeToVReg(unsigned BitWidth,
3540
return SpirvType;
3641
}
3742

43+
SPIRVType *
44+
SPIRVGlobalRegistry::assignFloatTypeToVReg(unsigned BitWidth, Register VReg,
45+
MachineInstr &I,
46+
const SPIRVInstrInfo &TII) {
47+
SPIRVType *SpirvType = getOrCreateSPIRVFloatType(BitWidth, I, TII);
48+
assignSPIRVTypeToVReg(SpirvType, VReg, *CurMF);
49+
return SpirvType;
50+
}
51+
3852
SPIRVType *SPIRVGlobalRegistry::assignVectTypeToVReg(
3953
SPIRVType *BaseType, unsigned NumElements, Register VReg, MachineInstr &I,
4054
const SPIRVInstrInfo &TII) {
@@ -151,6 +165,8 @@ SPIRVGlobalRegistry::getOrCreateConstIntReg(uint64_t Val, SPIRVType *SpvType,
151165
Register Res = DT.find(CI, CurMF);
152166
if (!Res.isValid()) {
153167
unsigned BitWidth = SpvType ? getScalarOrVectorBitWidth(SpvType) : 32;
168+
// TODO: handle cases where the type is not 32bit wide
169+
// TODO: https://github.com/llvm/llvm-project/issues/88129
154170
LLT LLTy = LLT::scalar(32);
155171
Res = CurMF->getRegInfo().createGenericVirtualRegister(LLTy);
156172
CurMF->getRegInfo().setRegClass(Res, &SPIRV::IDRegClass);
@@ -164,9 +180,83 @@ SPIRVGlobalRegistry::getOrCreateConstIntReg(uint64_t Val, SPIRVType *SpvType,
164180
return std::make_tuple(Res, CI, NewInstr);
165181
}
166182

183+
std::tuple<Register, ConstantFP *, bool, unsigned>
184+
SPIRVGlobalRegistry::getOrCreateConstFloatReg(APFloat Val, SPIRVType *SpvType,
185+
MachineIRBuilder *MIRBuilder,
186+
MachineInstr *I,
187+
const SPIRVInstrInfo *TII) {
188+
const Type *LLVMFloatTy;
189+
LLVMContext &Ctx = CurMF->getFunction().getContext();
190+
unsigned BitWidth = 32;
191+
if (SpvType)
192+
LLVMFloatTy = getTypeForSPIRVType(SpvType);
193+
else {
194+
LLVMFloatTy = Type::getFloatTy(Ctx);
195+
if (MIRBuilder)
196+
SpvType = getOrCreateSPIRVType(LLVMFloatTy, *MIRBuilder);
197+
}
198+
bool NewInstr = false;
199+
// Find a constant in DT or build a new one.
200+
auto *const CI = ConstantFP::get(Ctx, Val);
201+
Register Res = DT.find(CI, CurMF);
202+
if (!Res.isValid()) {
203+
if (SpvType)
204+
BitWidth = getScalarOrVectorBitWidth(SpvType);
205+
// TODO: handle cases where the type is not 32bit wide
206+
// TODO: https://github.com/llvm/llvm-project/issues/88129
207+
LLT LLTy = LLT::scalar(32);
208+
Res = CurMF->getRegInfo().createGenericVirtualRegister(LLTy);
209+
CurMF->getRegInfo().setRegClass(Res, &SPIRV::IDRegClass);
210+
if (MIRBuilder)
211+
assignTypeToVReg(LLVMFloatTy, Res, *MIRBuilder);
212+
else
213+
assignFloatTypeToVReg(BitWidth, Res, *I, *TII);
214+
DT.add(CI, CurMF, Res);
215+
NewInstr = true;
216+
}
217+
return std::make_tuple(Res, CI, NewInstr, BitWidth);
218+
}
219+
220+
Register SPIRVGlobalRegistry::getOrCreateConstFP(APFloat Val, MachineInstr &I,
221+
SPIRVType *SpvType,
222+
const SPIRVInstrInfo &TII,
223+
bool ZeroAsNull) {
224+
assert(SpvType);
225+
ConstantFP *CI;
226+
Register Res;
227+
bool New;
228+
unsigned BitWidth;
229+
std::tie(Res, CI, New, BitWidth) =
230+
getOrCreateConstFloatReg(Val, SpvType, nullptr, &I, &TII);
231+
// If we have found Res register which is defined by the passed G_CONSTANT
232+
// machine instruction, a new constant instruction should be created.
233+
if (!New && (!I.getOperand(0).isReg() || Res != I.getOperand(0).getReg()))
234+
return Res;
235+
MachineInstrBuilder MIB;
236+
MachineBasicBlock &BB = *I.getParent();
237+
// In OpenCL OpConstantNull - Scalar floating point: +0.0 (all bits 0)
238+
if (Val.isPosZero() && ZeroAsNull) {
239+
MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpConstantNull))
240+
.addDef(Res)
241+
.addUse(getSPIRVTypeID(SpvType));
242+
} else {
243+
MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpConstantF))
244+
.addDef(Res)
245+
.addUse(getSPIRVTypeID(SpvType));
246+
addNumImm(
247+
APInt(BitWidth, CI->getValueAPF().bitcastToAPInt().getZExtValue()),
248+
MIB);
249+
}
250+
const auto &ST = CurMF->getSubtarget();
251+
constrainSelectedInstRegOperands(*MIB, *ST.getInstrInfo(),
252+
*ST.getRegisterInfo(), *ST.getRegBankInfo());
253+
return Res;
254+
}
255+
167256
Register SPIRVGlobalRegistry::getOrCreateConstInt(uint64_t Val, MachineInstr &I,
168257
SPIRVType *SpvType,
169-
const SPIRVInstrInfo &TII) {
258+
const SPIRVInstrInfo &TII,
259+
bool ZeroAsNull) {
170260
assert(SpvType);
171261
ConstantInt *CI;
172262
Register Res;
@@ -179,7 +269,7 @@ Register SPIRVGlobalRegistry::getOrCreateConstInt(uint64_t Val, MachineInstr &I,
179269
return Res;
180270
MachineInstrBuilder MIB;
181271
MachineBasicBlock &BB = *I.getParent();
182-
if (Val) {
272+
if (Val || !ZeroAsNull) {
183273
MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpConstantI))
184274
.addDef(Res)
185275
.addUse(getSPIRVTypeID(SpvType));
@@ -270,21 +360,46 @@ Register SPIRVGlobalRegistry::buildConstantFP(APFloat Val,
270360
return Res;
271361
}
272362

273-
Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
274-
uint64_t Val, MachineInstr &I, SPIRVType *SpvType,
363+
Register SPIRVGlobalRegistry::getOrCreateBaseRegister(Constant *Val,
364+
MachineInstr &I,
365+
SPIRVType *SpvType,
366+
const SPIRVInstrInfo &TII,
367+
unsigned BitWidth) {
368+
SPIRVType *Type = SpvType;
369+
if (SpvType->getOpcode() == SPIRV::OpTypeVector ||
370+
SpvType->getOpcode() == SPIRV::OpTypeArray) {
371+
auto EleTypeReg = SpvType->getOperand(1).getReg();
372+
Type = getSPIRVTypeForVReg(EleTypeReg);
373+
}
374+
if (Type->getOpcode() == SPIRV::OpTypeFloat) {
375+
SPIRVType *SpvBaseType = getOrCreateSPIRVFloatType(BitWidth, I, TII);
376+
return getOrCreateConstFP(dyn_cast<ConstantFP>(Val)->getValue(), I,
377+
SpvBaseType, TII);
378+
}
379+
assert(Type->getOpcode() == SPIRV::OpTypeInt);
380+
SPIRVType *SpvBaseType = getOrCreateSPIRVIntegerType(BitWidth, I, TII);
381+
return getOrCreateConstInt(Val->getUniqueInteger().getSExtValue(), I,
382+
SpvBaseType, TII);
383+
}
384+
385+
Register SPIRVGlobalRegistry::getOrCreateCompositeOrNull(
386+
Constant *Val, MachineInstr &I, SPIRVType *SpvType,
275387
const SPIRVInstrInfo &TII, Constant *CA, unsigned BitWidth,
276-
unsigned ElemCnt) {
388+
unsigned ElemCnt, bool ZeroAsNull) {
277389
// Find a constant vector in DT or build a new one.
278390
Register Res = DT.find(CA, CurMF);
391+
// If no values are attached, the composite is null constant.
392+
bool IsNull = Val->isNullValue() && ZeroAsNull;
279393
if (!Res.isValid()) {
280-
SPIRVType *SpvBaseType = getOrCreateSPIRVIntegerType(BitWidth, I, TII);
281394
// SpvScalConst should be created before SpvVecConst to avoid undefined ID
282395
// error on validation.
283396
// TODO: can moved below once sorting of types/consts/defs is implemented.
284397
Register SpvScalConst;
285-
if (Val)
286-
SpvScalConst = getOrCreateConstInt(Val, I, SpvBaseType, TII);
287-
// TODO: maybe use bitwidth of base type.
398+
if (!IsNull)
399+
SpvScalConst = getOrCreateBaseRegister(Val, I, SpvType, TII, BitWidth);
400+
401+
// TODO: handle cases where the type is not 32bit wide
402+
// TODO: https://github.com/llvm/llvm-project/issues/88129
288403
LLT LLTy = LLT::scalar(32);
289404
Register SpvVecConst =
290405
CurMF->getRegInfo().createGenericVirtualRegister(LLTy);
@@ -293,7 +408,7 @@ Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
293408
DT.add(CA, CurMF, SpvVecConst);
294409
MachineInstrBuilder MIB;
295410
MachineBasicBlock &BB = *I.getParent();
296-
if (Val) {
411+
if (!IsNull) {
297412
MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpConstantComposite))
298413
.addDef(SpvVecConst)
299414
.addUse(getSPIRVTypeID(SpvType));
@@ -313,20 +428,42 @@ Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
313428
return Res;
314429
}
315430

316-
Register
317-
SPIRVGlobalRegistry::getOrCreateConsIntVector(uint64_t Val, MachineInstr &I,
318-
SPIRVType *SpvType,
319-
const SPIRVInstrInfo &TII) {
431+
Register SPIRVGlobalRegistry::getOrCreateConstVector(uint64_t Val,
432+
MachineInstr &I,
433+
SPIRVType *SpvType,
434+
const SPIRVInstrInfo &TII,
435+
bool ZeroAsNull) {
320436
const Type *LLVMTy = getTypeForSPIRVType(SpvType);
321437
assert(LLVMTy->isVectorTy());
322438
const FixedVectorType *LLVMVecTy = cast<FixedVectorType>(LLVMTy);
323439
Type *LLVMBaseTy = LLVMVecTy->getElementType();
324-
const auto ConstInt = ConstantInt::get(LLVMBaseTy, Val);
325-
auto ConstVec =
326-
ConstantVector::getSplat(LLVMVecTy->getElementCount(), ConstInt);
440+
assert(LLVMBaseTy->isIntegerTy());
441+
auto *ConstVal = ConstantInt::get(LLVMBaseTy, Val);
442+
auto *ConstVec =
443+
ConstantVector::getSplat(LLVMVecTy->getElementCount(), ConstVal);
327444
unsigned BW = getScalarOrVectorBitWidth(SpvType);
328-
return getOrCreateIntCompositeOrNull(Val, I, SpvType, TII, ConstVec, BW,
329-
SpvType->getOperand(2).getImm());
445+
return getOrCreateCompositeOrNull(ConstVal, I, SpvType, TII, ConstVec, BW,
446+
SpvType->getOperand(2).getImm(),
447+
ZeroAsNull);
448+
}
449+
450+
Register SPIRVGlobalRegistry::getOrCreateConstVector(APFloat Val,
451+
MachineInstr &I,
452+
SPIRVType *SpvType,
453+
const SPIRVInstrInfo &TII,
454+
bool ZeroAsNull) {
455+
const Type *LLVMTy = getTypeForSPIRVType(SpvType);
456+
assert(LLVMTy->isVectorTy());
457+
const FixedVectorType *LLVMVecTy = cast<FixedVectorType>(LLVMTy);
458+
Type *LLVMBaseTy = LLVMVecTy->getElementType();
459+
assert(LLVMBaseTy->isFloatingPointTy());
460+
auto *ConstVal = ConstantFP::get(LLVMBaseTy, Val);
461+
auto *ConstVec =
462+
ConstantVector::getSplat(LLVMVecTy->getElementCount(), ConstVal);
463+
unsigned BW = getScalarOrVectorBitWidth(SpvType);
464+
return getOrCreateCompositeOrNull(ConstVal, I, SpvType, TII, ConstVec, BW,
465+
SpvType->getOperand(2).getImm(),
466+
ZeroAsNull);
330467
}
331468

332469
Register
@@ -337,13 +474,13 @@ SPIRVGlobalRegistry::getOrCreateConsIntArray(uint64_t Val, MachineInstr &I,
337474
assert(LLVMTy->isArrayTy());
338475
const ArrayType *LLVMArrTy = cast<ArrayType>(LLVMTy);
339476
Type *LLVMBaseTy = LLVMArrTy->getElementType();
340-
const auto ConstInt = ConstantInt::get(LLVMBaseTy, Val);
341-
auto ConstArr =
477+
auto *ConstInt = ConstantInt::get(LLVMBaseTy, Val);
478+
auto *ConstArr =
342479
ConstantArray::get(const_cast<ArrayType *>(LLVMArrTy), {ConstInt});
343480
SPIRVType *SpvBaseTy = getSPIRVTypeForVReg(SpvType->getOperand(1).getReg());
344481
unsigned BW = getScalarOrVectorBitWidth(SpvBaseTy);
345-
return getOrCreateIntCompositeOrNull(Val, I, SpvType, TII, ConstArr, BW,
346-
LLVMArrTy->getNumElements());
482+
return getOrCreateCompositeOrNull(ConstInt, I, SpvType, TII, ConstArr, BW,
483+
LLVMArrTy->getNumElements());
347484
}
348485

349486
Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
@@ -1093,21 +1230,48 @@ SPIRVType *SPIRVGlobalRegistry::finishCreatingSPIRVType(const Type *LLVMTy,
10931230
return SpirvType;
10941231
}
10951232

1096-
SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVIntegerType(
1097-
unsigned BitWidth, MachineInstr &I, const SPIRVInstrInfo &TII) {
1098-
Type *LLVMTy = IntegerType::get(CurMF->getFunction().getContext(), BitWidth);
1233+
SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVType(unsigned BitWidth,
1234+
MachineInstr &I,
1235+
const SPIRVInstrInfo &TII,
1236+
unsigned SPIRVOPcode,
1237+
Type *LLVMTy) {
10991238
Register Reg = DT.find(LLVMTy, CurMF);
11001239
if (Reg.isValid())
11011240
return getSPIRVTypeForVReg(Reg);
11021241
MachineBasicBlock &BB = *I.getParent();
1103-
auto MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpTypeInt))
1242+
auto MIB = BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRVOPcode))
11041243
.addDef(createTypeVReg(CurMF->getRegInfo()))
11051244
.addImm(BitWidth)
11061245
.addImm(0);
11071246
DT.add(LLVMTy, CurMF, getSPIRVTypeID(MIB));
11081247
return finishCreatingSPIRVType(LLVMTy, MIB);
11091248
}
11101249

1250+
SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVIntegerType(
1251+
unsigned BitWidth, MachineInstr &I, const SPIRVInstrInfo &TII) {
1252+
Type *LLVMTy = IntegerType::get(CurMF->getFunction().getContext(), BitWidth);
1253+
return getOrCreateSPIRVType(BitWidth, I, TII, SPIRV::OpTypeInt, LLVMTy);
1254+
}
1255+
SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVFloatType(
1256+
unsigned BitWidth, MachineInstr &I, const SPIRVInstrInfo &TII) {
1257+
LLVMContext &Ctx = CurMF->getFunction().getContext();
1258+
Type *LLVMTy;
1259+
switch (BitWidth) {
1260+
case 16:
1261+
LLVMTy = Type::getHalfTy(Ctx);
1262+
break;
1263+
case 32:
1264+
LLVMTy = Type::getFloatTy(Ctx);
1265+
break;
1266+
case 64:
1267+
LLVMTy = Type::getDoubleTy(Ctx);
1268+
break;
1269+
default:
1270+
llvm_unreachable("Bit width is of unexpected size.");
1271+
}
1272+
return getOrCreateSPIRVType(BitWidth, I, TII, SPIRV::OpTypeFloat, LLVMTy);
1273+
}
1274+
11111275
SPIRVType *
11121276
SPIRVGlobalRegistry::getOrCreateSPIRVBoolType(MachineIRBuilder &MIRBuilder) {
11131277
return getOrCreateSPIRVType(

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "SPIRVDuplicatesTracker.h"
2121
#include "SPIRVInstrInfo.h"
2222
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
23+
#include "llvm/IR/Constant.h"
2324

2425
namespace llvm {
2526
using SPIRVType = const MachineInstr;
@@ -234,6 +235,8 @@ class SPIRVGlobalRegistry {
234235
bool EmitIR = true);
235236
SPIRVType *assignIntTypeToVReg(unsigned BitWidth, Register VReg,
236237
MachineInstr &I, const SPIRVInstrInfo &TII);
238+
SPIRVType *assignFloatTypeToVReg(unsigned BitWidth, Register VReg,
239+
MachineInstr &I, const SPIRVInstrInfo &TII);
237240
SPIRVType *assignVectTypeToVReg(SPIRVType *BaseType, unsigned NumElements,
238241
Register VReg, MachineInstr &I,
239242
const SPIRVInstrInfo &TII);
@@ -372,12 +375,20 @@ class SPIRVGlobalRegistry {
372375
std::tuple<Register, ConstantInt *, bool> getOrCreateConstIntReg(
373376
uint64_t Val, SPIRVType *SpvType, MachineIRBuilder *MIRBuilder,
374377
MachineInstr *I = nullptr, const SPIRVInstrInfo *TII = nullptr);
378+
std::tuple<Register, ConstantFP *, bool, unsigned> getOrCreateConstFloatReg(
379+
APFloat Val, SPIRVType *SpvType, MachineIRBuilder *MIRBuilder,
380+
MachineInstr *I = nullptr, const SPIRVInstrInfo *TII = nullptr);
375381
SPIRVType *finishCreatingSPIRVType(const Type *LLVMTy, SPIRVType *SpirvType);
376-
Register getOrCreateIntCompositeOrNull(uint64_t Val, MachineInstr &I,
377-
SPIRVType *SpvType,
378-
const SPIRVInstrInfo &TII,
379-
Constant *CA, unsigned BitWidth,
380-
unsigned ElemCnt);
382+
Register getOrCreateBaseRegister(Constant *Val, MachineInstr &I,
383+
SPIRVType *SpvType,
384+
const SPIRVInstrInfo &TII,
385+
unsigned BitWidth);
386+
Register getOrCreateCompositeOrNull(Constant *Val, MachineInstr &I,
387+
SPIRVType *SpvType,
388+
const SPIRVInstrInfo &TII, Constant *CA,
389+
unsigned BitWidth, unsigned ElemCnt,
390+
bool ZeroAsNull = true);
391+
381392
Register getOrCreateIntCompositeOrNull(uint64_t Val,
382393
MachineIRBuilder &MIRBuilder,
383394
SPIRVType *SpvType, bool EmitIR,
@@ -388,12 +399,20 @@ class SPIRVGlobalRegistry {
388399
Register buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder,
389400
SPIRVType *SpvType = nullptr, bool EmitIR = true);
390401
Register getOrCreateConstInt(uint64_t Val, MachineInstr &I,
391-
SPIRVType *SpvType, const SPIRVInstrInfo &TII);
402+
SPIRVType *SpvType, const SPIRVInstrInfo &TII,
403+
bool ZeroAsNull = true);
404+
Register getOrCreateConstFP(APFloat Val, MachineInstr &I, SPIRVType *SpvType,
405+
const SPIRVInstrInfo &TII,
406+
bool ZeroAsNull = true);
392407
Register buildConstantFP(APFloat Val, MachineIRBuilder &MIRBuilder,
393408
SPIRVType *SpvType = nullptr);
394-
Register getOrCreateConsIntVector(uint64_t Val, MachineInstr &I,
395-
SPIRVType *SpvType,
396-
const SPIRVInstrInfo &TII);
409+
410+
Register getOrCreateConstVector(uint64_t Val, MachineInstr &I,
411+
SPIRVType *SpvType, const SPIRVInstrInfo &TII,
412+
bool ZeroAsNull = true);
413+
Register getOrCreateConstVector(APFloat Val, MachineInstr &I,
414+
SPIRVType *SpvType, const SPIRVInstrInfo &TII,
415+
bool ZeroAsNull = true);
397416
Register getOrCreateConsIntArray(uint64_t Val, MachineInstr &I,
398417
SPIRVType *SpvType,
399418
const SPIRVInstrInfo &TII);
@@ -423,6 +442,11 @@ class SPIRVGlobalRegistry {
423442
MachineIRBuilder &MIRBuilder);
424443
SPIRVType *getOrCreateSPIRVIntegerType(unsigned BitWidth, MachineInstr &I,
425444
const SPIRVInstrInfo &TII);
445+
SPIRVType *getOrCreateSPIRVType(unsigned BitWidth, MachineInstr &I,
446+
const SPIRVInstrInfo &TII,
447+
unsigned SPIRVOPcode, Type *LLVMTy);
448+
SPIRVType *getOrCreateSPIRVFloatType(unsigned BitWidth, MachineInstr &I,
449+
const SPIRVInstrInfo &TII);
426450
SPIRVType *getOrCreateSPIRVBoolType(MachineIRBuilder &MIRBuilder);
427451
SPIRVType *getOrCreateSPIRVBoolType(MachineInstr &I,
428452
const SPIRVInstrInfo &TII);

0 commit comments

Comments
 (0)