simplify a bunch of code to use the well-known LLVM IR types computed by CodeGenModule.
llvm-svn: 149943
This commit is contained in:
parent
8573dc7e1f
commit
ece0409a1a
|
@ -1851,7 +1851,7 @@ llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) {
|
|||
|
||||
unsigned NumPaddingBytes = AlignedOffsetInBytes - CurrentOffsetInBytes;
|
||||
if (NumPaddingBytes > 0) {
|
||||
llvm::Type *Ty = llvm::Type::getInt8Ty(getLLVMContext());
|
||||
llvm::Type *Ty = Int8Ty;
|
||||
// FIXME: We need a sema error for alignment larger than the minimum of
|
||||
// the maximal stack alignment and the alignment of malloc on the system.
|
||||
if (NumPaddingBytes > 1)
|
||||
|
|
|
@ -1151,8 +1151,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
Value *V = Builder.CreateCall(F, Args);
|
||||
QualType BuiltinRetType = E->getType();
|
||||
|
||||
llvm::Type *RetTy = llvm::Type::getVoidTy(getLLVMContext());
|
||||
if (!BuiltinRetType->isVoidType()) RetTy = ConvertType(BuiltinRetType);
|
||||
llvm::Type *RetTy = VoidTy;
|
||||
if (!BuiltinRetType->isVoidType())
|
||||
RetTy = ConvertType(BuiltinRetType);
|
||||
|
||||
if (RetTy != V->getType()) {
|
||||
assert(V->getType()->canLosslesslyBitCastTo(RetTy) &&
|
||||
|
@ -1194,22 +1195,23 @@ Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
|
|||
}
|
||||
}
|
||||
|
||||
static llvm::VectorType *GetNeonType(LLVMContext &C, NeonTypeFlags TypeFlags) {
|
||||
static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
|
||||
NeonTypeFlags TypeFlags) {
|
||||
int IsQuad = TypeFlags.isQuad();
|
||||
switch (TypeFlags.getEltType()) {
|
||||
case NeonTypeFlags::Int8:
|
||||
case NeonTypeFlags::Poly8:
|
||||
return llvm::VectorType::get(llvm::Type::getInt8Ty(C), 8 << IsQuad);
|
||||
return llvm::VectorType::get(CGF->Int8Ty, 8 << IsQuad);
|
||||
case NeonTypeFlags::Int16:
|
||||
case NeonTypeFlags::Poly16:
|
||||
case NeonTypeFlags::Float16:
|
||||
return llvm::VectorType::get(llvm::Type::getInt16Ty(C), 4 << IsQuad);
|
||||
return llvm::VectorType::get(CGF->Int16Ty, 4 << IsQuad);
|
||||
case NeonTypeFlags::Int32:
|
||||
return llvm::VectorType::get(llvm::Type::getInt32Ty(C), 2 << IsQuad);
|
||||
return llvm::VectorType::get(CGF->Int32Ty, 2 << IsQuad);
|
||||
case NeonTypeFlags::Int64:
|
||||
return llvm::VectorType::get(llvm::Type::getInt64Ty(C), 1 << IsQuad);
|
||||
return llvm::VectorType::get(CGF->Int64Ty, 1 << IsQuad);
|
||||
case NeonTypeFlags::Float32:
|
||||
return llvm::VectorType::get(llvm::Type::getFloatTy(C), 2 << IsQuad);
|
||||
return llvm::VectorType::get(CGF->FloatTy, 2 << IsQuad);
|
||||
}
|
||||
llvm_unreachable("Invalid NeonTypeFlags element type!");
|
||||
}
|
||||
|
@ -1359,9 +1361,9 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
|
|||
// Determine the overloaded type of this builtin.
|
||||
llvm::Type *Ty;
|
||||
if (BuiltinID == ARM::BI__builtin_arm_vcvtr_f)
|
||||
Ty = llvm::Type::getFloatTy(getLLVMContext());
|
||||
Ty = FloatTy;
|
||||
else
|
||||
Ty = llvm::Type::getDoubleTy(getLLVMContext());
|
||||
Ty = DoubleTy;
|
||||
|
||||
// Determine whether this is an unsigned conversion or not.
|
||||
bool usgn = Result.getZExtValue() == 1;
|
||||
|
@ -1378,7 +1380,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
|
|||
bool quad = Type.isQuad();
|
||||
bool rightShift = false;
|
||||
|
||||
llvm::VectorType *VTy = GetNeonType(getLLVMContext(), Type);
|
||||
llvm::VectorType *VTy = GetNeonType(this, Type);
|
||||
llvm::Type *Ty = VTy;
|
||||
if (!Ty)
|
||||
return 0;
|
||||
|
@ -1451,8 +1453,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
|
|||
case ARM::BI__builtin_neon_vcvt_f32_v:
|
||||
case ARM::BI__builtin_neon_vcvtq_f32_v:
|
||||
Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
|
||||
Ty = GetNeonType(getLLVMContext(),
|
||||
NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
return usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
|
||||
: Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
|
||||
case ARM::BI__builtin_neon_vcvt_s32_v:
|
||||
|
@ -1460,8 +1461,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
|
|||
case ARM::BI__builtin_neon_vcvtq_s32_v:
|
||||
case ARM::BI__builtin_neon_vcvtq_u32_v: {
|
||||
llvm::Type *FloatTy =
|
||||
GetNeonType(getLLVMContext(),
|
||||
NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
Ops[0] = Builder.CreateBitCast(Ops[0], FloatTy);
|
||||
return usgn ? Builder.CreateFPToUI(Ops[0], Ty, "vcvt")
|
||||
: Builder.CreateFPToSI(Ops[0], Ty, "vcvt");
|
||||
|
@ -1469,8 +1469,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
|
|||
case ARM::BI__builtin_neon_vcvt_n_f32_v:
|
||||
case ARM::BI__builtin_neon_vcvtq_n_f32_v: {
|
||||
llvm::Type *FloatTy =
|
||||
GetNeonType(getLLVMContext(),
|
||||
NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
llvm::Type *Tys[2] = { FloatTy, Ty };
|
||||
Int = usgn ? Intrinsic::arm_neon_vcvtfxu2fp
|
||||
: Intrinsic::arm_neon_vcvtfxs2fp;
|
||||
|
@ -1482,8 +1481,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
|
|||
case ARM::BI__builtin_neon_vcvtq_n_s32_v:
|
||||
case ARM::BI__builtin_neon_vcvtq_n_u32_v: {
|
||||
llvm::Type *FloatTy =
|
||||
GetNeonType(getLLVMContext(),
|
||||
NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, quad));
|
||||
llvm::Type *Tys[2] = { Ty, FloatTy };
|
||||
Int = usgn ? Intrinsic::arm_neon_vcvtfp2fxu
|
||||
: Intrinsic::arm_neon_vcvtfp2fxs;
|
||||
|
|
|
@ -95,7 +95,6 @@ CodeGenFunction::GetAddressOfDirectBaseInCompleteClass(llvm::Value *This,
|
|||
// TODO: for complete types, this should be possible with a GEP.
|
||||
llvm::Value *V = This;
|
||||
if (Offset.isPositive()) {
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(getLLVMContext());
|
||||
V = Builder.CreateBitCast(V, Int8PtrTy);
|
||||
V = Builder.CreateConstInBoundsGEP1_64(V, Offset.getQuantity());
|
||||
}
|
||||
|
@ -125,8 +124,7 @@ ApplyNonVirtualAndVirtualOffset(CodeGenFunction &CGF, llvm::Value *ThisPtr,
|
|||
BaseOffset = NonVirtualOffset;
|
||||
|
||||
// Apply the base offset.
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
ThisPtr = CGF.Builder.CreateBitCast(ThisPtr, Int8PtrTy);
|
||||
ThisPtr = CGF.Builder.CreateBitCast(ThisPtr, CGF.Int8PtrTy);
|
||||
ThisPtr = CGF.Builder.CreateGEP(ThisPtr, BaseOffset, "add.ptr");
|
||||
|
||||
return ThisPtr;
|
||||
|
|
|
@ -2141,7 +2141,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
|
|||
if (VD->hasAttr<BlocksAttr>()) {
|
||||
CharUnits offset = CharUnits::fromQuantity(32);
|
||||
SmallVector<llvm::Value *, 9> addr;
|
||||
llvm::Type *Int64Ty = llvm::Type::getInt64Ty(CGM.getLLVMContext());
|
||||
llvm::Type *Int64Ty = CGM.Int64Ty;
|
||||
addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpPlus));
|
||||
// offset of __forwarding field
|
||||
offset = CGM.getContext().toCharUnitsFromBits(
|
||||
|
@ -2246,7 +2246,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
|
|||
->getElementOffset(blockInfo.getCapture(VD).getIndex()));
|
||||
|
||||
SmallVector<llvm::Value *, 9> addr;
|
||||
llvm::Type *Int64Ty = llvm::Type::getInt64Ty(CGM.getLLVMContext());
|
||||
llvm::Type *Int64Ty = CGM.Int64Ty;
|
||||
addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpPlus));
|
||||
addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity()));
|
||||
if (isByRef) {
|
||||
|
|
|
@ -128,9 +128,7 @@ CodeGenFunction::EmitCXXGlobalDtorRegistration(llvm::Constant *DtorFn,
|
|||
}
|
||||
|
||||
// Get the destructor function type
|
||||
llvm::Type *DtorFnTy =
|
||||
llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()),
|
||||
Int8PtrTy, false);
|
||||
llvm::Type *DtorFnTy = llvm::FunctionType::get(VoidTy, Int8PtrTy, false);
|
||||
DtorFnTy = llvm::PointerType::getUnqual(DtorFnTy);
|
||||
|
||||
llvm::Type *Params[] = { DtorFnTy, Int8PtrTy, Int8PtrTy };
|
||||
|
@ -189,9 +187,7 @@ CreateGlobalInitOrDestructFunction(CodeGenModule &CGM,
|
|||
void
|
||||
CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
|
||||
llvm::GlobalVariable *Addr) {
|
||||
llvm::FunctionType *FTy
|
||||
= llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext),
|
||||
false);
|
||||
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
|
||||
|
||||
// Create a variable initialization function.
|
||||
llvm::Function *Fn =
|
||||
|
@ -226,9 +222,7 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
|
|||
if (CXXGlobalInits.empty() && PrioritizedCXXGlobalInits.empty())
|
||||
return;
|
||||
|
||||
llvm::FunctionType *FTy
|
||||
= llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext),
|
||||
false);
|
||||
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
|
||||
|
||||
// Create our global initialization function.
|
||||
llvm::Function *Fn =
|
||||
|
@ -260,9 +254,7 @@ void CodeGenModule::EmitCXXGlobalDtorFunc() {
|
|||
if (CXXGlobalDtors.empty())
|
||||
return;
|
||||
|
||||
llvm::FunctionType *FTy
|
||||
= llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext),
|
||||
false);
|
||||
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
|
||||
|
||||
// Create our global destructor function.
|
||||
llvm::Function *Fn =
|
||||
|
|
|
@ -211,9 +211,7 @@ const EHPersonality &EHPersonality::get(const LangOptions &L) {
|
|||
static llvm::Constant *getPersonalityFn(CodeGenModule &CGM,
|
||||
const EHPersonality &Personality) {
|
||||
llvm::Constant *Fn =
|
||||
CGM.CreateRuntimeFunction(llvm::FunctionType::get(
|
||||
llvm::Type::getInt32Ty(CGM.getLLVMContext()),
|
||||
true),
|
||||
CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty, true),
|
||||
Personality.getPersonalityFnName());
|
||||
return Fn;
|
||||
}
|
||||
|
|
|
@ -881,8 +881,7 @@ RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV) {
|
|||
}
|
||||
|
||||
// Cast to the access type.
|
||||
llvm::Type *PTy = llvm::Type::getIntNPtrTy(getLLVMContext(),
|
||||
AI.AccessWidth,
|
||||
llvm::Type *PTy = llvm::Type::getIntNPtrTy(getLLVMContext(), AI.AccessWidth,
|
||||
CGM.getContext().getTargetAddressSpace(LV.getType()));
|
||||
Ptr = Builder.CreateBitCast(Ptr, PTy);
|
||||
|
||||
|
|
|
@ -1014,9 +1014,8 @@ static void CheckAggExprForMemSetUse(AggValueSlot &Slot, const Expr *E,
|
|||
CharUnits Align = TypeInfo.second;
|
||||
|
||||
llvm::Value *Loc = Slot.getAddr();
|
||||
llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
|
||||
Loc = CGF.Builder.CreateBitCast(Loc, BP);
|
||||
Loc = CGF.Builder.CreateBitCast(Loc, CGF.Int8PtrTy);
|
||||
CGF.Builder.CreateMemSet(Loc, CGF.Builder.getInt8(0), SizeVal,
|
||||
Align.getQuantity(), false);
|
||||
|
||||
|
|
|
@ -1523,10 +1523,7 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
|
|||
|
||||
static llvm::Constant *getBadTypeidFn(CodeGenFunction &CGF) {
|
||||
// void __cxa_bad_typeid();
|
||||
|
||||
llvm::Type *VoidTy = llvm::Type::getVoidTy(CGF.getLLVMContext());
|
||||
llvm::FunctionType *FTy =
|
||||
llvm::FunctionType::get(VoidTy, false);
|
||||
llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.VoidTy, false);
|
||||
|
||||
return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_bad_typeid");
|
||||
}
|
||||
|
@ -1607,7 +1604,7 @@ static llvm::Constant *getDynamicCastFn(CodeGenFunction &CGF) {
|
|||
// const abi::__class_type_info *dst,
|
||||
// std::ptrdiff_t src2dst_offset);
|
||||
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
llvm::Type *Int8PtrTy = CGF.Int8PtrTy;
|
||||
llvm::Type *PtrDiffTy =
|
||||
CGF.ConvertType(CGF.getContext().getPointerDiffType());
|
||||
|
||||
|
@ -1621,11 +1618,7 @@ static llvm::Constant *getDynamicCastFn(CodeGenFunction &CGF) {
|
|||
|
||||
static llvm::Constant *getBadCastFn(CodeGenFunction &CGF) {
|
||||
// void __cxa_bad_cast();
|
||||
|
||||
llvm::Type *VoidTy = llvm::Type::getVoidTy(CGF.getLLVMContext());
|
||||
llvm::FunctionType *FTy =
|
||||
llvm::FunctionType::get(VoidTy, false);
|
||||
|
||||
llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.VoidTy, false);
|
||||
return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_bad_cast");
|
||||
}
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ void ConstStructBuilder::AppendPadding(CharUnits PadSize) {
|
|||
if (PadSize.isZero())
|
||||
return;
|
||||
|
||||
llvm::Type *Ty = llvm::Type::getInt8Ty(CGM.getLLVMContext());
|
||||
llvm::Type *Ty = CGM.Int8Ty;
|
||||
if (PadSize > CharUnits::One())
|
||||
Ty = llvm::ArrayType::get(Ty, PadSize.getQuantity());
|
||||
|
||||
|
@ -317,7 +317,7 @@ void ConstStructBuilder::ConvertStructToPacked() {
|
|||
CharUnits NumChars =
|
||||
AlignedElementOffsetInChars - ElementOffsetInChars;
|
||||
|
||||
llvm::Type *Ty = llvm::Type::getInt8Ty(CGM.getLLVMContext());
|
||||
llvm::Type *Ty = CGM.Int8Ty;
|
||||
if (NumChars > CharUnits::One())
|
||||
Ty = llvm::ArrayType::get(Ty, NumChars.getQuantity());
|
||||
|
||||
|
@ -599,7 +599,7 @@ public:
|
|||
|
||||
assert(CurSize <= TotalSize && "Union size mismatch!");
|
||||
if (unsigned NumPadBytes = TotalSize - CurSize) {
|
||||
llvm::Type *Ty = llvm::Type::getInt8Ty(VMContext);
|
||||
llvm::Type *Ty = CGM.Int8Ty;
|
||||
if (NumPadBytes > 1)
|
||||
Ty = llvm::ArrayType::get(Ty, NumPadBytes);
|
||||
|
||||
|
@ -982,8 +982,7 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value,
|
|||
case APValue::LValue: {
|
||||
llvm::Type *DestTy = getTypes().ConvertTypeForMem(DestType);
|
||||
llvm::Constant *Offset =
|
||||
llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext),
|
||||
Value.getLValueOffset().getQuantity());
|
||||
llvm::ConstantInt::get(Int64Ty, Value.getLValueOffset().getQuantity());
|
||||
|
||||
llvm::Constant *C;
|
||||
if (APValue::LValueBase LVBase = Value.getLValueBase()) {
|
||||
|
@ -998,8 +997,7 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value,
|
|||
|
||||
// Apply offset if necessary.
|
||||
if (!Offset->isNullValue()) {
|
||||
llvm::Type *Type = llvm::Type::getInt8PtrTy(VMContext);
|
||||
llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Type);
|
||||
llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Int8PtrTy);
|
||||
Casted = llvm::ConstantExpr::getGetElementPtr(Casted, Offset);
|
||||
C = llvm::ConstantExpr::getBitCast(Casted, C->getType());
|
||||
}
|
||||
|
@ -1242,8 +1240,7 @@ FillInNullDataMemberPointers(CodeGenModule &CGM, QualType T,
|
|||
|
||||
// FIXME: hardcodes Itanium member pointer representation!
|
||||
llvm::Constant *NegativeOne =
|
||||
llvm::ConstantInt::get(llvm::Type::getInt8Ty(CGM.getLLVMContext()),
|
||||
-1ULL, /*isSigned*/true);
|
||||
llvm::ConstantInt::get(CGM.Int8Ty, -1ULL, /*isSigned*/true);
|
||||
|
||||
// Fill in the null data member pointer.
|
||||
for (CharUnits I = StartIndex; I != EndIndex; ++I)
|
||||
|
@ -1362,8 +1359,7 @@ static llvm::Constant *EmitNullConstantForBase(CodeGenModule &CGM,
|
|||
|
||||
// Now go through all other elements and zero them out.
|
||||
if (numBaseElements) {
|
||||
llvm::Type *i8 = llvm::Type::getInt8Ty(CGM.getLLVMContext());
|
||||
llvm::Constant *i8_zero = llvm::Constant::getNullValue(i8);
|
||||
llvm::Constant *i8_zero = llvm::Constant::getNullValue(CGM.Int8Ty);
|
||||
for (unsigned i = 0; i != numBaseElements; ++i) {
|
||||
if (!baseElements[i])
|
||||
baseElements[i] = i8_zero;
|
||||
|
|
|
@ -560,7 +560,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
|
|||
if (SrcType->isHalfType()) {
|
||||
Src = Builder.CreateCall(CGF.CGM.getIntrinsic(llvm::Intrinsic::convert_from_fp16), Src);
|
||||
SrcType = CGF.getContext().FloatTy;
|
||||
SrcTy = llvm::Type::getFloatTy(VMContext);
|
||||
SrcTy = CGF.FloatTy;
|
||||
}
|
||||
|
||||
// Handle conversions to bool first, they are special: comparisons against 0.
|
||||
|
@ -628,7 +628,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
|
|||
|
||||
// Cast to half via float
|
||||
if (DstType->isHalfType())
|
||||
DstTy = llvm::Type::getFloatTy(VMContext);
|
||||
DstTy = CGF.FloatTy;
|
||||
|
||||
if (isa<llvm::IntegerType>(SrcTy)) {
|
||||
bool InputSigned = SrcType->isSignedIntegerOrEnumerationType();
|
||||
|
@ -1898,7 +1898,7 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
|
|||
Builder.SetInsertPoint(overflowBB);
|
||||
|
||||
// Get the overflow handler.
|
||||
llvm::Type *Int8Ty = llvm::Type::getInt8Ty(VMContext);
|
||||
llvm::Type *Int8Ty = CGF.Int8Ty;
|
||||
llvm::Type *argTypes[] = { CGF.Int64Ty, CGF.Int64Ty, Int8Ty, Int8Ty };
|
||||
llvm::FunctionType *handlerTy =
|
||||
llvm::FunctionType::get(CGF.Int64Ty, argTypes, true);
|
||||
|
@ -2726,8 +2726,7 @@ Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {
|
|||
Args.push_back(Builder.getInt32(2));
|
||||
|
||||
if (numElementsDst == 4)
|
||||
Args.push_back(llvm::UndefValue::get(
|
||||
llvm::Type::getInt32Ty(CGF.getLLVMContext())));
|
||||
Args.push_back(llvm::UndefValue::get(CGF.Int32Ty));
|
||||
|
||||
llvm::Constant *Mask = llvm::ConstantVector::get(Args);
|
||||
|
||||
|
|
|
@ -1696,8 +1696,7 @@ CodeGenFunction::EmitARCRetainAutoreleasedReturnValue(llvm::Value *value) {
|
|||
// in a moment.
|
||||
} else if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
|
||||
llvm::FunctionType *type =
|
||||
llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()),
|
||||
/*variadic*/ false);
|
||||
llvm::FunctionType::get(VoidTy, /*variadic*/false);
|
||||
|
||||
marker = llvm::InlineAsm::get(type, assembly, "", /*sideeffects*/ true);
|
||||
|
||||
|
|
|
@ -92,9 +92,8 @@ private:
|
|||
/// would be unbalanced.
|
||||
llvm::Constant *getMessageSendFpretFn() const {
|
||||
llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };
|
||||
return CGM.CreateRuntimeFunction(llvm::FunctionType::get(
|
||||
llvm::Type::getDoubleTy(VMContext),
|
||||
params, true),
|
||||
return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.DoubleTy,
|
||||
params, true),
|
||||
"objc_msgSend_fpret");
|
||||
|
||||
}
|
||||
|
@ -1744,8 +1743,7 @@ static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT) {
|
|||
|
||||
llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM,
|
||||
const CGBlockInfo &blockInfo) {
|
||||
llvm::Constant *nullPtr =
|
||||
llvm::Constant::getNullValue(llvm::Type::getInt8PtrTy(VMContext));
|
||||
llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy);
|
||||
|
||||
if (CGM.getLangOptions().getGC() == LangOptions::NonGC &&
|
||||
!CGM.getLangOptions().ObjCAutoRefCount)
|
||||
|
@ -3922,7 +3920,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
|
|||
/// filled already by the caller.
|
||||
llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string &BitMap) {
|
||||
unsigned int WordsToScan, WordsToSkip;
|
||||
llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
llvm::Type *PtrTy = CGM.Int8PtrTy;
|
||||
|
||||
// Build the string of skip/scan nibbles
|
||||
SmallVector<SKIP_SCAN, 32> SkipScanIvars;
|
||||
|
@ -4066,7 +4064,7 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout(
|
|||
bool ForStrongLayout) {
|
||||
bool hasUnion = false;
|
||||
|
||||
llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
llvm::Type *PtrTy = CGM.Int8PtrTy;
|
||||
if (CGM.getLangOptions().getGC() == LangOptions::NonGC &&
|
||||
!CGM.getLangOptions().ObjCAutoRefCount)
|
||||
return llvm::Constant::getNullValue(PtrTy);
|
||||
|
@ -4286,8 +4284,8 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
|
|||
IntTy = Types.ConvertType(Ctx.IntTy);
|
||||
LongTy = Types.ConvertType(Ctx.LongTy);
|
||||
LongLongTy = Types.ConvertType(Ctx.LongLongTy);
|
||||
Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Int8PtrPtrTy = llvm::PointerType::getUnqual(Int8PtrTy);
|
||||
Int8PtrTy = CGM.Int8PtrTy;
|
||||
Int8PtrPtrTy = CGM.Int8PtrPtrTy;
|
||||
|
||||
ObjectPtrTy = Types.ConvertType(Ctx.getObjCIdType());
|
||||
PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy);
|
||||
|
@ -4528,14 +4526,12 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
|||
uint64_t SetJmpBufferSize = 18;
|
||||
|
||||
// Exceptions
|
||||
llvm::Type *StackPtrTy = llvm::ArrayType::get(
|
||||
llvm::Type::getInt8PtrTy(VMContext), 4);
|
||||
llvm::Type *StackPtrTy = llvm::ArrayType::get(CGM.Int8PtrTy, 4);
|
||||
|
||||
ExceptionDataTy =
|
||||
llvm::StructType::create("struct._objc_exception_data",
|
||||
llvm::ArrayType::get(llvm::Type::getInt32Ty(VMContext),
|
||||
SetJmpBufferSize),
|
||||
StackPtrTy, NULL);
|
||||
llvm::ArrayType::get(CGM.Int32Ty,SetJmpBufferSize),
|
||||
StackPtrTy, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
@ -6266,8 +6262,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
|
|||
llvm::GlobalValue::ExternalLinkage,
|
||||
0, VTableName);
|
||||
|
||||
llvm::Value *VTableIdx =
|
||||
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 2);
|
||||
llvm::Value *VTableIdx = llvm::ConstantInt::get(CGM.Int32Ty, 2);
|
||||
|
||||
llvm::Constant *Values[] = {
|
||||
llvm::ConstantExpr::getGetElementPtr(VTableGV, VTableIdx),
|
||||
|
|
|
@ -85,7 +85,7 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
|
|||
unsigned CVRQualifiers,
|
||||
llvm::Value *Offset) {
|
||||
// Compute (type*) ( (char *) BaseValue + Offset)
|
||||
llvm::Type *I8Ptr = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
llvm::Type *I8Ptr = CGF.Int8PtrTy;
|
||||
QualType IvarTy = Ivar->getType();
|
||||
llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
|
||||
llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, I8Ptr);
|
||||
|
|
|
@ -26,8 +26,6 @@ class RTTIBuilder {
|
|||
CodeGenModule &CGM; // Per-module state.
|
||||
llvm::LLVMContext &VMContext;
|
||||
|
||||
llvm::Type *Int8PtrTy;
|
||||
|
||||
/// Fields - The fields of the RTTI descriptor currently being built.
|
||||
SmallVector<llvm::Constant *, 16> Fields;
|
||||
|
||||
|
@ -65,8 +63,7 @@ class RTTIBuilder {
|
|||
|
||||
public:
|
||||
RTTIBuilder(CodeGenModule &CGM) : CGM(CGM),
|
||||
VMContext(CGM.getModule().getContext()),
|
||||
Int8PtrTy(llvm::Type::getInt8PtrTy(VMContext)) { }
|
||||
VMContext(CGM.getModule().getContext()) { }
|
||||
|
||||
// Pointer type info flags.
|
||||
enum {
|
||||
|
@ -149,11 +146,12 @@ llvm::Constant *RTTIBuilder::GetAddrOfExternalRTTIDescriptor(QualType Ty) {
|
|||
|
||||
if (!GV) {
|
||||
// Create a new global variable.
|
||||
GV = new llvm::GlobalVariable(CGM.getModule(), Int8PtrTy, /*Constant=*/true,
|
||||
GV = new llvm::GlobalVariable(CGM.getModule(), CGM.Int8PtrTy,
|
||||
/*Constant=*/true,
|
||||
llvm::GlobalValue::ExternalLinkage, 0, Name);
|
||||
}
|
||||
|
||||
return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
|
||||
return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
|
||||
}
|
||||
|
||||
/// TypeInfoIsInStandardLibrary - Given a builtin type, returns whether the type
|
||||
|
@ -482,7 +480,7 @@ void RTTIBuilder::BuildVTablePointer(const Type *Ty) {
|
|||
}
|
||||
|
||||
llvm::Constant *VTable =
|
||||
CGM.getModule().getOrInsertGlobal(VTableName, Int8PtrTy);
|
||||
CGM.getModule().getOrInsertGlobal(VTableName, CGM.Int8PtrTy);
|
||||
|
||||
llvm::Type *PtrDiffTy =
|
||||
CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());
|
||||
|
@ -490,7 +488,7 @@ void RTTIBuilder::BuildVTablePointer(const Type *Ty) {
|
|||
// The vtable address point is 2.
|
||||
llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2);
|
||||
VTable = llvm::ConstantExpr::getInBoundsGetElementPtr(VTable, Two);
|
||||
VTable = llvm::ConstantExpr::getBitCast(VTable, Int8PtrTy);
|
||||
VTable = llvm::ConstantExpr::getBitCast(VTable, CGM.Int8PtrTy);
|
||||
|
||||
Fields.push_back(VTable);
|
||||
}
|
||||
|
@ -564,7 +562,7 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) {
|
|||
if (OldGV && !OldGV->isDeclaration()) {
|
||||
maybeUpdateRTTILinkage(CGM, OldGV, Ty);
|
||||
|
||||
return llvm::ConstantExpr::getBitCast(OldGV, Int8PtrTy);
|
||||
return llvm::ConstantExpr::getBitCast(OldGV, CGM.Int8PtrTy);
|
||||
}
|
||||
|
||||
// Check if there is already an external RTTI descriptor for this type.
|
||||
|
@ -585,8 +583,7 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) {
|
|||
// And the name.
|
||||
llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
|
||||
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Fields.push_back(llvm::ConstantExpr::getBitCast(TypeName, Int8PtrTy));
|
||||
Fields.push_back(llvm::ConstantExpr::getBitCast(TypeName, CGM.Int8PtrTy));
|
||||
|
||||
switch (Ty->getTypeClass()) {
|
||||
#define TYPE(Class, Base)
|
||||
|
@ -708,7 +705,7 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) {
|
|||
|
||||
GV->setUnnamedAddr(true);
|
||||
|
||||
return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
|
||||
return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
|
||||
}
|
||||
|
||||
/// ComputeQualifierFlags - Compute the pointer type info flags from the
|
||||
|
@ -985,14 +982,11 @@ llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty,
|
|||
// Return a bogus pointer if RTTI is disabled, unless it's for EH.
|
||||
// FIXME: should we even be calling this method if RTTI is disabled
|
||||
// and it's not for EH?
|
||||
if (!ForEH && !getContext().getLangOptions().RTTI) {
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
if (!ForEH && !getContext().getLangOptions().RTTI)
|
||||
return llvm::Constant::getNullValue(Int8PtrTy);
|
||||
}
|
||||
|
||||
if (ForEH && Ty->isObjCObjectPointerType() && !Features.NeXTRuntime) {
|
||||
if (ForEH && Ty->isObjCObjectPointerType() && !Features.NeXTRuntime)
|
||||
return ObjCRuntime->GetEHType(Ty);
|
||||
}
|
||||
|
||||
return RTTIBuilder(*this).BuildTypeInfo(Ty);
|
||||
}
|
||||
|
|
|
@ -1612,7 +1612,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
|
|||
|
||||
llvm::Type *ResultType;
|
||||
if (ResultRegTypes.empty())
|
||||
ResultType = llvm::Type::getVoidTy(getLLVMContext());
|
||||
ResultType = VoidTy;
|
||||
else if (ResultRegTypes.size() == 1)
|
||||
ResultType = ResultRegTypes[0];
|
||||
else
|
||||
|
|
|
@ -43,8 +43,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
|
|||
const CXXRecordDecl *RD) {
|
||||
VTTBuilder Builder(CGM.getContext(), RD, /*GenerateDefinition=*/true);
|
||||
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext()),
|
||||
*Int64Ty = llvm::Type::getInt64Ty(CGM.getLLVMContext());
|
||||
llvm::Type *Int8PtrTy = CGM.Int8PtrTy, *Int64Ty = CGM.Int64Ty;
|
||||
llvm::ArrayType *ArrayType =
|
||||
llvm::ArrayType::get(Int8PtrTy, Builder.getVTTComponents().size());
|
||||
|
||||
|
@ -111,10 +110,8 @@ llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {
|
|||
|
||||
VTTBuilder Builder(CGM.getContext(), RD, /*GenerateDefinition=*/false);
|
||||
|
||||
llvm::Type *Int8PtrTy =
|
||||
llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
|
||||
llvm::ArrayType *ArrayType =
|
||||
llvm::ArrayType::get(Int8PtrTy, Builder.getVTTComponents().size());
|
||||
llvm::ArrayType::get(CGM.Int8PtrTy, Builder.getVTTComponents().size());
|
||||
|
||||
llvm::GlobalVariable *GV =
|
||||
CGM.CreateOrReplaceCXXRuntimeVariable(Name, ArrayType,
|
||||
|
|
|
@ -83,9 +83,7 @@ static llvm::Value *PerformTypeAdjustment(CodeGenFunction &CGF,
|
|||
if (!NonVirtualAdjustment && !VirtualAdjustment)
|
||||
return Ptr;
|
||||
|
||||
llvm::Type *Int8PtrTy =
|
||||
llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
|
||||
llvm::Type *Int8PtrTy = CGF.Int8PtrTy;
|
||||
llvm::Value *V = CGF.Builder.CreateBitCast(Ptr, Int8PtrTy);
|
||||
|
||||
if (NonVirtualAdjustment) {
|
||||
|
@ -511,7 +509,7 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD,
|
|||
unsigned NumVTableThunks) {
|
||||
SmallVector<llvm::Constant *, 64> Inits;
|
||||
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
|
||||
llvm::Type *Int8PtrTy = CGM.Int8PtrTy;
|
||||
|
||||
llvm::Type *PtrDiffTy =
|
||||
CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());
|
||||
|
@ -571,8 +569,7 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD,
|
|||
// We have a pure virtual member function.
|
||||
if (!PureVirtualFn) {
|
||||
llvm::FunctionType *Ty =
|
||||
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
|
||||
/*isVarArg=*/false);
|
||||
llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
|
||||
PureVirtualFn =
|
||||
CGM.CreateRuntimeFunction(Ty, "__cxa_pure_virtual");
|
||||
PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn,
|
||||
|
@ -628,9 +625,8 @@ llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTable(const CXXRecordDecl *RD) {
|
|||
Out.flush();
|
||||
StringRef Name = OutName.str();
|
||||
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
|
||||
llvm::ArrayType *ArrayType =
|
||||
llvm::ArrayType::get(Int8PtrTy,
|
||||
llvm::ArrayType::get(CGM.Int8PtrTy,
|
||||
VTContext.getVTableLayout(RD).getNumVTableComponents());
|
||||
|
||||
VTable =
|
||||
|
@ -685,9 +681,8 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
|
|||
Out.flush();
|
||||
StringRef Name = OutName.str();
|
||||
|
||||
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
|
||||
llvm::ArrayType *ArrayType =
|
||||
llvm::ArrayType::get(Int8PtrTy, VTLayout->getNumVTableComponents());
|
||||
llvm::ArrayType::get(CGM.Int8PtrTy, VTLayout->getNumVTableComponents());
|
||||
|
||||
// Create the variable that will hold the construction vtable.
|
||||
llvm::GlobalVariable *VTable =
|
||||
|
|
|
@ -229,8 +229,7 @@ void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
|
|||
llvm::PointerType *PointerTy = Int8PtrTy;
|
||||
llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };
|
||||
llvm::FunctionType *FunctionTy =
|
||||
llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()),
|
||||
ProfileFuncArgs, false);
|
||||
llvm::FunctionType::get(VoidTy, ProfileFuncArgs, false);
|
||||
|
||||
llvm::Constant *F = CGM.CreateRuntimeFunction(FunctionTy, Fn);
|
||||
llvm::CallInst *CallSite = Builder.CreateCall(
|
||||
|
@ -244,8 +243,7 @@ void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
|
|||
}
|
||||
|
||||
void CodeGenFunction::EmitMCountInstrumentation() {
|
||||
llvm::FunctionType *FTy =
|
||||
llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()), false);
|
||||
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
|
||||
|
||||
llvm::Constant *MCountFn = CGM.CreateRuntimeFunction(FTy,
|
||||
Target.getMCountName());
|
||||
|
|
|
@ -75,6 +75,24 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
|
|||
NSConcreteGlobalBlock(0), NSConcreteStackBlock(0),
|
||||
BlockObjectAssign(0), BlockObjectDispose(0),
|
||||
BlockDescriptorType(0), GenericBlockLiteralType(0) {
|
||||
|
||||
// Initialize the type cache.
|
||||
llvm::LLVMContext &LLVMContext = M.getContext();
|
||||
VoidTy = llvm::Type::getVoidTy(LLVMContext);
|
||||
Int8Ty = llvm::Type::getInt8Ty(LLVMContext);
|
||||
Int16Ty = llvm::Type::getInt16Ty(LLVMContext);
|
||||
Int32Ty = llvm::Type::getInt32Ty(LLVMContext);
|
||||
Int64Ty = llvm::Type::getInt64Ty(LLVMContext);
|
||||
FloatTy = llvm::Type::getFloatTy(LLVMContext);
|
||||
DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
|
||||
PointerWidthInBits = C.getTargetInfo().getPointerWidth(0);
|
||||
PointerAlignInBytes =
|
||||
C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(0)).getQuantity();
|
||||
IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
|
||||
IntPtrTy = llvm::IntegerType::get(LLVMContext, PointerWidthInBits);
|
||||
Int8PtrTy = Int8Ty->getPointerTo(0);
|
||||
Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
|
||||
|
||||
if (Features.ObjC1)
|
||||
createObjCRuntime();
|
||||
if (Features.OpenCL)
|
||||
|
@ -98,20 +116,6 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
|
|||
if (C.getLangOptions().ObjCAutoRefCount)
|
||||
ARCData = new ARCEntrypoints();
|
||||
RRData = new RREntrypoints();
|
||||
|
||||
// Initialize the type cache.
|
||||
llvm::LLVMContext &LLVMContext = M.getContext();
|
||||
VoidTy = llvm::Type::getVoidTy(LLVMContext);
|
||||
Int8Ty = llvm::Type::getInt8Ty(LLVMContext);
|
||||
Int32Ty = llvm::Type::getInt32Ty(LLVMContext);
|
||||
Int64Ty = llvm::Type::getInt64Ty(LLVMContext);
|
||||
PointerWidthInBits = C.getTargetInfo().getPointerWidth(0);
|
||||
PointerAlignInBytes =
|
||||
C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(0)).getQuantity();
|
||||
IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
|
||||
IntPtrTy = llvm::IntegerType::get(LLVMContext, PointerWidthInBits);
|
||||
Int8PtrTy = Int8Ty->getPointerTo(0);
|
||||
Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
|
||||
}
|
||||
|
||||
CodeGenModule::~CodeGenModule() {
|
||||
|
@ -379,8 +383,7 @@ void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) {
|
|||
|
||||
// Get the type of a ctor entry, { i32, void ()* }.
|
||||
llvm::StructType *CtorStructTy =
|
||||
llvm::StructType::get(llvm::Type::getInt32Ty(VMContext),
|
||||
llvm::PointerType::getUnqual(CtorFTy), NULL);
|
||||
llvm::StructType::get(Int32Ty, llvm::PointerType::getUnqual(CtorFTy), NULL);
|
||||
|
||||
// Construct the constructor and destructor arrays.
|
||||
SmallVector<llvm::Constant*, 8> Ctors;
|
||||
|
@ -1819,8 +1822,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
|
|||
if (llvm::Constant *C = Entry.getValue())
|
||||
return C;
|
||||
|
||||
llvm::Constant *Zero =
|
||||
llvm::Constant::getNullValue(llvm::Type::getInt32Ty(VMContext));
|
||||
llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
|
||||
llvm::Constant *Zeros[] = { Zero, Zero };
|
||||
|
||||
// If we don't already have it, get __CFConstantStringClassReference.
|
||||
|
|
|
@ -102,8 +102,10 @@ namespace CodeGen {
|
|||
/// void
|
||||
llvm::Type *VoidTy;
|
||||
|
||||
/// i8, i32, and i64
|
||||
llvm::IntegerType *Int8Ty, *Int32Ty, *Int64Ty;
|
||||
/// i8, i16, i32, and i64
|
||||
llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
|
||||
/// float, double
|
||||
llvm::Type *FloatTy, *DoubleTy;
|
||||
|
||||
/// int
|
||||
llvm::IntegerType *IntTy;
|
||||
|
|
|
@ -986,8 +986,7 @@ static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
|
|||
llvm::PointerType *GuardPtrTy) {
|
||||
// void __cxa_guard_release(__guard *guard_object);
|
||||
llvm::FunctionType *FTy =
|
||||
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
|
||||
GuardPtrTy, /*isVarArg=*/false);
|
||||
llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
|
||||
|
||||
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release");
|
||||
}
|
||||
|
@ -996,8 +995,7 @@ static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
|
|||
llvm::PointerType *GuardPtrTy) {
|
||||
// void __cxa_guard_abort(__guard *guard_object);
|
||||
llvm::FunctionType *FTy =
|
||||
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
|
||||
GuardPtrTy, /*isVarArg=*/false);
|
||||
llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
|
||||
|
||||
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort");
|
||||
}
|
||||
|
|
|
@ -741,8 +741,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty) const {
|
|||
|
||||
llvm::Value *X86_32ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
|
||||
llvm::Type *BPP = CGF.Int8PtrPtrTy;
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::Value *VAListAddrAsBPP = Builder.CreateBitCast(VAListAddr, BPP,
|
||||
|
@ -798,10 +797,8 @@ bool X86_32TargetCodeGenInfo::initDwarfEHRegSizeTable(
|
|||
CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *Address) const {
|
||||
CodeGen::CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::LLVMContext &Context = CGF.getLLVMContext();
|
||||
|
||||
llvm::IntegerType *i8 = llvm::Type::getInt8Ty(Context);
|
||||
llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4);
|
||||
llvm::Value *Four8 = llvm::ConstantInt::get(CGF.Int8Ty, 4);
|
||||
|
||||
// 0-7 are the eight integer registers; the order is different
|
||||
// on Darwin (for EH), but the range is the same.
|
||||
|
@ -812,7 +809,7 @@ bool X86_32TargetCodeGenInfo::initDwarfEHRegSizeTable(
|
|||
// 12-16 are st(0..4). Not sure why we stop at 4.
|
||||
// These have size 16, which is sizeof(long double) on
|
||||
// platforms with 8-byte alignment for that type.
|
||||
llvm::Value *Sixteen8 = llvm::ConstantInt::get(i8, 16);
|
||||
llvm::Value *Sixteen8 = llvm::ConstantInt::get(CGF.Int8Ty, 16);
|
||||
AssignToArrayRange(Builder, Address, Sixteen8, 12, 16);
|
||||
|
||||
} else {
|
||||
|
@ -823,7 +820,7 @@ bool X86_32TargetCodeGenInfo::initDwarfEHRegSizeTable(
|
|||
// 11-16 are st(0..5). Not sure why we stop at 5.
|
||||
// These have size 12, which is sizeof(long double) on
|
||||
// platforms with 4-byte alignment for that type.
|
||||
llvm::Value *Twelve8 = llvm::ConstantInt::get(i8, 12);
|
||||
llvm::Value *Twelve8 = llvm::ConstantInt::get(CGF.Int8Ty, 12);
|
||||
AssignToArrayRange(Builder, Address, Twelve8, 11, 16);
|
||||
}
|
||||
|
||||
|
@ -969,16 +966,11 @@ public:
|
|||
|
||||
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *Address) const {
|
||||
CodeGen::CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::LLVMContext &Context = CGF.getLLVMContext();
|
||||
|
||||
llvm::IntegerType *i8 = llvm::Type::getInt8Ty(Context);
|
||||
llvm::Value *Eight8 = llvm::ConstantInt::get(i8, 8);
|
||||
llvm::Value *Eight8 = llvm::ConstantInt::get(CGF.Int8Ty, 8);
|
||||
|
||||
// 0-15 are the 16 integer registers.
|
||||
// 16 is %rip.
|
||||
AssignToArrayRange(Builder, Address, Eight8, 0, 16);
|
||||
|
||||
AssignToArrayRange(CGF.Builder, Address, Eight8, 0, 16);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1030,16 +1022,11 @@ public:
|
|||
|
||||
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *Address) const {
|
||||
CodeGen::CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::LLVMContext &Context = CGF.getLLVMContext();
|
||||
|
||||
llvm::IntegerType *i8 = llvm::Type::getInt8Ty(Context);
|
||||
llvm::Value *Eight8 = llvm::ConstantInt::get(i8, 8);
|
||||
llvm::Value *Eight8 = llvm::ConstantInt::get(CGF.Int8Ty, 8);
|
||||
|
||||
// 0-15 are the 16 integer registers.
|
||||
// 16 is %rip.
|
||||
AssignToArrayRange(Builder, Address, Eight8, 0, 16);
|
||||
|
||||
AssignToArrayRange(CGF.Builder, Address, Eight8, 0, 16);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -2069,8 +2056,6 @@ static llvm::Value *EmitVAArgFromMemory(llvm::Value *VAListAddr,
|
|||
|
||||
llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
llvm::LLVMContext &VMContext = CGF.getLLVMContext();
|
||||
|
||||
// Assume that va_list type is correct; should be pointer to LLVM type:
|
||||
// struct {
|
||||
// i32 gp_offset;
|
||||
|
@ -2179,7 +2164,7 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
|||
// area, we need to collect the two eightbytes together.
|
||||
llvm::Value *RegAddrLo = CGF.Builder.CreateGEP(RegAddr, fp_offset);
|
||||
llvm::Value *RegAddrHi = CGF.Builder.CreateConstGEP1_32(RegAddrLo, 16);
|
||||
llvm::Type *DoubleTy = llvm::Type::getDoubleTy(VMContext);
|
||||
llvm::Type *DoubleTy = CGF.DoubleTy;
|
||||
llvm::Type *DblPtrTy =
|
||||
llvm::PointerType::getUnqual(DoubleTy);
|
||||
llvm::StructType *ST = llvm::StructType::get(DoubleTy,
|
||||
|
@ -2275,8 +2260,7 @@ void WinX86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
|
|||
|
||||
llvm::Value *WinX86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
|
||||
llvm::Type *BPP = CGF.Int8PtrPtrTy;
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::Value *VAListAddrAsBPP = Builder.CreateBitCast(VAListAddr, BPP,
|
||||
|
@ -2321,9 +2305,8 @@ PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
|||
// against gcc output. AFAIK all ABIs use the same encoding.
|
||||
|
||||
CodeGen::CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::LLVMContext &Context = CGF.getLLVMContext();
|
||||
|
||||
llvm::IntegerType *i8 = llvm::Type::getInt8Ty(Context);
|
||||
llvm::IntegerType *i8 = CGF.Int8Ty;
|
||||
llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4);
|
||||
llvm::Value *Eight8 = llvm::ConstantInt::get(i8, 8);
|
||||
llvm::Value *Sixteen8 = llvm::ConstantInt::get(i8, 16);
|
||||
|
@ -2414,15 +2397,10 @@ public:
|
|||
|
||||
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *Address) const {
|
||||
CodeGen::CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::LLVMContext &Context = CGF.getLLVMContext();
|
||||
|
||||
llvm::IntegerType *i8 = llvm::Type::getInt8Ty(Context);
|
||||
llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4);
|
||||
llvm::Value *Four8 = llvm::ConstantInt::get(CGF.Int8Ty, 4);
|
||||
|
||||
// 0-15 are the 16 integer registers.
|
||||
AssignToArrayRange(Builder, Address, Four8, 0, 15);
|
||||
|
||||
AssignToArrayRange(CGF.Builder, Address, Four8, 0, 15);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2748,12 +2726,11 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy) const {
|
|||
|
||||
llvm::Value *ARMABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
|
||||
llvm::Type *BP = CGF.Int8PtrTy;
|
||||
llvm::Type *BPP = CGF.Int8PtrPtrTy;
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::Value *VAListAddrAsBPP = Builder.CreateBitCast(VAListAddr, BPP,
|
||||
"ap");
|
||||
llvm::Value *VAListAddrAsBPP = Builder.CreateBitCast(VAListAddr, BPP, "ap");
|
||||
llvm::Value *Addr = Builder.CreateLoad(VAListAddrAsBPP, "ap.cur");
|
||||
// Handle address alignment for type alignment > 32 bits
|
||||
uint64_t TyAlign = CGF.getContext().getTypeAlign(Ty) / 8;
|
||||
|
@ -3267,8 +3244,8 @@ void MipsABIInfo::computeInfo(CGFunctionInfo &FI) const {
|
|||
|
||||
llvm::Value* MipsABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
|
||||
llvm::Type *BP = CGF.Int8PtrTy;
|
||||
llvm::Type *BPP = CGF.Int8PtrPtrTy;
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::Value *VAListAddrAsBPP = Builder.CreateBitCast(VAListAddr, BPP, "ap");
|
||||
|
@ -3308,19 +3285,15 @@ MIPSTargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
|||
// This information comes from gcc's implementation, which seems to
|
||||
// as canonical as it gets.
|
||||
|
||||
CodeGen::CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::LLVMContext &Context = CGF.getLLVMContext();
|
||||
|
||||
// Everything on MIPS is 4 bytes. Double-precision FP registers
|
||||
// are aliased to pairs of single-precision FP registers.
|
||||
llvm::IntegerType *i8 = llvm::Type::getInt8Ty(Context);
|
||||
llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4);
|
||||
llvm::Value *Four8 = llvm::ConstantInt::get(CGF.Int8Ty, 4);
|
||||
|
||||
// 0-31 are the general purpose registers, $0 - $31.
|
||||
// 32-63 are the floating-point registers, $f0 - $f31.
|
||||
// 64 and 65 are the multiply/divide registers, $hi and $lo.
|
||||
// 66 is the (notional, I think) register for signal-handler return.
|
||||
AssignToArrayRange(Builder, Address, Four8, 0, 65);
|
||||
AssignToArrayRange(CGF.Builder, Address, Four8, 0, 65);
|
||||
|
||||
// 67-74 are the floating-point status registers, $fcc0 - $fcc7.
|
||||
// They are one bit wide and ignored here.
|
||||
|
@ -3330,8 +3303,7 @@ MIPSTargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
|||
// 112-143 are the coprocessor 2 registers, $c2r0 - $c2r31.
|
||||
// 144-175 are the coprocessor 3 registers, $c3r0 - $c3r31.
|
||||
// 176-181 are the DSP accumulator registers.
|
||||
AssignToArrayRange(Builder, Address, Four8, 80, 181);
|
||||
|
||||
AssignToArrayRange(CGF.Builder, Address, Four8, 80, 181);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3375,27 +3347,20 @@ void TCETargetCodeGenInfo::SetTargetAttributes(const Decl *D,
|
|||
SmallVector<llvm::Value*, 5> Operands;
|
||||
Operands.push_back(F);
|
||||
|
||||
Operands.push_back(llvm::Constant::getIntegerValue(
|
||||
llvm::Type::getInt32Ty(Context),
|
||||
llvm::APInt(
|
||||
32,
|
||||
FD->getAttr<ReqdWorkGroupSizeAttr>()->getXDim())));
|
||||
Operands.push_back(llvm::Constant::getIntegerValue(
|
||||
llvm::Type::getInt32Ty(Context),
|
||||
llvm::APInt(
|
||||
32,
|
||||
Operands.push_back(llvm::Constant::getIntegerValue(M.Int32Ty,
|
||||
llvm::APInt(32,
|
||||
FD->getAttr<ReqdWorkGroupSizeAttr>()->getXDim())));
|
||||
Operands.push_back(llvm::Constant::getIntegerValue(M.Int32Ty,
|
||||
llvm::APInt(32,
|
||||
FD->getAttr<ReqdWorkGroupSizeAttr>()->getYDim())));
|
||||
Operands.push_back(llvm::Constant::getIntegerValue(
|
||||
llvm::Type::getInt32Ty(Context),
|
||||
llvm::APInt(
|
||||
32,
|
||||
Operands.push_back(llvm::Constant::getIntegerValue(M.Int32Ty,
|
||||
llvm::APInt(32,
|
||||
FD->getAttr<ReqdWorkGroupSizeAttr>()->getZDim())));
|
||||
|
||||
// Add a boolean constant operand for "required" (true) or "hint" (false)
|
||||
// for implementing the work_group_size_hint attr later. Currently
|
||||
// always true as the hint is not yet implemented.
|
||||
Operands.push_back(llvm::ConstantInt::getTrue(llvm::Type::getInt1Ty(Context)));
|
||||
|
||||
Operands.push_back(llvm::ConstantInt::getTrue(Context));
|
||||
OpenCLMetadata->addOperand(llvm::MDNode::get(Context, Operands));
|
||||
}
|
||||
}
|
||||
|
@ -3522,10 +3487,9 @@ ABIArgInfo HexagonABIInfo::classifyReturnType(QualType RetTy) const {
|
|||
}
|
||||
|
||||
llvm::Value *HexagonABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
CodeGenFunction &CGF) const {
|
||||
// FIXME: Need to handle alignment
|
||||
llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
|
||||
llvm::Type *BPP = CGF.Int8PtrPtrTy;
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::Value *VAListAddrAsBPP = Builder.CreateBitCast(VAListAddr, BPP,
|
||||
|
|
Loading…
Reference in New Issue