Skip to content

Fix build with LLVM 12 #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ inline Type* LegalizedIntVectorType(Module& M, const Type* const oldTy)
else if (size <= 64) newSize = 64;
else IGC_ASSERT_MESSAGE(0, "Currently don't support upscaling int sizes > 64 bits");

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

void LegalizeFunctionSignatures::FixFunctionSignatures()
Expand Down
22 changes: 11 additions & 11 deletions IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ void SPIRVToLLVMDbgTran::transDbgInfo(SPIRVValue *SV, Value *V) {
Line->getColumn(), scope, iat);

if(scope && !isa<DIFile>(scope))
I->setDebugLoc(DebugLoc::get(Line->getLine(), Line->getColumn(),
I->setDebugLoc(DILocation::get(scope->getContext(), Line->getLine(), Line->getColumn(),
scope, iat));
}
}
Expand Down Expand Up @@ -1925,7 +1925,7 @@ SPIRVToLLVM::transType(SPIRVType *T) {
auto name = isSubgroupAvcINTELTypeOpCode(OC) ?
OCLSubgroupINTELTypeOpCodeMap::rmap(OC) :
BuiltinOpaqueGenericTypeOpCodeMap::rmap(OC);
auto *pST = M->getTypeByName(name);
auto *pST = IGCLLVM::getTypeByName(M, name);
pST = pST ? pST : StructType::create(*Context, name);

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

auto *PromoType = isa<VectorType>(pVal->getType()) ?
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt8Ty(pVal->getContext()),
(unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
(unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
Type::getInt8Ty(pVal->getContext());

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

auto *TruncType = isa<VectorType>(pVal->getType()) ?
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(pVal->getContext()),
(unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
(unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
Type::getInt1Ty(pVal->getContext());

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

return isa<VectorType>(LLType) ?
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(LLType->getContext()),
(unsigned)cast<VectorType>(LLType)->getNumElements())) :
(unsigned)cast<IGCLLVM::FixedVectorType>(LLType)->getNumElements())) :
Type::getInt1Ty(LLType->getContext());
}

Expand Down Expand Up @@ -2648,7 +2648,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
{
if(CV[i]->getType()->isVectorTy())
{
for(uint32_t j = 0; j < cast<VectorType>(CV[i]->getType())->getNumElements(); j++)
for(uint32_t j = 0; j < cast<IGCLLVM::FixedVectorType>(CV[i]->getType())->getNumElements(); j++)
{
Value *v = ExtractElementInst::Create( CV[i],ConstantInt::get( *Context,APInt( 32,j ) ),BCC->getName(),BB );
elm1 = CreateCompositeConstruct( elm1,v,pos++ );
Expand Down Expand Up @@ -3336,7 +3336,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
auto Vector = transValue(BI->getOperand(0), F, BB);
auto Scalar = transValue(BI->getOperand(1), F, BB);

auto VecType = cast<VectorType>(Vector->getType());
auto VecType = cast<IGCLLVM::FixedVectorType>(Vector->getType());
auto Undef = UndefValue::get(VecType);

auto ScalarVec = InsertElementInst::Create(Undef, Scalar,
Expand All @@ -3361,7 +3361,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
a->getType()->getScalarSizeInBits() - 1);
auto *ShiftOp = isa<VectorType>(a->getType()) ?
ConstantVector::getSplat(
IGCLLVM::getElementCount((unsigned)cast<VectorType>(a->getType())->getNumElements()), ShiftAmt) :
IGCLLVM::getElementCount((unsigned)cast<IGCLLVM::FixedVectorType>(a->getType())->getNumElements()), ShiftAmt) :
ShiftAmt;

// OCL C:
Expand Down Expand Up @@ -3705,15 +3705,15 @@ SPIRVToLLVM::transSPIRVBuiltinFromInst(SPIRVInstruction *BI, BasicBlock *BB) {
"",
BB);
}
else if (cast<VectorType>(coordType)->getNumElements() != 4)
else if (cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements() != 4)
{
Value *undef = UndefValue::get(coordType);

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

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

imageCoordinateWiden = new ShuffleVectorInst(
Expand Down
4 changes: 2 additions & 2 deletions IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ saveLLVMModule(Module *M, const std::string &OutputFile) {
PointerType*
getOrCreateOpaquePtrType(Module *M, const std::string &Name,
unsigned AddrSpace) {
auto OpaqueType = M->getTypeByName(Name);
auto OpaqueType = IGCLLVM::getTypeByName(M, Name);
if (!OpaqueType)
OpaqueType = StructType::create(M->getContext(), Name);
return PointerType::get(OpaqueType, AddrSpace);
Expand Down Expand Up @@ -159,7 +159,7 @@ std::string recursive_mangle(const Type* pType)
return "i" + utostr(pType->getIntegerBitWidth());
case IGCLLVM::VectorTyID:
{
unsigned vecLen = (unsigned)cast<VectorType>(pType)->getNumElements();
unsigned vecLen = (unsigned)cast<IGCLLVM::FixedVectorType>(pType)->getNumElements();
Type* pEltType = cast<VectorType>(pType)->getElementType();
return "v" + utostr(vecLen) + recursive_mangle(pEltType);
}
Expand Down
3 changes: 2 additions & 1 deletion IGC/Compiler/CISACodeGen/AdvMemOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ IN THE SOFTWARE.
#include <llvm/Support/Debug.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Transforms/Utils/Local.h>
#include "llvmWrapper/Transforms/Utils/LoopUtils.h"
#include "common/LLVMWarningsPop.hpp"
#include "GenISAIntrinsics/GenIntrinsics.h"
#include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
Expand Down Expand Up @@ -134,7 +135,7 @@ bool AdvMemOpt::runOnFunction(Function& F) {
for (auto I = LI->begin(), E = LI->end(); I != E; ++I)
for (auto DFI = df_begin(*I), DFE = df_end(*I); DFI != DFE; ++DFI) {
Loop* L = *DFI;
if (L->empty())
if (IGCLLVM::isInnermost(L))
InnermostLoops.push_back(L);
}

Expand Down
14 changes: 7 additions & 7 deletions IGC/Compiler/CISACodeGen/CShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ void CShader::CreateAliasVars()
continue;

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

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

uint16_t CShader::AdjustExtractIndex(llvm::Value* vecVal, uint16_t index)
{
uint16_t result = index;
if (cast<VectorType>(vecVal->getType())->getNumElements() < 32)
if (cast<IGCLLVM::FixedVectorType>(vecVal->getType())->getNumElements() < 32)
{
uint32_t mask = GetExtractMask(vecVal);
for (uint i = 0; i < index; ++i)
Expand Down Expand Up @@ -1591,7 +1591,7 @@ auto sizeToSIMDMode = [](uint32_t size)

CVariable* CShader::GetConstant(llvm::Constant* C, CVariable* dstVar)
{
llvm::VectorType* VTy = llvm::dyn_cast<llvm::VectorType>(C->getType());
IGCLLVM::FixedVectorType* VTy = llvm::dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
if (C && VTy)
{ // Vector constant
llvm::Type* eTy = VTy->getElementType();
Expand Down Expand Up @@ -1816,7 +1816,7 @@ uint32_t CShader::GetNumElts(llvm::Type* type, bool isUniform)
{
IGC_ASSERT(type->getContainedType(0)->isIntegerTy() || type->getContainedType(0)->isFloatingPointTy());

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

Expand Down
14 changes: 7 additions & 7 deletions IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static void checkInsertExtractMatch(InsertElementInst* insertInst, Value* base,

static bool canReplaceInsert(InsertElementInst* insertElt)
{
VectorType* VTy = cast<VectorType>(insertElt->getOperand(0)->getType());
IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(insertElt->getOperand(0)->getType());
ConstantInt* index = dyn_cast<ConstantInt>(insertElt->getOperand(2));
if (!index || index->getZExtValue() != VTy->getNumElements() - 1)
{
Expand Down Expand Up @@ -312,7 +312,7 @@ void ConstantCoalescing::VectorizePrep(llvm::BasicBlock* bb)
{
if (load->getType()->isVectorTy() && wiAns->isUniform(load))
{
srcNElts = (uint32_t)cast<VectorType>(load->getType())->getNumElements();
srcNElts = (uint32_t)cast<IGCLLVM::FixedVectorType>(load->getType())->getNumElements();
DenseMap<uint64_t, Instruction*> extractElementMap;

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

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

MaxEltPlus = CheckVectorElementUses(I);
Expand Down Expand Up @@ -1787,7 +1787,7 @@ void ConstantCoalescing::AdjustChunk(BufChunk* cov_chunk, uint start_adj, uint s
WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
Value* vec = UndefValue::get(originalType);
for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
{
Value* channel = irBuilder->CreateExtractElement(
cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
Expand Down Expand Up @@ -1851,7 +1851,7 @@ void ConstantCoalescing::MoveExtracts(BufChunk* cov_chunk, Instruction* load, ui
irBuilder->SetInsertPoint(load->getNextNode());
Type* vecType = load->getType();
Value* vec = UndefValue::get(vecType);
for (unsigned i = 0; i < cast<VectorType>(vecType)->getNumElements(); i++)
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(vecType)->getNumElements(); i++)
{
Value* channel = irBuilder->CreateExtractElement(
cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
Expand Down Expand Up @@ -1915,7 +1915,7 @@ void ConstantCoalescing::EnlargeChunk(BufChunk* cov_chunk, uint size_adj)
WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
Value* vec = UndefValue::get(originalType);
for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
{
Value* channel = irBuilder->CreateExtractElement(
cov_chunk->chunkIO, irBuilder->getInt32(i));
Expand Down Expand Up @@ -2343,7 +2343,7 @@ void ConstantCoalescing::ReplaceLoadWithSamplerLoad(
if (dstTy->isVectorTy())
{
result = UndefValue::get(dstTy);
for (uint i = 0; i < cast<VectorType>(dstTy)->getNumElements(); i++)
for (uint i = 0; i < cast<IGCLLVM::FixedVectorType>(dstTy)->getNumElements(); i++)
{
Value* tmpData = ExtractFromSamplerData(cast<VectorType>(dstTy)->getElementType(), i);
result = irBuilder->CreateInsertElement(result, tmpData, irBuilder->getInt32(i));
Expand Down
3 changes: 2 additions & 1 deletion IGC/Compiler/CISACodeGen/DeSSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ IN THE SOFTWARE.
#include "Compiler/IGCPassSupport.h"
#include "common/LLVMWarningsPush.hpp"
#include <llvm/IR/InstIterator.h>
#include <llvmWrapper/IR/DerivedTypes.h>
#include "common/LLVMWarningsPop.hpp"
#include <algorithm>
#include "Probe/Assertion.h"
Expand Down Expand Up @@ -1284,7 +1285,7 @@ int DeSSA::checkInsertElementAlias(
//
// If found, return the actual vector size;
// otherwise, return 0.
VectorType* VTy = cast<VectorType>(IEI->getType());
IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(IEI->getType());
IGC_ASSERT(nullptr != VTy);
int nelts = (int)VTy->getNumElements();
AllIEIs.resize(nelts, nullptr);
Expand Down
Loading