[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Mar 13 15:09:17 PST 2006
Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.256 -> 1.257
---
Log message:
Handle builtins that directly correspond to GCC builtins.
---
Diffs of the changes: (+25 -2)
Writer.cpp | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.256 llvm/lib/Target/CBackend/Writer.cpp:1.257
--- llvm/lib/Target/CBackend/Writer.cpp:1.256 Mon Mar 13 07:07:37 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Mon Mar 13 17:09:05 2006
@@ -1602,6 +1602,15 @@
// We directly implement these intrinsics
break;
default:
+ // If this is an intrinsic that directly corresponds to a GCC
+ // builtin, we handle it.
+ const char *BuiltinName = "";
+#define GET_GCC_BUILTIN_NAME
+#include "llvm/Intrinsics.gen"
+#undef GET_GCC_BUILTIN_NAME
+ // If we handle it, don't lower it.
+ if (BuiltinName[0]) break;
+
// All other intrinsic calls we must lower.
Instruction *Before = 0;
if (CI != &BB->front())
@@ -1613,17 +1622,32 @@
} else {
I = BB->begin();
}
+ break;
}
}
void CWriter::visitCallInst(CallInst &I) {
+ bool WroteCallee = false;
+
// Handle intrinsic function calls first...
if (Function *F = I.getCalledFunction())
if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) {
switch (ID) {
- default: assert(0 && "Unknown LLVM intrinsic!");
+ default: {
+ // If this is an intrinsic that directly corresponds to a GCC
+ // builtin, we emit it here.
+ const char *BuiltinName = "";
+#define GET_GCC_BUILTIN_NAME
+#include "llvm/Intrinsics.gen"
+#undef GET_GCC_BUILTIN_NAME
+ assert(BuiltinName[0] && "Unknown LLVM intrinsic!");
+
+ Out << BuiltinName;
+ WroteCallee = true;
+ break;
+ }
case Intrinsic::vastart:
Out << "0; ";
@@ -1720,7 +1744,6 @@
// in the common case, we handle casts where the number of arguments passed
// match exactly.
//
- bool WroteCallee = false;
if (I.isTailCall()) Out << " /*tail*/ ";
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Callee))
if (CE->getOpcode() == Instruction::Cast)
More information about the llvm-commits
mailing list