git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77012 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-07-24 23:12:58 +00:00
Родитель 7caa6825f4
Коммит 4a28d5deeb
17 изменённых файлов: 207 добавлений и 202 удалений

Просмотреть файл

@ -120,4 +120,4 @@ DispatchCast:
return CastResult(state, return CastResult(state,
isa<Loc>(val) ? EvalCastL(cast<Loc>(val), castTy) isa<Loc>(val) ? EvalCastL(cast<Loc>(val), castTy)
: EvalCastNL(cast<NonLoc>(val), castTy)); : EvalCastNL(cast<NonLoc>(val), castTy));
} }

Просмотреть файл

@ -32,14 +32,14 @@ BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size,
llvm::LLVMContext &VMContext = CGM.getLLVMContext(); llvm::LLVMContext &VMContext = CGM.getLLVMContext();
// reserved // reserved
C = VMContext.getConstantInt(UnsignedLongTy, 0); C = llvm::ConstantInt::get(UnsignedLongTy, 0);
Elts.push_back(C); Elts.push_back(C);
// Size // Size
// FIXME: What is the right way to say this doesn't fit? We should give // FIXME: What is the right way to say this doesn't fit? We should give
// a user diagnostic in that case. Better fix would be to change the // a user diagnostic in that case. Better fix would be to change the
// API to size_t. // API to size_t.
C = VMContext.getConstantInt(UnsignedLongTy, Size); C = llvm::ConstantInt::get(UnsignedLongTy, Size);
Elts.push_back(C); Elts.push_back(C);
if (BlockHasCopyDispose) { if (BlockHasCopyDispose) {
@ -148,11 +148,11 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
// __flags // __flags
const llvm::IntegerType *IntTy = cast<llvm::IntegerType>( const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
CGM.getTypes().ConvertType(CGM.getContext().IntTy)); CGM.getTypes().ConvertType(CGM.getContext().IntTy));
C = VMContext.getConstantInt(IntTy, flags); C = llvm::ConstantInt::get(IntTy, flags);
Elts[1] = C; Elts[1] = C;
// __reserved // __reserved
C = VMContext.getConstantInt(IntTy, 0); C = llvm::ConstantInt::get(IntTy, 0);
Elts[2] = C; Elts[2] = C;
if (subBlockDeclRefDecls.size() == 0) { if (subBlockDeclRefDecls.size() == 0) {
@ -161,7 +161,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
// Optimize to being a global block. // Optimize to being a global block.
Elts[0] = CGM.getNSConcreteGlobalBlock(); Elts[0] = CGM.getNSConcreteGlobalBlock();
Elts[1] = VMContext.getConstantInt(IntTy, flags|BLOCK_IS_GLOBAL); Elts[1] = llvm::ConstantInt::get(IntTy, flags|BLOCK_IS_GLOBAL);
C = VMContext.getConstantStruct(Elts); C = VMContext.getConstantStruct(Elts);
@ -267,7 +267,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
llvm::Value *BlockLiteral = LoadBlockStruct(); llvm::Value *BlockLiteral = LoadBlockStruct();
Loc = Builder.CreateGEP(BlockLiteral, Loc = Builder.CreateGEP(BlockLiteral,
VMContext.getConstantInt(llvm::Type::Int64Ty, llvm::ConstantInt::get(llvm::Type::Int64Ty,
offset), offset),
"block.literal"); "block.literal");
Ty = VMContext.getPointerType(Ty, 0); Ty = VMContext.getPointerType(Ty, 0);
@ -455,7 +455,7 @@ llvm::Value *CodeGenFunction::GetAddrOfBlockDecl(const BlockDeclRefExpr *E) {
llvm::Value *BlockLiteral = LoadBlockStruct(); llvm::Value *BlockLiteral = LoadBlockStruct();
llvm::Value *V = Builder.CreateGEP(BlockLiteral, llvm::Value *V = Builder.CreateGEP(BlockLiteral,
VMContext.getConstantInt(llvm::Type::Int64Ty, llvm::ConstantInt::get(llvm::Type::Int64Ty,
offset), offset),
"block.literal"); "block.literal");
if (E->isByRef()) { if (E->isByRef()) {
@ -510,7 +510,7 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
uint64_t BlockLiteralSize = uint64_t BlockLiteralSize =
TheTargetData.getTypeStoreSizeInBits(getGenericBlockLiteralType()) / 8; TheTargetData.getTypeStoreSizeInBits(getGenericBlockLiteralType()) / 8;
DescriptorFields[1] = DescriptorFields[1] =
VMContext.getConstantInt(UnsignedLongTy,BlockLiteralSize); llvm::ConstantInt::get(UnsignedLongTy,BlockLiteralSize);
llvm::Constant *DescriptorStruct = llvm::Constant *DescriptorStruct =
VMContext.getConstantStruct(&DescriptorFields[0], 2); VMContext.getConstantStruct(&DescriptorFields[0], 2);
@ -542,7 +542,7 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
// Flags // Flags
LiteralFields[1] = LiteralFields[1] =
VMContext.getConstantInt(IntTy, BLOCK_IS_GLOBAL | BLOCK_HAS_DESCRIPTOR); llvm::ConstantInt::get(IntTy, BLOCK_IS_GLOBAL | BLOCK_HAS_DESCRIPTOR);
// Reserved // Reserved
LiteralFields[2] = getModule().getContext().getNullValue(IntTy); LiteralFields[2] = getModule().getContext().getNullValue(IntTy);
@ -777,7 +777,7 @@ GenerateCopyHelperFunction(bool BlockHasCopyDispose, const llvm::StructType *T,
llvm::Value *Dstv = Builder.CreateStructGEP(DstObj, index); llvm::Value *Dstv = Builder.CreateStructGEP(DstObj, index);
Dstv = Builder.CreateBitCast(Dstv, PtrToInt8Ty); Dstv = Builder.CreateBitCast(Dstv, PtrToInt8Ty);
llvm::Value *N = VMContext.getConstantInt(llvm::Type::Int32Ty, flag); llvm::Value *N = llvm::ConstantInt::get(llvm::Type::Int32Ty, flag);
llvm::Value *F = getBlockObjectAssign(); llvm::Value *F = getBlockObjectAssign();
Builder.CreateCall3(F, Dstv, Srcv, N); Builder.CreateCall3(F, Dstv, Srcv, N);
} }
@ -928,7 +928,7 @@ GeneratebyrefCopyHelperFunction(const llvm::Type *T, int flag) {
flag |= BLOCK_BYREF_CALLER; flag |= BLOCK_BYREF_CALLER;
llvm::Value *N = VMContext.getConstantInt(llvm::Type::Int32Ty, flag); llvm::Value *N = llvm::ConstantInt::get(llvm::Type::Int32Ty, flag);
llvm::Value *F = getBlockObjectAssign(); llvm::Value *F = getBlockObjectAssign();
Builder.CreateCall3(F, DstObj, SrcObj, N); Builder.CreateCall3(F, DstObj, SrcObj, N);
@ -1054,7 +1054,7 @@ void BlockFunction::BuildBlockRelease(llvm::Value *V, int flag) {
llvm::Value *F = getBlockObjectDispose(); llvm::Value *F = getBlockObjectDispose();
llvm::Value *N; llvm::Value *N;
V = Builder.CreateBitCast(V, PtrToInt8Ty); V = Builder.CreateBitCast(V, PtrToInt8Ty);
N = VMContext.getConstantInt(llvm::Type::Int32Ty, flag); N = llvm::ConstantInt::get(llvm::Type::Int32Ty, flag);
Builder.CreateCall2(F, V, N); Builder.CreateCall2(F, V, N);
} }

Просмотреть файл

@ -63,7 +63,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Expr::EvalResult Result; Expr::EvalResult Result;
if (E->Evaluate(Result, CGM.getContext())) { if (E->Evaluate(Result, CGM.getContext())) {
if (Result.Val.isInt()) if (Result.Val.isInt())
return RValue::get(VMContext.getConstantInt(Result.Val.getInt())); return RValue::get(llvm::ConstantInt::get(VMContext,
Result.Val.getInt()));
else if (Result.Val.isFloat()) else if (Result.Val.isFloat())
return RValue::get(VMContext.getConstantFP(Result.Val.getFloat())); return RValue::get(VMContext.getConstantFP(Result.Val.getFloat()));
} }
@ -150,7 +151,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
const llvm::Type *ResultType = ConvertType(E->getType()); const llvm::Type *ResultType = ConvertType(E->getType());
Value *Tmp = Builder.CreateAdd(Builder.CreateCall(F, ArgValue, "tmp"), Value *Tmp = Builder.CreateAdd(Builder.CreateCall(F, ArgValue, "tmp"),
VMContext.getConstantInt(ArgType, 1), "tmp"); llvm::ConstantInt::get(ArgType, 1), "tmp");
Value *Zero = VMContext.getNullValue(ArgType); Value *Zero = VMContext.getNullValue(ArgType);
Value *IsZero = Builder.CreateICmpEQ(ArgValue, Zero, "iszero"); Value *IsZero = Builder.CreateICmpEQ(ArgValue, Zero, "iszero");
Value *Result = Builder.CreateSelect(IsZero, Zero, Tmp, "ffs"); Value *Result = Builder.CreateSelect(IsZero, Zero, Tmp, "ffs");
@ -169,7 +170,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
const llvm::Type *ResultType = ConvertType(E->getType()); const llvm::Type *ResultType = ConvertType(E->getType());
Value *Tmp = Builder.CreateCall(F, ArgValue, "tmp"); Value *Tmp = Builder.CreateCall(F, ArgValue, "tmp");
Value *Result = Builder.CreateAnd(Tmp, VMContext.getConstantInt(ArgType, 1), Value *Result = Builder.CreateAnd(Tmp, llvm::ConstantInt::get(ArgType, 1),
"tmp"); "tmp");
if (Result->getType() != ResultType) if (Result->getType() != ResultType)
Result = Builder.CreateIntCast(Result, ResultType, "cast"); Result = Builder.CreateIntCast(Result, ResultType, "cast");
@ -207,15 +208,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
// bool UseSubObject = TypeArg.getZExtValue() & 1; // bool UseSubObject = TypeArg.getZExtValue() & 1;
bool UseMinimum = TypeArg.getZExtValue() & 2; bool UseMinimum = TypeArg.getZExtValue() & 2;
return RValue::get( return RValue::get(
VMContext.getConstantInt(ResType, UseMinimum ? 0 : -1LL)); llvm::ConstantInt::get(ResType, UseMinimum ? 0 : -1LL));
} }
case Builtin::BI__builtin_prefetch: { case Builtin::BI__builtin_prefetch: {
Value *Locality, *RW, *Address = EmitScalarExpr(E->getArg(0)); Value *Locality, *RW, *Address = EmitScalarExpr(E->getArg(0));
// FIXME: Technically these constants should of type 'int', yes? // FIXME: Technically these constants should of type 'int', yes?
RW = (E->getNumArgs() > 1) ? EmitScalarExpr(E->getArg(1)) : RW = (E->getNumArgs() > 1) ? EmitScalarExpr(E->getArg(1)) :
VMContext.getConstantInt(llvm::Type::Int32Ty, 0); llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
Locality = (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : Locality = (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) :
VMContext.getConstantInt(llvm::Type::Int32Ty, 3); llvm::ConstantInt::get(llvm::Type::Int32Ty, 3);
Value *F = CGM.getIntrinsic(Intrinsic::prefetch, 0, 0); Value *F = CGM.getIntrinsic(Intrinsic::prefetch, 0, 0);
return RValue::get(Builder.CreateCall3(F, Address, RW, Locality)); return RValue::get(Builder.CreateCall3(F, Address, RW, Locality));
} }
@ -280,9 +281,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_bzero: { case Builtin::BI__builtin_bzero: {
Value *Address = EmitScalarExpr(E->getArg(0)); Value *Address = EmitScalarExpr(E->getArg(0));
Builder.CreateCall4(CGM.getMemSetFn(), Address, Builder.CreateCall4(CGM.getMemSetFn(), Address,
VMContext.getConstantInt(llvm::Type::Int8Ty, 0), llvm::ConstantInt::get(llvm::Type::Int8Ty, 0),
EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(1)),
VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); llvm::ConstantInt::get(llvm::Type::Int32Ty, 1));
return RValue::get(Address); return RValue::get(Address);
} }
case Builtin::BI__builtin_memcpy: { case Builtin::BI__builtin_memcpy: {
@ -290,7 +291,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Builder.CreateCall4(CGM.getMemCpyFn(), Address, Builder.CreateCall4(CGM.getMemCpyFn(), Address,
EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(1)),
EmitScalarExpr(E->getArg(2)), EmitScalarExpr(E->getArg(2)),
VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); llvm::ConstantInt::get(llvm::Type::Int32Ty, 1));
return RValue::get(Address); return RValue::get(Address);
} }
case Builtin::BI__builtin_memmove: { case Builtin::BI__builtin_memmove: {
@ -298,7 +299,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Builder.CreateCall4(CGM.getMemMoveFn(), Address, Builder.CreateCall4(CGM.getMemMoveFn(), Address,
EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(1)),
EmitScalarExpr(E->getArg(2)), EmitScalarExpr(E->getArg(2)),
VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); llvm::ConstantInt::get(llvm::Type::Int32Ty, 1));
return RValue::get(Address); return RValue::get(Address);
} }
case Builtin::BI__builtin_memset: { case Builtin::BI__builtin_memset: {
@ -307,7 +308,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Builder.CreateTrunc(EmitScalarExpr(E->getArg(1)), Builder.CreateTrunc(EmitScalarExpr(E->getArg(1)),
llvm::Type::Int8Ty), llvm::Type::Int8Ty),
EmitScalarExpr(E->getArg(2)), EmitScalarExpr(E->getArg(2)),
VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); llvm::ConstantInt::get(llvm::Type::Int32Ty, 1));
return RValue::get(Address); return RValue::get(Address);
} }
case Builtin::BI__builtin_return_address: { case Builtin::BI__builtin_return_address: {
@ -513,8 +514,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__sync_synchronize: { case Builtin::BI__sync_synchronize: {
Value *C[5]; Value *C[5];
C[0] = C[1] = C[2] = C[3] = VMContext.getConstantInt(llvm::Type::Int1Ty, 1); C[0] = C[1] = C[2] = C[3] = llvm::ConstantInt::get(llvm::Type::Int1Ty, 1);
C[4] = VMContext.getConstantInt(llvm::Type::Int1Ty, 0); C[4] = llvm::ConstantInt::get(llvm::Type::Int1Ty, 0);
Builder.CreateCall(CGM.getIntrinsic(Intrinsic::memory_barrier), C, C + 5); Builder.CreateCall(CGM.getIntrinsic(Intrinsic::memory_barrier), C, C + 5);
return RValue::get(0); return RValue::get(0);
} }
@ -637,7 +638,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
case X86::BI__builtin_ia32_psrlwi128: { case X86::BI__builtin_ia32_psrlwi128: {
Ops[1] = Builder.CreateZExt(Ops[1], llvm::Type::Int64Ty, "zext"); Ops[1] = Builder.CreateZExt(Ops[1], llvm::Type::Int64Ty, "zext");
const llvm::Type *Ty = VMContext.getVectorType(llvm::Type::Int64Ty, 2); const llvm::Type *Ty = VMContext.getVectorType(llvm::Type::Int64Ty, 2);
llvm::Value *Zero = VMContext.getConstantInt(llvm::Type::Int32Ty, 0); llvm::Value *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
Ops[1] = Builder.CreateInsertElement(VMContext.getUndef(Ty), Ops[1] = Builder.CreateInsertElement(VMContext.getUndef(Ty),
Ops[1], Zero, "insert"); Ops[1], Zero, "insert");
Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "bitcast"); Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "bitcast");
@ -744,7 +745,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
} }
case X86::BI__builtin_ia32_ldmxcsr: { case X86::BI__builtin_ia32_ldmxcsr: {
llvm::Type *PtrTy = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); llvm::Type *PtrTy = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty);
Value *One = VMContext.getConstantInt(llvm::Type::Int32Ty, 1); Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1);
Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp");
Builder.CreateStore(Ops[0], Tmp); Builder.CreateStore(Ops[0], Tmp);
return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr), return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr),
@ -752,7 +753,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
} }
case X86::BI__builtin_ia32_stmxcsr: { case X86::BI__builtin_ia32_stmxcsr: {
llvm::Type *PtrTy = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); llvm::Type *PtrTy = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty);
Value *One = VMContext.getConstantInt(llvm::Type::Int32Ty, 1); Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1);
Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp");
One = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr), One = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr),
Builder.CreateBitCast(Tmp, PtrTy)); Builder.CreateBitCast(Tmp, PtrTy));
@ -777,7 +778,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
// extract (0, 1) // extract (0, 1)
unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1; unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1;
llvm::Value *Idx = VMContext.getConstantInt(llvm::Type::Int32Ty, Index); llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, Index);
Ops[1] = Builder.CreateExtractElement(Ops[1], Idx, "extract"); Ops[1] = Builder.CreateExtractElement(Ops[1], Idx, "extract");
// cast pointer to i64 & store // cast pointer to i64 & store

Просмотреть файл

@ -70,7 +70,7 @@ CodeGenFunction::GenerateStaticCXXBlockVarDeclInit(const VarDecl &D,
EmitAggExpr(Init, GV, D.getType().isVolatileQualified()); EmitAggExpr(Init, GV, D.getType().isVolatileQualified());
} }
Builder.CreateStore(VMContext.getConstantInt(llvm::Type::Int8Ty, 1), Builder.CreateStore(llvm::ConstantInt::get(llvm::Type::Int8Ty, 1),
Builder.CreateBitCast(GuardV, PtrTy)); Builder.CreateBitCast(GuardV, PtrTy));
EmitBlock(EndBlock); EmitBlock(EndBlock);
@ -203,7 +203,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
// The allocation size is the first argument. // The allocation size is the first argument.
QualType SizeTy = getContext().getSizeType(); QualType SizeTy = getContext().getSizeType();
llvm::Value *AllocSize = llvm::Value *AllocSize =
VMContext.getConstantInt(ConvertType(SizeTy), llvm::ConstantInt::get(ConvertType(SizeTy),
getContext().getTypeSize(AllocType) / 8); getContext().getTypeSize(AllocType) / 8);
NewArgs.push_back(std::make_pair(RValue::get(AllocSize), SizeTy)); NewArgs.push_back(std::make_pair(RValue::get(AllocSize), SizeTy));

Просмотреть файл

@ -405,19 +405,19 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
int isa = 0; int isa = 0;
if (flag&BLOCK_FIELD_IS_WEAK) if (flag&BLOCK_FIELD_IS_WEAK)
isa = 1; isa = 1;
V = VMContext.getConstantInt(llvm::Type::Int32Ty, isa); V = llvm::ConstantInt::get(llvm::Type::Int32Ty, isa);
V = Builder.CreateIntToPtr(V, PtrToInt8Ty, "isa"); V = Builder.CreateIntToPtr(V, PtrToInt8Ty, "isa");
Builder.CreateStore(V, isa_field); Builder.CreateStore(V, isa_field);
V = Builder.CreateBitCast(DeclPtr, PtrToInt8Ty, "forwarding"); V = Builder.CreateBitCast(DeclPtr, PtrToInt8Ty, "forwarding");
Builder.CreateStore(V, forwarding_field); Builder.CreateStore(V, forwarding_field);
V = VMContext.getConstantInt(llvm::Type::Int32Ty, flags); V = llvm::ConstantInt::get(llvm::Type::Int32Ty, flags);
Builder.CreateStore(V, flags_field); Builder.CreateStore(V, flags_field);
const llvm::Type *V1; const llvm::Type *V1;
V1 = cast<llvm::PointerType>(DeclPtr->getType())->getElementType(); V1 = cast<llvm::PointerType>(DeclPtr->getType())->getElementType();
V = VMContext.getConstantInt(llvm::Type::Int32Ty, V = llvm::ConstantInt::get(llvm::Type::Int32Ty,
(CGM.getTargetData().getTypeStoreSizeInBits(V1) (CGM.getTargetData().getTypeStoreSizeInBits(V1)
/ 8)); / 8));
Builder.CreateStore(V, size_field); Builder.CreateStore(V, size_field);

Просмотреть файл

@ -329,38 +329,38 @@ RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
// Shift to proper location. // Shift to proper location.
if (StartBit) if (StartBit)
Val = Builder.CreateLShr(Val, VMContext.getConstantInt(EltTy, StartBit), Val = Builder.CreateLShr(Val, llvm::ConstantInt::get(EltTy, StartBit),
"bf.lo"); "bf.lo");
// Mask off unused bits. // Mask off unused bits.
llvm::Constant *LowMask = llvm::Constant *LowMask = llvm::ConstantInt::get(VMContext,
VMContext.getConstantInt(llvm::APInt::getLowBitsSet(EltTySize, LowBits)); llvm::APInt::getLowBitsSet(EltTySize, LowBits));
Val = Builder.CreateAnd(Val, LowMask, "bf.lo.cleared"); Val = Builder.CreateAnd(Val, LowMask, "bf.lo.cleared");
// Fetch the high bits if necessary. // Fetch the high bits if necessary.
if (LowBits < BitfieldSize) { if (LowBits < BitfieldSize) {
unsigned HighBits = BitfieldSize - LowBits; unsigned HighBits = BitfieldSize - LowBits;
llvm::Value *HighPtr = llvm::Value *HighPtr =
Builder.CreateGEP(Ptr, VMContext.getConstantInt(llvm::Type::Int32Ty, 1), Builder.CreateGEP(Ptr, llvm::ConstantInt::get(llvm::Type::Int32Ty, 1),
"bf.ptr.hi"); "bf.ptr.hi");
llvm::Value *HighVal = Builder.CreateLoad(HighPtr, llvm::Value *HighVal = Builder.CreateLoad(HighPtr,
LV.isVolatileQualified(), LV.isVolatileQualified(),
"tmp"); "tmp");
// Mask off unused bits. // Mask off unused bits.
llvm::Constant *HighMask = llvm::Constant *HighMask = llvm::ConstantInt::get(VMContext,
VMContext.getConstantInt(llvm::APInt::getLowBitsSet(EltTySize, HighBits)); llvm::APInt::getLowBitsSet(EltTySize, HighBits));
HighVal = Builder.CreateAnd(HighVal, HighMask, "bf.lo.cleared"); HighVal = Builder.CreateAnd(HighVal, HighMask, "bf.lo.cleared");
// Shift to proper location and or in to bitfield value. // Shift to proper location and or in to bitfield value.
HighVal = Builder.CreateShl(HighVal, HighVal = Builder.CreateShl(HighVal,
VMContext.getConstantInt(EltTy, LowBits)); llvm::ConstantInt::get(EltTy, LowBits));
Val = Builder.CreateOr(Val, HighVal, "bf.val"); Val = Builder.CreateOr(Val, HighVal, "bf.val");
} }
// Sign extend if necessary. // Sign extend if necessary.
if (LV.isBitfieldSigned()) { if (LV.isBitfieldSigned()) {
llvm::Value *ExtraBits = VMContext.getConstantInt(EltTy, llvm::Value *ExtraBits = llvm::ConstantInt::get(EltTy,
EltTySize - BitfieldSize); EltTySize - BitfieldSize);
Val = Builder.CreateAShr(Builder.CreateShl(Val, ExtraBits), Val = Builder.CreateAShr(Builder.CreateShl(Val, ExtraBits),
ExtraBits, "bf.val.sext"); ExtraBits, "bf.val.sext");
@ -397,7 +397,7 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV,
const VectorType *ExprVT = ExprType->getAsVectorType(); const VectorType *ExprVT = ExprType->getAsVectorType();
if (!ExprVT) { if (!ExprVT) {
unsigned InIdx = getAccessedFieldNo(0, Elts); unsigned InIdx = getAccessedFieldNo(0, Elts);
llvm::Value *Elt = VMContext.getConstantInt(llvm::Type::Int32Ty, InIdx); llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
return RValue::get(Builder.CreateExtractElement(Vec, Elt, "tmp")); return RValue::get(Builder.CreateExtractElement(Vec, Elt, "tmp"));
} }
@ -407,7 +407,7 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV,
llvm::SmallVector<llvm::Constant*, 4> Mask; llvm::SmallVector<llvm::Constant*, 4> Mask;
for (unsigned i = 0; i != NumResultElts; ++i) { for (unsigned i = 0; i != NumResultElts; ++i) {
unsigned InIdx = getAccessedFieldNo(i, Elts); unsigned InIdx = getAccessedFieldNo(i, Elts);
Mask.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, InIdx)); Mask.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx));
} }
llvm::Value *MaskV = VMContext.getConstantVector(&Mask[0], Mask.size()); llvm::Value *MaskV = VMContext.getConstantVector(&Mask[0], Mask.size());
@ -501,8 +501,8 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
// exactly the size of the bit-field. // exactly the size of the bit-field.
llvm::Value *SrcVal = Src.getScalarVal(); llvm::Value *SrcVal = Src.getScalarVal();
llvm::Value *NewVal = Builder.CreateIntCast(SrcVal, EltTy, false, "tmp"); llvm::Value *NewVal = Builder.CreateIntCast(SrcVal, EltTy, false, "tmp");
llvm::Constant *Mask = llvm::Constant *Mask = llvm::ConstantInt::get(VMContext,
VMContext.getConstantInt(llvm::APInt::getLowBitsSet(EltTySize, BitfieldSize)); llvm::APInt::getLowBitsSet(EltTySize, BitfieldSize));
NewVal = Builder.CreateAnd(NewVal, Mask, "bf.value"); NewVal = Builder.CreateAnd(NewVal, Mask, "bf.value");
// Return the new value of the bit-field, if requested. // Return the new value of the bit-field, if requested.
@ -515,7 +515,7 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
// Sign extend if necessary. // Sign extend if necessary.
if (Dst.isBitfieldSigned()) { if (Dst.isBitfieldSigned()) {
unsigned SrcTySize = CGM.getTargetData().getTypeSizeInBits(SrcTy); unsigned SrcTySize = CGM.getTargetData().getTypeSizeInBits(SrcTy);
llvm::Value *ExtraBits = VMContext.getConstantInt(SrcTy, llvm::Value *ExtraBits = llvm::ConstantInt::get(SrcTy,
SrcTySize - BitfieldSize); SrcTySize - BitfieldSize);
SrcTrunc = Builder.CreateAShr(Builder.CreateShl(SrcTrunc, ExtraBits), SrcTrunc = Builder.CreateAShr(Builder.CreateShl(SrcTrunc, ExtraBits),
ExtraBits, "bf.reload.sext"); ExtraBits, "bf.reload.sext");
@ -533,14 +533,14 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
// Compute the mask for zero-ing the low part of this bitfield. // Compute the mask for zero-ing the low part of this bitfield.
llvm::Constant *InvMask = llvm::Constant *InvMask =
VMContext.getConstantInt(~llvm::APInt::getBitsSet(EltTySize, StartBit, llvm::ConstantInt::get(VMContext,
StartBit + LowBits)); ~llvm::APInt::getBitsSet(EltTySize, StartBit, StartBit + LowBits));
// Compute the new low part as // Compute the new low part as
// LowVal = (LowVal & InvMask) | (NewVal << StartBit), // LowVal = (LowVal & InvMask) | (NewVal << StartBit),
// with the shift of NewVal implicitly stripping the high bits. // with the shift of NewVal implicitly stripping the high bits.
llvm::Value *NewLowVal = llvm::Value *NewLowVal =
Builder.CreateShl(NewVal, VMContext.getConstantInt(EltTy, StartBit), Builder.CreateShl(NewVal, llvm::ConstantInt::get(EltTy, StartBit),
"bf.value.lo"); "bf.value.lo");
LowVal = Builder.CreateAnd(LowVal, InvMask, "bf.prev.lo.cleared"); LowVal = Builder.CreateAnd(LowVal, InvMask, "bf.prev.lo.cleared");
LowVal = Builder.CreateOr(LowVal, NewLowVal, "bf.new.lo"); LowVal = Builder.CreateOr(LowVal, NewLowVal, "bf.new.lo");
@ -552,7 +552,7 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
if (LowBits < BitfieldSize) { if (LowBits < BitfieldSize) {
unsigned HighBits = BitfieldSize - LowBits; unsigned HighBits = BitfieldSize - LowBits;
llvm::Value *HighPtr = llvm::Value *HighPtr =
Builder.CreateGEP(Ptr, VMContext.getConstantInt(llvm::Type::Int32Ty, 1), Builder.CreateGEP(Ptr, llvm::ConstantInt::get(llvm::Type::Int32Ty, 1),
"bf.ptr.hi"); "bf.ptr.hi");
llvm::Value *HighVal = Builder.CreateLoad(HighPtr, llvm::Value *HighVal = Builder.CreateLoad(HighPtr,
Dst.isVolatileQualified(), Dst.isVolatileQualified(),
@ -560,7 +560,7 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
// Compute the mask for zero-ing the high part of this bitfield. // Compute the mask for zero-ing the high part of this bitfield.
llvm::Constant *InvMask = llvm::Constant *InvMask =
VMContext.getConstantInt(~llvm::APInt::getLowBitsSet(EltTySize, llvm::ConstantInt::get(VMContext, ~llvm::APInt::getLowBitsSet(EltTySize,
HighBits)); HighBits));
// Compute the new high part as // Compute the new high part as
@ -568,7 +568,7 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
// where the high bits of NewVal have already been cleared and the // where the high bits of NewVal have already been cleared and the
// shift stripping the low bits. // shift stripping the low bits.
llvm::Value *NewHighVal = llvm::Value *NewHighVal =
Builder.CreateLShr(NewVal, VMContext.getConstantInt(EltTy, LowBits), Builder.CreateLShr(NewVal, llvm::ConstantInt::get(EltTy, LowBits),
"bf.value.high"); "bf.value.high");
HighVal = Builder.CreateAnd(HighVal, InvMask, "bf.prev.hi.cleared"); HighVal = Builder.CreateAnd(HighVal, InvMask, "bf.prev.hi.cleared");
HighVal = Builder.CreateOr(HighVal, NewHighVal, "bf.new.hi"); HighVal = Builder.CreateOr(HighVal, NewHighVal, "bf.new.hi");
@ -612,7 +612,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
llvm::SmallVector<llvm::Constant*, 4> Mask(NumDstElts); llvm::SmallVector<llvm::Constant*, 4> Mask(NumDstElts);
for (unsigned i = 0; i != NumSrcElts; ++i) { for (unsigned i = 0; i != NumSrcElts; ++i) {
unsigned InIdx = getAccessedFieldNo(i, Elts); unsigned InIdx = getAccessedFieldNo(i, Elts);
Mask[InIdx] = VMContext.getConstantInt(llvm::Type::Int32Ty, i); Mask[InIdx] = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
} }
llvm::Value *MaskV = VMContext.getConstantVector(&Mask[0], Mask.size()); llvm::Value *MaskV = VMContext.getConstantVector(&Mask[0], Mask.size());
@ -628,7 +628,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
llvm::SmallVector<llvm::Constant*, 4> ExtMask; llvm::SmallVector<llvm::Constant*, 4> ExtMask;
unsigned i; unsigned i;
for (i = 0; i != NumSrcElts; ++i) for (i = 0; i != NumSrcElts; ++i)
ExtMask.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, i)); ExtMask.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, i));
for (; i != NumDstElts; ++i) for (; i != NumDstElts; ++i)
ExtMask.push_back(VMContext.getUndef(llvm::Type::Int32Ty)); ExtMask.push_back(VMContext.getUndef(llvm::Type::Int32Ty));
llvm::Value *ExtMaskV = VMContext.getConstantVector(&ExtMask[0], llvm::Value *ExtMaskV = VMContext.getConstantVector(&ExtMask[0],
@ -640,12 +640,12 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
// build identity // build identity
llvm::SmallVector<llvm::Constant*, 4> Mask; llvm::SmallVector<llvm::Constant*, 4> Mask;
for (unsigned i = 0; i != NumDstElts; ++i) { for (unsigned i = 0; i != NumDstElts; ++i) {
Mask.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, i)); Mask.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, i));
} }
// modify when what gets shuffled in // modify when what gets shuffled in
for (unsigned i = 0; i != NumSrcElts; ++i) { for (unsigned i = 0; i != NumSrcElts; ++i) {
unsigned Idx = getAccessedFieldNo(i, Elts); unsigned Idx = getAccessedFieldNo(i, Elts);
Mask[Idx] = VMContext.getConstantInt(llvm::Type::Int32Ty, i+NumDstElts); Mask[Idx] = llvm::ConstantInt::get(llvm::Type::Int32Ty, i+NumDstElts);
} }
llvm::Value *MaskV = VMContext.getConstantVector(&Mask[0], Mask.size()); llvm::Value *MaskV = VMContext.getConstantVector(&Mask[0], Mask.size());
Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV, "tmp"); Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV, "tmp");
@ -657,7 +657,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
} else { } else {
// If the Src is a scalar (not a vector) it must be updating one element. // If the Src is a scalar (not a vector) it must be updating one element.
unsigned InIdx = getAccessedFieldNo(0, Elts); unsigned InIdx = getAccessedFieldNo(0, Elts);
llvm::Value *Elt = VMContext.getConstantInt(llvm::Type::Int32Ty, InIdx); llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp"); Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp");
} }
@ -891,13 +891,13 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
uint64_t BaseTypeSize = getContext().getTypeSize(BaseType) / 8; uint64_t BaseTypeSize = getContext().getTypeSize(BaseType) / 8;
Idx = Builder.CreateUDiv(Idx, Idx = Builder.CreateUDiv(Idx,
VMContext.getConstantInt(Idx->getType(), llvm::ConstantInt::get(Idx->getType(),
BaseTypeSize)); BaseTypeSize));
Address = Builder.CreateGEP(Base, Idx, "arrayidx"); Address = Builder.CreateGEP(Base, Idx, "arrayidx");
} else if (const ObjCInterfaceType *OIT = } else if (const ObjCInterfaceType *OIT =
dyn_cast<ObjCInterfaceType>(E->getType())) { dyn_cast<ObjCInterfaceType>(E->getType())) {
llvm::Value *InterfaceSize = llvm::Value *InterfaceSize =
VMContext.getConstantInt(Idx->getType(), llvm::ConstantInt::get(Idx->getType(),
getContext().getTypeSize(OIT) / 8); getContext().getTypeSize(OIT) / 8);
Idx = Builder.CreateMul(Idx, InterfaceSize); Idx = Builder.CreateMul(Idx, InterfaceSize);
@ -930,7 +930,7 @@ llvm::Constant *GenerateConstantVector(llvm::LLVMContext &VMContext,
llvm::SmallVector<llvm::Constant *, 4> CElts; llvm::SmallVector<llvm::Constant *, 4> CElts;
for (unsigned i = 0, e = Elts.size(); i != e; ++i) for (unsigned i = 0, e = Elts.size(); i != e; ++i)
CElts.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, Elts[i])); CElts.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, Elts[i]));
return VMContext.getConstantVector(&CElts[0], CElts.size()); return VMContext.getConstantVector(&CElts[0], CElts.size());
} }
@ -968,7 +968,7 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
for (unsigned i = 0, e = Indices.size(); i != e; ++i) { for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
if (isa<llvm::ConstantAggregateZero>(BaseElts)) if (isa<llvm::ConstantAggregateZero>(BaseElts))
CElts.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, 0)); CElts.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
else else
CElts.push_back(BaseElts->getOperand(Indices[i])); CElts.push_back(BaseElts->getOperand(Indices[i]));
} }
@ -1040,7 +1040,7 @@ LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value* BaseValue,
"tmp"); "tmp");
llvm::Value *Idx = llvm::Value *Idx =
VMContext.getConstantInt(llvm::Type::Int32Ty, Info.FieldNo); llvm::ConstantInt::get(llvm::Type::Int32Ty, Info.FieldNo);
llvm::Value *V = Builder.CreateGEP(BaseValue, Idx, "tmp"); llvm::Value *V = Builder.CreateGEP(BaseValue, Idx, "tmp");
return LValue::MakeBitfield(V, Info.Start, Info.Size, return LValue::MakeBitfield(V, Info.Start, Info.Size,

Просмотреть файл

@ -570,7 +570,7 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
Builder.CreateCall4(CGM.getMemCpyFn(), Builder.CreateCall4(CGM.getMemCpyFn(),
DestPtr, SrcPtr, DestPtr, SrcPtr,
// TypeInfo.first describes size in bits. // TypeInfo.first describes size in bits.
VMContext.getConstantInt(IntPtr, TypeInfo.first/8), llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::ConstantInt::get(llvm::Type::Int32Ty,
TypeInfo.second/8)); TypeInfo.second/8));
} }

Просмотреть файл

@ -376,7 +376,7 @@ ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
llvm::Value *NextVal; llvm::Value *NextVal;
if (isa<llvm::IntegerType>(InVal.first->getType())) { if (isa<llvm::IntegerType>(InVal.first->getType())) {
uint64_t AmountVal = isInc ? 1 : -1; uint64_t AmountVal = isInc ? 1 : -1;
NextVal = VMContext.getConstantInt(InVal.first->getType(), AmountVal, true); NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal, true);
// Add the inc/dec to the real part. // Add the inc/dec to the real part.
NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec");

Просмотреть файл

@ -315,7 +315,7 @@ public:
unsigned byte = V.getLoBits(curBits).getZExtValue() << (FieldOffset & 7); unsigned byte = V.getLoBits(curBits).getZExtValue() << (FieldOffset & 7);
do { do {
llvm::Constant* byteC = llvm::Constant* byteC =
VMContext.getConstantInt(llvm::Type::Int8Ty, byte); llvm::ConstantInt::get(llvm::Type::Int8Ty, byte);
Elts[i] = VMContext.getConstantExprOr(Elts[i], byteC); Elts[i] = VMContext.getConstantExprOr(Elts[i], byteC);
++i; ++i;
V = V.lshr(curBits); V = V.lshr(curBits);
@ -591,7 +591,7 @@ public:
case Expr::AddrLabelExprClass: { case Expr::AddrLabelExprClass: {
assert(CGF && "Invalid address of label expression outside function."); assert(CGF && "Invalid address of label expression outside function.");
unsigned id = CGF->GetIDForAddrOfLabel(cast<AddrLabelExpr>(E)->getLabel()); unsigned id = CGF->GetIDForAddrOfLabel(cast<AddrLabelExpr>(E)->getLabel());
llvm::Constant *C = VMContext.getConstantInt(llvm::Type::Int32Ty, id); llvm::Constant *C = llvm::ConstantInt::get(llvm::Type::Int32Ty, id);
return VMContext.getConstantExprIntToPtr(C, ConvertType(E->getType())); return VMContext.getConstantExprIntToPtr(C, ConvertType(E->getType()));
} }
case Expr::CallExprClass: { case Expr::CallExprClass: {
@ -643,7 +643,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
case APValue::LValue: { case APValue::LValue: {
const llvm::Type *DestTy = getTypes().ConvertTypeForMem(DestType); const llvm::Type *DestTy = getTypes().ConvertTypeForMem(DestType);
llvm::Constant *Offset = llvm::Constant *Offset =
VMContext.getConstantInt(llvm::Type::Int64Ty, llvm::ConstantInt::get(llvm::Type::Int64Ty,
Result.Val.getLValueOffset()); Result.Val.getLValueOffset());
llvm::Constant *C; llvm::Constant *C;
@ -681,7 +681,8 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
} }
} }
case APValue::Int: { case APValue::Int: {
llvm::Constant *C = VMContext.getConstantInt(Result.Val.getInt()); llvm::Constant *C = llvm::ConstantInt::get(VMContext,
Result.Val.getInt());
if (C->getType() == llvm::Type::Int1Ty) { if (C->getType() == llvm::Type::Int1Ty) {
const llvm::Type *BoolTy = getTypes().ConvertTypeForMem(E->getType()); const llvm::Type *BoolTy = getTypes().ConvertTypeForMem(E->getType());
@ -692,8 +693,10 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
case APValue::ComplexInt: { case APValue::ComplexInt: {
llvm::Constant *Complex[2]; llvm::Constant *Complex[2];
Complex[0] = VMContext.getConstantInt(Result.Val.getComplexIntReal()); Complex[0] = llvm::ConstantInt::get(VMContext,
Complex[1] = VMContext.getConstantInt(Result.Val.getComplexIntImag()); Result.Val.getComplexIntReal());
Complex[1] = llvm::ConstantInt::get(VMContext,
Result.Val.getComplexIntImag());
return VMContext.getConstantStruct(Complex, 2); return VMContext.getConstantStruct(Complex, 2);
} }
@ -714,7 +717,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
for (unsigned i = 0; i != NumElts; ++i) { for (unsigned i = 0; i != NumElts; ++i) {
APValue &Elt = Result.Val.getVectorElt(i); APValue &Elt = Result.Val.getVectorElt(i);
if (Elt.isInt()) if (Elt.isInt())
Inits.push_back(VMContext.getConstantInt(Elt.getInt())); Inits.push_back(llvm::ConstantInt::get(VMContext, Elt.getInt()));
else else
Inits.push_back(VMContext.getConstantFP(Elt.getFloat())); Inits.push_back(VMContext.getConstantFP(Elt.getFloat()));
} }

Просмотреть файл

@ -109,16 +109,16 @@ public:
// Leaves. // Leaves.
Value *VisitIntegerLiteral(const IntegerLiteral *E) { Value *VisitIntegerLiteral(const IntegerLiteral *E) {
return VMContext.getConstantInt(E->getValue()); return llvm::ConstantInt::get(VMContext, E->getValue());
} }
Value *VisitFloatingLiteral(const FloatingLiteral *E) { Value *VisitFloatingLiteral(const FloatingLiteral *E) {
return VMContext.getConstantFP(E->getValue()); return VMContext.getConstantFP(E->getValue());
} }
Value *VisitCharacterLiteral(const CharacterLiteral *E) { Value *VisitCharacterLiteral(const CharacterLiteral *E) {
return VMContext.getConstantInt(ConvertType(E->getType()), E->getValue()); return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
} }
Value *VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) { Value *VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
return VMContext.getConstantInt(ConvertType(E->getType()), E->getValue()); return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
} }
Value *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) { Value *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
return VMContext.getNullValue(ConvertType(E->getType())); return VMContext.getNullValue(ConvertType(E->getType()));
@ -127,14 +127,14 @@ public:
return VMContext.getNullValue(ConvertType(E->getType())); return VMContext.getNullValue(ConvertType(E->getType()));
} }
Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) { Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
return VMContext.getConstantInt(ConvertType(E->getType()), return llvm::ConstantInt::get(ConvertType(E->getType()),
CGF.getContext().typesAreCompatible( CGF.getContext().typesAreCompatible(
E->getArgType1(), E->getArgType2())); E->getArgType1(), E->getArgType2()));
} }
Value *VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E); Value *VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E);
Value *VisitAddrLabelExpr(const AddrLabelExpr *E) { Value *VisitAddrLabelExpr(const AddrLabelExpr *E) {
llvm::Value *V = llvm::Value *V =
VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::ConstantInt::get(llvm::Type::Int32Ty,
CGF.GetIDForAddrOfLabel(E->getLabel())); CGF.GetIDForAddrOfLabel(E->getLabel()));
return Builder.CreateIntToPtr(V, ConvertType(E->getType())); return Builder.CreateIntToPtr(V, ConvertType(E->getType()));
@ -143,7 +143,7 @@ public:
// l-values. // l-values.
Value *VisitDeclRefExpr(DeclRefExpr *E) { Value *VisitDeclRefExpr(DeclRefExpr *E) {
if (const EnumConstantDecl *EC = dyn_cast<EnumConstantDecl>(E->getDecl())) if (const EnumConstantDecl *EC = dyn_cast<EnumConstantDecl>(E->getDecl()))
return VMContext.getConstantInt(EC->getInitVal()); return llvm::ConstantInt::get(VMContext, EC->getInitVal());
return EmitLoadOfLValue(E); return EmitLoadOfLValue(E);
} }
Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E) { Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
@ -206,13 +206,13 @@ public:
unsigned i; unsigned i;
for (i = 0; i < NumInitElements; ++i) { for (i = 0; i < NumInitElements; ++i) {
Value *NewV = Visit(E->getInit(i)); Value *NewV = Visit(E->getInit(i));
Value *Idx = VMContext.getConstantInt(llvm::Type::Int32Ty, i); Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
V = Builder.CreateInsertElement(V, NewV, Idx); V = Builder.CreateInsertElement(V, NewV, Idx);
} }
// Emit remaining default initializers // Emit remaining default initializers
for (/* Do not initialize i*/; i < NumVectorElements; ++i) { for (/* Do not initialize i*/; i < NumVectorElements; ++i) {
Value *Idx = VMContext.getConstantInt(llvm::Type::Int32Ty, i); Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
llvm::Value *NewV = VMContext.getNullValue(ElementType); llvm::Value *NewV = VMContext.getNullValue(ElementType);
V = Builder.CreateInsertElement(V, NewV, Idx); V = Builder.CreateInsertElement(V, NewV, Idx);
} }
@ -467,14 +467,14 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
// Insert the element in element zero of an undef vector // Insert the element in element zero of an undef vector
llvm::Value *UnV = VMContext.getUndef(DstTy); llvm::Value *UnV = VMContext.getUndef(DstTy);
llvm::Value *Idx = VMContext.getConstantInt(llvm::Type::Int32Ty, 0); llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
UnV = Builder.CreateInsertElement(UnV, Elt, Idx, "tmp"); UnV = Builder.CreateInsertElement(UnV, Elt, Idx, "tmp");
// Splat the element across to all elements // Splat the element across to all elements
llvm::SmallVector<llvm::Constant*, 16> Args; llvm::SmallVector<llvm::Constant*, 16> Args;
unsigned NumElements = cast<llvm::VectorType>(DstTy)->getNumElements(); unsigned NumElements = cast<llvm::VectorType>(DstTy)->getNumElements();
for (unsigned i = 0; i < NumElements; i++) for (unsigned i = 0; i < NumElements; i++)
Args.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, 0)); Args.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
llvm::Constant *Mask = VMContext.getConstantVector(&Args[0], NumElements); llvm::Constant *Mask = VMContext.getConstantVector(&Args[0], NumElements);
llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat"); llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat");
@ -689,7 +689,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
if (const llvm::PointerType *PT = if (const llvm::PointerType *PT =
dyn_cast<llvm::PointerType>(InVal->getType())) { dyn_cast<llvm::PointerType>(InVal->getType())) {
llvm::Constant *Inc = llvm::Constant *Inc =
VMContext.getConstantInt(llvm::Type::Int32Ty, AmountVal); llvm::ConstantInt::get(llvm::Type::Int32Ty, AmountVal);
if (!isa<llvm::FunctionType>(PT->getElementType())) { if (!isa<llvm::FunctionType>(PT->getElementType())) {
QualType PTEE = ValTy->getPointeeType(); QualType PTEE = ValTy->getPointeeType();
if (const ObjCInterfaceType *OIT = if (const ObjCInterfaceType *OIT =
@ -698,7 +698,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
int size = CGF.getContext().getTypeSize(OIT) / 8; int size = CGF.getContext().getTypeSize(OIT) / 8;
if (!isInc) if (!isInc)
size = -size; size = -size;
Inc = VMContext.getConstantInt(Inc->getType(), size); Inc = llvm::ConstantInt::get(Inc->getType(), size);
const llvm::Type *i8Ty = const llvm::Type *i8Ty =
VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty);
InVal = Builder.CreateBitCast(InVal, i8Ty); InVal = Builder.CreateBitCast(InVal, i8Ty);
@ -725,7 +725,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
// Decrement does not have this property. // Decrement does not have this property.
NextVal = VMContext.getTrue(); NextVal = VMContext.getTrue();
} else if (isa<llvm::IntegerType>(InVal->getType())) { } else if (isa<llvm::IntegerType>(InVal->getType())) {
NextVal = VMContext.getConstantInt(InVal->getType(), AmountVal); NextVal = llvm::ConstantInt::get(InVal->getType(), AmountVal);
NextVal = Builder.CreateAdd(InVal, NextVal, isInc ? "inc" : "dec"); NextVal = Builder.CreateAdd(InVal, NextVal, isInc ? "inc" : "dec");
} else { } else {
// Add the inc/dec to the real part. // Add the inc/dec to the real part.
@ -810,7 +810,7 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
// constant folding logic so we don't have to duplicate it here. // constant folding logic so we don't have to duplicate it here.
Expr::EvalResult Result; Expr::EvalResult Result;
E->Evaluate(Result, CGF.getContext()); E->Evaluate(Result, CGF.getContext());
return VMContext.getConstantInt(Result.Val.getInt()); return llvm::ConstantInt::get(VMContext, Result.Val.getInt());
} }
Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E) { Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E) {
@ -989,8 +989,8 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
llvm::Value *handlerResult = Builder.CreateCall4(handlerFunction, llvm::Value *handlerResult = Builder.CreateCall4(handlerFunction,
Builder.CreateSExt(Ops.LHS, llvm::Type::Int64Ty), Builder.CreateSExt(Ops.LHS, llvm::Type::Int64Ty),
Builder.CreateSExt(Ops.RHS, llvm::Type::Int64Ty), Builder.CreateSExt(Ops.RHS, llvm::Type::Int64Ty),
VMContext.getConstantInt(llvm::Type::Int8Ty, OpID), llvm::ConstantInt::get(llvm::Type::Int8Ty, OpID),
VMContext.getConstantInt(llvm::Type::Int8Ty, llvm::ConstantInt::get(llvm::Type::Int8Ty,
cast<llvm::IntegerType>(opTy)->getBitWidth())); cast<llvm::IntegerType>(opTy)->getBitWidth()));
handlerResult = Builder.CreateTrunc(handlerResult, opTy); handlerResult = Builder.CreateTrunc(handlerResult, opTy);
@ -1058,7 +1058,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
// type. // type.
if (const ObjCInterfaceType *OIT = dyn_cast<ObjCInterfaceType>(ElementType)) { if (const ObjCInterfaceType *OIT = dyn_cast<ObjCInterfaceType>(ElementType)) {
llvm::Value *InterfaceSize = llvm::Value *InterfaceSize =
VMContext.getConstantInt(Idx->getType(), llvm::ConstantInt::get(Idx->getType(),
CGF.getContext().getTypeSize(OIT) / 8); CGF.getContext().getTypeSize(OIT) / 8);
Idx = Builder.CreateMul(Idx, InterfaceSize); Idx = Builder.CreateMul(Idx, InterfaceSize);
const llvm::Type *i8Ty = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); const llvm::Type *i8Ty = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty);
@ -1123,7 +1123,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
if (const ObjCInterfaceType *OIT = if (const ObjCInterfaceType *OIT =
dyn_cast<ObjCInterfaceType>(LHSElementType)) { dyn_cast<ObjCInterfaceType>(LHSElementType)) {
llvm::Value *InterfaceSize = llvm::Value *InterfaceSize =
VMContext.getConstantInt(Idx->getType(), llvm::ConstantInt::get(Idx->getType(),
CGF.getContext().getTypeSize(OIT) / 8); CGF.getContext().getTypeSize(OIT) / 8);
Idx = Builder.CreateMul(Idx, InterfaceSize); Idx = Builder.CreateMul(Idx, InterfaceSize);
const llvm::Type *i8Ty = const llvm::Type *i8Ty =
@ -1174,12 +1174,12 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
// better code. See PR2247. // better code. See PR2247.
if (llvm::isPowerOf2_64(ElementSize)) { if (llvm::isPowerOf2_64(ElementSize)) {
Value *ShAmt = Value *ShAmt =
VMContext.getConstantInt(ResultType, llvm::Log2_64(ElementSize)); llvm::ConstantInt::get(ResultType, llvm::Log2_64(ElementSize));
return Builder.CreateAShr(BytesBetween, ShAmt, "sub.ptr.shr"); return Builder.CreateAShr(BytesBetween, ShAmt, "sub.ptr.shr");
} }
// Otherwise, do a full sdiv. // Otherwise, do a full sdiv.
Value *BytesPerElt = VMContext.getConstantInt(ResultType, ElementSize); Value *BytesPerElt = llvm::ConstantInt::get(ResultType, ElementSize);
return Builder.CreateSDiv(BytesBetween, BytesPerElt, "sub.ptr.div"); return Builder.CreateSDiv(BytesBetween, BytesPerElt, "sub.ptr.div");
} }
} }
@ -1351,7 +1351,7 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
// 1 || RHS: If it is safe, just elide the RHS, and return 1. // 1 || RHS: If it is safe, just elide the RHS, and return 1.
if (!CGF.ContainsLabel(E->getRHS())) if (!CGF.ContainsLabel(E->getRHS()))
return VMContext.getConstantInt(CGF.LLVMIntTy, 1); return llvm::ConstantInt::get(CGF.LLVMIntTy, 1);
} }
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor.end"); llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor.end");
@ -1591,7 +1591,7 @@ Value *CodeGenFunction::EmitShuffleVector(Value* V1, Value *V2, ...) {
int n = va_arg(va, int); int n = va_arg(va, int);
assert(n >= 0 && n < (int)NumElements * 2 && assert(n >= 0 && n < (int)NumElements * 2 &&
"Vector shuffle index out of bounds!"); "Vector shuffle index out of bounds!");
Args.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, n)); Args.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, n));
} }
const char *Name = va_arg(va, const char *); const char *Name = va_arg(va, const char *);
@ -1609,7 +1609,7 @@ llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals,
for (unsigned i = 0, e = NumVals; i != e; ++i) { for (unsigned i = 0, e = NumVals; i != e; ++i) {
llvm::Value *Val = isSplat ? Vals[0] : Vals[i]; llvm::Value *Val = isSplat ? Vals[0] : Vals[i];
llvm::Value *Idx = VMContext.getConstantInt(llvm::Type::Int32Ty, i); llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
Vec = Builder.CreateInsertElement(Vec, Val, Idx, "tmp"); Vec = Builder.CreateInsertElement(Vec, Val, Idx, "tmp");
} }

Просмотреть файл

@ -179,7 +179,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy)); Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy));
llvm::Value *Offset = EmitIvarOffset(IMP->getClassInterface(), Ivar); llvm::Value *Offset = EmitIvarOffset(IMP->getClassInterface(), Ivar);
llvm::Value *True = llvm::Value *True =
VMContext.getConstantInt(Types.ConvertType(getContext().BoolTy), 1); llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 1);
CallArgList Args; CallArgList Args;
Args.push_back(std::make_pair(RValue::get(SelfAsId), IdTy)); Args.push_back(std::make_pair(RValue::get(SelfAsId), IdTy));
Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType())); Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType()));
@ -262,9 +262,9 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
Builder.CreateBitCast(Builder.CreateLoad(Arg, "arg"), Builder.CreateBitCast(Builder.CreateLoad(Arg, "arg"),
Types.ConvertType(IdTy)); Types.ConvertType(IdTy));
llvm::Value *True = llvm::Value *True =
VMContext.getConstantInt(Types.ConvertType(getContext().BoolTy), 1); llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 1);
llvm::Value *False = llvm::Value *False =
VMContext.getConstantInt(Types.ConvertType(getContext().BoolTy), 0); llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 0);
CallArgList Args; CallArgList Args;
Args.push_back(std::make_pair(RValue::get(SelfAsId), IdTy)); Args.push_back(std::make_pair(RValue::get(SelfAsId), IdTy));
Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType())); Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType()));
@ -471,7 +471,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
getContext().getPointerType(ItemsTy))); getContext().getPointerType(ItemsTy)));
const llvm::Type *UnsignedLongLTy = ConvertType(getContext().UnsignedLongTy); const llvm::Type *UnsignedLongLTy = ConvertType(getContext().UnsignedLongTy);
llvm::Constant *Count = VMContext.getConstantInt(UnsignedLongLTy, NumItems); llvm::Constant *Count = llvm::ConstantInt::get(UnsignedLongLTy, NumItems);
Args.push_back(std::make_pair(RValue::get(Count), Args.push_back(std::make_pair(RValue::get(Count),
getContext().UnsignedLongTy)); getContext().UnsignedLongTy));
@ -574,7 +574,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
// Increment the counter. // Increment the counter.
Counter = Builder.CreateAdd(Counter, Counter = Builder.CreateAdd(Counter,
VMContext.getConstantInt(UnsignedLongLTy, 1)); llvm::ConstantInt::get(UnsignedLongLTy, 1));
Builder.CreateStore(Counter, CounterPtr); Builder.CreateStore(Counter, CounterPtr);
llvm::BasicBlock *LoopEnd = createBasicBlock("loopend"); llvm::BasicBlock *LoopEnd = createBasicBlock("loopend");

Просмотреть файл

@ -210,7 +210,7 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm)
LongTy = cast<llvm::IntegerType>( LongTy = cast<llvm::IntegerType>(
CGM.getTypes().ConvertType(CGM.getContext().LongTy)); CGM.getTypes().ConvertType(CGM.getContext().LongTy));
Zeros[0] = VMContext.getConstantInt(LongTy, 0); Zeros[0] = llvm::ConstantInt::get(LongTy, 0);
Zeros[1] = Zeros[0]; Zeros[1] = Zeros[0];
NULLPtr = VMContext.getConstantPointerNull( NULLPtr = VMContext.getConstantPointerNull(
VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty)); VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty));
@ -319,7 +319,7 @@ llvm::Constant *CGObjCGNU::GenerateConstantString(const ObjCStringLiteral *SL) {
std::vector<llvm::Constant*> Ivars; std::vector<llvm::Constant*> Ivars;
Ivars.push_back(NULLPtr); Ivars.push_back(NULLPtr);
Ivars.push_back(MakeConstantString(Str)); Ivars.push_back(MakeConstantString(Str));
Ivars.push_back(VMContext.getConstantInt(IntTy, Str.size())); Ivars.push_back(llvm::ConstantInt::get(IntTy, Str.size()));
llvm::Constant *ObjCStr = MakeGlobal( llvm::Constant *ObjCStr = MakeGlobal(
VMContext.getStructType(PtrToInt8Ty, PtrToInt8Ty, IntTy, NULL), VMContext.getStructType(PtrToInt8Ty, PtrToInt8Ty, IntTy, NULL),
Ivars, ".objc_str"); Ivars, ".objc_str");
@ -540,7 +540,7 @@ llvm::Constant *CGObjCGNU::GenerateMethodList(const std::string &ClassName,
Methods.clear(); Methods.clear();
Methods.push_back(VMContext.getConstantPointerNull( Methods.push_back(VMContext.getConstantPointerNull(
VMContext.getPointerTypeUnqual(ObjCMethodListTy))); VMContext.getPointerTypeUnqual(ObjCMethodListTy)));
Methods.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, Methods.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty,
MethodTypes.size())); MethodTypes.size()));
Methods.push_back(MethodArray); Methods.push_back(MethodArray);
@ -577,7 +577,7 @@ llvm::Constant *CGObjCGNU::GenerateIvarList(
Elements.clear(); Elements.clear();
Elements.push_back(VMContext.getConstantInt(IntTy, (int)IvarNames.size())); Elements.push_back(llvm::ConstantInt::get(IntTy, (int)IvarNames.size()));
Elements.push_back(VMContext.getConstantArray(ObjCIvarArrayTy, Ivars)); Elements.push_back(VMContext.getConstantArray(ObjCIvarArrayTy, Ivars));
// Structure containing array and array count // Structure containing array and array count
llvm::StructType *ObjCIvarListTy = VMContext.getStructType(IntTy, llvm::StructType *ObjCIvarListTy = VMContext.getStructType(IntTy,
@ -618,7 +618,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
PtrTy, // protocols PtrTy, // protocols
PtrTy, // gc_object_type PtrTy, // gc_object_type
NULL); NULL);
llvm::Constant *Zero = VMContext.getConstantInt(LongTy, 0); llvm::Constant *Zero = llvm::ConstantInt::get(LongTy, 0);
llvm::Constant *NullP = llvm::Constant *NullP =
VMContext.getConstantPointerNull(PtrTy); VMContext.getConstantPointerNull(PtrTy);
// Fill in the structure // Fill in the structure
@ -627,7 +627,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
Elements.push_back(SuperClass); Elements.push_back(SuperClass);
Elements.push_back(MakeConstantString(Name, ".class_name")); Elements.push_back(MakeConstantString(Name, ".class_name"));
Elements.push_back(Zero); Elements.push_back(Zero);
Elements.push_back(VMContext.getConstantInt(LongTy, info)); Elements.push_back(llvm::ConstantInt::get(LongTy, info));
Elements.push_back(InstanceSize); Elements.push_back(InstanceSize);
Elements.push_back(IVars); Elements.push_back(IVars);
Elements.push_back(Methods); Elements.push_back(Methods);
@ -665,7 +665,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolMethodList(
llvm::StructType *ObjCMethodDescListTy = VMContext.getStructType( llvm::StructType *ObjCMethodDescListTy = VMContext.getStructType(
IntTy, ObjCMethodArrayTy, NULL); IntTy, ObjCMethodArrayTy, NULL);
Methods.clear(); Methods.clear();
Methods.push_back(VMContext.getConstantInt(IntTy, MethodNames.size())); Methods.push_back(llvm::ConstantInt::get(IntTy, MethodNames.size()));
Methods.push_back(Array); Methods.push_back(Array);
return MakeGlobal(ObjCMethodDescListTy, Methods, ".objc_method_list"); return MakeGlobal(ObjCMethodDescListTy, Methods, ".objc_method_list");
} }
@ -693,7 +693,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList(
Elements); Elements);
Elements.clear(); Elements.clear();
Elements.push_back(NULLPtr); Elements.push_back(NULLPtr);
Elements.push_back(VMContext.getConstantInt(LongTy, Protocols.size())); Elements.push_back(llvm::ConstantInt::get(LongTy, Protocols.size()));
Elements.push_back(ProtocolArray); Elements.push_back(ProtocolArray);
return MakeGlobal(ProtocolListTy, Elements, ".objc_protocol_list"); return MakeGlobal(ProtocolListTy, Elements, ".objc_protocol_list");
} }
@ -728,7 +728,7 @@ llvm::Constant *CGObjCGNU::GenerateEmptyProtocol(
// The isa pointer must be set to a magic number so the runtime knows it's // The isa pointer must be set to a magic number so the runtime knows it's
// the correct layout. // the correct layout.
Elements.push_back(VMContext.getConstantExprIntToPtr( Elements.push_back(VMContext.getConstantExprIntToPtr(
VMContext.getConstantInt(llvm::Type::Int32Ty, ProtocolVersion), IdTy)); llvm::ConstantInt::get(llvm::Type::Int32Ty, ProtocolVersion), IdTy));
Elements.push_back(MakeConstantString(ProtocolName, ".objc_protocol_name")); Elements.push_back(MakeConstantString(ProtocolName, ".objc_protocol_name"));
Elements.push_back(ProtocolList); Elements.push_back(ProtocolList);
Elements.push_back(InstanceMethodList); Elements.push_back(InstanceMethodList);
@ -783,7 +783,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
// The isa pointer must be set to a magic number so the runtime knows it's // The isa pointer must be set to a magic number so the runtime knows it's
// the correct layout. // the correct layout.
Elements.push_back(VMContext.getConstantExprIntToPtr( Elements.push_back(VMContext.getConstantExprIntToPtr(
VMContext.getConstantInt(llvm::Type::Int32Ty, ProtocolVersion), IdTy)); llvm::ConstantInt::get(llvm::Type::Int32Ty, ProtocolVersion), IdTy));
Elements.push_back(MakeConstantString(ProtocolName, ".objc_protocol_name")); Elements.push_back(MakeConstantString(ProtocolName, ".objc_protocol_name"));
Elements.push_back(ProtocolList); Elements.push_back(ProtocolList);
Elements.push_back(InstanceMethodList); Elements.push_back(InstanceMethodList);
@ -868,10 +868,10 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
std::string classSymbolName = "__objc_class_name_" + ClassName; std::string classSymbolName = "__objc_class_name_" + ClassName;
if (llvm::GlobalVariable *symbol = if (llvm::GlobalVariable *symbol =
TheModule.getGlobalVariable(classSymbolName)) { TheModule.getGlobalVariable(classSymbolName)) {
symbol->setInitializer(VMContext.getConstantInt(LongTy, 0)); symbol->setInitializer(llvm::ConstantInt::get(LongTy, 0));
} else { } else {
new llvm::GlobalVariable(TheModule, LongTy, false, new llvm::GlobalVariable(TheModule, LongTy, false,
llvm::GlobalValue::ExternalLinkage, VMContext.getConstantInt(LongTy, 0), llvm::GlobalValue::ExternalLinkage, llvm::ConstantInt::get(LongTy, 0),
classSymbolName); classSymbolName);
} }
@ -909,7 +909,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
Offset = ComputeIvarBaseOffset(CGM, ClassDecl, *iter); Offset = ComputeIvarBaseOffset(CGM, ClassDecl, *iter);
} }
IvarOffsets.push_back( IvarOffsets.push_back(
VMContext.getConstantInt(llvm::Type::Int32Ty, Offset)); llvm::ConstantInt::get(llvm::Type::Int32Ty, Offset));
} }
// Collect information about instance methods // Collect information about instance methods
@ -986,7 +986,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
llvm::Constant *ClassStruct = llvm::Constant *ClassStruct =
GenerateClassStructure(MetaClassStruct, SuperClass, 0x1L, GenerateClassStructure(MetaClassStruct, SuperClass, 0x1L,
ClassName.c_str(), 0, ClassName.c_str(), 0,
VMContext.getConstantInt(LongTy, instanceSize), IvarList, llvm::ConstantInt::get(LongTy, instanceSize), IvarList,
MethodList, GenerateProtocolList(Protocols)); MethodList, GenerateProtocolList(Protocols));
// Resolve the class aliases, if they exist. // Resolve the class aliases, if they exist.
@ -1087,7 +1087,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
Selectors.push_back(VMContext.getConstantStruct(SelStructTy, Elements)); Selectors.push_back(VMContext.getConstantStruct(SelStructTy, Elements));
Elements.clear(); Elements.clear();
// Number of static selectors // Number of static selectors
Elements.push_back(VMContext.getConstantInt(LongTy, Selectors.size() )); Elements.push_back(llvm::ConstantInt::get(LongTy, Selectors.size() ));
llvm::Constant *SelectorList = MakeGlobal( llvm::Constant *SelectorList = MakeGlobal(
VMContext.getArrayType(SelStructTy, Selectors.size()), Selectors, VMContext.getArrayType(SelStructTy, Selectors.size()), Selectors,
".objc_selector_list"); ".objc_selector_list");
@ -1100,7 +1100,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
iter=TypedSelectors.begin(), iterEnd =TypedSelectors.end(); iter=TypedSelectors.begin(), iterEnd =TypedSelectors.end();
iter != iterEnd; ++iter) { iter != iterEnd; ++iter) {
llvm::Constant *Idxs[] = {Zeros[0], llvm::Constant *Idxs[] = {Zeros[0],
VMContext.getConstantInt(llvm::Type::Int32Ty, index++), Zeros[0]}; llvm::ConstantInt::get(llvm::Type::Int32Ty, index++), Zeros[0]};
llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule, SelStructPtrTy, llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule, SelStructPtrTy,
true, llvm::GlobalValue::InternalLinkage, true, llvm::GlobalValue::InternalLinkage,
VMContext.getConstantExprGetElementPtr(SelectorList, Idxs, 2), VMContext.getConstantExprGetElementPtr(SelectorList, Idxs, 2),
@ -1117,7 +1117,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
iter=UntypedSelectors.begin(), iterEnd = UntypedSelectors.end(); iter=UntypedSelectors.begin(), iterEnd = UntypedSelectors.end();
iter != iterEnd; iter++) { iter != iterEnd; iter++) {
llvm::Constant *Idxs[] = {Zeros[0], llvm::Constant *Idxs[] = {Zeros[0],
VMContext.getConstantInt(llvm::Type::Int32Ty, index++), Zeros[0]}; llvm::ConstantInt::get(llvm::Type::Int32Ty, index++), Zeros[0]};
llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule, SelStructPtrTy, llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule, SelStructPtrTy,
true, llvm::GlobalValue::InternalLinkage, true, llvm::GlobalValue::InternalLinkage,
VMContext.getConstantExprGetElementPtr(SelectorList, Idxs, 2), VMContext.getConstantExprGetElementPtr(SelectorList, Idxs, 2),
@ -1131,10 +1131,10 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
(*iter).second->setAliasee(SelPtr); (*iter).second->setAliasee(SelPtr);
} }
// Number of classes defined. // Number of classes defined.
Elements.push_back(VMContext.getConstantInt(llvm::Type::Int16Ty, Elements.push_back(llvm::ConstantInt::get(llvm::Type::Int16Ty,
Classes.size())); Classes.size()));
// Number of categories defined // Number of categories defined
Elements.push_back(VMContext.getConstantInt(llvm::Type::Int16Ty, Elements.push_back(llvm::ConstantInt::get(llvm::Type::Int16Ty,
Categories.size())); Categories.size()));
// Create an array of classes, then categories, then static object instances // Create an array of classes, then categories, then static object instances
Classes.insert(Classes.end(), Categories.begin(), Categories.end()); Classes.insert(Classes.end(), Categories.begin(), Categories.end());
@ -1153,14 +1153,14 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
Elements.clear(); Elements.clear();
// Runtime version used for compatibility checking. // Runtime version used for compatibility checking.
if (CGM.getContext().getLangOptions().ObjCNonFragileABI) { if (CGM.getContext().getLangOptions().ObjCNonFragileABI) {
Elements.push_back(VMContext.getConstantInt(LongTy, Elements.push_back(llvm::ConstantInt::get(LongTy,
NonFragileRuntimeVersion)); NonFragileRuntimeVersion));
} else { } else {
Elements.push_back(VMContext.getConstantInt(LongTy, RuntimeVersion)); Elements.push_back(llvm::ConstantInt::get(LongTy, RuntimeVersion));
} }
// sizeof(ModuleTy) // sizeof(ModuleTy)
llvm::TargetData td = llvm::TargetData::TargetData(&TheModule); llvm::TargetData td = llvm::TargetData::TargetData(&TheModule);
Elements.push_back(VMContext.getConstantInt(LongTy, Elements.push_back(llvm::ConstantInt::get(LongTy,
td.getTypeSizeInBits(ModuleTy)/8)); td.getTypeSizeInBits(ModuleTy)/8));
//FIXME: Should be the path to the file where this module was declared //FIXME: Should be the path to the file where this module was declared
Elements.push_back(NULLPtr); Elements.push_back(NULLPtr);
@ -1368,7 +1368,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// We use a cleanup unless there was already a catch all. // We use a cleanup unless there was already a catch all.
if (!HasCatchAll) { if (!HasCatchAll) {
ESelArgs.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, 0)); ESelArgs.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
Handlers.push_back(std::make_pair((const ParmVarDecl*) 0, (const Stmt*) 0)); Handlers.push_back(std::make_pair((const ParmVarDecl*) 0, (const Stmt*) 0));
} }
@ -1433,7 +1433,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
ESelArgs.clear(); ESelArgs.clear();
ESelArgs.push_back(Exc); ESelArgs.push_back(Exc);
ESelArgs.push_back(Personality); ESelArgs.push_back(Personality);
ESelArgs.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, 0)); ESelArgs.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
CGF.Builder.CreateCall(llvm_eh_selector, ESelArgs.begin(), ESelArgs.end(), CGF.Builder.CreateCall(llvm_eh_selector, ESelArgs.begin(), ESelArgs.end(),
"selector"); "selector");
CGF.Builder.CreateCall(llvm_eh_typeid_for, CGF.Builder.CreateCall(llvm_eh_typeid_for,
@ -1572,7 +1572,7 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
if (!IvarOffsetGV) { if (!IvarOffsetGV) {
uint64_t Offset = ComputeIvarBaseOffset(CGM, ID, Ivar); uint64_t Offset = ComputeIvarBaseOffset(CGM, ID, Ivar);
llvm::ConstantInt *OffsetGuess = llvm::ConstantInt *OffsetGuess =
VMContext.getConstantInt(LongTy, Offset, "ivar"); llvm::ConstantInt::get(LongTy, Offset, "ivar");
IvarOffsetGV = new llvm::GlobalVariable(TheModule, LongTy, false, IvarOffsetGV = new llvm::GlobalVariable(TheModule, LongTy, false,
llvm::GlobalValue::CommonLinkage, OffsetGuess, Name); llvm::GlobalValue::CommonLinkage, OffsetGuess, Name);
} }
@ -1615,7 +1615,7 @@ llvm::Value *CGObjCGNU::EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
false, "ivar"); false, "ivar");
} }
uint64_t Offset = ComputeIvarBaseOffset(CGF.CGM, Interface, Ivar); uint64_t Offset = ComputeIvarBaseOffset(CGF.CGM, Interface, Ivar);
return VMContext.getConstantInt(LongTy, Offset, "ivar"); return llvm::ConstantInt::get(LongTy, Offset, "ivar");
} }
CodeGen::CGObjCRuntime *CodeGen::CreateGNUObjCRuntime(CodeGen::CodeGenModule &CGM){ CodeGen::CGObjCRuntime *CodeGen::CreateGNUObjCRuntime(CodeGen::CodeGenModule &CGM){

Просмотреть файл

@ -1378,8 +1378,8 @@ static llvm::Constant *getConstantGEP(llvm::LLVMContext &VMContext,
unsigned idx0, unsigned idx0,
unsigned idx1) { unsigned idx1) {
llvm::Value *Idxs[] = { llvm::Value *Idxs[] = {
VMContext.getConstantInt(llvm::Type::Int32Ty, idx0), llvm::ConstantInt::get(llvm::Type::Int32Ty, idx0),
VMContext.getConstantInt(llvm::Type::Int32Ty, idx1) llvm::ConstantInt::get(llvm::Type::Int32Ty, idx1)
}; };
return VMContext.getConstantExprGetElementPtr(C, Idxs, 2); return VMContext.getConstantExprGetElementPtr(C, Idxs, 2);
} }
@ -1711,7 +1711,7 @@ CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD,
uint64_t Size = uint64_t Size =
CGM.getTargetData().getTypeAllocSize(ObjCTypes.ProtocolExtensionTy); CGM.getTargetData().getTypeAllocSize(ObjCTypes.ProtocolExtensionTy);
std::vector<llvm::Constant*> Values(4); std::vector<llvm::Constant*> Values(4);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, Size); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
Values[1] = Values[1] =
EmitMethodDescList("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_OPT_" EmitMethodDescList("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_OPT_"
+ PD->getNameAsString(), + PD->getNameAsString(),
@ -1766,7 +1766,7 @@ CGObjCMac::EmitProtocolList(const std::string &Name,
std::vector<llvm::Constant*> Values(3); std::vector<llvm::Constant*> Values(3);
// This field is only used by the runtime. // This field is only used by the runtime.
Values[0] = VMContext.getNullValue(ObjCTypes.ProtocolListPtrTy); Values[0] = VMContext.getNullValue(ObjCTypes.ProtocolListPtrTy);
Values[1] = VMContext.getConstantInt(ObjCTypes.LongTy, Values[1] = llvm::ConstantInt::get(ObjCTypes.LongTy,
ProtocolRefs.size() - 1); ProtocolRefs.size() - 1);
Values[2] = Values[2] =
VMContext.getConstantArray(VMContext.getArrayType(ObjCTypes.ProtocolPtrTy, VMContext.getConstantArray(VMContext.getArrayType(ObjCTypes.ProtocolPtrTy,
@ -1813,8 +1813,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(const std::string &Name,
unsigned PropertySize = unsigned PropertySize =
CGM.getTargetData().getTypeAllocSize(ObjCTypes.PropertyTy); CGM.getTargetData().getTypeAllocSize(ObjCTypes.PropertyTy);
std::vector<llvm::Constant*> Values(3); std::vector<llvm::Constant*> Values(3);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, PropertySize); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, PropertySize);
Values[1] = VMContext.getConstantInt(ObjCTypes.IntTy, Properties.size()); Values[1] = llvm::ConstantInt::get(ObjCTypes.IntTy, Properties.size());
llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.PropertyTy, llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.PropertyTy,
Properties.size()); Properties.size());
Values[2] = VMContext.getConstantArray(AT, Properties); Values[2] = VMContext.getConstantArray(AT, Properties);
@ -1854,7 +1854,7 @@ llvm::Constant *CGObjCMac::EmitMethodDescList(const std::string &Name,
return VMContext.getNullValue(ObjCTypes.MethodDescriptionListPtrTy); return VMContext.getNullValue(ObjCTypes.MethodDescriptionListPtrTy);
std::vector<llvm::Constant*> Values(2); std::vector<llvm::Constant*> Values(2);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, Methods.size()); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Methods.size());
llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.MethodDescriptionTy, llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.MethodDescriptionTy,
Methods.size()); Methods.size());
Values[1] = VMContext.getConstantArray(AT, Methods); Values[1] = VMContext.getConstantArray(AT, Methods);
@ -1922,7 +1922,7 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
} else { } else {
Values[4] = VMContext.getNullValue(ObjCTypes.ProtocolListPtrTy); Values[4] = VMContext.getNullValue(ObjCTypes.ProtocolListPtrTy);
} }
Values[5] = VMContext.getConstantInt(ObjCTypes.IntTy, Size); Values[5] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
// If there is no category @interface then there can be no properties. // If there is no category @interface then there can be no properties.
if (Category) { if (Category) {
@ -2033,9 +2033,9 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
} }
Values[ 2] = GetClassName(ID->getIdentifier()); Values[ 2] = GetClassName(ID->getIdentifier());
// Version is always 0. // Version is always 0.
Values[ 3] = VMContext.getConstantInt(ObjCTypes.LongTy, 0); Values[ 3] = llvm::ConstantInt::get(ObjCTypes.LongTy, 0);
Values[ 4] = VMContext.getConstantInt(ObjCTypes.LongTy, Flags); Values[ 4] = llvm::ConstantInt::get(ObjCTypes.LongTy, Flags);
Values[ 5] = VMContext.getConstantInt(ObjCTypes.LongTy, Size); Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
Values[ 6] = EmitIvarList(ID, false); Values[ 6] = EmitIvarList(ID, false);
Values[ 7] = Values[ 7] =
EmitMethodList("\01L_OBJC_INSTANCE_METHODS_" + ID->getNameAsString(), EmitMethodList("\01L_OBJC_INSTANCE_METHODS_" + ID->getNameAsString(),
@ -2085,9 +2085,9 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
} }
Values[ 2] = GetClassName(ID->getIdentifier()); Values[ 2] = GetClassName(ID->getIdentifier());
// Version is always 0. // Version is always 0.
Values[ 3] = VMContext.getConstantInt(ObjCTypes.LongTy, 0); Values[ 3] = llvm::ConstantInt::get(ObjCTypes.LongTy, 0);
Values[ 4] = VMContext.getConstantInt(ObjCTypes.LongTy, Flags); Values[ 4] = llvm::ConstantInt::get(ObjCTypes.LongTy, Flags);
Values[ 5] = VMContext.getConstantInt(ObjCTypes.LongTy, Size); Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
Values[ 6] = EmitIvarList(ID, true); Values[ 6] = EmitIvarList(ID, true);
Values[ 7] = Values[ 7] =
EmitMethodList("\01L_OBJC_CLASS_METHODS_" + ID->getNameAsString(), EmitMethodList("\01L_OBJC_CLASS_METHODS_" + ID->getNameAsString(),
@ -2163,7 +2163,7 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID) {
CGM.getTargetData().getTypeAllocSize(ObjCTypes.ClassExtensionTy); CGM.getTargetData().getTypeAllocSize(ObjCTypes.ClassExtensionTy);
std::vector<llvm::Constant*> Values(3); std::vector<llvm::Constant*> Values(3);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, Size); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
Values[1] = BuildIvarLayout(ID, false); Values[1] = BuildIvarLayout(ID, false);
Values[2] = EmitPropertyList("\01l_OBJC_$_PROP_LIST_" + ID->getNameAsString(), Values[2] = EmitPropertyList("\01l_OBJC_$_PROP_LIST_" + ID->getNameAsString(),
ID, ID->getClassInterface(), ObjCTypes); ID, ID->getClassInterface(), ObjCTypes);
@ -2216,7 +2216,7 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
continue; continue;
Ivar[0] = GetMethodVarName(IVD->getIdentifier()); Ivar[0] = GetMethodVarName(IVD->getIdentifier());
Ivar[1] = GetMethodVarType(IVD); Ivar[1] = GetMethodVarType(IVD);
Ivar[2] = VMContext.getConstantInt(ObjCTypes.IntTy, Ivar[2] = llvm::ConstantInt::get(ObjCTypes.IntTy,
ComputeIvarBaseOffset(CGM, OID, IVD)); ComputeIvarBaseOffset(CGM, OID, IVD));
Ivars.push_back(VMContext.getConstantStruct(ObjCTypes.IvarTy, Ivar)); Ivars.push_back(VMContext.getConstantStruct(ObjCTypes.IvarTy, Ivar));
} }
@ -2226,7 +2226,7 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
return VMContext.getNullValue(ObjCTypes.IvarListPtrTy); return VMContext.getNullValue(ObjCTypes.IvarListPtrTy);
std::vector<llvm::Constant*> Values(2); std::vector<llvm::Constant*> Values(2);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, Ivars.size()); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Ivars.size());
llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.IvarTy, llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.IvarTy,
Ivars.size()); Ivars.size());
Values[1] = VMContext.getConstantArray(AT, Ivars); Values[1] = VMContext.getConstantArray(AT, Ivars);
@ -2286,7 +2286,7 @@ llvm::Constant *CGObjCMac::EmitMethodList(const std::string &Name,
std::vector<llvm::Constant*> Values(3); std::vector<llvm::Constant*> Values(3);
Values[0] = VMContext.getNullValue(ObjCTypes.Int8PtrTy); Values[0] = VMContext.getNullValue(ObjCTypes.Int8PtrTy);
Values[1] = VMContext.getConstantInt(ObjCTypes.IntTy, Methods.size()); Values[1] = llvm::ConstantInt::get(ObjCTypes.IntTy, Methods.size());
llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.MethodTy, llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.MethodTy,
Methods.size()); Methods.size());
Values[2] = VMContext.getConstantArray(AT, Methods); Values[2] = VMContext.getConstantArray(AT, Methods);
@ -2784,7 +2784,7 @@ void CGObjCMac::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
unsigned long size) { unsigned long size) {
SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, ObjCTypes.Int8PtrTy); SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, ObjCTypes.Int8PtrTy);
DestPtr = CGF.Builder.CreateBitCast(DestPtr, ObjCTypes.Int8PtrTy); DestPtr = CGF.Builder.CreateBitCast(DestPtr, ObjCTypes.Int8PtrTy);
llvm::Value *N = VMContext.getConstantInt(ObjCTypes.LongTy, size); llvm::Value *N = llvm::ConstantInt::get(ObjCTypes.LongTy, size);
CGF.Builder.CreateCall3(ObjCTypes.GcMemmoveCollectableFn(), CGF.Builder.CreateCall3(ObjCTypes.GcMemmoveCollectableFn(),
DestPtr, SrcPtr, N); DestPtr, SrcPtr, N);
return; return;
@ -2806,7 +2806,7 @@ llvm::Value *CGObjCMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
const ObjCInterfaceDecl *Interface, const ObjCInterfaceDecl *Interface,
const ObjCIvarDecl *Ivar) { const ObjCIvarDecl *Ivar) {
uint64_t Offset = ComputeIvarBaseOffset(CGM, Interface, Ivar); uint64_t Offset = ComputeIvarBaseOffset(CGM, Interface, Ivar);
return VMContext.getConstantInt( return llvm::ConstantInt::get(
CGM.getTypes().ConvertType(CGM.getContext().LongTy), CGM.getTypes().ConvertType(CGM.getContext().LongTy),
Offset); Offset);
} }
@ -2848,8 +2848,8 @@ void CGObjCMac::EmitImageInfo() {
// Emitted as int[2]; // Emitted as int[2];
llvm::Constant *values[2] = { llvm::Constant *values[2] = {
VMContext.getConstantInt(llvm::Type::Int32Ty, version), llvm::ConstantInt::get(llvm::Type::Int32Ty, version),
VMContext.getConstantInt(llvm::Type::Int32Ty, flags) llvm::ConstantInt::get(llvm::Type::Int32Ty, flags)
}; };
llvm::ArrayType *AT = VMContext.getArrayType(llvm::Type::Int32Ty, 2); llvm::ArrayType *AT = VMContext.getArrayType(llvm::Type::Int32Ty, 2);
@ -2882,8 +2882,8 @@ void CGObjCMac::EmitModuleInfo() {
uint64_t Size = CGM.getTargetData().getTypeAllocSize(ObjCTypes.ModuleTy); uint64_t Size = CGM.getTargetData().getTypeAllocSize(ObjCTypes.ModuleTy);
std::vector<llvm::Constant*> Values(4); std::vector<llvm::Constant*> Values(4);
Values[0] = VMContext.getConstantInt(ObjCTypes.LongTy, ModuleVersion); Values[0] = llvm::ConstantInt::get(ObjCTypes.LongTy, ModuleVersion);
Values[1] = VMContext.getConstantInt(ObjCTypes.LongTy, Size); Values[1] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
// This used to be the filename, now it is unused. <rdr://4327263> // This used to be the filename, now it is unused. <rdr://4327263>
Values[2] = GetClassName(&CGM.getContext().Idents.get("")); Values[2] = GetClassName(&CGM.getContext().Idents.get(""));
Values[3] = EmitModuleSymbols(); Values[3] = EmitModuleSymbols();
@ -2902,10 +2902,10 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() {
return VMContext.getNullValue(ObjCTypes.SymtabPtrTy); return VMContext.getNullValue(ObjCTypes.SymtabPtrTy);
std::vector<llvm::Constant*> Values(5); std::vector<llvm::Constant*> Values(5);
Values[0] = VMContext.getConstantInt(ObjCTypes.LongTy, 0); Values[0] = llvm::ConstantInt::get(ObjCTypes.LongTy, 0);
Values[1] = VMContext.getNullValue(ObjCTypes.SelectorPtrTy); Values[1] = VMContext.getNullValue(ObjCTypes.SelectorPtrTy);
Values[2] = VMContext.getConstantInt(ObjCTypes.ShortTy, NumClasses); Values[2] = llvm::ConstantInt::get(ObjCTypes.ShortTy, NumClasses);
Values[3] = VMContext.getConstantInt(ObjCTypes.ShortTy, NumCategories); Values[3] = llvm::ConstantInt::get(ObjCTypes.ShortTy, NumCategories);
// The runtime expects exactly the list of defined classes followed // The runtime expects exactly the list of defined classes followed
// by the list of defined categories, in a single array. // by the list of defined categories, in a single array.
@ -4106,14 +4106,14 @@ void CGObjCNonFragileABIMac::FinishNonFragileABIModule() {
// static int L_OBJC_IMAGE_INFO[2] = { 0, flags }; // static int L_OBJC_IMAGE_INFO[2] = { 0, flags };
// FIXME. flags can be 0 | 1 | 2 | 6. For now just use 0 // FIXME. flags can be 0 | 1 | 2 | 6. For now just use 0
std::vector<llvm::Constant*> Values(2); std::vector<llvm::Constant*> Values(2);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, 0); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, 0);
unsigned int flags = 0; unsigned int flags = 0;
// FIXME: Fix and continue? // FIXME: Fix and continue?
if (CGM.getLangOptions().getGCMode() != LangOptions::NonGC) if (CGM.getLangOptions().getGCMode() != LangOptions::NonGC)
flags |= eImageInfo_GarbageCollected; flags |= eImageInfo_GarbageCollected;
if (CGM.getLangOptions().getGCMode() == LangOptions::GCOnly) if (CGM.getLangOptions().getGCMode() == LangOptions::GCOnly)
flags |= eImageInfo_GCOnly; flags |= eImageInfo_GCOnly;
Values[1] = VMContext.getConstantInt(ObjCTypes.IntTy, flags); Values[1] = llvm::ConstantInt::get(ObjCTypes.IntTy, flags);
llvm::Constant* Init = VMContext.getConstantArray( llvm::Constant* Init = VMContext.getConstantArray(
VMContext.getArrayType(ObjCTypes.IntTy, 2), VMContext.getArrayType(ObjCTypes.IntTy, 2),
Values); Values);
@ -4195,9 +4195,9 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
const ObjCImplementationDecl *ID) { const ObjCImplementationDecl *ID) {
std::string ClassName = ID->getNameAsString(); std::string ClassName = ID->getNameAsString();
std::vector<llvm::Constant*> Values(10); // 11 for 64bit targets! std::vector<llvm::Constant*> Values(10); // 11 for 64bit targets!
Values[ 0] = VMContext.getConstantInt(ObjCTypes.IntTy, flags); Values[ 0] = llvm::ConstantInt::get(ObjCTypes.IntTy, flags);
Values[ 1] = VMContext.getConstantInt(ObjCTypes.IntTy, InstanceStart); Values[ 1] = llvm::ConstantInt::get(ObjCTypes.IntTy, InstanceStart);
Values[ 2] = VMContext.getConstantInt(ObjCTypes.IntTy, InstanceSize); Values[ 2] = llvm::ConstantInt::get(ObjCTypes.IntTy, InstanceSize);
// FIXME. For 64bit targets add 0 here. // FIXME. For 64bit targets add 0 here.
Values[ 3] = (flags & CLS_META) ? GetIvarLayoutName(0, ObjCTypes) Values[ 3] = (flags & CLS_META) ? GetIvarLayoutName(0, ObjCTypes)
: BuildIvarLayout(ID, true); : BuildIvarLayout(ID, true);
@ -4591,9 +4591,9 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitMethodList(
std::vector<llvm::Constant*> Values(3); std::vector<llvm::Constant*> Values(3);
// sizeof(struct _objc_method) // sizeof(struct _objc_method)
unsigned Size = CGM.getTargetData().getTypeAllocSize(ObjCTypes.MethodTy); unsigned Size = CGM.getTargetData().getTypeAllocSize(ObjCTypes.MethodTy);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, Size); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
// method_count // method_count
Values[1] = VMContext.getConstantInt(ObjCTypes.IntTy, Methods.size()); Values[1] = llvm::ConstantInt::get(ObjCTypes.IntTy, Methods.size());
llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.MethodTy, llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.MethodTy,
Methods.size()); Methods.size());
Values[2] = VMContext.getConstantArray(AT, Methods); Values[2] = VMContext.getConstantArray(AT, Methods);
@ -4641,7 +4641,7 @@ llvm::Constant * CGObjCNonFragileABIMac::EmitIvarOffsetVar(
const ObjCIvarDecl *Ivar, const ObjCIvarDecl *Ivar,
unsigned long int Offset) { unsigned long int Offset) {
llvm::GlobalVariable *IvarOffsetGV = ObjCIvarOffsetVariable(ID, Ivar); llvm::GlobalVariable *IvarOffsetGV = ObjCIvarOffsetVariable(ID, Ivar);
IvarOffsetGV->setInitializer(VMContext.getConstantInt(ObjCTypes.LongTy, IvarOffsetGV->setInitializer(llvm::ConstantInt::get(ObjCTypes.LongTy,
Offset)); Offset));
IvarOffsetGV->setAlignment( IvarOffsetGV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.LongTy)); CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.LongTy));
@ -4704,13 +4704,13 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
unsigned Align = CGM.getContext().getPreferredTypeAlign( unsigned Align = CGM.getContext().getPreferredTypeAlign(
IVD->getType().getTypePtr()) >> 3; IVD->getType().getTypePtr()) >> 3;
Align = llvm::Log2_32(Align); Align = llvm::Log2_32(Align);
Ivar[3] = VMContext.getConstantInt(ObjCTypes.IntTy, Align); Ivar[3] = llvm::ConstantInt::get(ObjCTypes.IntTy, Align);
// NOTE. Size of a bitfield does not match gcc's, because of the // NOTE. Size of a bitfield does not match gcc's, because of the
// way bitfields are treated special in each. But I am told that // way bitfields are treated special in each. But I am told that
// 'size' for bitfield ivars is ignored by the runtime so it does // 'size' for bitfield ivars is ignored by the runtime so it does
// not matter. If it matters, there is enough info to get the // not matter. If it matters, there is enough info to get the
// bitfield right! // bitfield right!
Ivar[4] = VMContext.getConstantInt(ObjCTypes.IntTy, Size); Ivar[4] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
Ivars.push_back(VMContext.getConstantStruct(ObjCTypes.IvarnfABITy, Ivar)); Ivars.push_back(VMContext.getConstantStruct(ObjCTypes.IvarnfABITy, Ivar));
} }
// Return null for empty list. // Return null for empty list.
@ -4718,8 +4718,8 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
return VMContext.getNullValue(ObjCTypes.IvarListnfABIPtrTy); return VMContext.getNullValue(ObjCTypes.IvarListnfABIPtrTy);
std::vector<llvm::Constant*> Values(3); std::vector<llvm::Constant*> Values(3);
unsigned Size = CGM.getTargetData().getTypeAllocSize(ObjCTypes.IvarnfABITy); unsigned Size = CGM.getTargetData().getTypeAllocSize(ObjCTypes.IvarnfABITy);
Values[0] = VMContext.getConstantInt(ObjCTypes.IntTy, Size); Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
Values[1] = VMContext.getConstantInt(ObjCTypes.IntTy, Ivars.size()); Values[1] = llvm::ConstantInt::get(ObjCTypes.IntTy, Ivars.size());
llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.IvarnfABITy, llvm::ArrayType *AT = VMContext.getArrayType(ObjCTypes.IvarnfABITy,
Ivars.size()); Ivars.size());
Values[2] = VMContext.getConstantArray(AT, Ivars); Values[2] = VMContext.getConstantArray(AT, Ivars);
@ -4838,7 +4838,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
0, PD, ObjCTypes); 0, PD, ObjCTypes);
uint32_t Size = uint32_t Size =
CGM.getTargetData().getTypeAllocSize(ObjCTypes.ProtocolnfABITy); CGM.getTargetData().getTypeAllocSize(ObjCTypes.ProtocolnfABITy);
Values[8] = VMContext.getConstantInt(ObjCTypes.IntTy, Size); Values[8] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
Values[9] = VMContext.getNullValue(ObjCTypes.IntTy); Values[9] = VMContext.getNullValue(ObjCTypes.IntTy);
llvm::Constant *Init = VMContext.getConstantStruct(ObjCTypes.ProtocolnfABITy, llvm::Constant *Init = VMContext.getConstantStruct(ObjCTypes.ProtocolnfABITy,
Values); Values);
@ -4910,7 +4910,7 @@ CGObjCNonFragileABIMac::EmitProtocolList(const std::string &Name,
std::vector<llvm::Constant*> Values(2); std::vector<llvm::Constant*> Values(2);
Values[0] = Values[0] =
VMContext.getConstantInt(ObjCTypes.LongTy, ProtocolRefs.size() - 1); llvm::ConstantInt::get(ObjCTypes.LongTy, ProtocolRefs.size() - 1);
Values[1] = Values[1] =
VMContext.getConstantArray( VMContext.getConstantArray(
VMContext.getArrayType(ObjCTypes.ProtocolnfABIPtrTy, VMContext.getArrayType(ObjCTypes.ProtocolnfABIPtrTy,
@ -5319,7 +5319,7 @@ void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable(
unsigned long size) { unsigned long size) {
SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, ObjCTypes.Int8PtrTy); SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, ObjCTypes.Int8PtrTy);
DestPtr = CGF.Builder.CreateBitCast(DestPtr, ObjCTypes.Int8PtrTy); DestPtr = CGF.Builder.CreateBitCast(DestPtr, ObjCTypes.Int8PtrTy);
llvm::Value *N = VMContext.getConstantInt(ObjCTypes.LongTy, size); llvm::Value *N = llvm::ConstantInt::get(ObjCTypes.LongTy, size);
CGF.Builder.CreateCall3(ObjCTypes.GcMemmoveCollectableFn(), CGF.Builder.CreateCall3(ObjCTypes.GcMemmoveCollectableFn(),
DestPtr, SrcPtr, N); DestPtr, SrcPtr, N);
return; return;
@ -5482,7 +5482,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// We use a cleanup unless there was already a catch all. // We use a cleanup unless there was already a catch all.
if (!HasCatchAll) { if (!HasCatchAll) {
SelectorArgs.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, 0)); SelectorArgs.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
Handlers.push_back(std::make_pair((const ParmVarDecl*) 0, (const Stmt*) 0)); Handlers.push_back(std::make_pair((const ParmVarDecl*) 0, (const Stmt*) 0));
} }
@ -5552,7 +5552,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
llvm::SmallVector<llvm::Value*, 8> Args; llvm::SmallVector<llvm::Value*, 8> Args;
Args.push_back(Exc); Args.push_back(Exc);
Args.push_back(ObjCTypes.getEHPersonalityPtr()); Args.push_back(ObjCTypes.getEHPersonalityPtr());
Args.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, Args.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty,
0)); 0));
CGF.Builder.CreateCall(llvm_eh_selector_i64, Args.begin(), Args.end()); CGF.Builder.CreateCall(llvm_eh_selector_i64, Args.begin(), Args.end());
CGF.Builder.CreateStore(Exc, RethrowPtr); CGF.Builder.CreateStore(Exc, RethrowPtr);
@ -5584,7 +5584,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
Args.clear(); Args.clear();
Args.push_back(Exc); Args.push_back(Exc);
Args.push_back(ObjCTypes.getEHPersonalityPtr()); Args.push_back(ObjCTypes.getEHPersonalityPtr());
Args.push_back(VMContext.getConstantInt(llvm::Type::Int32Ty, Args.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty,
0)); 0));
CGF.Builder.CreateCall(llvm_eh_selector_i64, Args.begin(), Args.end()); CGF.Builder.CreateCall(llvm_eh_selector_i64, Args.begin(), Args.end());
CGF.Builder.CreateStore(Exc, RethrowPtr); CGF.Builder.CreateStore(Exc, RethrowPtr);
@ -5697,7 +5697,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, VTableName); 0, VTableName);
llvm::Value *VTableIdx = VMContext.getConstantInt(llvm::Type::Int32Ty, 2); llvm::Value *VTableIdx = llvm::ConstantInt::get(llvm::Type::Int32Ty, 2);
std::vector<llvm::Constant*> Values(3); std::vector<llvm::Constant*> Values(3);
Values[0] = VMContext.getConstantExprGetElementPtr(VTableGV, &VTableIdx, 1); Values[0] = VMContext.getConstantExprGetElementPtr(VTableGV, &VTableIdx, 1);

Просмотреть файл

@ -597,7 +597,7 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) {
if (Range.ult(llvm::APInt(Range.getBitWidth(), 64))) { if (Range.ult(llvm::APInt(Range.getBitWidth(), 64))) {
// Range is small enough to add multiple switch instruction cases. // Range is small enough to add multiple switch instruction cases.
for (unsigned i = 0, e = Range.getZExtValue() + 1; i != e; ++i) { for (unsigned i = 0, e = Range.getZExtValue() + 1; i != e; ++i) {
SwitchInsn->addCase(VMContext.getConstantInt(LHS), CaseDest); SwitchInsn->addCase(llvm::ConstantInt::get(VMContext, LHS), CaseDest);
LHS++; LHS++;
} }
return; return;
@ -618,10 +618,11 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) {
// Emit range check. // Emit range check.
llvm::Value *Diff = llvm::Value *Diff =
Builder.CreateSub(SwitchInsn->getCondition(), VMContext.getConstantInt(LHS), Builder.CreateSub(SwitchInsn->getCondition(),
"tmp"); llvm::ConstantInt::get(VMContext, LHS), "tmp");
llvm::Value *Cond = llvm::Value *Cond =
Builder.CreateICmpULE(Diff, VMContext.getConstantInt(Range), "tmp"); Builder.CreateICmpULE(Diff,
llvm::ConstantInt::get(VMContext, Range), "tmp");
Builder.CreateCondBr(Cond, CaseDest, FalseDest); Builder.CreateCondBr(Cond, CaseDest, FalseDest);
// Restore the appropriate insertion point. // Restore the appropriate insertion point.
@ -640,7 +641,7 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
EmitBlock(createBasicBlock("sw.bb")); EmitBlock(createBasicBlock("sw.bb"));
llvm::BasicBlock *CaseDest = Builder.GetInsertBlock(); llvm::BasicBlock *CaseDest = Builder.GetInsertBlock();
llvm::APSInt CaseVal = S.getLHS()->EvaluateAsInt(getContext()); llvm::APSInt CaseVal = S.getLHS()->EvaluateAsInt(getContext());
SwitchInsn->addCase(VMContext.getConstantInt(CaseVal), CaseDest); SwitchInsn->addCase(llvm::ConstantInt::get(VMContext, CaseVal), CaseDest);
// Recursively emitting the statement is acceptable, but is not wonderful for // Recursively emitting the statement is acceptable, but is not wonderful for
// code where we have many case statements nested together, i.e.: // code where we have many case statements nested together, i.e.:
@ -658,7 +659,7 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
while (NextCase && NextCase->getRHS() == 0) { while (NextCase && NextCase->getRHS() == 0) {
CurCase = NextCase; CurCase = NextCase;
CaseVal = CurCase->getLHS()->EvaluateAsInt(getContext()); CaseVal = CurCase->getLHS()->EvaluateAsInt(getContext());
SwitchInsn->addCase(VMContext.getConstantInt(CaseVal), CaseDest); SwitchInsn->addCase(llvm::ConstantInt::get(VMContext, CaseVal), CaseDest);
NextCase = dyn_cast<CaseStmt>(CurCase->getSubStmt()); NextCase = dyn_cast<CaseStmt>(CurCase->getSubStmt());
} }

Просмотреть файл

@ -420,8 +420,8 @@ void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty) {
Builder.CreateCall4(CGM.getMemSetFn(), DestPtr, Builder.CreateCall4(CGM.getMemSetFn(), DestPtr,
getLLVMContext().getNullValue(llvm::Type::Int8Ty), getLLVMContext().getNullValue(llvm::Type::Int8Ty),
// TypeInfo.first describes size in bits. // TypeInfo.first describes size in bits.
VMContext.getConstantInt(IntPtr, TypeInfo.first/8), llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::ConstantInt::get(llvm::Type::Int32Ty,
TypeInfo.second/8)); TypeInfo.second/8));
} }
@ -447,7 +447,7 @@ void CodeGenFunction::EmitIndirectSwitches() {
I->setSuccessor(0, Default); I->setSuccessor(0, Default);
for (std::map<const LabelStmt*,unsigned>::iterator LI = LabelIDs.begin(), for (std::map<const LabelStmt*,unsigned>::iterator LI = LabelIDs.begin(),
LE = LabelIDs.end(); LI != LE; ++LI) { LE = LabelIDs.end(); LI != LE; ++LI) {
I->addCase(VMContext.getConstantInt(llvm::Type::Int32Ty, I->addCase(llvm::ConstantInt::get(llvm::Type::Int32Ty,
LI->second), LI->second),
getBasicBlockForLabel(LI->first)); getBasicBlockForLabel(LI->first));
} }
@ -481,7 +481,7 @@ llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty) {
if (ElemTy->isVariableArrayType()) if (ElemTy->isVariableArrayType())
ElemSize = EmitVLASize(ElemTy); ElemSize = EmitVLASize(ElemTy);
else { else {
ElemSize = VMContext.getConstantInt(SizeTy, ElemSize = llvm::ConstantInt::get(SizeTy,
getContext().getTypeSize(ElemTy) / 8); getContext().getTypeSize(ElemTy) / 8);
} }
@ -600,13 +600,13 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
// Check if we already have a destination for this block. // Check if we already have a destination for this block.
if (Dest == SI->getDefaultDest()) if (Dest == SI->getDefaultDest())
ID = VMContext.getConstantInt(llvm::Type::Int32Ty, 0); ID = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
else { else {
ID = SI->findCaseDest(Dest); ID = SI->findCaseDest(Dest);
if (!ID) { if (!ID) {
// No code found, get a new unique one by using the number of // No code found, get a new unique one by using the number of
// switch successors. // switch successors.
ID = VMContext.getConstantInt(llvm::Type::Int32Ty, ID = llvm::ConstantInt::get(llvm::Type::Int32Ty,
SI->getNumSuccessors()); SI->getNumSuccessors());
SI->addCase(ID, Dest); SI->addCase(ID, Dest);
} }
@ -623,7 +623,7 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
llvm::BasicBlock *CleanupPad = createBasicBlock("cleanup.pad", CurFn); llvm::BasicBlock *CleanupPad = createBasicBlock("cleanup.pad", CurFn);
// Create a unique case ID. // Create a unique case ID.
llvm::ConstantInt *ID = VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::ConstantInt *ID = llvm::ConstantInt::get(llvm::Type::Int32Ty,
SI->getNumSuccessors()); SI->getNumSuccessors());
// Store the jump destination before the branch instruction. // Store the jump destination before the branch instruction.

Просмотреть файл

@ -211,7 +211,7 @@ void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) {
for (CtorList::const_iterator I = Fns.begin(), E = Fns.end(); I != E; ++I) { for (CtorList::const_iterator I = Fns.begin(), E = Fns.end(); I != E; ++I) {
std::vector<llvm::Constant*> S; std::vector<llvm::Constant*> S;
S.push_back( S.push_back(
VMContext.getConstantInt(llvm::Type::Int32Ty, I->second, false)); llvm::ConstantInt::get(llvm::Type::Int32Ty, I->second, false));
S.push_back(VMContext.getConstantExprBitCast(I->first, CtorPFTy)); S.push_back(VMContext.getConstantExprBitCast(I->first, CtorPFTy));
Ctors.push_back(VMContext.getConstantStruct(CtorStructTy, S)); Ctors.push_back(VMContext.getConstantStruct(CtorStructTy, S));
} }
@ -505,7 +505,7 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
VMContext.getConstantExprBitCast(GV, SBP), VMContext.getConstantExprBitCast(GV, SBP),
VMContext.getConstantExprBitCast(annoGV, SBP), VMContext.getConstantExprBitCast(annoGV, SBP),
VMContext.getConstantExprBitCast(unitGV, SBP), VMContext.getConstantExprBitCast(unitGV, SBP),
VMContext.getConstantInt(llvm::Type::Int32Ty, LineNo) llvm::ConstantInt::get(llvm::Type::Int32Ty, LineNo)
}; };
return VMContext.getConstantStruct(Fields, 4, false); return VMContext.getConstantStruct(Fields, 4, false);
} }
@ -1294,8 +1294,8 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
NextField = *Field++; NextField = *Field++;
const llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy); const llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy);
appendFieldAndPadding(*this, Fields, CurField, NextField, appendFieldAndPadding(*this, Fields, CurField, NextField,
isUTF16 ? VMContext.getConstantInt(Ty, 0x07d0) isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0)
: VMContext.getConstantInt(Ty, 0x07C8), : llvm::ConstantInt::get(Ty, 0x07C8),
CFRD, STy); CFRD, STy);
// String pointer. // String pointer.
@ -1339,7 +1339,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
NextField = 0; NextField = 0;
Ty = getTypes().ConvertType(getContext().LongTy); Ty = getTypes().ConvertType(getContext().LongTy);
appendFieldAndPadding(*this, Fields, CurField, NextField, appendFieldAndPadding(*this, Fields, CurField, NextField,
VMContext.getConstantInt(Ty, StringLength), CFRD, STy); llvm::ConstantInt::get(Ty, StringLength), CFRD, STy);
// The struct. // The struct.
C = VMContext.getConstantStruct(STy, Fields); C = VMContext.getConstantStruct(STy, Fields);

Просмотреть файл

@ -440,7 +440,7 @@ llvm::Value *X86_32ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
llvm::RoundUpToAlignment(CGF.getContext().getTypeSize(Ty) / 8, 4); llvm::RoundUpToAlignment(CGF.getContext().getTypeSize(Ty) / 8, 4);
llvm::Value *NextAddr = llvm::Value *NextAddr =
Builder.CreateGEP(Addr, Builder.CreateGEP(Addr,
VMContext.getConstantInt(llvm::Type::Int32Ty, Offset), llvm::ConstantInt::get(llvm::Type::Int32Ty, Offset),
"ap.next"); "ap.next");
Builder.CreateStore(NextAddr, VAListAddrAsBPP); Builder.CreateStore(NextAddr, VAListAddrAsBPP);
@ -1062,11 +1062,11 @@ static llvm::Value *EmitVAArgFromMemory(llvm::Value *VAListAddr,
// shouldn't ever matter in practice. // shouldn't ever matter in practice.
// overflow_arg_area = (overflow_arg_area + 15) & ~15; // overflow_arg_area = (overflow_arg_area + 15) & ~15;
llvm::Value *Offset = VMContext.getConstantInt(llvm::Type::Int32Ty, 15); llvm::Value *Offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, 15);
overflow_arg_area = CGF.Builder.CreateGEP(overflow_arg_area, Offset); overflow_arg_area = CGF.Builder.CreateGEP(overflow_arg_area, Offset);
llvm::Value *AsInt = CGF.Builder.CreatePtrToInt(overflow_arg_area, llvm::Value *AsInt = CGF.Builder.CreatePtrToInt(overflow_arg_area,
llvm::Type::Int64Ty); llvm::Type::Int64Ty);
llvm::Value *Mask = VMContext.getConstantInt(llvm::Type::Int64Ty, ~15LL); llvm::Value *Mask = llvm::ConstantInt::get(llvm::Type::Int64Ty, ~15LL);
overflow_arg_area = overflow_arg_area =
CGF.Builder.CreateIntToPtr(CGF.Builder.CreateAnd(AsInt, Mask), CGF.Builder.CreateIntToPtr(CGF.Builder.CreateAnd(AsInt, Mask),
overflow_arg_area->getType(), overflow_arg_area->getType(),
@ -1085,7 +1085,7 @@ static llvm::Value *EmitVAArgFromMemory(llvm::Value *VAListAddr,
// an 8 byte boundary. // an 8 byte boundary.
uint64_t SizeInBytes = (CGF.getContext().getTypeSize(Ty) + 7) / 8; uint64_t SizeInBytes = (CGF.getContext().getTypeSize(Ty) + 7) / 8;
llvm::Value *Offset = VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::Value *Offset = llvm::ConstantInt::get(llvm::Type::Int32Ty,
(SizeInBytes + 7) & ~7); (SizeInBytes + 7) & ~7);
overflow_arg_area = CGF.Builder.CreateGEP(overflow_arg_area, Offset, overflow_arg_area = CGF.Builder.CreateGEP(overflow_arg_area, Offset,
"overflow_arg_area.next"); "overflow_arg_area.next");
@ -1134,7 +1134,7 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
gp_offset = CGF.Builder.CreateLoad(gp_offset_p, "gp_offset"); gp_offset = CGF.Builder.CreateLoad(gp_offset_p, "gp_offset");
InRegs = InRegs =
CGF.Builder.CreateICmpULE(gp_offset, CGF.Builder.CreateICmpULE(gp_offset,
VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::ConstantInt::get(llvm::Type::Int32Ty,
48 - neededInt * 8), 48 - neededInt * 8),
"fits_in_gp"); "fits_in_gp");
} }
@ -1144,7 +1144,7 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
fp_offset = CGF.Builder.CreateLoad(fp_offset_p, "fp_offset"); fp_offset = CGF.Builder.CreateLoad(fp_offset_p, "fp_offset");
llvm::Value *FitsInFP = llvm::Value *FitsInFP =
CGF.Builder.CreateICmpULE(fp_offset, CGF.Builder.CreateICmpULE(fp_offset,
VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::ConstantInt::get(llvm::Type::Int32Ty,
176 - neededSSE * 16), 176 - neededSSE * 16),
"fits_in_fp"); "fits_in_fp");
InRegs = InRegs ? CGF.Builder.CreateAnd(InRegs, FitsInFP) : FitsInFP; InRegs = InRegs ? CGF.Builder.CreateAnd(InRegs, FitsInFP) : FitsInFP;
@ -1213,7 +1213,7 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
llvm::Value *RegAddrLo = CGF.Builder.CreateGEP(RegAddr, fp_offset); llvm::Value *RegAddrLo = CGF.Builder.CreateGEP(RegAddr, fp_offset);
llvm::Value *RegAddrHi = llvm::Value *RegAddrHi =
CGF.Builder.CreateGEP(RegAddrLo, CGF.Builder.CreateGEP(RegAddrLo,
VMContext.getConstantInt(llvm::Type::Int32Ty, 16)); llvm::ConstantInt::get(llvm::Type::Int32Ty, 16));
const llvm::Type *DblPtrTy = const llvm::Type *DblPtrTy =
VMContext.getPointerTypeUnqual(llvm::Type::DoubleTy); VMContext.getPointerTypeUnqual(llvm::Type::DoubleTy);
const llvm::StructType *ST = VMContext.getStructType(llvm::Type::DoubleTy, const llvm::StructType *ST = VMContext.getStructType(llvm::Type::DoubleTy,
@ -1235,13 +1235,13 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
// l->gp_offset = l->gp_offset + num_gp * 8 // l->gp_offset = l->gp_offset + num_gp * 8
// l->fp_offset = l->fp_offset + num_fp * 16. // l->fp_offset = l->fp_offset + num_fp * 16.
if (neededInt) { if (neededInt) {
llvm::Value *Offset = VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::Value *Offset = llvm::ConstantInt::get(llvm::Type::Int32Ty,
neededInt * 8); neededInt * 8);
CGF.Builder.CreateStore(CGF.Builder.CreateAdd(gp_offset, Offset), CGF.Builder.CreateStore(CGF.Builder.CreateAdd(gp_offset, Offset),
gp_offset_p); gp_offset_p);
} }
if (neededSSE) { if (neededSSE) {
llvm::Value *Offset = VMContext.getConstantInt(llvm::Type::Int32Ty, llvm::Value *Offset = llvm::ConstantInt::get(llvm::Type::Int32Ty,
neededSSE * 16); neededSSE * 16);
CGF.Builder.CreateStore(CGF.Builder.CreateAdd(fp_offset, Offset), CGF.Builder.CreateStore(CGF.Builder.CreateAdd(fp_offset, Offset),
fp_offset_p); fp_offset_p);
@ -1399,7 +1399,7 @@ llvm::Value *ARMABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
llvm::RoundUpToAlignment(CGF.getContext().getTypeSize(Ty) / 8, 4); llvm::RoundUpToAlignment(CGF.getContext().getTypeSize(Ty) / 8, 4);
llvm::Value *NextAddr = llvm::Value *NextAddr =
Builder.CreateGEP(Addr, Builder.CreateGEP(Addr,
VMContext.getConstantInt(llvm::Type::Int32Ty, Offset), llvm::ConstantInt::get(llvm::Type::Int32Ty, Offset),
"ap.next"); "ap.next");
Builder.CreateStore(NextAddr, VAListAddrAsBPP); Builder.CreateStore(NextAddr, VAListAddrAsBPP);