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

Alkis Evlogimenos alkis at cs.uiuc.edu
Tue Mar 29 09:30:07 PST 2005



Changes in directory llvm-java/lib/Compiler:

Compiler.cpp updated: 1.265 -> 1.266
---
Log message:

Inline getField() to its two users.


---
Diffs of the changes:  (+12 -14)

 Compiler.cpp |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)


Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.265 llvm-java/lib/Compiler/Compiler.cpp:1.266
--- llvm-java/lib/Compiler/Compiler.cpp:1.265	Tue Mar 29 07:24:46 2005
+++ llvm-java/lib/Compiler/Compiler.cpp	Tue Mar 29 11:29:56 2005
@@ -845,18 +845,6 @@
       return NULL;
     }
 
-    /// Emits the necessary code to get a field from the passed
-    /// pointer to an object.
-    Value* getField(const VMField* field, Value* ptr) {
-      std::vector<Value*> indices(2, ConstantUInt::get(Type::UIntTy, 0));
-      indices[1] = ConstantUInt::get(Type::UIntTy, field->getMemberIndex());
-
-      return new GetElementPtrInst(ptr,
-                                   indices,
-                                   field->getName()+'*',
-                                   currentBB_);
-    }
-
     std::string getMangledString(const std::string& str) {
       std::string mangledStr;
 
@@ -1603,7 +1591,12 @@
       const VMField* field = class_->getField(index);
 
       Value* p = pop(field->getParent()->getType());
-      Value* v = new LoadInst(getField(field, p), field->getName(), currentBB_);
+      std::vector<Value*> indices(2);
+      indices[0] = ConstantUInt::get(Type::UIntTy, 0);
+      indices[1] = ConstantUInt::get(Type::UIntTy, field->getMemberIndex());
+      Value* fieldPtr =
+        new GetElementPtrInst(p, indices, field->getName()+'*', currentBB_);
+      Value* v = new LoadInst(fieldPtr, field->getName(), currentBB_);
       push(v);
     }
 
@@ -1612,7 +1605,12 @@
 
       Value* v = pop(field->getClass()->getType());
       Value* p = pop(field->getParent()->getType());
-      new StoreInst(v, getField(field, p), currentBB_);
+      std::vector<Value*> indices(2);
+      indices[0] = ConstantUInt::get(Type::UIntTy, 0);
+      indices[1] = ConstantUInt::get(Type::UIntTy, field->getMemberIndex());
+      Value* fieldPtr =
+        new GetElementPtrInst(p, indices, field->getName()+'*', currentBB_);
+      new StoreInst(v, fieldPtr, currentBB_);
     }
 
     void makeCall(Value* fun, const std::vector<Value*> params) {






More information about the llvm-commits mailing list