From: Chris Lattner Date: Mon, 13 Mar 2006 23:09:05 +0000 (+0000) Subject: Handle builtins that directly correspond to GCC builtins. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=872421553e3187717b6c29784e2009ce5cc6811c;p=oota-llvm.git Handle builtins that directly correspond to GCC builtins. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26737 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 43b4b71c2b2..89881897cd5 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1602,6 +1602,15 @@ void CWriter::lowerIntrinsics(Function &F) { // 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 @@ void CWriter::lowerIntrinsics(Function &F) { } 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 @@ void CWriter::visitCallInst(CallInst &I) { // 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(Callee)) if (CE->getOpcode() == Instruction::Cast) diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 43b4b71c2b2..89881897cd5 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -1602,6 +1602,15 @@ void CWriter::lowerIntrinsics(Function &F) { // 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 @@ void CWriter::lowerIntrinsics(Function &F) { } 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 @@ void CWriter::visitCallInst(CallInst &I) { // 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(Callee)) if (CE->getOpcode() == Instruction::Cast)