[cfe-commits] r41188 - in /cfe/trunk/CodeGen: CGBuiltin.cpp CGExpr.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Mon Aug 20 11:05:57 PDT 2007
Author: andersca
Date: Mon Aug 20 13:05:56 2007
New Revision: 41188
URL: http://llvm.org/viewvc/llvm-project?rev=41188&view=rev
Log:
Add support for code generation of builtins.
Added:
cfe/trunk/CodeGen/CGBuiltin.cpp
Modified:
cfe/trunk/CodeGen/CGExpr.cpp
cfe/trunk/CodeGen/CodeGenFunction.h
Added: cfe/trunk/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=41188&view=auto
==============================================================================
--- cfe/trunk/CodeGen/CGBuiltin.cpp (added)
+++ cfe/trunk/CodeGen/CGBuiltin.cpp Mon Aug 20 13:05:56 2007
@@ -0,0 +1,30 @@
+//===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Anders Carlsson and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This contains code to emit Builtin calls as LLVM code.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CodeGenFunction.h"
+#include "CodeGenModule.h"
+#include "clang/AST/Builtins.h"
+#include "clang/AST/Expr.h"
+
+using namespace clang;
+using namespace CodeGen;
+
+RValue CodeGenFunction::EmitBuiltinExpr(unsigned builtinID, const CallExpr *E)
+{
+ switch (builtinID) {
+ default:
+ assert(0 && "Unknown builtin id");
+ }
+
+ return RValue::get(0);
+}
Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=41188&r1=41187&r2=41188&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Mon Aug 20 13:05:56 2007
@@ -14,6 +14,7 @@
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
+#include "clang/Lex/IdentifierTable.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
@@ -660,6 +661,15 @@
}
RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) {
+ if (const ImplicitCastExpr *IcExpr =
+ dyn_cast<const ImplicitCastExpr>(E->getCallee()))
+ if (const DeclRefExpr *DRExpr =
+ dyn_cast<const DeclRefExpr>(IcExpr->getSubExpr()))
+ if (const FunctionDecl *FDecl =
+ dyn_cast<const FunctionDecl>(DRExpr->getDecl()))
+ if (unsigned builtinID = FDecl->getIdentifier()->getBuiltinID())
+ return EmitBuiltinExpr(builtinID, E);
+
llvm::Value *Callee = EmitExpr(E->getCallee()).getVal();
// The callee type will always be a pointer to function type, get the function
Modified: cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.h?rev=41188&r1=41187&r2=41188&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.h Mon Aug 20 13:05:56 2007
@@ -352,6 +352,7 @@
RValue EmitCastExpr(const Expr *Op, QualType DestTy);
RValue EmitCallExpr(const CallExpr *E);
+ RValue EmitBuiltinExpr(unsigned builtinID, const CallExpr *E);
RValue EmitArraySubscriptExprRV(const ArraySubscriptExpr *E);
// Unary Operators.
More information about the cfe-commits
mailing list