diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-07-21 22:59:13 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-07-21 22:59:13 +0000 |
commit | 4493f79fce48cd9cbd9f55fa9d452cde736747a0 (patch) | |
tree | f6f43d19eaedfd8260833ed9c714babc56b0ff8c /lib/CodeGen | |
parent | 7caeabd868d46cf4e68478c6e9136dae4e735d21 (diff) |
Implement nans, prefetch, and trap builtins.
This closes <rdar://problem/6080720>, support for __builtin_constant_p
has been filed separately.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 1fc568e507..87d09a981d 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -190,7 +190,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { Result = Builder.CreateIntCast(Result, ResultType, "cast"); return RValue::get(Result); } - case Builtin::BI__builtin_expect: // FIXME: pass expect through to LLVM return RValue::get(EmitScalarExpr(E->getArg(0))); @@ -200,7 +199,22 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { const llvm::Type *ArgType = ArgValue->getType(); Value *F = CGM.getIntrinsic(Intrinsic::bswap, &ArgType, 1); return RValue::get(Builder.CreateCall(F, ArgValue, "tmp")); + } + 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); + Locality = (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : + ConstantInt::get(llvm::Type::Int32Ty, 3); + Value *F = CGM.getIntrinsic(Intrinsic::prefetch, 0, 0); + return RValue::get(Builder.CreateCall3(F, Address, RW, Locality)); + } + case Builtin::BI__builtin_trap: { + Value *F = CGM.getIntrinsic(Intrinsic::trap, 0, 0); + return RValue::get(Builder.CreateCall(F)); } + case Builtin::BI__builtin_huge_val: case Builtin::BI__builtin_huge_valf: case Builtin::BI__builtin_huge_vall: |