Skip to content

Commit 2ae1f13

Browse files
author
Zoltán Böszörményi
committed
Fix build with LLVM 12
Signed-off-by: Zoltán Böszörményi <[email protected]>
1 parent 7a98648 commit 2ae1f13

File tree

66 files changed

+300
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+300
-192
lines changed

IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ inline Type* LegalizedIntVectorType(Module& M, const Type* const oldTy)
156156
else if (size <= 64) newSize = 64;
157157
else IGC_ASSERT_MESSAGE(0, "Currently don't support upscaling int sizes > 64 bits");
158158

159-
return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast<VectorType>(oldTy)->getNumElements());
159+
return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast<IGCLLVM::FixedVectorType>(oldTy)->getNumElements());
160160
}
161161

162162
void LegalizeFunctionSignatures::FixFunctionSignatures()

IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,11 @@ void SPIRVToLLVMDbgTran::transDbgInfo(SPIRVValue *SV, Value *V) {
15761576
Line->getColumn(), scope, iat);
15771577

15781578
if(scope && !isa<DIFile>(scope))
1579+
#if LLVM_VERSION_MAJOR >= 12
1580+
I->setDebugLoc(DILocation::get(scope->getContext(), Line->getLine(), Line->getColumn(),
1581+
#else
15791582
I->setDebugLoc(DebugLoc::get(Line->getLine(), Line->getColumn(),
1583+
#endif
15801584
scope, iat));
15811585
}
15821586
}
@@ -1925,7 +1929,11 @@ SPIRVToLLVM::transType(SPIRVType *T) {
19251929
auto name = isSubgroupAvcINTELTypeOpCode(OC) ?
19261930
OCLSubgroupINTELTypeOpCodeMap::rmap(OC) :
19271931
BuiltinOpaqueGenericTypeOpCodeMap::rmap(OC);
1932+
#if LLVM_VERSION_MAJOR >= 12
1933+
auto *pST = llvm::StructType::getTypeByName(M->getContext(), name);
1934+
#else
19281935
auto *pST = M->getTypeByName(name);
1936+
#endif
19291937
pST = pST ? pST : StructType::create(*Context, name);
19301938

19311939
return mapType(T, PointerType::get(pST, getOCLOpaqueTypeAddrSpace(OC)));
@@ -2403,7 +2411,7 @@ Value *SPIRVToLLVM::promoteBool(Value *pVal, BasicBlock *BB)
24032411

24042412
auto *PromoType = isa<VectorType>(pVal->getType()) ?
24052413
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt8Ty(pVal->getContext()),
2406-
(unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
2414+
(unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
24072415
Type::getInt8Ty(pVal->getContext());
24082416

24092417
if (auto *C = dyn_cast<Constant>(pVal))
@@ -2445,7 +2453,7 @@ Value *SPIRVToLLVM::truncBool(Value *pVal, BasicBlock *BB)
24452453

24462454
auto *TruncType = isa<VectorType>(pVal->getType()) ?
24472455
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(pVal->getContext()),
2448-
(unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
2456+
(unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
24492457
Type::getInt1Ty(pVal->getContext());
24502458

24512459
if (auto *C = dyn_cast<Constant>(pVal))
@@ -2491,7 +2499,7 @@ Type *SPIRVToLLVM::truncBoolType(SPIRVType *SPVType, Type *LLType)
24912499

24922500
return isa<VectorType>(LLType) ?
24932501
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(LLType->getContext()),
2494-
(unsigned)cast<VectorType>(LLType)->getNumElements())) :
2502+
(unsigned)cast<IGCLLVM::FixedVectorType>(LLType)->getNumElements())) :
24952503
Type::getInt1Ty(LLType->getContext());
24962504
}
24972505

@@ -2648,7 +2656,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
26482656
{
26492657
if(CV[i]->getType()->isVectorTy())
26502658
{
2651-
for(uint32_t j = 0; j < cast<VectorType>(CV[i]->getType())->getNumElements(); j++)
2659+
for(uint32_t j = 0; j < cast<IGCLLVM::FixedVectorType>(CV[i]->getType())->getNumElements(); j++)
26522660
{
26532661
Value *v = ExtractElementInst::Create( CV[i],ConstantInt::get( *Context,APInt( 32,j ) ),BCC->getName(),BB );
26542662
elm1 = CreateCompositeConstruct( elm1,v,pos++ );
@@ -3336,7 +3344,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
33363344
auto Vector = transValue(BI->getOperand(0), F, BB);
33373345
auto Scalar = transValue(BI->getOperand(1), F, BB);
33383346

3339-
auto VecType = cast<VectorType>(Vector->getType());
3347+
auto VecType = cast<IGCLLVM::FixedVectorType>(Vector->getType());
33403348
auto Undef = UndefValue::get(VecType);
33413349

33423350
auto ScalarVec = InsertElementInst::Create(Undef, Scalar,
@@ -3361,7 +3369,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
33613369
a->getType()->getScalarSizeInBits() - 1);
33623370
auto *ShiftOp = isa<VectorType>(a->getType()) ?
33633371
ConstantVector::getSplat(
3364-
IGCLLVM::getElementCount((unsigned)cast<VectorType>(a->getType())->getNumElements()), ShiftAmt) :
3372+
IGCLLVM::getElementCount((unsigned)cast<IGCLLVM::FixedVectorType>(a->getType())->getNumElements()), ShiftAmt) :
33653373
ShiftAmt;
33663374

33673375
// OCL C:
@@ -3705,15 +3713,15 @@ SPIRVToLLVM::transSPIRVBuiltinFromInst(SPIRVInstruction *BI, BasicBlock *BB) {
37053713
"",
37063714
BB);
37073715
}
3708-
else if (cast<VectorType>(coordType)->getNumElements() != 4)
3716+
else if (cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements() != 4)
37093717
{
37103718
Value *undef = UndefValue::get(coordType);
37113719

37123720
SmallVector<Constant*, 4> shuffleIdx;
3713-
for (unsigned i = 0; i < cast<VectorType>(coordType)->getNumElements(); i++)
3721+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements(); i++)
37143722
shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), i));
37153723

3716-
for (uint64_t i = (unsigned)cast<VectorType>(coordType)->getNumElements(); i < 4; i++)
3724+
for (uint64_t i = (unsigned)cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements(); i < 4; i++)
37173725
shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), 0));
37183726

37193727
imageCoordinateWiden = new ShuffleVectorInst(

IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ saveLLVMModule(Module *M, const std::string &OutputFile) {
9393
PointerType*
9494
getOrCreateOpaquePtrType(Module *M, const std::string &Name,
9595
unsigned AddrSpace) {
96+
#if LLVM_VERSION_MAJOR >= 12
97+
auto OpaqueType = llvm::StructType::getTypeByName(M->getContext(), Name);
98+
#else
9699
auto OpaqueType = M->getTypeByName(Name);
100+
#endif
97101
if (!OpaqueType)
98102
OpaqueType = StructType::create(M->getContext(), Name);
99103
return PointerType::get(OpaqueType, AddrSpace);
@@ -159,7 +163,7 @@ std::string recursive_mangle(const Type* pType)
159163
return "i" + utostr(pType->getIntegerBitWidth());
160164
case IGCLLVM::VectorTyID:
161165
{
162-
unsigned vecLen = (unsigned)cast<VectorType>(pType)->getNumElements();
166+
unsigned vecLen = (unsigned)cast<IGCLLVM::FixedVectorType>(pType)->getNumElements();
163167
Type* pEltType = cast<VectorType>(pType)->getElementType();
164168
return "v" + utostr(vecLen) + recursive_mangle(pEltType);
165169
}

IGC/Compiler/CISACodeGen/AdvMemOpt.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ bool AdvMemOpt::runOnFunction(Function& F) {
134134
for (auto I = LI->begin(), E = LI->end(); I != E; ++I)
135135
for (auto DFI = df_begin(*I), DFE = df_end(*I); DFI != DFE; ++DFI) {
136136
Loop* L = *DFI;
137+
#if LLVM_VERSION_MAJOR >= 12
138+
if (L->isInnermost())
139+
#else
137140
if (L->empty())
141+
#endif
138142
InnermostLoops.push_back(L);
139143
}
140144

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ void CShader::CreateAliasVars()
430430
continue;
431431

432432
Type* Ty = V->getType();
433-
VectorType* VTy = dyn_cast<VectorType>(Ty);
433+
IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
434434
Type* BTy = VTy ? VTy->getElementType() : Ty;
435435
int nelts = (VTy ? (int)VTy->getNumElements() : 1);
436436

@@ -961,7 +961,7 @@ bool CShader::InsideDivergentCF(llvm::Instruction* inst)
961961
uint CShader::GetNbVectorElementAndMask(llvm::Value* val, uint32_t& mask)
962962
{
963963
llvm::Type* type = val->getType();
964-
uint nbElement = int_cast<uint>(cast<VectorType>(type)->getNumElements());
964+
uint nbElement = int_cast<uint>(cast<IGCLLVM::FixedVectorType>(type)->getNumElements());
965965
mask = 0;
966966
// we don't process vector bigger than 31 elements as the mask has only 32bits
967967
// If we want to support longer vectors we need to extend the mask size
@@ -1166,15 +1166,15 @@ uint32_t CShader::GetExtractMask(llvm::Value* vecVal)
11661166
{
11671167
return it->second;
11681168
}
1169-
const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast<VectorType>(vecVal->getType())->getNumElements() : 1;
1169+
const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(vecVal->getType())->getNumElements() : 1;
11701170
IGC_ASSERT_MESSAGE(numChannels <= 32, "Mask has 32 bits maximally!");
11711171
return (1ULL << numChannels) - 1;
11721172
}
11731173

11741174
uint16_t CShader::AdjustExtractIndex(llvm::Value* vecVal, uint16_t index)
11751175
{
11761176
uint16_t result = index;
1177-
if (cast<VectorType>(vecVal->getType())->getNumElements() < 32)
1177+
if (cast<IGCLLVM::FixedVectorType>(vecVal->getType())->getNumElements() < 32)
11781178
{
11791179
uint32_t mask = GetExtractMask(vecVal);
11801180
for (uint i = 0; i < index; ++i)
@@ -1591,7 +1591,7 @@ auto sizeToSIMDMode = [](uint32_t size)
15911591

15921592
CVariable* CShader::GetConstant(llvm::Constant* C, CVariable* dstVar)
15931593
{
1594-
llvm::VectorType* VTy = llvm::dyn_cast<llvm::VectorType>(C->getType());
1594+
IGCLLVM::FixedVectorType* VTy = llvm::dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
15951595
if (C && VTy)
15961596
{ // Vector constant
15971597
llvm::Type* eTy = VTy->getElementType();
@@ -1816,7 +1816,7 @@ uint32_t CShader::GetNumElts(llvm::Type* type, bool isUniform)
18161816
{
18171817
IGC_ASSERT(type->getContainedType(0)->isIntegerTy() || type->getContainedType(0)->isFloatingPointTy());
18181818

1819-
auto VT = cast<VectorType>(type);
1819+
auto VT = cast<IGCLLVM::FixedVectorType>(type);
18201820
numElts *= (uint16_t)VT->getNumElements();
18211821
}
18221822
return numElts;
@@ -2516,7 +2516,7 @@ CVariable* CShader::GetSymbol(llvm::Value* value, bool fromConstantPool)
25162516
if (isVecType)
25172517
{
25182518
// Map the entire vector value to the CVar
2519-
unsigned numElements = (unsigned)cast<VectorType>(value->getType())->getNumElements();
2519+
unsigned numElements = (unsigned)cast<IGCLLVM::FixedVectorType>(value->getType())->getNumElements();
25202520
var = GetNewVariable(numElements, ISA_TYPE_UQ, (GetContext()->platform.getGRFSize() == 64) ? EALIGN_32WORD : EALIGN_HWORD, true, 1, valName);
25212521
symbolMapping.insert(std::pair<llvm::Value*, CVariable*>(value, var));
25222522

IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void checkInsertExtractMatch(InsertElementInst* insertInst, Value* base,
224224

225225
static bool canReplaceInsert(InsertElementInst* insertElt)
226226
{
227-
VectorType* VTy = cast<VectorType>(insertElt->getOperand(0)->getType());
227+
IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(insertElt->getOperand(0)->getType());
228228
ConstantInt* index = dyn_cast<ConstantInt>(insertElt->getOperand(2));
229229
if (!index || index->getZExtValue() != VTy->getNumElements() - 1)
230230
{
@@ -312,7 +312,7 @@ void ConstantCoalescing::VectorizePrep(llvm::BasicBlock* bb)
312312
{
313313
if (load->getType()->isVectorTy() && wiAns->isUniform(load))
314314
{
315-
srcNElts = (uint32_t)cast<VectorType>(load->getType())->getNumElements();
315+
srcNElts = (uint32_t)cast<IGCLLVM::FixedVectorType>(load->getType())->getNumElements();
316316
DenseMap<uint64_t, Instruction*> extractElementMap;
317317

318318
for (auto iter = load->user_begin(); iter != load->user_end(); iter++)
@@ -396,7 +396,7 @@ bool ConstantCoalescing::isProfitableLoad(
396396
(isa<LoadInst>(I) && wiAns->isUniform(I)) ?
397397
16 : 4;
398398

399-
if (cast<VectorType>(LoadTy)->getNumElements() > MaxVectorInput)
399+
if (cast<IGCLLVM::FixedVectorType>(LoadTy)->getNumElements() > MaxVectorInput)
400400
return false;
401401

402402
MaxEltPlus = CheckVectorElementUses(I);
@@ -1787,7 +1787,7 @@ void ConstantCoalescing::AdjustChunk(BufChunk* cov_chunk, uint start_adj, uint s
17871787
WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
17881788
irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
17891789
Value* vec = UndefValue::get(originalType);
1790-
for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
1790+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
17911791
{
17921792
Value* channel = irBuilder->CreateExtractElement(
17931793
cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
@@ -1851,7 +1851,7 @@ void ConstantCoalescing::MoveExtracts(BufChunk* cov_chunk, Instruction* load, ui
18511851
irBuilder->SetInsertPoint(load->getNextNode());
18521852
Type* vecType = load->getType();
18531853
Value* vec = UndefValue::get(vecType);
1854-
for (unsigned i = 0; i < cast<VectorType>(vecType)->getNumElements(); i++)
1854+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(vecType)->getNumElements(); i++)
18551855
{
18561856
Value* channel = irBuilder->CreateExtractElement(
18571857
cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
@@ -1915,7 +1915,7 @@ void ConstantCoalescing::EnlargeChunk(BufChunk* cov_chunk, uint size_adj)
19151915
WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
19161916
irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
19171917
Value* vec = UndefValue::get(originalType);
1918-
for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
1918+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
19191919
{
19201920
Value* channel = irBuilder->CreateExtractElement(
19211921
cov_chunk->chunkIO, irBuilder->getInt32(i));
@@ -2343,7 +2343,7 @@ void ConstantCoalescing::ReplaceLoadWithSamplerLoad(
23432343
if (dstTy->isVectorTy())
23442344
{
23452345
result = UndefValue::get(dstTy);
2346-
for (uint i = 0; i < cast<VectorType>(dstTy)->getNumElements(); i++)
2346+
for (uint i = 0; i < cast<IGCLLVM::FixedVectorType>(dstTy)->getNumElements(); i++)
23472347
{
23482348
Value* tmpData = ExtractFromSamplerData(cast<VectorType>(dstTy)->getElementType(), i);
23492349
result = irBuilder->CreateInsertElement(result, tmpData, irBuilder->getInt32(i));

IGC/Compiler/CISACodeGen/DeSSA.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ IN THE SOFTWARE.
8383
#include "Compiler/IGCPassSupport.h"
8484
#include "common/LLVMWarningsPush.hpp"
8585
#include <llvm/IR/InstIterator.h>
86+
#include <llvmWrapper/IR/DerivedTypes.h>
8687
#include "common/LLVMWarningsPop.hpp"
8788
#include <algorithm>
8889
#include "Probe/Assertion.h"
@@ -1284,7 +1285,7 @@ int DeSSA::checkInsertElementAlias(
12841285
//
12851286
// If found, return the actual vector size;
12861287
// otherwise, return 0.
1287-
VectorType* VTy = cast<VectorType>(IEI->getType());
1288+
IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(IEI->getType());
12881289
IGC_ASSERT(nullptr != VTy);
12891290
int nelts = (int)VTy->getNumElements();
12901291
AllIEIs.resize(nelts, nullptr);

0 commit comments

Comments
 (0)