summaryrefslogtreecommitdiffstats
path: root/clang/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-29 23:50:05 +0000
committerChris Lattner <sabre@nondot.org>2007-05-29 23:50:05 +0000
commit308f431017429c94728ea0f719ae3fa6cd00e275 (patch)
tree262c9afc7c72cefb9b21d3b3c989bc19ddb04b43 /clang/CodeGen/CodeGenFunction.cpp
parentd5322cd27ee955b509f01eb566f01142f5e79fd8 (diff)
downloadbcm5719-llvm-308f431017429c94728ea0f719ae3fa6cd00e275.tar.gz
bcm5719-llvm-308f431017429c94728ea0f719ae3fa6cd00e275.zip
Add codegen support for NullStmt and CompoundStmt. {;;{};;} is now ours!
llvm-svn: 39522
Diffstat (limited to 'clang/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/CodeGen/CodeGenFunction.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/clang/CodeGen/CodeGenFunction.cpp b/clang/CodeGen/CodeGenFunction.cpp
index cfe5d9d9521..ff31a835ce9 100644
--- a/clang/CodeGen/CodeGenFunction.cpp
+++ b/clang/CodeGen/CodeGenFunction.cpp
@@ -16,7 +16,7 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/AST/AST.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/Support/LLVMBuilder.h"
+#include "llvm/Function.h"
using namespace llvm;
using namespace clang;
using namespace CodeGen;
@@ -101,9 +101,45 @@ const llvm::Type *CodeGenFunction::ConvertType(QualType T, SourceLocation Loc) {
}
-void CodeGenFunction::GenerateCode(FunctionDecl *FD) {
+void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
const llvm::Type *Ty = ConvertType(FD->getType(), FD->getLocation());
- Ty->dump();
+ llvm::Function *F = new Function(cast<llvm::FunctionType>(Ty),
+ Function::ExternalLinkage,
+ FD->getName(), &CGM.getModule());
+ BasicBlock *EntryBB = new BasicBlock("entry", F);
+
+ // TODO: Walk the decls, creating allocas etc.
+
+ Builder.SetInsertPoint(EntryBB);
+
+ EmitStmt(FD->getBody());
+}
+
+
+//===----------------------------------------------------------------------===//
+// Statement Emission
+//===----------------------------------------------------------------------===//
+
+void CodeGenFunction::EmitStmt(const Stmt *S) {
+ assert(S && "Null statement?");
+
+ switch (S->getStmtClass()) {
+ default:
+ printf("Unimplemented stmt!\n");
+ S->dump();
+ break;
+ case Stmt::NullStmtClass: break;
+ case Stmt::CompoundStmtClass: EmitCompoundStmt(cast<CompoundStmt>(*S)); break;
+ }
}
+
+void CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S) {
+ // FIXME: handle vla's etc.
+
+ for (CompoundStmt::const_body_iterator I = S.body_begin(), E = S.body_end();
+ I != E; ++I)
+ EmitStmt(*I);
+}
+
OpenPOWER on IntegriCloud