From f02e9ddf5efc75917af712b3c7f909581205f0a5 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 10 Oct 2008 00:24:54 +0000 Subject: [PATCH] Lift EmitTargetBuiltinExpr out of EmitBuiltinExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57335 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBuiltin.cpp | 19 +++++++++++-------- lib/CodeGen/CodeGenFunction.h | 4 ++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 29d77b6e82..aa9fdd813f 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -382,14 +382,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { } // See if we have a target specific builtin that needs to be lowered. - Value *V = 0; - - if (strcmp(TargetPrefix, "x86") == 0) - V = EmitX86BuiltinExpr(BuiltinID, E); - else if (strcmp(TargetPrefix, "ppc") == 0) - V = EmitPPCBuiltinExpr(BuiltinID, E); - - if (V) + if (Value *V = EmitTargetBuiltinExpr(BuiltinID, E)) return RValue::get(V); ErrorUnsupported(E, "builtin function"); @@ -400,6 +393,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { return RValue::get(UndefValue::get(ConvertType(E->getType()))); } +Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID, + const CallExpr *E) { + const char *TargetPrefix = Target.getTargetPrefix(); + if (strcmp(TargetPrefix, "x86") == 0) + return EmitX86BuiltinExpr(BuiltinID, E); + else if (strcmp(TargetPrefix, "ppc") == 0) + return EmitPPCBuiltinExpr(BuiltinID, E); + return 0; +} + Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E) { diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 8058c342e7..ca499d85e4 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -418,6 +418,10 @@ public: RValue EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E); + /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 + /// if the call is unhandled by the current target. + llvm::Value *EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E); + llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E); -- 2.40.0