[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Mon Sep 20 17:08:15 PDT 2004



Changes in directory llvm-java/lib/Compiler:

Compiler.cpp updated: 1.106 -> 1.107
---
Log message:

Initialize locals with the function arguments. This makes function
calls complete.


---
Diffs of the changes:  (+25 -11)

Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.106 llvm-java/lib/Compiler/Compiler.cpp:1.107
--- llvm-java/lib/Compiler/Compiler.cpp:1.106	Sun Sep 19 17:38:00 2004
+++ llvm-java/lib/Compiler/Compiler.cpp	Mon Sep 20 19:08:05 2004
@@ -51,12 +51,20 @@
   typedef std::stack<Value*, std::vector<Value*> > OperandStack;
   typedef std::vector<Value*> Locals;
 
+  inline bool isTwoSlotType(const Type* t) {
+    return t == Type::LongTy | t == Type::DoubleTy;
+  }
+
   inline bool isTwoSlotValue(const Value* v) {
-    return v->getType() == Type::LongTy | v->getType() == Type::DoubleTy;
+    return isTwoSlotType(v->getType());
+  }
+
+  inline bool isOneSlotType(const Type* t) {
+    return !isTwoSlotType(t);
   }
 
   inline bool isOneSlotValue(const Value* v) {
-    return !isTwoSlotValue(v);
+    return isOneSlotType(v->getType());
   }
 
   class Bytecode2BasicBlockMapper
@@ -770,17 +778,23 @@
       mapper.compute();
 
       prologue_ = new BasicBlock("prologue");
+      unsigned index = 0;
+      for (Function::aiterator
+             a = function->abegin(), ae = function->aend(); a != ae; ++a) {
+        // create a new local
+        locals_[index] = new AllocaInst(
+          a->getType(), NULL, "arg" + utostr(index), prologue_);
+        // initialize the local with the contents of this argument
+        new StoreInst(a, locals_[index], prologue_);
+        index += isTwoSlotType(a->getType()) ? 2 : 1;
+      }
 
       parse(codeAttr->getCode(), codeAttr->getCodeSize());
 
-      // if the prologue is not empty, make it the entry block
-      // of the function with entry as its only successor
-      if (prologue_->empty())
-        delete prologue_;
-      else {
-        function->getBasicBlockList().push_front(prologue_);
-        new BranchInst(prologue_->getNext(), prologue_);
-      }
+      // makethe prologue the entry block of the function with a
+      // fallthrough branch to the original entry block
+      function->getBasicBlockList().push_front(prologue_);
+      new BranchInst(prologue_->getNext(), prologue_);
 
       // now insert fall through branches to all basic blocks that
       // don't have a terminator
@@ -874,7 +888,7 @@
       // compile all other methods called by this method recursively
       for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) {
         Function* f = toCompileFunctions_[i];
-        compileMethodOnly(f->getName());
+//        compileMethodOnly(f->getName());
       }
 
       return function;






More information about the llvm-commits mailing list