[llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Jan 12 19:00:06 PST 2003


Changes in directory llvm/tools/lli/Interpreter:

Execution.cpp updated: 1.74 -> 1.75

---
Log message:

Handle value promotion properly to work with tracing better


---
Diffs of the changes:

Index: llvm/tools/lli/Interpreter/Execution.cpp
diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.74 llvm/tools/lli/Interpreter/Execution.cpp:1.75
--- llvm/tools/lli/Interpreter/Execution.cpp:1.74	Mon Dec 23 17:59:41 2002
+++ llvm/tools/lli/Interpreter/Execution.cpp	Sun Jan 12 18:58:52 2003
@@ -815,8 +815,28 @@
   ECStack.back().Caller = &I;
   vector<GenericValue> ArgVals;
   ArgVals.reserve(I.getNumOperands()-1);
-  for (unsigned i = 1; i < I.getNumOperands(); ++i)
+  for (unsigned i = 1; i < I.getNumOperands(); ++i) {
     ArgVals.push_back(getOperandValue(I.getOperand(i), SF));
+    // Promote all integral types whose size is < sizeof(int) into ints.  We do
+    // this by zero or sign extending the value as appropriate according to the
+    // source type.
+    if (I.getOperand(i)->getType()->isIntegral() &&
+	I.getOperand(i)->getType()->getPrimitiveSize() < 4) {
+      const Type *Ty = I.getOperand(i)->getType();
+      if (Ty == Type::ShortTy)
+	ArgVals.back().IntVal = ArgVals.back().ShortVal;
+      else if (Ty == Type::UShortTy)
+	ArgVals.back().UIntVal = ArgVals.back().UShortVal;
+      else if (Ty == Type::SByteTy)
+	ArgVals.back().IntVal = ArgVals.back().SByteVal;
+      else if (Ty == Type::UByteTy)
+	ArgVals.back().UIntVal = ArgVals.back().UByteVal;
+      else if (Ty == Type::BoolTy)
+	ArgVals.back().UIntVal = ArgVals.back().BoolVal;
+      else
+	assert(0 && "Unknown type!");
+    }
+  }
 
   // To handle indirect calls, we must get the pointer value from the argument 
   // and treat it as a function pointer.





More information about the llvm-commits mailing list