diff options
author | John McCall <rjmccall@apple.com> | 2010-03-04 00:44:01 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-03-04 00:44:01 +0000 |
commit | 06a3066ea137b79e87a2f5d67e3012334bf4896b (patch) | |
tree | 78464b73d7b91ea5f3475b190b46bdb3b035f303 | |
parent | 29a4071fc450ee17449ad73266012c1b1b975511 (diff) |
Implement __builtin_dwarf_sp_column().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97700 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 15 | ||||
-rw-r--r-- | test/CodeGen/builtins.c | 7 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index df6ac7fc24..37435cd815 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -21,6 +21,9 @@ #include "clang/Basic/TargetBuiltins.h" #include "llvm/Intrinsics.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetLowering.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegisterInfo.h" using namespace clang; using namespace CodeGen; using namespace llvm; @@ -407,6 +410,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Value *F = CGM.getIntrinsic(Intrinsic::eh_unwind_init, 0, 0); return RValue::get(Builder.CreateCall(F)); } + case Builtin::BI__builtin_dwarf_sp_column: { + const llvm::TargetMachine &Machine = CGM.getTargetMachine(); + llvm::TargetLowering *TL = Machine.getTargetLowering(); + assert(TL && "need lowering to codegen __builtin_dwarf_sp_column"); + const llvm::TargetRegisterInfo *TRI = Machine.getRegisterInfo(); + assert(TRI && "need register info to codegen __builtin_dwarf_sp_column"); + unsigned SP = TL->getStackPointerRegisterToSaveRestore(); + int DwarfSP = TRI->getDwarfRegNum(SP, /*for EH*/ true); + + return RValue::get( + llvm::ConstantInt::getSigned(cast<IntegerType>(LLVMIntTy), DwarfSP)); + } case Builtin::BI__builtin_extend_pointer: { // Extends a pointer to the size of an _Unwind_Word, which is // uint64_t on all platforms. Generally this gets poked into a diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c index 417ca7def5..70d0857a31 100644 --- a/test/CodeGen/builtins.c +++ b/test/CodeGen/builtins.c @@ -162,3 +162,10 @@ void bar() { } // CHECK: } + +// CHECK: define void @test0( +void test0() { + // CHECK: i64 7 + unsigned long long x = __builtin_dwarf_sp_column(); +} +// CHECK: } |