[llvm-commits] [llvm-gcc-4.0] r42212 - in /llvm-gcc-4.0/trunk/gcc: builtin-types.def builtins.def llvm-convert.cpp
Tanya Lattner
tonic at nondot.org
Fri Sep 21 16:01:00 PDT 2007
Author: tbrethou
Date: Fri Sep 21 18:01:00 2007
New Revision: 42212
URL: http://llvm.org/viewvc/llvm-project?rev=42212&view=rev
Log:
Adding support for __builtin_annotation with an intrinsic called llvm.annotation. This is similar to llvm.var.annotation but is applied to expressions.
Modified:
llvm-gcc-4.0/trunk/gcc/builtin-types.def
llvm-gcc-4.0/trunk/gcc/builtins.def
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.0/trunk/gcc/builtin-types.def
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/builtin-types.def?rev=42212&r1=42211&r2=42212&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/builtin-types.def (original)
+++ llvm-gcc-4.0/trunk/gcc/builtin-types.def Fri Sep 21 18:01:00 2007
@@ -244,6 +244,10 @@
DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_PTR, BT_VOID, BT_PTR, BT_PTR)
DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_STRING_PTR_CONST_STRING,
BT_INT, BT_CONST_STRING, BT_PTR_CONST_STRING)
+/* APPLE LOCAL begin LLVM */
+DEF_FUNCTION_TYPE_2 (BT_FN_UINT_UINT_CONST_STRING,
+ BT_UINT, BT_UINT, BT_CONST_STRING)
+/* APPLE LOCAL end LLVM */
/* APPLE LOCAL mainline */
DEF_FUNCTION_TYPE_2 (BT_FN_SIZE_CONST_PTR_INT, BT_SIZE, BT_CONST_PTR, BT_INT)
Modified: llvm-gcc-4.0/trunk/gcc/builtins.def
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/builtins.def?rev=42212&r1=42211&r2=42212&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/builtins.def (original)
+++ llvm-gcc-4.0/trunk/gcc/builtins.def Fri Sep 21 18:01:00 2007
@@ -633,6 +633,10 @@
DEF_EXT_LIB_BUILTIN (BUILT_IN__EXIT, "_exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
DEF_C99_BUILTIN (BUILT_IN__EXIT2, "_Exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
+/* APPLE LOCAL begin LLVM */
+DEF_GCC_BUILTIN (BUILT_IN_ANNOTATION, "_annotation", BT_FN_UINT_UINT_CONST_STRING, ATTR_NULL)
+/* APPLE LOCAL end LLVM */
+
/* Implementing nested functions. */
DEF_BUILTIN_STUB (BUILT_IN_INIT_TRAMPOLINE, "__builtin_init_trampoline")
/* LLVM local deleted 1 line */
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=42212&r1=42211&r2=42212&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Fri Sep 21 18:01:00 2007
@@ -4409,7 +4409,36 @@
return true;
}
-
+ // Convert annotation built-in to llvm.annotation intrinsic.
+ case BUILT_IN_ANNOTATION: {
+
+ // Get file and line number
+ location_t locus = EXPR_LOCATION (exp);
+ Constant *lineNo = ConstantInt::get(Type::Int32Ty, locus.line);
+ Constant *file = ConvertMetadataStringToGV(locus.file);
+ const Type *SBP= PointerType::get(Type::Int8Ty);
+ file = ConstantExpr::getBitCast(file, SBP);
+
+ // Get arguments.
+ tree arglist = TREE_OPERAND(exp, 1);
+ Value *ExprVal = Emit(TREE_VALUE(arglist), 0);
+ const Type *Ty = ExprVal->getType();
+ Value *StrVal = Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0);
+
+ SmallVector<Value *, 4> Args;
+ Args.push_back(ExprVal);
+ Args.push_back(StrVal);
+ Args.push_back(file);
+ Args.push_back(lineNo);
+
+ assert(Ty && "llvm.annotation arg type may not be null");
+ Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
+ Intrinsic::annotation,
+ &Ty,
+ 1),
+ Args.begin(), Args.end());
+ return true;
+ }
#undef HANDLE_UNARY_FP
#if 1 // FIXME: Should handle these GCC extensions eventually.
More information about the llvm-commits
mailing list