diff options
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index f250bac63e..638d83ecb0 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -63,9 +63,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Expr::EvalResult Result; if (E->Evaluate(Result, CGM.getContext())) { if (Result.Val.isInt()) - return RValue::get(llvm::ConstantInt::get(Result.Val.getInt())); + return RValue::get(VMContext.getConstantInt(Result.Val.getInt())); else if (Result.Val.isFloat()) - return RValue::get(llvm::ConstantFP::get(Result.Val.getFloat())); + return RValue::get(VMContext.getConstantFP(Result.Val.getFloat())); } switch (BuiltinID) { @@ -77,7 +77,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BI__builtin_va_end: { Value *ArgValue = EmitVAListRef(E->getArg(0)); const llvm::Type *DestType = - llvm::PointerType::getUnqual(llvm::Type::Int8Ty); + VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); if (ArgValue->getType() != DestType) ArgValue = Builder.CreateBitCast(ArgValue, DestType, ArgValue->getNameStart()); @@ -91,7 +91,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Value *SrcPtr = EmitVAListRef(E->getArg(1)); const llvm::Type *Type = - llvm::PointerType::getUnqual(llvm::Type::Int8Ty); + VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); DstPtr = Builder.CreateBitCast(DstPtr, Type); SrcPtr = Builder.CreateBitCast(SrcPtr, Type); @@ -104,7 +104,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Value *NegOp = Builder.CreateNeg(ArgValue, "neg"); Value *CmpResult = Builder.CreateICmpSGE(ArgValue, - getLLVMContext().getNullValue(ArgValue->getType()), + VMContext.getNullValue(ArgValue->getType()), "abscond"); Value *Result = Builder.CreateSelect(CmpResult, ArgValue, NegOp, "abs"); @@ -150,8 +150,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, const llvm::Type *ResultType = ConvertType(E->getType()); Value *Tmp = Builder.CreateAdd(Builder.CreateCall(F, ArgValue, "tmp"), - ConstantInt::get(ArgType, 1), "tmp"); - Value *Zero = getLLVMContext().getNullValue(ArgType); + VMContext.getConstantInt(ArgType, 1), "tmp"); + Value *Zero = VMContext.getNullValue(ArgType); Value *IsZero = Builder.CreateICmpEQ(ArgValue, Zero, "iszero"); Value *Result = Builder.CreateSelect(IsZero, Zero, Tmp, "ffs"); if (Result->getType() != ResultType) @@ -169,7 +169,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, const llvm::Type *ResultType = ConvertType(E->getType()); Value *Tmp = Builder.CreateCall(F, ArgValue, "tmp"); - Value *Result = Builder.CreateAnd(Tmp, ConstantInt::get(ArgType, 1), + Value *Result = Builder.CreateAnd(Tmp, VMContext.getConstantInt(ArgType, 1), "tmp"); if (Result->getType() != ResultType) Result = Builder.CreateIntCast(Result, ResultType, "cast"); @@ -206,15 +206,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, const llvm::Type *ResType = ConvertType(E->getType()); // bool UseSubObject = TypeArg.getZExtValue() & 1; bool UseMinimum = TypeArg.getZExtValue() & 2; - return RValue::get(ConstantInt::get(ResType, UseMinimum ? 0 : -1LL)); + return RValue::get( + VMContext.getConstantInt(ResType, UseMinimum ? 0 : -1LL)); } case Builtin::BI__builtin_prefetch: { Value *Locality, *RW, *Address = EmitScalarExpr(E->getArg(0)); // FIXME: Technically these constants should of type 'int', yes? RW = (E->getNumArgs() > 1) ? EmitScalarExpr(E->getArg(1)) : - ConstantInt::get(llvm::Type::Int32Ty, 0); + VMContext.getConstantInt(llvm::Type::Int32Ty, 0); Locality = (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : - ConstantInt::get(llvm::Type::Int32Ty, 3); + VMContext.getConstantInt(llvm::Type::Int32Ty, 3); Value *F = CGM.getIntrinsic(Intrinsic::prefetch, 0, 0); return RValue::get(Builder.CreateCall3(F, Address, RW, Locality)); } @@ -279,9 +280,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BI__builtin_bzero: { Value *Address = EmitScalarExpr(E->getArg(0)); Builder.CreateCall4(CGM.getMemSetFn(), Address, - llvm::ConstantInt::get(llvm::Type::Int8Ty, 0), + VMContext.getConstantInt(llvm::Type::Int8Ty, 0), EmitScalarExpr(E->getArg(1)), - llvm::ConstantInt::get(llvm::Type::Int32Ty, 1)); + VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); return RValue::get(Address); } case Builtin::BI__builtin_memcpy: { @@ -289,7 +290,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Builder.CreateCall4(CGM.getMemCpyFn(), Address, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), - llvm::ConstantInt::get(llvm::Type::Int32Ty, 1)); + VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); return RValue::get(Address); } case Builtin::BI__builtin_memmove: { @@ -297,7 +298,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Builder.CreateCall4(CGM.getMemMoveFn(), Address, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), - llvm::ConstantInt::get(llvm::Type::Int32Ty, 1)); + VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); return RValue::get(Address); } case Builtin::BI__builtin_memset: { @@ -306,7 +307,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Builder.CreateTrunc(EmitScalarExpr(E->getArg(1)), llvm::Type::Int8Ty), EmitScalarExpr(E->getArg(2)), - llvm::ConstantInt::get(llvm::Type::Int32Ty, 1)); + VMContext.getConstantInt(llvm::Type::Int32Ty, 1)); return RValue::get(Address); } case Builtin::BI__builtin_return_address: { @@ -480,7 +481,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, { const llvm::Type *ResType[2]; ResType[0]= ConvertType(E->getArg(1)->getType()); - ResType[1] = llvm::PointerType::getUnqual(ResType[0]); + ResType[1] = VMContext.getPointerTypeUnqual(ResType[0]); Value *AtomF = CGM.getIntrinsic(Intrinsic::atomic_cmp_swap, ResType, 2); Value *OldVal = EmitScalarExpr(E->getArg(1)); Value *PrevVal = Builder.CreateCall3(AtomF, @@ -506,14 +507,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Value *Ptr = EmitScalarExpr(E->getArg(0)); const llvm::Type *ElTy = cast<llvm::PointerType>(Ptr->getType())->getElementType(); - Builder.CreateStore(getLLVMContext().getNullValue(ElTy), Ptr, true); + Builder.CreateStore(VMContext.getNullValue(ElTy), Ptr, true); return RValue::get(0); } case Builtin::BI__sync_synchronize: { Value *C[5]; - C[0] = C[1] = C[2] = C[3] = llvm::ConstantInt::get(llvm::Type::Int1Ty, 1); - C[4] = ConstantInt::get(llvm::Type::Int1Ty, 0); + C[0] = C[1] = C[2] = C[3] = VMContext.getConstantInt(llvm::Type::Int1Ty, 1); + C[4] = VMContext.getConstantInt(llvm::Type::Int1Ty, 0); Builder.CreateCall(CGM.getIntrinsic(Intrinsic::memory_barrier), C, C + 5); return RValue::get(0); } @@ -603,7 +604,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, // Unknown builtin, for now just dump it out and return undef. if (hasAggregateLLVMType(E->getType())) return RValue::getAggregate(CreateTempAlloca(ConvertType(E->getType()))); - return RValue::get(UndefValue::get(ConvertType(E->getType()))); + return RValue::get(VMContext.getUndef(ConvertType(E->getType()))); } Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID, @@ -635,9 +636,9 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, case X86::BI__builtin_ia32_psrlqi128: case X86::BI__builtin_ia32_psrlwi128: { Ops[1] = Builder.CreateZExt(Ops[1], llvm::Type::Int64Ty, "zext"); - const llvm::Type *Ty = llvm::VectorType::get(llvm::Type::Int64Ty, 2); - llvm::Value *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0); - Ops[1] = Builder.CreateInsertElement(llvm::UndefValue::get(Ty), + const llvm::Type *Ty = VMContext.getVectorType(llvm::Type::Int64Ty, 2); + llvm::Value *Zero = VMContext.getConstantInt(llvm::Type::Int32Ty, 0); + Ops[1] = Builder.CreateInsertElement(VMContext.getUndef(Ty), Ops[1], Zero, "insert"); Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "bitcast"); const char *name = 0; @@ -690,7 +691,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, case X86::BI__builtin_ia32_psrlqi: case X86::BI__builtin_ia32_psrlwi: { Ops[1] = Builder.CreateZExt(Ops[1], llvm::Type::Int64Ty, "zext"); - const llvm::Type *Ty = llvm::VectorType::get(llvm::Type::Int64Ty, 1); + const llvm::Type *Ty = VMContext.getVectorType(llvm::Type::Int64Ty, 1); Ops[1] = Builder.CreateBitCast(Ops[1], Ty, "bitcast"); const char *name = 0; Intrinsic::ID ID = Intrinsic::not_intrinsic; @@ -742,16 +743,16 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), "cmpss"); } case X86::BI__builtin_ia32_ldmxcsr: { - llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); - Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1); + llvm::Type *PtrTy = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); + Value *One = VMContext.getConstantInt(llvm::Type::Int32Ty, 1); Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); Builder.CreateStore(Ops[0], Tmp); return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr), Builder.CreateBitCast(Tmp, PtrTy)); } case X86::BI__builtin_ia32_stmxcsr: { - llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); - Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1); + llvm::Type *PtrTy = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); + Value *One = VMContext.getConstantInt(llvm::Type::Int32Ty, 1); Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); One = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr), Builder.CreateBitCast(Tmp, PtrTy)); @@ -768,15 +769,15 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, case X86::BI__builtin_ia32_storehps: case X86::BI__builtin_ia32_storelps: { const llvm::Type *EltTy = llvm::Type::Int64Ty; - llvm::Type *PtrTy = llvm::PointerType::getUnqual(EltTy); - llvm::Type *VecTy = llvm::VectorType::get(EltTy, 2); + llvm::Type *PtrTy = VMContext.getPointerTypeUnqual(EltTy); + llvm::Type *VecTy = VMContext.getVectorType(EltTy, 2); // cast val v2i64 Ops[1] = Builder.CreateBitCast(Ops[1], VecTy, "cast"); // extract (0, 1) unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1; - llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, Index); + llvm::Value *Idx = VMContext.getConstantInt(llvm::Type::Int32Ty, Index); Ops[1] = Builder.CreateExtractElement(Ops[1], Idx, "extract"); // cast pointer to i64 & store |