[cfe-commits] r97700 - in /cfe/trunk: lib/CodeGen/CGBuiltin.cpp test/CodeGen/builtins.c
John McCall
rjmccall at apple.com
Wed Mar 3 16:44:01 PST 2010
Author: rjmccall
Date: Wed Mar 3 18:44:01 2010
New Revision: 97700
URL: http://llvm.org/viewvc/llvm-project?rev=97700&view=rev
Log:
Implement __builtin_dwarf_sp_column().
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=97700&r1=97699&r2=97700&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Mar 3 18:44:01 2010
@@ -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 @@
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
Modified: cfe/trunk/test/CodeGen/builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=97700&r1=97699&r2=97700&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Wed Mar 3 18:44:01 2010
@@ -162,3 +162,10 @@
}
// CHECK: }
+
+// CHECK: define void @test0(
+void test0() {
+ // CHECK: i64 7
+ unsigned long long x = __builtin_dwarf_sp_column();
+}
+// CHECK: }
More information about the cfe-commits
mailing list