From fefa86e0cfb9af0c54cd202b06a8eafc2e01e98f Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 15 Apr 2012 20:11:27 -0700 Subject: [PATCH] Remove LLVM_TYPE_CONST #define / usage. Now with LLVM 3.0 and beyond, types aren't const. --- builtins.cpp | 6 +- ctx.cpp | 172 +++++++++++++++++++++++++-------------------------- ctx.h | 20 +++--- expr.cpp | 92 +++++++++++++-------------- func.cpp | 4 +- ispc.cpp | 28 ++++----- ispc.h | 10 +-- llvmutil.cpp | 102 +++++++++++++++--------------- llvmutil.h | 71 ++++++++++----------- module.cpp | 8 +-- opt.cpp | 40 ++++++------ stmt.cpp | 8 +-- type.cpp | 34 +++++----- type.h | 20 +++--- 14 files changed, 303 insertions(+), 312 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index ac763f7b..405c8290 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -291,7 +291,7 @@ lCheckModuleIntrinsics(llvm::Module *module) { if (!strncmp(funcName.c_str(), "llvm.x86.", 9)) { llvm::Intrinsic::ID id = (llvm::Intrinsic::ID)func->getIntrinsicID(); Assert(id != 0); - LLVM_TYPE_CONST llvm::Type *intrinsicType = + llvm::Type *intrinsicType = llvm::Intrinsic::getType(*g->ctx, id); intrinsicType = llvm::PointerType::get(intrinsicType, 0); Assert(func->getType() == intrinsicType); @@ -641,7 +641,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module, new Symbol(name, SourcePos(), AtomicType::UniformInt32->GetAsConstType(), SC_STATIC); pw->constValue = new ConstExpr(pw->type, val, SourcePos()); - LLVM_TYPE_CONST llvm::Type *ltype = LLVMTypes::Int32Type; + llvm::Type *ltype = LLVMTypes::Int32Type; llvm::Constant *linit = LLVMInt32(val); pw->storagePtr = new llvm::GlobalVariable(*module, ltype, true, llvm::GlobalValue::InternalLinkage, @@ -681,7 +681,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) { pi[i] = i; pidx->constValue = new ConstExpr(pidx->type, pi, SourcePos()); - LLVM_TYPE_CONST llvm::Type *ltype = LLVMTypes::Int32VectorType; + llvm::Type *ltype = LLVMTypes::Int32VectorType; llvm::Constant *linit = LLVMInt32Vector(pi); pidx->storagePtr = new llvm::GlobalVariable(*module, ltype, true, llvm::GlobalValue::InternalLinkage, linit, diff --git a/ctx.cpp b/ctx.cpp index 00ef1f7a..4e7b3479 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -251,7 +251,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, if (!returnType || Type::Equal(returnType, AtomicType::Void)) returnValuePtr = NULL; else { - LLVM_TYPE_CONST llvm::Type *ftype = returnType->LLVMType(g->ctx); + llvm::Type *ftype = returnType->LLVMType(g->ctx); returnValuePtr = AllocaInst(ftype, "return_value_memory"); } @@ -1050,7 +1050,7 @@ FunctionEmitContext::SwitchInst(llvm::Value *expr, llvm::BasicBlock *bbDefault, caseBlocks = new std::vector >(bbCases); nextBlocks = new std::map(bbNext); switchConditionWasUniform = - (llvm::isa(expr->getType()) == false); + (llvm::isa(expr->getType()) == false); if (switchConditionWasUniform == true) { // For a uniform switch condition, just wire things up to the LLVM @@ -1325,12 +1325,12 @@ FunctionEmitContext::I1VecToBoolVec(llvm::Value *b) { if (g->target.maskBitCount == 1) return b; - LLVM_TYPE_CONST llvm::ArrayType *at = - llvm::dyn_cast(b->getType()); + llvm::ArrayType *at = + llvm::dyn_cast(b->getType()); if (at) { // If we're given an array of vectors of i1s, then do the // conversion for each of the elements - LLVM_TYPE_CONST llvm::Type *boolArrayType = + llvm::Type *boolArrayType = llvm::ArrayType::get(LLVMTypes::BoolVectorType, at->getNumElements()); llvm::Value *ret = llvm::UndefValue::get(boolArrayType); @@ -1493,16 +1493,16 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) { Otherwise return zero. */ static int -lArrayVectorWidth(LLVM_TYPE_CONST llvm::Type *t) { - LLVM_TYPE_CONST llvm::ArrayType *arrayType = - llvm::dyn_cast(t); +lArrayVectorWidth(llvm::Type *t) { + llvm::ArrayType *arrayType = + llvm::dyn_cast(t); if (arrayType == NULL) return 0; // We shouldn't be seeing arrays of anything but vectors being passed // to things like FunctionEmitContext::BinaryOperator() as operands. - LLVM_TYPE_CONST llvm::VectorType *vectorElementType = - llvm::dyn_cast(arrayType->getElementType()); + llvm::VectorType *vectorElementType = + llvm::dyn_cast(arrayType->getElementType()); Assert((vectorElementType != NULL && (int)vectorElementType->getNumElements() == g->target.vectorWidth)); @@ -1520,7 +1520,7 @@ FunctionEmitContext::BinaryOperator(llvm::Instruction::BinaryOps inst, } Assert(v0->getType() == v1->getType()); - LLVM_TYPE_CONST llvm::Type *type = v0->getType(); + llvm::Type *type = v0->getType(); int arraySize = lArrayVectorWidth(type); if (arraySize == 0) { llvm::Instruction *bop = @@ -1554,7 +1554,7 @@ FunctionEmitContext::NotOperator(llvm::Value *v, const char *name) { // Similarly to BinaryOperator, do the operation on all the elements of // the array if we're given an array type; otherwise just do the // regular llvm operation. - LLVM_TYPE_CONST llvm::Type *type = v->getType(); + llvm::Type *type = v->getType(); int arraySize = lArrayVectorWidth(type); if (arraySize == 0) { llvm::Instruction *binst = @@ -1579,18 +1579,18 @@ FunctionEmitContext::NotOperator(llvm::Value *v, const char *name) { // Given the llvm Type that represents an ispc VectorType, return an // equally-shaped type with boolean elements. (This is the type that will // be returned from CmpInst with ispc VectorTypes). -static LLVM_TYPE_CONST llvm::Type * -lGetMatchingBoolVectorType(LLVM_TYPE_CONST llvm::Type *type) { - LLVM_TYPE_CONST llvm::ArrayType *arrayType = - llvm::dyn_cast(type); +static llvm::Type * +lGetMatchingBoolVectorType(llvm::Type *type) { + llvm::ArrayType *arrayType = + llvm::dyn_cast(type); Assert(arrayType != NULL); - LLVM_TYPE_CONST llvm::VectorType *vectorElementType = - llvm::dyn_cast(arrayType->getElementType()); + llvm::VectorType *vectorElementType = + llvm::dyn_cast(arrayType->getElementType()); Assert(vectorElementType != NULL); Assert((int)vectorElementType->getNumElements() == g->target.vectorWidth); - LLVM_TYPE_CONST llvm::Type *base = + llvm::Type *base = llvm::VectorType::get(LLVMTypes::BoolType, g->target.vectorWidth); return llvm::ArrayType::get(base, arrayType->getNumElements()); } @@ -1607,7 +1607,7 @@ FunctionEmitContext::CmpInst(llvm::Instruction::OtherOps inst, } Assert(v0->getType() == v1->getType()); - LLVM_TYPE_CONST llvm::Type *type = v0->getType(); + llvm::Type *type = v0->getType(); int arraySize = lArrayVectorWidth(type); if (arraySize == 0) { llvm::Instruction *ci = @@ -1617,7 +1617,7 @@ FunctionEmitContext::CmpInst(llvm::Instruction::OtherOps inst, return ci; } else { - LLVM_TYPE_CONST llvm::Type *boolType = lGetMatchingBoolVectorType(type); + llvm::Type *boolType = lGetMatchingBoolVectorType(type); llvm::Value *ret = llvm::UndefValue::get(boolType); for (int i = 0; i < arraySize; ++i) { llvm::Value *a = ExtractInst(v0, i); @@ -1638,10 +1638,10 @@ FunctionEmitContext::SmearUniform(llvm::Value *value, const char *name) { } llvm::Value *ret = NULL; - LLVM_TYPE_CONST llvm::Type *eltType = value->getType(); + llvm::Type *eltType = value->getType(); - LLVM_TYPE_CONST llvm::PointerType *pt = - llvm::dyn_cast(eltType); + llvm::PointerType *pt = + llvm::dyn_cast(eltType); if (pt != NULL) { // Varying pointers are represented as vectors of i32/i64s ret = llvm::UndefValue::get(LLVMTypes::VoidPointerVectorType); @@ -1665,7 +1665,7 @@ FunctionEmitContext::SmearUniform(llvm::Value *value, const char *name) { llvm::Value * FunctionEmitContext::BitCastInst(llvm::Value *value, - LLVM_TYPE_CONST llvm::Type *type, + llvm::Type *type, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); @@ -1686,11 +1686,11 @@ FunctionEmitContext::PtrToIntInst(llvm::Value *value, const char *name) { return NULL; } - if (llvm::isa(value->getType())) + if (llvm::isa(value->getType())) // no-op for varying pointers; they're already vectors of ints return value; - LLVM_TYPE_CONST llvm::Type *type = LLVMTypes::PointerIntType; + llvm::Type *type = LLVMTypes::PointerIntType; llvm::Instruction *inst = new llvm::PtrToIntInst(value, type, name ? name : "ptr2int", bblock); AddDebugPos(inst); @@ -1700,15 +1700,15 @@ FunctionEmitContext::PtrToIntInst(llvm::Value *value, const char *name) { llvm::Value * FunctionEmitContext::PtrToIntInst(llvm::Value *value, - LLVM_TYPE_CONST llvm::Type *toType, + llvm::Type *toType, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); return NULL; } - LLVM_TYPE_CONST llvm::Type *fromType = value->getType(); - if (llvm::isa(fromType)) { + llvm::Type *fromType = value->getType(); + if (llvm::isa(fromType)) { // varying pointer if (fromType == toType) // already the right type--done @@ -1731,15 +1731,15 @@ FunctionEmitContext::PtrToIntInst(llvm::Value *value, llvm::Value * FunctionEmitContext::IntToPtrInst(llvm::Value *value, - LLVM_TYPE_CONST llvm::Type *toType, + llvm::Type *toType, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); return NULL; } - LLVM_TYPE_CONST llvm::Type *fromType = value->getType(); - if (llvm::isa(fromType)) { + llvm::Type *fromType = value->getType(); + if (llvm::isa(fromType)) { // varying pointer if (fromType == toType) // done @@ -1761,7 +1761,7 @@ FunctionEmitContext::IntToPtrInst(llvm::Value *value, llvm::Instruction * -FunctionEmitContext::TruncInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, +FunctionEmitContext::TruncInst(llvm::Value *value, llvm::Type *type, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); @@ -1779,7 +1779,7 @@ FunctionEmitContext::TruncInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *t llvm::Instruction * FunctionEmitContext::CastInst(llvm::Instruction::CastOps op, llvm::Value *value, - LLVM_TYPE_CONST llvm::Type *type, const char *name) { + llvm::Type *type, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); return NULL; @@ -1795,7 +1795,7 @@ FunctionEmitContext::CastInst(llvm::Instruction::CastOps op, llvm::Value *value, llvm::Instruction * -FunctionEmitContext::FPCastInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, +FunctionEmitContext::FPCastInst(llvm::Value *value, llvm::Type *type, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); @@ -1812,7 +1812,7 @@ FunctionEmitContext::FPCastInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type * llvm::Instruction * -FunctionEmitContext::SExtInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, +FunctionEmitContext::SExtInst(llvm::Value *value, llvm::Type *type, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); @@ -1829,7 +1829,7 @@ FunctionEmitContext::SExtInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *ty llvm::Instruction * -FunctionEmitContext::ZExtInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, +FunctionEmitContext::ZExtInst(llvm::Value *value, llvm::Type *type, const char *name) { if (value == NULL) { Assert(m->errorCount > 0); @@ -1860,7 +1860,7 @@ FunctionEmitContext::applyVaryingGEP(llvm::Value *basePtr, llvm::Value *index, llvm::Value *scale = g->target.SizeOf(scaleType->LLVMType(g->ctx), bblock); bool indexIsVarying = - llvm::isa(index->getType()); + llvm::isa(index->getType()); llvm::Value *offset = NULL; if (indexIsVarying == false) { // Truncate or sign extend the index as appropriate to a 32 or @@ -1904,7 +1904,7 @@ FunctionEmitContext::applyVaryingGEP(llvm::Value *basePtr, llvm::Value *index, // Smear out the pointer to be varying; either the base pointer or the // index must be varying for this method to be called. bool baseIsUniform = - (llvm::isa(basePtr->getType())); + (llvm::isa(basePtr->getType())); Assert(baseIsUniform == false || indexIsVarying == true); llvm::Value *varyingPtr = baseIsUniform ? SmearUniform(basePtr, "ptr_smear") : basePtr; @@ -1916,18 +1916,18 @@ FunctionEmitContext::applyVaryingGEP(llvm::Value *basePtr, llvm::Value *index, void FunctionEmitContext::MatchIntegerTypes(llvm::Value **v0, llvm::Value **v1) { - LLVM_TYPE_CONST llvm::Type *type0 = (*v0)->getType(); - LLVM_TYPE_CONST llvm::Type *type1 = (*v1)->getType(); + llvm::Type *type0 = (*v0)->getType(); + llvm::Type *type1 = (*v1)->getType(); // First, promote to a vector type if one of the two values is a vector // type - if (llvm::isa(type0) && - !llvm::isa(type1)) { + if (llvm::isa(type0) && + !llvm::isa(type1)) { *v1 = SmearUniform(*v1, "smear_v1"); type1 = (*v1)->getType(); } - if (!llvm::isa(type0) && - llvm::isa(type1)) { + if (!llvm::isa(type0) && + llvm::isa(type1)) { *v0 = SmearUniform(*v0, "smear_v0"); type0 = (*v0)->getType(); } @@ -1964,7 +1964,7 @@ lComputeSliceIndex(FunctionEmitContext *ctx, int soaWidth, ctx->MatchIntegerTypes(&indexValue, &ptrSliceOffset); - LLVM_TYPE_CONST llvm::Type *indexType = indexValue->getType(); + llvm::Type *indexType = indexValue->getType(); llvm::Value *shift = LLVMIntAsType(logWidth, indexType); llvm::Value *mask = LLVMIntAsType(soaWidth-1, indexType); @@ -1992,10 +1992,10 @@ FunctionEmitContext::MakeSlicePointer(llvm::Value *ptr, llvm::Value *offset) { // Create a small struct where the first element is the type of the // given pointer and the second element is the type of the offset // value. - std::vector eltTypes; + std::vector eltTypes; eltTypes.push_back(ptr->getType()); eltTypes.push_back(offset->getType()); - LLVM_TYPE_CONST llvm::StructType *st = + llvm::StructType *st = llvm::StructType::get(*g->ctx, eltTypes); llvm::Value *ret = llvm::UndefValue::get(st); @@ -2023,7 +2023,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index, } if (ptrType->IsSlice()) { - Assert(llvm::isa(basePtr->getType())); + Assert(llvm::isa(basePtr->getType())); llvm::Value *ptrSliceOffset = ExtractInst(basePtr, 1); if (ptrType->IsFrozenSlice() == false) { @@ -2051,12 +2051,12 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index, // Double-check consistency between the given pointer type and its LLVM // type. if (ptrType->IsUniformType()) - Assert(llvm::isa(basePtr->getType())); + Assert(llvm::isa(basePtr->getType())); else if (ptrType->IsVaryingType()) - Assert(llvm::isa(basePtr->getType())); + Assert(llvm::isa(basePtr->getType())); bool indexIsVaryingType = - llvm::isa(index->getType()); + llvm::isa(index->getType()); if (indexIsVaryingType == false && ptrType->IsUniformType() == true) { // The easy case: both the base pointer and the indices are @@ -2096,7 +2096,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0 // Similar to the 1D GEP implementation above, for non-frozen slice // pointers we do the two-step indexing calculation and then pass // the new major index on to a recursive GEP call. - Assert(llvm::isa(basePtr->getType())); + Assert(llvm::isa(basePtr->getType())); llvm::Value *ptrSliceOffset = ExtractInst(basePtr, 1); if (ptrType->IsFrozenSlice() == false) { llvm::Value *newSliceOffset; @@ -2113,9 +2113,9 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0 } bool index0IsVaryingType = - llvm::isa(index0->getType()); + llvm::isa(index0->getType()); bool index1IsVaryingType = - llvm::isa(index1->getType()); + llvm::isa(index1->getType()); if (index0IsVaryingType == false && index1IsVaryingType == false && ptrType->IsUniformType() == true) { @@ -2140,7 +2140,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0 Assert(st != NULL); bool ptr0IsUniform = - llvm::isa(ptr0->getType()); + llvm::isa(ptr0->getType()); const Type *ptr0BaseType = st->GetElementType(); const Type *ptr0Type = ptr0IsUniform ? PointerType::GetUniform(ptr0BaseType) : @@ -2175,7 +2175,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum, // unfortunate... llvm::Value *basePtr = fullBasePtr; bool baseIsSlicePtr = - llvm::isa(fullBasePtr->getType()); + llvm::isa(fullBasePtr->getType()); const PointerType *rpt; if (baseIsSlicePtr) { Assert(ptrType != NULL); @@ -2263,8 +2263,8 @@ FunctionEmitContext::LoadInst(llvm::Value *ptr, const char *name) { return NULL; } - LLVM_TYPE_CONST llvm::PointerType *pt = - llvm::dyn_cast(ptr->getType()); + llvm::PointerType *pt = + llvm::dyn_cast(ptr->getType()); Assert(pt != NULL); // FIXME: it's not clear to me that we generate unaligned vector loads @@ -2272,7 +2272,7 @@ FunctionEmitContext::LoadInst(llvm::Value *ptr, const char *name) { // optimization passes that lower gathers to vector loads, I think..) // So remove this?? int align = 0; - if (llvm::isa(pt->getElementType())) + if (llvm::isa(pt->getElementType())) align = 1; llvm::Instruction *inst = new llvm::LoadInst(ptr, name ? name : "load", false /* not volatile */, @@ -2332,7 +2332,7 @@ FunctionEmitContext::loadUniformFromSOA(llvm::Value *ptr, llvm::Value *mask, // If we have a struct/array, we need to decompose it into // individual element loads to fill in the result structure since // the SOA slice of values we need isn't contiguous in memory... - LLVM_TYPE_CONST llvm::Type *llvmReturnType = unifType->LLVMType(g->ctx); + llvm::Type *llvmReturnType = unifType->LLVMType(g->ctx); llvm::Value *retValue = llvm::UndefValue::get(llvmReturnType); for (int i = 0; i < ct->GetElementCount(); ++i) { @@ -2416,7 +2416,7 @@ FunctionEmitContext::gather(llvm::Value *ptr, const PointerType *ptrType, Assert(ptrType->IsVaryingType()); const Type *returnType = ptrType->GetBaseType()->GetAsVaryingType(); - LLVM_TYPE_CONST llvm::Type *llvmReturnType = returnType->LLVMType(g->ctx); + llvm::Type *llvmReturnType = returnType->LLVMType(g->ctx); const CollectionType *collectionType = dynamic_cast(ptrType->GetBaseType()); @@ -2524,7 +2524,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) { llvm::Value * -FunctionEmitContext::AllocaInst(LLVM_TYPE_CONST llvm::Type *llvmType, +FunctionEmitContext::AllocaInst(llvm::Type *llvmType, const char *name, int align, bool atEntryBlock) { if (llvmType == NULL) { @@ -2550,10 +2550,10 @@ FunctionEmitContext::AllocaInst(LLVM_TYPE_CONST llvm::Type *llvmType, // unlikely that this array will be loaded into varying variables with // what will be aligned accesses if the uniform -> varying load is done // in regular chunks. - LLVM_TYPE_CONST llvm::ArrayType *arrayType = - llvm::dyn_cast(llvmType); + llvm::ArrayType *arrayType = + llvm::dyn_cast(llvmType); if (align == 0 && arrayType != NULL && - !llvm::isa(arrayType->getElementType())) + !llvm::isa(arrayType->getElementType())) align = 4 * g->target.nativeVectorWidth; if (align != 0) @@ -2760,7 +2760,7 @@ FunctionEmitContext::scatter(llvm::Value *value, llvm::Value *ptr, Assert(pt != NULL || dynamic_cast(valueType) != NULL); - LLVM_TYPE_CONST llvm::Type *type = value->getType(); + llvm::Type *type = value->getType(); const char *funcName = NULL; if (pt != NULL) funcName = g->target.is32Bit ? "__pseudo_scatter32_32" : @@ -2957,7 +2957,7 @@ FunctionEmitContext::ExtractInst(llvm::Value *v, int elt, const char *name) { } llvm::Instruction *ei = NULL; - if (llvm::isa(v->getType())) + if (llvm::isa(v->getType())) ei = llvm::ExtractElementInst::Create(v, LLVMInt32(elt), name ? name : "extract", bblock); else @@ -2977,7 +2977,7 @@ FunctionEmitContext::InsertInst(llvm::Value *v, llvm::Value *eltVal, int elt, } llvm::Instruction *ii = NULL; - if (llvm::isa(v->getType())) + if (llvm::isa(v->getType())) ii = llvm::InsertElementInst::Create(v, eltVal, LLVMInt32(elt), name ? name : "insert", bblock); else @@ -2989,7 +2989,7 @@ FunctionEmitContext::InsertInst(llvm::Value *v, llvm::Value *eltVal, int elt, llvm::PHINode * -FunctionEmitContext::PhiNode(LLVM_TYPE_CONST llvm::Type *type, int count, +FunctionEmitContext::PhiNode(llvm::Type *type, int count, const char *name) { llvm::PHINode *pn = llvm::PHINode::Create(type, count, name ? name : "phi", bblock); @@ -3019,18 +3019,18 @@ FunctionEmitContext::SelectInst(llvm::Value *test, llvm::Value *val0, function has. */ static unsigned int lCalleeArgCount(llvm::Value *callee, const FunctionType *funcType) { - LLVM_TYPE_CONST llvm::FunctionType *ft = - llvm::dyn_cast(callee->getType()); + llvm::FunctionType *ft = + llvm::dyn_cast(callee->getType()); if (ft == NULL) { - LLVM_TYPE_CONST llvm::PointerType *pt = - llvm::dyn_cast(callee->getType()); + llvm::PointerType *pt = + llvm::dyn_cast(callee->getType()); if (pt == NULL) { // varying--in this case, it must be the version of the // function that takes a mask return funcType->GetNumParameters() + 1; } - ft = llvm::dyn_cast(pt->getElementType()); + ft = llvm::dyn_cast(pt->getElementType()); } Assert(ft != NULL); @@ -3057,7 +3057,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType, if (argVals.size() + 1 == calleeArgCount) argVals.push_back(GetFullMask()); - if (llvm::isa(func->getType()) == false) { + if (llvm::isa(func->getType()) == false) { // Regular 'uniform' function call--just one function or function // pointer, so just emit the IR directly. llvm::Instruction *ci = @@ -3085,7 +3085,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType, // First allocate memory to accumulate the various program // instances' return values... const Type *returnType = funcType->GetReturnType(); - LLVM_TYPE_CONST llvm::Type *llvmReturnType = returnType->LLVMType(g->ctx); + llvm::Type *llvmReturnType = returnType->LLVMType(g->ctx); llvm::Value *resultPtr = NULL; if (llvmReturnType->isVoidTy() == false) resultPtr = AllocaInst(llvmReturnType); @@ -3152,9 +3152,9 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType, // bitcast the i32/64 function pointer to the actual function // pointer type (the variant that includes a mask). - LLVM_TYPE_CONST llvm::Type *llvmFuncType = + llvm::Type *llvmFuncType = funcType->LLVMFunctionType(g->ctx, true); - LLVM_TYPE_CONST llvm::Type *llvmFPtrType = + llvm::Type *llvmFPtrType = llvm::PointerType::get(llvmFuncType, 0); llvm::Value *fptrCast = IntToPtrInst(fptr, llvmFPtrType); @@ -3251,14 +3251,14 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee, launchedTasks = true; Assert(llvm::isa(callee)); - LLVM_TYPE_CONST llvm::Type *argType = + llvm::Type *argType = (llvm::dyn_cast(callee))->arg_begin()->getType(); Assert(llvm::PointerType::classof(argType)); - LLVM_TYPE_CONST llvm::PointerType *pt = - llvm::dyn_cast(argType); + llvm::PointerType *pt = + llvm::dyn_cast(argType); Assert(llvm::StructType::classof(pt->getElementType())); - LLVM_TYPE_CONST llvm::StructType *argStructType = - static_cast(pt->getElementType()); + llvm::StructType *argStructType = + static_cast(pt->getElementType()); Assert(argStructType->getNumElements() == argVals.size() + 1); llvm::Function *falloc = m->module->getFunction("ISPCAlloc"); @@ -3356,7 +3356,7 @@ FunctionEmitContext::addVaryingOffsetsIfNeeded(llvm::Value *ptr, return ptr; // Find the size of a uniform element of the varying type - LLVM_TYPE_CONST llvm::Type *llvmBaseUniformType = + llvm::Type *llvmBaseUniformType = baseType->GetAsUniformType()->LLVMType(g->ctx); llvm::Value *unifSize = g->target.SizeOf(llvmBaseUniformType, bblock); unifSize = SmearUniform(unifSize); diff --git a/ctx.h b/ctx.h index 8cb24a06..6c3f2887 100644 --- a/ctx.h +++ b/ctx.h @@ -380,23 +380,23 @@ public: array, for pointer types). */ llvm::Value *SmearUniform(llvm::Value *value, const char *name = NULL); - llvm::Value *BitCastInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, + llvm::Value *BitCastInst(llvm::Value *value, llvm::Type *type, const char *name = NULL); llvm::Value *PtrToIntInst(llvm::Value *value, const char *name = NULL); - llvm::Value *PtrToIntInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, + llvm::Value *PtrToIntInst(llvm::Value *value, llvm::Type *type, const char *name = NULL); - llvm::Value *IntToPtrInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, + llvm::Value *IntToPtrInst(llvm::Value *value, llvm::Type *type, const char *name = NULL); - llvm::Instruction *TruncInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, + llvm::Instruction *TruncInst(llvm::Value *value, llvm::Type *type, const char *name = NULL); llvm::Instruction *CastInst(llvm::Instruction::CastOps op, llvm::Value *value, - LLVM_TYPE_CONST llvm::Type *type, const char *name = NULL); - llvm::Instruction *FPCastInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, + llvm::Type *type, const char *name = NULL); + llvm::Instruction *FPCastInst(llvm::Value *value, llvm::Type *type, const char *name = NULL); - llvm::Instruction *SExtInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, + llvm::Instruction *SExtInst(llvm::Value *value, llvm::Type *type, const char *name = NULL); - llvm::Instruction *ZExtInst(llvm::Value *value, LLVM_TYPE_CONST llvm::Type *type, + llvm::Instruction *ZExtInst(llvm::Value *value, llvm::Type *type, const char *name = NULL); /** Given two integer-typed values (but possibly one vector and the @@ -448,7 +448,7 @@ public: instruction is added at the start of the function in the entry basic block; if it should be added to the current basic block, then the atEntryBlock parameter should be false. */ - llvm::Value *AllocaInst(LLVM_TYPE_CONST llvm::Type *llvmType, + llvm::Value *AllocaInst(llvm::Type *llvmType, const char *name = NULL, int align = 0, bool atEntryBlock = true); @@ -485,7 +485,7 @@ public: llvm::Value *InsertInst(llvm::Value *v, llvm::Value *eltVal, int elt, const char *name = NULL); - llvm::PHINode *PhiNode(LLVM_TYPE_CONST llvm::Type *type, int count, + llvm::PHINode *PhiNode(llvm::Type *type, int count, const char *name = NULL); llvm::Instruction *SelectInst(llvm::Value *test, llvm::Value *val0, llvm::Value *val1, const char *name = NULL); diff --git a/expr.cpp b/expr.cpp index e22217a0..fdaf878c 100644 --- a/expr.cpp +++ b/expr.cpp @@ -637,7 +637,7 @@ InitSymbol(llvm::Value *ptr, const Type *symType, Expr *initExpr, // instead we'll make a constant static global that holds the // constant value and emit a memcpy to put its value into the // pointer we have. - LLVM_TYPE_CONST llvm::Type *llvmType = symType->LLVMType(g->ctx); + llvm::Type *llvmType = symType->LLVMType(g->ctx); if (llvmType == NULL) { Assert(m->errorCount > 0); return; @@ -771,7 +771,7 @@ InitSymbol(llvm::Value *ptr, const Type *symType, Expr *initExpr, else { // If we don't have enough initializer values, initialize the // rest as zero. - LLVM_TYPE_CONST llvm::Type *llvmType = elementType->LLVMType(g->ctx); + llvm::Type *llvmType = elementType->LLVMType(g->ctx); if (llvmType == NULL) { Assert(m->errorCount > 0); return; @@ -905,7 +905,7 @@ lLLVMConstantValue(const Type *type, llvm::LLVMContext *ctx, double value) { // a recursive call to lLLVMConstantValue(). const Type *baseType = vectorType->GetBaseType(); llvm::Constant *constElement = lLLVMConstantValue(baseType, ctx, value); - LLVM_TYPE_CONST llvm::Type *llvmVectorType = vectorType->LLVMType(ctx); + llvm::Type *llvmVectorType = vectorType->LLVMType(ctx); // Now create a constant version of the corresponding LLVM type that we // use to represent the VectorType. @@ -914,8 +914,8 @@ lLLVMConstantValue(const Type *type, llvm::LLVMContext *ctx, double value) { // LLVM ArrayTypes leaks into the code here; it feels like this detail // should be better encapsulated? if (baseType->IsUniformType()) { - LLVM_TYPE_CONST llvm::VectorType *lvt = - llvm::dyn_cast(llvmVectorType); + llvm::VectorType *lvt = + llvm::dyn_cast(llvmVectorType); Assert(lvt != NULL); std::vector vals; for (unsigned int i = 0; i < lvt->getNumElements(); ++i) @@ -923,8 +923,8 @@ lLLVMConstantValue(const Type *type, llvm::LLVMContext *ctx, double value) { return llvm::ConstantVector::get(vals); } else { - LLVM_TYPE_CONST llvm::ArrayType *lat = - llvm::dyn_cast(llvmVectorType); + llvm::ArrayType *lat = + llvm::dyn_cast(llvmVectorType); Assert(lat != NULL); std::vector vals; for (unsigned int i = 0; i < lat->getNumElements(); ++i) @@ -1439,7 +1439,7 @@ lEmitBinaryPointerArith(BinaryExpr::Op op, llvm::Value *value0, // Now divide by the size of the type that the pointer // points to in order to return the difference in elements. - LLVM_TYPE_CONST llvm::Type *llvmElementType = + llvm::Type *llvmElementType = ptrType->GetBaseType()->LLVMType(g->ctx); llvm::Value *size = g->target.SizeOf(llvmElementType, ctx->GetCurrentBasicBlock()); @@ -1648,7 +1648,7 @@ lEmitLogicalOp(BinaryExpr::Op op, Expr *arg0, Expr *arg1, // Allocate temporary storage for the return value const Type *retType = Type::MoreGeneralType(type0, type1, pos, lOpString(op)); - LLVM_TYPE_CONST llvm::Type *llvmRetType = retType->LLVMType(g->ctx); + llvm::Type *llvmRetType = retType->LLVMType(g->ctx); llvm::Value *retPtr = ctx->AllocaInst(llvmRetType, "logical_op_mem"); llvm::BasicBlock *bbSkipEvalValue1 = ctx->CreateBasicBlock("skip_eval_1"); @@ -3010,7 +3010,7 @@ SelectExpr::GetValue(FunctionEmitContext *ctx) const { // Temporary storage to store the values computed for each // expression, if any. (These stay as uninitialized memory if we // short circuit around the corresponding expression.) - LLVM_TYPE_CONST llvm::Type *exprType = + llvm::Type *exprType = expr1->GetType()->LLVMType(g->ctx); llvm::Value *expr1Ptr = ctx->AllocaInst(exprType); llvm::Value *expr2Ptr = ctx->AllocaInst(exprType); @@ -3690,7 +3690,7 @@ ExprList::GetConstant(const Type *type) const { return NULL; } - LLVM_TYPE_CONST llvm::Type *llvmType = elementType->LLVMType(g->ctx); + llvm::Type *llvmType = elementType->LLVMType(g->ctx); if (llvmType == NULL) { Assert(m->errorCount > 0); return NULL; @@ -3701,23 +3701,23 @@ ExprList::GetConstant(const Type *type) const { } if (dynamic_cast(type) != NULL) { - LLVM_TYPE_CONST llvm::StructType *llvmStructType = - llvm::dyn_cast(collectionType->LLVMType(g->ctx)); + llvm::StructType *llvmStructType = + llvm::dyn_cast(collectionType->LLVMType(g->ctx)); Assert(llvmStructType != NULL); return llvm::ConstantStruct::get(llvmStructType, cv); } else { - LLVM_TYPE_CONST llvm::Type *lt = type->LLVMType(g->ctx); - LLVM_TYPE_CONST llvm::ArrayType *lat = - llvm::dyn_cast(lt); + llvm::Type *lt = type->LLVMType(g->ctx); + llvm::ArrayType *lat = + llvm::dyn_cast(lt); if (lat != NULL) return llvm::ConstantArray::get(lat, cv); else { // uniform short vector type Assert(type->IsUniformType() && dynamic_cast(type) != NULL); - LLVM_TYPE_CONST llvm::VectorType *lvt = - llvm::dyn_cast(lt); + llvm::VectorType *lvt = + llvm::dyn_cast(lt); Assert(lvt != NULL); // Uniform short vectors are stored as vectors of length @@ -3994,10 +3994,10 @@ IndexExpr::GetBaseSymbol() const { static llvm::Value * lConvertToSlicePointer(FunctionEmitContext *ctx, llvm::Value *ptr, const PointerType *slicePtrType) { - LLVM_TYPE_CONST llvm::Type *llvmSlicePtrType = + llvm::Type *llvmSlicePtrType = slicePtrType->LLVMType(g->ctx); - LLVM_TYPE_CONST llvm::StructType *sliceStructType = - llvm::dyn_cast(llvmSlicePtrType); + llvm::StructType *sliceStructType = + llvm::dyn_cast(llvmSlicePtrType); Assert(sliceStructType != NULL && sliceStructType->getElementType(0) == ptr->getType()); @@ -5675,7 +5675,7 @@ ConstExpr::GetConstant(const Type *type) const { // The only time we should get here is if we have an integer '0' // constant that should be turned into a NULL pointer of the // appropriate type. - LLVM_TYPE_CONST llvm::Type *llvmType = type->LLVMType(g->ctx); + llvm::Type *llvmType = type->LLVMType(g->ctx); if (llvmType == NULL) { Assert(m->errorCount > 0); return NULL; @@ -5788,7 +5788,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, switch (toType->basicType) { case AtomicType::TYPE_FLOAT: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::FloatType : LLVMTypes::FloatVectorType; switch (fromType->basicType) { @@ -5832,7 +5832,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_DOUBLE: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::DoubleType : LLVMTypes::DoubleVectorType; switch (fromType->basicType) { @@ -5870,7 +5870,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_INT8: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int8Type : LLVMTypes::Int8VectorType; switch (fromType->basicType) { @@ -5906,7 +5906,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_UINT8: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int8Type : LLVMTypes::Int8VectorType; switch (fromType->basicType) { @@ -5948,7 +5948,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_INT16: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int16Type : LLVMTypes::Int16VectorType; switch (fromType->basicType) { @@ -5988,7 +5988,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_UINT16: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int16Type : LLVMTypes::Int16VectorType; switch (fromType->basicType) { @@ -6034,7 +6034,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_INT32: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int32Type : LLVMTypes::Int32VectorType; switch (fromType->basicType) { @@ -6074,7 +6074,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_UINT32: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int32Type : LLVMTypes::Int32VectorType; switch (fromType->basicType) { @@ -6120,7 +6120,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_INT64: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int64Type : LLVMTypes::Int64VectorType; switch (fromType->basicType) { @@ -6158,7 +6158,7 @@ lTypeConvAtomic(FunctionEmitContext *ctx, llvm::Value *exprVal, break; } case AtomicType::TYPE_UINT64: { - LLVM_TYPE_CONST llvm::Type *targetType = + llvm::Type *targetType = fromType->IsUniformType() ? LLVMTypes::Int64Type : LLVMTypes::Int64VectorType; switch (fromType->basicType) { @@ -6302,7 +6302,7 @@ lUniformValueToVarying(FunctionEmitContext *ctx, llvm::Value *value, const CollectionType *collectionType = dynamic_cast(type); if (collectionType != NULL) { - LLVM_TYPE_CONST llvm::Type *llvmType = + llvm::Type *llvmType = type->GetAsVaryingType()->LLVMType(g->ctx); llvm::Value *retValue = llvm::UndefValue::get(llvmType); @@ -6404,10 +6404,10 @@ TypeCastExpr::GetValue(FunctionEmitContext *ctx) const { Assert(dynamic_cast(toType) != NULL); if (toType->IsBoolType()) { // convert pointer to bool - LLVM_TYPE_CONST llvm::Type *lfu = + llvm::Type *lfu = fromType->GetAsUniformType()->LLVMType(g->ctx); - LLVM_TYPE_CONST llvm::PointerType *llvmFromUnifType = - llvm::dyn_cast(lfu); + llvm::PointerType *llvmFromUnifType = + llvm::dyn_cast(lfu); llvm::Value *nullPtrValue = llvm::ConstantPointerNull::get(llvmFromUnifType); @@ -6436,7 +6436,7 @@ TypeCastExpr::GetValue(FunctionEmitContext *ctx) const { if (toType->IsVaryingType() && fromType->IsUniformType()) value = ctx->SmearUniform(value); - LLVM_TYPE_CONST llvm::Type *llvmToType = toType->LLVMType(g->ctx); + llvm::Type *llvmToType = toType->LLVMType(g->ctx); if (llvmToType == NULL) return NULL; return ctx->PtrToIntInst(value, llvmToType, "ptr_typecast"); @@ -6479,7 +6479,7 @@ TypeCastExpr::GetValue(FunctionEmitContext *ctx) const { Assert(Type::EqualIgnoringConst(toArrayType->GetBaseType(), fromArrayType->GetBaseType())); llvm::Value *v = expr->GetValue(ctx); - LLVM_TYPE_CONST llvm::Type *ptype = toType->LLVMType(g->ctx); + llvm::Type *ptype = toType->LLVMType(g->ctx); return ctx->BitCastInst(v, ptype); //, "array_cast_0size"); } @@ -6501,7 +6501,7 @@ TypeCastExpr::GetValue(FunctionEmitContext *ctx) const { Assert(Type::EqualIgnoringConst(toArray->GetBaseType(), fromArray->GetBaseType())); llvm::Value *v = expr->GetValue(ctx); - LLVM_TYPE_CONST llvm::Type *ptype = toType->LLVMType(g->ctx); + llvm::Type *ptype = toType->LLVMType(g->ctx); return ctx->BitCastInst(v, ptype); //, "array_cast_0size"); } @@ -6589,7 +6589,7 @@ TypeCastExpr::GetValue(FunctionEmitContext *ctx) const { if (toType->IsVaryingType() && fromType->IsUniformType()) exprVal = ctx->SmearUniform(exprVal); - LLVM_TYPE_CONST llvm::Type *llvmToType = toType->LLVMType(g->ctx); + llvm::Type *llvmToType = toType->LLVMType(g->ctx); if (llvmToType == NULL) return NULL; @@ -6828,7 +6828,7 @@ lConvertPointerConstant(llvm::Constant *c, const Type *constType) { if (constType->IsVaryingType()) return llvm::ConstantVector::get(smear); else { - LLVM_TYPE_CONST llvm::ArrayType *at = + llvm::ArrayType *at = llvm::ArrayType::get(LLVMTypes::PointerIntType, count); return llvm::ConstantArray::get(at, smear); } @@ -6881,7 +6881,7 @@ ReferenceExpr::GetValue(FunctionEmitContext *ctx) const { // value is NULL if the expression is a temporary; in this case, we'll // allocate storage for it so that we can return the pointer to that... const Type *type; - LLVM_TYPE_CONST llvm::Type *llvmType; + llvm::Type *llvmType; if ((type = expr->GetType()) == NULL || (llvmType = type->LLVMType(g->ctx)) == NULL) { Assert(m->errorCount > 0); @@ -7299,7 +7299,7 @@ SizeOfExpr::GetValue(FunctionEmitContext *ctx) const { if (t == NULL) return NULL; - LLVM_TYPE_CONST llvm::Type *llvmType = t->LLVMType(g->ctx); + llvm::Type *llvmType = t->LLVMType(g->ctx); if (llvmType == NULL) return NULL; @@ -7913,7 +7913,7 @@ NullPointerExpr::GetConstant(const Type *type) const { if (pt == NULL) return NULL; - LLVM_TYPE_CONST llvm::Type *llvmType = type->LLVMType(g->ctx); + llvm::Type *llvmType = type->LLVMType(g->ctx); if (llvmType == NULL) { Assert(m->errorCount > 0); return NULL; @@ -8059,7 +8059,7 @@ NewExpr::GetValue(FunctionEmitContext *ctx) const { // Initialize the memory pointed to by the pointer for the // current lane. ctx->SetCurrentBasicBlock(bbInit); - LLVM_TYPE_CONST llvm::Type *ptrType = + llvm::Type *ptrType = retType->GetAsUniformType()->LLVMType(g->ctx); llvm::Value *ptr = ctx->IntToPtrInst(p, ptrType); InitSymbol(ptr, allocType, initExpr, ctx, pos); @@ -8075,7 +8075,7 @@ NewExpr::GetValue(FunctionEmitContext *ctx) const { // For uniform news, we just need to cast the void * to be a // pointer of the return type and to run the code for initializers, // if present. - LLVM_TYPE_CONST llvm::Type *ptrType = retType->LLVMType(g->ctx); + llvm::Type *ptrType = retType->LLVMType(g->ctx); ptrValue = ctx->BitCastInst(ptrValue, ptrType, "cast_new_ptr"); if (initExpr != NULL) diff --git a/func.cpp b/func.cpp index d6e24d72..29dd9ecf 100644 --- a/func.cpp +++ b/func.cpp @@ -165,7 +165,7 @@ lCopyInTaskParameter(int i, llvm::Value *structArgPtr, const llvm::dyn_cast(pt->getElementType()); // Get the type of the argument we're copying in and its Symbol pointer - LLVM_TYPE_CONST llvm::Type *argType = argStructType->getElementType(i); + llvm::Type *argType = argStructType->getElementType(i); Symbol *sym = args[i]; if (sym == NULL) @@ -435,7 +435,7 @@ Function::GenerateIR() { Assert(type != NULL); if (type->isExported) { if (!type->isTask) { - LLVM_TYPE_CONST llvm::FunctionType *ftype = + llvm::FunctionType *ftype = type->LLVMFunctionType(g->ctx); llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::ExternalLinkage; std::string functionName = sym->name; diff --git a/ispc.cpp b/ispc.cpp index e9357832..dce3ed77 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -457,7 +457,7 @@ Target::GetISAString() const { static bool -lGenericTypeLayoutIndeterminate(LLVM_TYPE_CONST llvm::Type *type) { +lGenericTypeLayoutIndeterminate(llvm::Type *type) { if (type->isPrimitiveType() || type->isIntegerTy()) return false; @@ -466,18 +466,18 @@ lGenericTypeLayoutIndeterminate(LLVM_TYPE_CONST llvm::Type *type) { type == LLVMTypes::Int1VectorType) return true; - LLVM_TYPE_CONST llvm::ArrayType *at = - llvm::dyn_cast(type); + llvm::ArrayType *at = + llvm::dyn_cast(type); if (at != NULL) return lGenericTypeLayoutIndeterminate(at->getElementType()); - LLVM_TYPE_CONST llvm::PointerType *pt = - llvm::dyn_cast(type); + llvm::PointerType *pt = + llvm::dyn_cast(type); if (pt != NULL) return false; - LLVM_TYPE_CONST llvm::StructType *st = - llvm::dyn_cast(type); + llvm::StructType *st = + llvm::dyn_cast(type); if (st != NULL) { for (int i = 0; i < (int)st->getNumElements(); ++i) if (lGenericTypeLayoutIndeterminate(st->getElementType(i))) @@ -485,18 +485,18 @@ lGenericTypeLayoutIndeterminate(LLVM_TYPE_CONST llvm::Type *type) { return false; } - Assert(llvm::isa(type)); + Assert(llvm::isa(type)); return true; } llvm::Value * -Target::SizeOf(LLVM_TYPE_CONST llvm::Type *type, +Target::SizeOf(llvm::Type *type, llvm::BasicBlock *insertAtEnd) { if (isa == Target::GENERIC && lGenericTypeLayoutIndeterminate(type)) { llvm::Value *index[1] = { LLVMInt32(1) }; - LLVM_TYPE_CONST llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); + llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); #if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) llvm::ArrayRef arrayRef(&index[0], &index[1]); @@ -529,12 +529,12 @@ Target::SizeOf(LLVM_TYPE_CONST llvm::Type *type, llvm::Value * -Target::StructOffset(LLVM_TYPE_CONST llvm::Type *type, int element, +Target::StructOffset(llvm::Type *type, int element, llvm::BasicBlock *insertAtEnd) { if (isa == Target::GENERIC && lGenericTypeLayoutIndeterminate(type) == true) { llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(element) }; - LLVM_TYPE_CONST llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); + llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); #if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) llvm::ArrayRef arrayRef(&indices[0], &indices[2]); @@ -556,8 +556,8 @@ Target::StructOffset(LLVM_TYPE_CONST llvm::Type *type, int element, const llvm::TargetData *td = GetTargetMachine()->getTargetData(); Assert(td != NULL); - LLVM_TYPE_CONST llvm::StructType *structType = - llvm::dyn_cast(type); + llvm::StructType *structType = + llvm::dyn_cast(type); Assert(structType != NULL); const llvm::StructLayout *sl = td->getStructLayout(structType); Assert(sl != NULL); diff --git a/ispc.h b/ispc.h index 480c4bb1..d93788ec 100644 --- a/ispc.h +++ b/ispc.h @@ -92,12 +92,6 @@ namespace llvm { class Value; } -// llvm::Type *s are no longer const in llvm 3.0 -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) -#define LLVM_TYPE_CONST -#else -#define LLVM_TYPE_CONST const -#endif class ArrayType; class AST; @@ -191,13 +185,13 @@ struct Target { const char *GetISAString() const; /** Returns the size of the given type */ - llvm::Value *SizeOf(LLVM_TYPE_CONST llvm::Type *type, + llvm::Value *SizeOf(llvm::Type *type, llvm::BasicBlock *insertAtEnd); /** Given a structure type and an element number in the structure, returns a value corresponding to the number of bytes from the start of the structure where the element is located. */ - llvm::Value *StructOffset(LLVM_TYPE_CONST llvm::Type *type, + llvm::Value *StructOffset(llvm::Type *type, int element, llvm::BasicBlock *insertAtEnd); /** llvm Target object representing this target. */ diff --git a/llvmutil.cpp b/llvmutil.cpp index 6012d4eb..5febaadf 100644 --- a/llvmutil.cpp +++ b/llvmutil.cpp @@ -43,44 +43,44 @@ #include #include -LLVM_TYPE_CONST llvm::Type *LLVMTypes::VoidType = NULL; -LLVM_TYPE_CONST llvm::PointerType *LLVMTypes::VoidPointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::PointerIntType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::BoolType = NULL; +llvm::Type *LLVMTypes::VoidType = NULL; +llvm::PointerType *LLVMTypes::VoidPointerType = NULL; +llvm::Type *LLVMTypes::PointerIntType = NULL; +llvm::Type *LLVMTypes::BoolType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int8Type = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int16Type = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int32Type = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int64Type = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::FloatType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::DoubleType = NULL; +llvm::Type *LLVMTypes::Int8Type = NULL; +llvm::Type *LLVMTypes::Int16Type = NULL; +llvm::Type *LLVMTypes::Int32Type = NULL; +llvm::Type *LLVMTypes::Int64Type = NULL; +llvm::Type *LLVMTypes::FloatType = NULL; +llvm::Type *LLVMTypes::DoubleType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int8PointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int16PointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int32PointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int64PointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::FloatPointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::DoublePointerType = NULL; +llvm::Type *LLVMTypes::Int8PointerType = NULL; +llvm::Type *LLVMTypes::Int16PointerType = NULL; +llvm::Type *LLVMTypes::Int32PointerType = NULL; +llvm::Type *LLVMTypes::Int64PointerType = NULL; +llvm::Type *LLVMTypes::FloatPointerType = NULL; +llvm::Type *LLVMTypes::DoublePointerType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::MaskType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::BoolVectorType = NULL; +llvm::VectorType *LLVMTypes::MaskType = NULL; +llvm::VectorType *LLVMTypes::BoolVectorType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int1VectorType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int8VectorType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int16VectorType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int32VectorType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::Int64VectorType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::FloatVectorType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::DoubleVectorType = NULL; +llvm::VectorType *LLVMTypes::Int1VectorType = NULL; +llvm::VectorType *LLVMTypes::Int8VectorType = NULL; +llvm::VectorType *LLVMTypes::Int16VectorType = NULL; +llvm::VectorType *LLVMTypes::Int32VectorType = NULL; +llvm::VectorType *LLVMTypes::Int64VectorType = NULL; +llvm::VectorType *LLVMTypes::FloatVectorType = NULL; +llvm::VectorType *LLVMTypes::DoubleVectorType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int8VectorPointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int16VectorPointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int32VectorPointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::Int64VectorPointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::FloatVectorPointerType = NULL; -LLVM_TYPE_CONST llvm::Type *LLVMTypes::DoubleVectorPointerType = NULL; +llvm::Type *LLVMTypes::Int8VectorPointerType = NULL; +llvm::Type *LLVMTypes::Int16VectorPointerType = NULL; +llvm::Type *LLVMTypes::Int32VectorPointerType = NULL; +llvm::Type *LLVMTypes::Int64VectorPointerType = NULL; +llvm::Type *LLVMTypes::FloatVectorPointerType = NULL; +llvm::Type *LLVMTypes::DoubleVectorPointerType = NULL; -LLVM_TYPE_CONST llvm::VectorType *LLVMTypes::VoidPointerVectorType = NULL; +llvm::VectorType *LLVMTypes::VoidPointerVectorType = NULL; llvm::Constant *LLVMTrue = NULL; llvm::Constant *LLVMFalse = NULL; @@ -473,9 +473,9 @@ LLVMBoolVector(const bool *bvec) { llvm::Constant * -LLVMIntAsType(int64_t val, LLVM_TYPE_CONST llvm::Type *type) { - LLVM_TYPE_CONST llvm::VectorType *vecType = - llvm::dyn_cast(type); +LLVMIntAsType(int64_t val, llvm::Type *type) { + llvm::VectorType *vecType = + llvm::dyn_cast(type); if (vecType != NULL) { llvm::Constant *v = llvm::ConstantInt::get(vecType->getElementType(), @@ -491,9 +491,9 @@ LLVMIntAsType(int64_t val, LLVM_TYPE_CONST llvm::Type *type) { llvm::Constant * -LLVMUIntAsType(uint64_t val, LLVM_TYPE_CONST llvm::Type *type) { - LLVM_TYPE_CONST llvm::VectorType *vecType = - llvm::dyn_cast(type); +LLVMUIntAsType(uint64_t val, llvm::Type *type) { + llvm::VectorType *vecType = + llvm::dyn_cast(type); if (vecType != NULL) { llvm::Constant *v = llvm::ConstantInt::get(vecType->getElementType(), @@ -642,8 +642,8 @@ LLVMFlattenInsertChain(llvm::InsertElementInst *ie, int vectorWidth, bool LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) { // Make sure we do in fact have a vector of integer values here - LLVM_TYPE_CONST llvm::VectorType *vt = - llvm::dyn_cast(v->getType()); + llvm::VectorType *vt = + llvm::dyn_cast(v->getType()); Assert(vt != NULL); Assert(llvm::isa(vt->getElementType())); @@ -696,7 +696,7 @@ lVectorValuesAllEqual(llvm::Value *v, int vectorLength, static bool lIsExactMultiple(llvm::Value *val, int baseValue, int vectorLength, std::vector &seenPhis) { - if (llvm::isa(val->getType()) == false) { + if (llvm::isa(val->getType()) == false) { // If we've worked down to a constant int, then the moment of truth // has arrived... llvm::ConstantInt *ci = llvm::dyn_cast(val); @@ -780,7 +780,7 @@ static bool lAllDivBaseEqual(llvm::Value *val, int64_t baseValue, int vectorLength, std::vector &seenPhis, bool &canAdd) { - Assert(llvm::isa(val->getType())); + Assert(llvm::isa(val->getType())); // Make sure the base value is a positive power of 2 Assert(baseValue > 0 && (baseValue & (baseValue-1)) == 0); @@ -790,7 +790,7 @@ lAllDivBaseEqual(llvm::Value *val, int64_t baseValue, int vectorLength, int64_t vecVals[ISPC_MAX_NVEC]; int nElts; - if (llvm::isa(val->getType()) && + if (llvm::isa(val->getType()) && LLVMExtractVectorInts(val, vecVals, &nElts)) { // If we have a vector of compile-time constant integer values, // then go ahead and check them directly.. @@ -1074,8 +1074,8 @@ lVectorValuesAllEqual(llvm::Value *v, int vectorLength, */ bool LLVMVectorValuesAllEqual(llvm::Value *v) { - LLVM_TYPE_CONST llvm::VectorType *vt = - llvm::dyn_cast(v->getType()); + llvm::VectorType *vt = + llvm::dyn_cast(v->getType()); Assert(vt != NULL); int vectorLength = vt->getNumElements(); @@ -1344,8 +1344,8 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride, */ bool LLVMVectorIsLinear(llvm::Value *v, int stride) { - LLVM_TYPE_CONST llvm::VectorType *vt = - llvm::dyn_cast(v->getType()); + llvm::VectorType *vt = + llvm::dyn_cast(v->getType()); Assert(vt != NULL); int vectorLength = vt->getNumElements(); @@ -1399,8 +1399,8 @@ lExtractFirstVectorElement(llvm::Value *v, llvm::Instruction *insertBefore, return llvm::ExtractElementInst::Create(v, LLVMInt32(0), "first_elt", insertBefore); - LLVM_TYPE_CONST llvm::VectorType *vt = - llvm::dyn_cast(v->getType()); + llvm::VectorType *vt = + llvm::dyn_cast(v->getType()); Assert(vt != NULL); std::string newName = v->getName().str() + std::string(".elt0"); @@ -1489,8 +1489,8 @@ LLVMConcatVectors(llvm::Value *v1, llvm::Value *v2, llvm::Instruction *insertBefore) { Assert(v1->getType() == v2->getType()); - LLVM_TYPE_CONST llvm::VectorType *vt = - llvm::dyn_cast(v1->getType()); + llvm::VectorType *vt = + llvm::dyn_cast(v1->getType()); Assert(vt != NULL); int32_t identity[ISPC_MAX_NVEC]; diff --git a/llvmutil.h b/llvmutil.h index 0025bf8e..de50ae70 100644 --- a/llvmutil.h +++ b/llvmutil.h @@ -48,53 +48,50 @@ namespace llvm { class InsertElementInst; } -// llvm::Type *s are no longer const in llvm 3.0 -#define LLVM_TYPE_CONST - /** This structure holds pointers to a variety of LLVM types; code elsewhere can use them from here, ratherthan needing to make more verbose LLVM API calls. */ struct LLVMTypes { - static LLVM_TYPE_CONST llvm::Type *VoidType; - static LLVM_TYPE_CONST llvm::PointerType *VoidPointerType; - static LLVM_TYPE_CONST llvm::Type *PointerIntType; - static LLVM_TYPE_CONST llvm::Type *BoolType; + static llvm::Type *VoidType; + static llvm::PointerType *VoidPointerType; + static llvm::Type *PointerIntType; + static llvm::Type *BoolType; - static LLVM_TYPE_CONST llvm::Type *Int8Type; - static LLVM_TYPE_CONST llvm::Type *Int16Type; - static LLVM_TYPE_CONST llvm::Type *Int32Type; - static LLVM_TYPE_CONST llvm::Type *Int64Type; - static LLVM_TYPE_CONST llvm::Type *FloatType; - static LLVM_TYPE_CONST llvm::Type *DoubleType; + static llvm::Type *Int8Type; + static llvm::Type *Int16Type; + static llvm::Type *Int32Type; + static llvm::Type *Int64Type; + static llvm::Type *FloatType; + static llvm::Type *DoubleType; - static LLVM_TYPE_CONST llvm::Type *Int8PointerType; - static LLVM_TYPE_CONST llvm::Type *Int16PointerType; - static LLVM_TYPE_CONST llvm::Type *Int32PointerType; - static LLVM_TYPE_CONST llvm::Type *Int64PointerType; - static LLVM_TYPE_CONST llvm::Type *FloatPointerType; - static LLVM_TYPE_CONST llvm::Type *DoublePointerType; + static llvm::Type *Int8PointerType; + static llvm::Type *Int16PointerType; + static llvm::Type *Int32PointerType; + static llvm::Type *Int64PointerType; + static llvm::Type *FloatPointerType; + static llvm::Type *DoublePointerType; - static LLVM_TYPE_CONST llvm::VectorType *MaskType; + static llvm::VectorType *MaskType; - static LLVM_TYPE_CONST llvm::VectorType *BoolVectorType; - static LLVM_TYPE_CONST llvm::VectorType *Int1VectorType; - static LLVM_TYPE_CONST llvm::VectorType *Int8VectorType; - static LLVM_TYPE_CONST llvm::VectorType *Int16VectorType; - static LLVM_TYPE_CONST llvm::VectorType *Int32VectorType; - static LLVM_TYPE_CONST llvm::VectorType *Int64VectorType; - static LLVM_TYPE_CONST llvm::VectorType *FloatVectorType; - static LLVM_TYPE_CONST llvm::VectorType *DoubleVectorType; + static llvm::VectorType *BoolVectorType; + static llvm::VectorType *Int1VectorType; + static llvm::VectorType *Int8VectorType; + static llvm::VectorType *Int16VectorType; + static llvm::VectorType *Int32VectorType; + static llvm::VectorType *Int64VectorType; + static llvm::VectorType *FloatVectorType; + static llvm::VectorType *DoubleVectorType; - static LLVM_TYPE_CONST llvm::Type *Int8VectorPointerType; - static LLVM_TYPE_CONST llvm::Type *Int16VectorPointerType; - static LLVM_TYPE_CONST llvm::Type *Int32VectorPointerType; - static LLVM_TYPE_CONST llvm::Type *Int64VectorPointerType; - static LLVM_TYPE_CONST llvm::Type *FloatVectorPointerType; - static LLVM_TYPE_CONST llvm::Type *DoubleVectorPointerType; + static llvm::Type *Int8VectorPointerType; + static llvm::Type *Int16VectorPointerType; + static llvm::Type *Int32VectorPointerType; + static llvm::Type *Int64VectorPointerType; + static llvm::Type *FloatVectorPointerType; + static llvm::Type *DoubleVectorPointerType; - static LLVM_TYPE_CONST llvm::VectorType *VoidPointerVectorType; + static llvm::VectorType *VoidPointerVectorType; }; /** These variables hold the corresponding LLVM constant values as a @@ -171,11 +168,11 @@ extern llvm::Constant *LLVMDoubleVector(double f); /** Returns a constant integer or vector (according to the given type) of the given signed integer value. */ -extern llvm::Constant *LLVMIntAsType(int64_t, LLVM_TYPE_CONST llvm::Type *t); +extern llvm::Constant *LLVMIntAsType(int64_t, llvm::Type *t); /** Returns a constant integer or vector (according to the given type) of the given unsigned integer value. */ -extern llvm::Constant *LLVMUIntAsType(uint64_t, LLVM_TYPE_CONST llvm::Type *t); +extern llvm::Constant *LLVMUIntAsType(uint64_t, llvm::Type *t); /** Returns an LLVM boolean vector based on the given array of values. The array should have g->target.vectorWidth elements. */ diff --git a/module.cpp b/module.cpp index 7ccc6db6..48bbf81b 100644 --- a/module.cpp +++ b/module.cpp @@ -278,7 +278,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE return; } - LLVM_TYPE_CONST llvm::Type *llvmType = type->LLVMType(g->ctx); + llvm::Type *llvmType = type->LLVMType(g->ctx); if (llvmType == NULL) return; @@ -573,7 +573,7 @@ Module::AddFunctionDeclaration(const std::string &name, // Get the LLVM FunctionType bool includeMask = (storageClass != SC_EXTERN_C); - LLVM_TYPE_CONST llvm::FunctionType *llvmFunctionType = + llvm::FunctionType *llvmFunctionType = functionType->LLVMFunctionType(g->ctx, includeMask); if (llvmFunctionType == NULL) return; @@ -1405,7 +1405,7 @@ lAddExtractedGlobals(llvm::Module *module, for (unsigned int i = 0; i < globals[firstActive].size(); ++i) { RewriteGlobalInfo &rgi = globals[firstActive][i]; llvm::GlobalVariable *gv = rgi.gv; - LLVM_TYPE_CONST llvm::Type *type = gv->getType()->getElementType(); + llvm::Type *type = gv->getType()->getElementType(); llvm::Constant *initializer = rgi.init; // Create a new global in the given model that matches the original @@ -1469,7 +1469,7 @@ lCreateDispatchFunction(llvm::Module *module, llvm::Function *setISAFunc, // we'll start by generating an 'extern' declaration of each one that // we have in the current module so that we can then call out to that. llvm::Function *targetFuncs[Target::NUM_ISAS]; - LLVM_TYPE_CONST llvm::FunctionType *ftype = NULL; + llvm::FunctionType *ftype = NULL; for (int i = 0; i < Target::NUM_ISAS; ++i) { if (funcs.func[i] == NULL) { diff --git a/opt.cpp b/opt.cpp index a16d4bad..6630331a 100644 --- a/opt.cpp +++ b/opt.cpp @@ -984,7 +984,7 @@ static llvm::Value * lCheckForActualPointer(llvm::Value *v) { if (v == NULL) return NULL; - else if (llvm::isa(v->getType())) + else if (llvm::isa(v->getType())) return v; else if (llvm::isa(v)) return v; @@ -1908,8 +1908,8 @@ MaskedStoreOptPass::runOnBasicBlock(llvm::BasicBlock &bb) { } else if (maskAsInt == allOnMask) { // The mask is all on, so turn this into a regular store - LLVM_TYPE_CONST llvm::Type *rvalueType = rvalue->getType(); - LLVM_TYPE_CONST llvm::Type *ptrType = + llvm::Type *rvalueType = rvalue->getType(); + llvm::Type *ptrType = llvm::PointerType::get(rvalueType, 0); lvalue = new llvm::BitCastInst(lvalue, ptrType, "lvalue_to_ptr_type", callInst); @@ -2011,7 +2011,7 @@ MaskedLoadOptPass::runOnBasicBlock(llvm::BasicBlock &bb) { } else if (maskAsInt == allOnMask) { // The mask is all on, so turn this into a regular load - LLVM_TYPE_CONST llvm::Type *ptrType = + llvm::Type *ptrType = llvm::PointerType::get(callInst->getType(), 0); ptr = new llvm::BitCastInst(ptr, ptrType, "ptr_cast_for_load", callInst); @@ -2069,17 +2069,17 @@ lIsSafeToBlend(llvm::Value *lvalue) { else { llvm::AllocaInst *ai = llvm::dyn_cast(lvalue); if (ai) { - LLVM_TYPE_CONST llvm::Type *type = ai->getType(); - LLVM_TYPE_CONST llvm::PointerType *pt = - llvm::dyn_cast(type); + llvm::Type *type = ai->getType(); + llvm::PointerType *pt = + llvm::dyn_cast(type); assert(pt != NULL); type = pt->getElementType(); - LLVM_TYPE_CONST llvm::ArrayType *at; - while ((at = llvm::dyn_cast(type))) { + llvm::ArrayType *at; + while ((at = llvm::dyn_cast(type))) { type = at->getElementType(); } - LLVM_TYPE_CONST llvm::VectorType *vt = - llvm::dyn_cast(type); + llvm::VectorType *vt = + llvm::dyn_cast(type); return (vt != NULL && (int)vt->getNumElements() == g->target.vectorWidth); } @@ -2232,7 +2232,7 @@ lComputeCommonPointer(llvm::Value *base, llvm::Value *offsets, struct ScatterImpInfo { ScatterImpInfo(const char *pName, const char *msName, - LLVM_TYPE_CONST llvm::Type *vpt, int a) + llvm::Type *vpt, int a) : align(a) { pseudoFunc = m->module->getFunction(pName); maskedStoreFunc = m->module->getFunction(msName); @@ -2241,7 +2241,7 @@ struct ScatterImpInfo { } llvm::Function *pseudoFunc; llvm::Function *maskedStoreFunc; - LLVM_TYPE_CONST llvm::Type *vecPtrType; + llvm::Type *vecPtrType; const int align; }; @@ -2742,7 +2742,7 @@ lCoalescePerfInfo(const std::vector &coalesceGroup, */ llvm::Value * lGEPAndLoad(llvm::Value *basePtr, int64_t offset, int align, - llvm::Instruction *insertBefore, LLVM_TYPE_CONST llvm::Type *type) { + llvm::Instruction *insertBefore, llvm::Type *type) { llvm::Value *ptr = lGEPInst(basePtr, LLVMInt64(offset), "new_base", insertBefore); ptr = new llvm::BitCastInst(ptr, llvm::PointerType::get(type, 0), @@ -2796,7 +2796,7 @@ lEmitLoads(llvm::Value *basePtr, std::vector &loadOps, } case 4: { // 4-wide vector load - LLVM_TYPE_CONST llvm::VectorType *vt = + llvm::VectorType *vt = llvm::VectorType::get(LLVMTypes::Int32Type, 4); loadOps[i].load = lGEPAndLoad(basePtr, start, align, insertBefore, vt); @@ -2804,7 +2804,7 @@ lEmitLoads(llvm::Value *basePtr, std::vector &loadOps, } case 8: { // 8-wide vector load - LLVM_TYPE_CONST llvm::VectorType *vt = + llvm::VectorType *vt = llvm::VectorType::get(LLVMTypes::Int32Type, 8); loadOps[i].load = lGEPAndLoad(basePtr, start, align, insertBefore, vt); @@ -2896,7 +2896,7 @@ lApplyLoad2(llvm::Value *result, const CoalescedLoadOp &load, Assert(set[elt] == false && set[elt+1] == false); // In this case, we bitcast from a 4xi32 to a 2xi64 vector - LLVM_TYPE_CONST llvm::Type *vec2x64Type = + llvm::Type *vec2x64Type = llvm::VectorType::get(LLVMTypes::Int64Type, 2); result = new llvm::BitCastInst(result, vec2x64Type, "to2x64", insertBefore); @@ -2908,7 +2908,7 @@ lApplyLoad2(llvm::Value *result, const CoalescedLoadOp &load, "insert64", insertBefore); // And back to 4xi32. - LLVM_TYPE_CONST llvm::Type *vec4x32Type = + llvm::Type *vec4x32Type = llvm::VectorType::get(LLVMTypes::Int32Type, 4); result = new llvm::BitCastInst(result, vec4x32Type, "to4x32", insertBefore); @@ -2988,7 +2988,7 @@ lApplyLoad4(llvm::Value *result, const CoalescedLoadOp &load, static llvm::Value * lAssemble4Vector(const std::vector &loadOps, const int64_t offsets[4], llvm::Instruction *insertBefore) { - LLVM_TYPE_CONST llvm::Type *returnType = + llvm::Type *returnType = llvm::VectorType::get(LLVMTypes::Int32Type, 4); llvm::Value *result = llvm::UndefValue::get(returnType); @@ -3128,7 +3128,7 @@ lApplyLoad12s(llvm::Value *result, const std::vector &loadOps, static llvm::Value * lAssemble4Vector(const std::vector &loadOps, const int64_t offsets[4], llvm::Instruction *insertBefore) { - LLVM_TYPE_CONST llvm::Type *returnType = + llvm::Type *returnType = llvm::VectorType::get(LLVMTypes::Int32Type, 4); llvm::Value *result = llvm::UndefValue::get(returnType); diff --git a/stmt.cpp b/stmt.cpp index 53a451ae..4f8c0f12 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -189,7 +189,7 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const { } } - LLVM_TYPE_CONST llvm::Type *llvmType = sym->type->LLVMType(g->ctx); + llvm::Type *llvmType = sym->type->LLVMType(g->ctx); if (llvmType == NULL) { Assert(m->errorCount > 0); return; @@ -2497,7 +2497,7 @@ lProcessPrintArg(Expr *expr, FunctionEmitContext *ctx, std::string &argTypes) { else { argTypes.push_back(t); - LLVM_TYPE_CONST llvm::Type *llvmExprType = type->LLVMType(g->ctx); + llvm::Type *llvmExprType = type->LLVMType(g->ctx); llvm::Value *ptr = ctx->AllocaInst(llvmExprType, "print_arg"); llvm::Value *val = expr->GetValue(ctx); if (!val) @@ -2537,7 +2537,7 @@ PrintStmt::EmitCode(FunctionEmitContext *ctx) const { std::string argTypes; if (values == NULL) { - LLVM_TYPE_CONST llvm::Type *ptrPtrType = + llvm::Type *ptrPtrType = llvm::PointerType::get(LLVMTypes::VoidPointerType, 0); args[4] = llvm::Constant::getNullValue(ptrPtrType); } @@ -2549,7 +2549,7 @@ PrintStmt::EmitCode(FunctionEmitContext *ctx) const { int nArgs = elist ? elist->exprs.size() : 1; // Allocate space for the array of pointers to values to be printed - LLVM_TYPE_CONST llvm::Type *argPtrArrayType = + llvm::Type *argPtrArrayType = llvm::ArrayType::get(LLVMTypes::VoidPointerType, nArgs); llvm::Value *argPtrArray = ctx->AllocaInst(argPtrArrayType, "print_arg_ptrs"); diff --git a/type.cpp b/type.cpp index 1a433c1f..0e4ecfe1 100644 --- a/type.cpp +++ b/type.cpp @@ -414,7 +414,7 @@ AtomicType::GetCDeclaration(const std::string &name) const { } -LLVM_TYPE_CONST llvm::Type * +llvm::Type * AtomicType::LLVMType(llvm::LLVMContext *ctx) const { Assert(variability.type != Variability::Unbound); bool isUniform = (variability == Variability::Uniform); @@ -725,7 +725,7 @@ EnumType::GetCDeclaration(const std::string &varName) const { } -LLVM_TYPE_CONST llvm::Type * +llvm::Type * EnumType::LLVMType(llvm::LLVMContext *ctx) const { Assert(variability != Variability::Unbound); @@ -1083,7 +1083,7 @@ PointerType::GetCDeclaration(const std::string &name) const { } -LLVM_TYPE_CONST llvm::Type * +llvm::Type * PointerType::LLVMType(llvm::LLVMContext *ctx) const { if (baseType == NULL) { Assert(m->errorCount > 0); @@ -1098,7 +1098,7 @@ PointerType::LLVMType(llvm::LLVMContext *ctx) const { switch (variability.type) { case Variability::Uniform: { - LLVM_TYPE_CONST llvm::Type *ptype = NULL; + llvm::Type *ptype = NULL; const FunctionType *ftype = dynamic_cast(baseType); if (ftype != NULL) // Get the type of the function variant that takes the mask as the @@ -1178,14 +1178,14 @@ ArrayType::ArrayType(const Type *c, int a) } -LLVM_TYPE_CONST llvm::ArrayType * +llvm::ArrayType * ArrayType::LLVMType(llvm::LLVMContext *ctx) const { if (child == NULL) { Assert(m->errorCount > 0); return NULL; } - LLVM_TYPE_CONST llvm::Type *ct = child->LLVMType(ctx); + llvm::Type *ct = child->LLVMType(ctx); if (ct == NULL) { Assert(m->errorCount > 0); return NULL; @@ -1630,14 +1630,14 @@ VectorType::GetElementType() const { } -LLVM_TYPE_CONST llvm::Type * +llvm::Type * VectorType::LLVMType(llvm::LLVMContext *ctx) const { if (base == NULL) { Assert(m->errorCount > 0); return NULL; } - LLVM_TYPE_CONST llvm::Type *bt = base->LLVMType(ctx); + llvm::Type *bt = base->LLVMType(ctx); if (!bt) return NULL; @@ -1912,9 +1912,9 @@ StructType::GetCDeclaration(const std::string &n) const { } -LLVM_TYPE_CONST llvm::Type * +llvm::Type * StructType::LLVMType(llvm::LLVMContext *ctx) const { - std::vector llvmTypes; + std::vector llvmTypes; for (int i = 0; i < GetElementCount(); ++i) { const Type *type = GetElementType(i); if (type == NULL) @@ -2257,14 +2257,14 @@ ReferenceType::GetCDeclaration(const std::string &name) const { } -LLVM_TYPE_CONST llvm::Type * +llvm::Type * ReferenceType::LLVMType(llvm::LLVMContext *ctx) const { if (targetType == NULL) { Assert(m->errorCount > 0); return NULL; } - LLVM_TYPE_CONST llvm::Type *t = targetType->LLVMType(ctx); + llvm::Type *t = targetType->LLVMType(ctx); if (t == NULL) { Assert(m->errorCount > 0); return NULL; @@ -2489,7 +2489,7 @@ FunctionType::GetCDeclaration(const std::string &fname) const { } -LLVM_TYPE_CONST llvm::Type * +llvm::Type * FunctionType::LLVMType(llvm::LLVMContext *ctx) const { FATAL("FunctionType::LLVMType() shouldn't be called"); return NULL; @@ -2540,13 +2540,13 @@ FunctionType::GetReturnTypeString() const { } -LLVM_TYPE_CONST llvm::FunctionType * +llvm::FunctionType * FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const { if (isTask == true) Assert(includeMask == true); // Get the LLVM Type *s for the function arguments - std::vector llvmArgTypes; + std::vector llvmArgTypes; for (unsigned int i = 0; i < paramTypes.size(); ++i) { if (paramTypes[i] == NULL) { Assert(m->errorCount > 0); @@ -2554,7 +2554,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const { } Assert(Type::Equal(paramTypes[i], AtomicType::Void) == false); - LLVM_TYPE_CONST llvm::Type *t = paramTypes[i]->LLVMType(ctx); + llvm::Type *t = paramTypes[i]->LLVMType(ctx); if (t == NULL) { Assert(m->errorCount > 0); return NULL; @@ -2566,7 +2566,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const { if (includeMask) llvmArgTypes.push_back(LLVMTypes::MaskType); - std::vector callTypes; + std::vector callTypes; if (isTask) { // Tasks take three arguments: a pointer to a struct that holds the // actual task arguments, the thread index, and the total number of diff --git a/type.h b/type.h index fdcc41e6..f81ea062 100644 --- a/type.h +++ b/type.h @@ -187,7 +187,7 @@ public: virtual std::string GetCDeclaration(const std::string &name) const = 0; /** Returns the LLVM type corresponding to this ispc type */ - virtual LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0; + virtual llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0; /** Returns the DIType (LLVM's debugging information structure), corresponding to this type. */ @@ -269,7 +269,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; /** This enumerator records the basic types that AtomicTypes can be @@ -343,7 +343,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; /** Provides the enumerators defined in the enum definition. */ @@ -425,7 +425,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; static PointerType *Void; @@ -523,7 +523,7 @@ public: std::string GetCDeclaration(const std::string &name) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; - LLVM_TYPE_CONST llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const; + llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const; /** This method returns the total number of elements in the array, including all dimensions if this is a multidimensional array. */ @@ -589,7 +589,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; int GetElementCount() const; @@ -639,7 +639,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; /** Returns the type of the structure element with the given name (if any). @@ -719,7 +719,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &name) const; - LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; private: @@ -771,7 +771,7 @@ public: std::string Mangle() const; std::string GetCDeclaration(const std::string &fname) const; - LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; + llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const; const Type *GetReturnType() const { return returnType; } @@ -782,7 +782,7 @@ public: function type. The \c includeMask parameter indicates whether the llvm::FunctionType should have a mask as the last argument in its function signature. */ - LLVM_TYPE_CONST llvm::FunctionType *LLVMFunctionType(llvm::LLVMContext *ctx, + llvm::FunctionType *LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask = false) const; int GetNumParameters() const { return (int)paramTypes.size(); }