summaryrefslogtreecommitdiffstats
path: root/clang/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-30 17:57:17 +0000
committerChris Lattner <sabre@nondot.org>2007-05-30 17:57:17 +0000
commit208ae96a8cb87706c45f4239a646c7a70e460d8e (patch)
tree0c011c1aecc3c6c08f4d817c1c9b382cbf2a6956 /clang/CodeGen/CodeGenFunction.cpp
parentb5217858ee1e0137a0bc49c969168103a0de7580 (diff)
downloadbcm5719-llvm-208ae96a8cb87706c45f4239a646c7a70e460d8e.tar.gz
bcm5719-llvm-208ae96a8cb87706c45f4239a646c7a70e460d8e.zip
implement codegen of integer literals.
llvm-svn: 39530
Diffstat (limited to 'clang/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/CodeGen/CodeGenFunction.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/clang/CodeGen/CodeGenFunction.cpp b/clang/CodeGen/CodeGenFunction.cpp
index 4061b417f7e..885ee41f36c 100644
--- a/clang/CodeGen/CodeGenFunction.cpp
+++ b/clang/CodeGen/CodeGenFunction.cpp
@@ -15,6 +15,7 @@
#include "CodeGenModule.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/AST/AST.h"
+#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
using namespace llvm;
@@ -136,8 +137,14 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
switch (S->getStmtClass()) {
default:
- printf("Unimplemented stmt!\n");
- S->dump();
+ // Must be an expression in a stmt context. Emit the value and ignore the
+ // result.
+ if (const Expr *E = dyn_cast<Expr>(S)) {
+ EmitExpr(E);
+ } else {
+ printf("Unimplemented stmt!\n");
+ S->dump();
+ }
break;
case Stmt::NullStmtClass: break;
case Stmt::CompoundStmtClass: EmitCompoundStmt(cast<CompoundStmt>(*S)); break;
@@ -180,3 +187,28 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
Builder.SetInsertPoint(new BasicBlock("", CurFn));
}
+
+
+//===--------------------------------------------------------------------===//
+// Expression Emission
+//===--------------------------------------------------------------------===//
+
+ExprResult CodeGenFunction::EmitExpr(const Expr *E) {
+ assert(E && "Null expression?");
+
+ switch (E->getStmtClass()) {
+ default:
+ printf("Unimplemented expr!\n");
+ E->dump();
+ return ExprResult::get(UndefValue::get(llvm::Type::Int32Ty));
+ case Stmt::IntegerLiteralClass:
+ return EmitIntegerLiteral(cast<IntegerLiteral>(E));
+ }
+
+}
+
+ExprResult CodeGenFunction::EmitIntegerLiteral(const IntegerLiteral *E) {
+ return ExprResult::get(ConstantInt::get(E->getValue()));
+}
+
+
OpenPOWER on IntegriCloud