Simplify some calls to Builder.CreateCall

llvm-svn: 55567
This commit is contained in:
Anders Carlsson 2008-08-30 16:17:45 +00:00
parent b52d1ed7e9
commit 7e1e57103e
2 changed files with 17 additions and 22 deletions

View File

@ -351,15 +351,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
case Builtin::BI__sync_fetch_and_xor:
return EmitBinaryAtomic(*this, Intrinsic::atomic_load_xor, E);
case Builtin::BI__sync_val_compare_and_swap: {
Value *Args[3];
Args[0]= EmitScalarExpr(E->getArg(0));
Args[1] = EmitScalarExpr(E->getArg(1));
Args[2] = EmitScalarExpr(E->getArg(2));
const llvm::Type *ResType[2];
ResType[0]= ConvertType(E->getType());
ResType[1] = ConvertType(E->getArg(0)->getType());
Value *AtomF = CGM.getIntrinsic(Intrinsic::atomic_cmp_swap, ResType, 2);
return RValue::get(Builder.CreateCall(AtomF, &Args[0], &Args[1]+2));
return RValue::get(Builder.CreateCall3(AtomF,
EmitScalarExpr(E->getArg(0)),
EmitScalarExpr(E->getArg(1)),
EmitScalarExpr(E->getArg(2))));
}
case Builtin::BI__sync_lock_test_and_set:
return EmitBinaryAtomic(*this, Intrinsic::atomic_swap, E);

View File

@ -125,15 +125,13 @@ void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
// FIXME: Handle variable sized types.
const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth);
llvm::Value *MemSetOps[4] = {
DestPtr,
llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty),
// TypeInfo.first describes size in bits.
llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
llvm::ConstantInt::get(llvm::Type::Int32Ty, TypeInfo.second/8)
};
Builder.CreateCall(CGF.CGM.getMemSetFn(), MemSetOps, MemSetOps+4);
Builder.CreateCall4(CGF.CGM.getMemSetFn(),
DestPtr,
llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty),
// TypeInfo.first describes size in bits.
llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
llvm::ConstantInt::get(llvm::Type::Int32Ty,
TypeInfo.second/8));
}
void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr,
@ -153,14 +151,12 @@ void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr,
// FIXME: Handle variable sized types.
const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth);
llvm::Value *MemMoveOps[4] = {
DestPtr, SrcPtr,
// TypeInfo.first describes size in bits.
llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
llvm::ConstantInt::get(llvm::Type::Int32Ty, TypeInfo.second/8)
};
Builder.CreateCall(CGF.CGM.getMemMoveFn(), MemMoveOps, MemMoveOps+4);
Builder.CreateCall4(CGF.CGM.getMemMoveFn(),
DestPtr, SrcPtr,
// TypeInfo.first describes size in bits.
llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
llvm::ConstantInt::get(llvm::Type::Int32Ty,
TypeInfo.second/8));
}