[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.cpp

2007-06-01 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.184 -> 1.185
Interpreter.cpp updated: 1.39 -> 1.40
---
Log message:

For PR1486: http://llvm.org/PR1486 :
Avoid overwriting the APInt instance with 0 bytes which causes the bitwidth
to be set to 0 (illegal) producing a subsequent assert. 


---
Diffs of the changes:  (+2 -2)

 Execution.cpp   |2 +-
 Interpreter.cpp |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.184 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.185
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.184Thu May 17 
01:47:54 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Fri Jun  1 17:23:29 2007
@@ -610,7 +610,7 @@
 if (RetTy && RetTy->isInteger()) {  // Nonvoid return type?
   ExitValue = Result;   // Capture the exit value of the program
 } else {
-  memset(&ExitValue, 0, sizeof(ExitValue));
+  memset(&ExitValue.Untyped, 0, sizeof(ExitValue.Untyped));
 }
   } else {
 // If we have a previous stack frame, and we have a previous call,


Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.39 
llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.40
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.39   Mon Mar  5 
21:05:57 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.cppFri Jun  1 
17:23:29 2007
@@ -54,7 +54,7 @@
 //
 Interpreter::Interpreter(Module *M) : ExecutionEngine(M), TD(M) {
   
-  memset(&ExitValue, 0, sizeof(ExitValue));
+  memset(&ExitValue.Untyped, 0, sizeof(ExitValue.Untyped));
   setTargetData(&TD);
   // Initialize the "backend"
   initializeExecutionEngine();



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-05-16 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.183 -> 1.184
---
Log message:

Print integer values as both decimal and hexadecimal for convenience
of verifying result values when debugging.


---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.183 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.184
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.183Wed May 16 
11:39:29 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu May 17 01:47:54 2007
@@ -1347,7 +1347,7 @@
 case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal); 
break;
 case Type::IntegerTyID: 
   DOUT << "i" << Val.IntVal.getBitWidth() << " " << Val.IntVal.toString(10)
-   << "\n";
+   << " (0x" << Val.IntVal.toString(16) << ")\n";
   break;
   }
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-05-16 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.182 -> 1.183
---
Log message:

Avoid a "loss of precision" error in gcc 4.1.3. 


---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.182 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.183
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.182Tue May 15 
21:05:13 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed May 16 11:39:29 2007
@@ -1344,7 +1344,7 @@
 case Type::VoidTyID:DOUT << "void"; break;
 case Type::FloatTyID:   DOUT << "float " << Val.FloatVal; break;
 case Type::DoubleTyID:  DOUT << "double " << Val.DoubleVal; break;
-case Type::PointerTyID: DOUT << "void* " << unsigned(Val.PointerVal); 
break;
+case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal); 
break;
 case Type::IntegerTyID: 
   DOUT << "i" << Val.IntVal.getBitWidth() << " " << Val.IntVal.toString(10)
<< "\n";



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-05-15 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.181 -> 1.182
---
Log message:

Implement printing of instruction result values when debug info is turned
on. This helps to speed up the debugging time by showing computational 
results as the program executes.


---
Diffs of the changes:  (+21 -0)

 Execution.cpp |   21 +
 1 files changed, 21 insertions(+)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.181 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.182
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.181Thu May  3 
22:37:38 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Tue May 15 21:05:13 2007
@@ -1338,6 +1338,20 @@
   StackFrame.VarArgs.assign(ArgVals.begin()+i, ArgVals.end());
 }
 
+static void PrintGenericValue(const GenericValue &Val, const Type* Ty) {
+  switch (Ty->getTypeID()) {
+default: assert(0 && "Invalid GenericValue Type");
+case Type::VoidTyID:DOUT << "void"; break;
+case Type::FloatTyID:   DOUT << "float " << Val.FloatVal; break;
+case Type::DoubleTyID:  DOUT << "double " << Val.DoubleVal; break;
+case Type::PointerTyID: DOUT << "void* " << unsigned(Val.PointerVal); 
break;
+case Type::IntegerTyID: 
+  DOUT << "i" << Val.IntVal.getBitWidth() << " " << Val.IntVal.toString(10)
+   << "\n";
+  break;
+  }
+}
+
 void Interpreter::run() {
   while (!ECStack.empty()) {
 // Interpret a single instruction & increment the "PC".
@@ -1349,5 +1363,12 @@
 
 DOUT << "About to interpret: " << I;
 visit(I);   // Dispatch to one of the visit* methods...
+#ifndef NDEBUG
+if (!isa(I) && !isa(I) && 
+I.getType() != Type::VoidTy) {
+  DOUT << "  --> ";
+  PrintGenericValue(SF.Values[&I], I.getType());
+}
+#endif
   }
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-05-03 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.180 -> 1.181
---
Log message:

Bitcast all the bits of a floating point value, not just one. The zero 
extension is needed because the constructor for the Destination value
causes the APInt to have a bit width of 1. 
Patch by Guoling Han.


---
Diffs of the changes:  (+2 -0)

 Execution.cpp |2 ++
 1 files changed, 2 insertions(+)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.180 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.181
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.180Thu Apr 26 
13:19:35 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu May  3 22:37:38 2007
@@ -1087,8 +1087,10 @@
 Dest.PointerVal = Src.PointerVal;
   } else if (DstTy->isInteger()) {
 if (SrcTy == Type::FloatTy) {
+  Dest.IntVal.zext(sizeof(Src.FloatVal) * 8);
   Dest.IntVal.floatToBits(Src.FloatVal);
 } else if (SrcTy == Type::DoubleTy) {
+  Dest.IntVal.zext(sizeof(Src.DoubleVal) * 8);
   Dest.IntVal.doubleToBits(Src.DoubleVal);
 } else if (SrcTy->isInteger()) {
   Dest.IntVal = Src.IntVal;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-04-26 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.179 -> 1.180
---
Log message:

1. Don't swap byte order in scanf. It isn't necessary and leads to
   incorrect results (canonicalization was dropped several commits ago).
2. Add support for fscanf.
3. Suppress a warning about cast to pointer from non-pointer-sized integer.


---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.179 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.180
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.179Tue Apr 17 
12:38:28 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu Apr 26 13:19:35 2007
@@ -1073,7 +1073,7 @@
   if (PtrSize != Src.IntVal.getBitWidth())
 Src.IntVal = Src.IntVal.zextOrTrunc(PtrSize);
 
-  Dest.PointerVal = (PointerTy) Src.IntVal.getZExtValue();
+  Dest.PointerVal = PointerTy(intptr_t(Src.IntVal.getZExtValue()));
   return Dest;
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-04-17 Thread Chris Lattner


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.178 -> 1.179
---
Log message:

eliminate use of Instruction::getPrev().  Patch by Gabor Greif in 2005.


---
Diffs of the changes:  (+6 -3)

 Execution.cpp |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.178 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.179
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.178Mon Apr 16 
16:50:40 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Tue Apr 17 12:38:28 2007
@@ -866,16 +866,19 @@
   // If it is an unknown intrinsic function, use the intrinsic lowering
   // class to transform it into hopefully tasty LLVM code.
   //
-  Instruction *Prev = CS.getInstruction()->getPrev();
+  BasicBlock::iterator me(CS.getInstruction());
   BasicBlock *Parent = CS.getInstruction()->getParent();
+  bool atBegin(Parent->begin() == me);
+  if (!atBegin)
+--me;
   IL->LowerIntrinsicCall(cast(CS.getInstruction()));
 
   // Restore the CurInst pointer to the first instruction newly inserted, 
if
   // any.
-  if (!Prev) {
+  if (atBegin) {
 SF.CurInst = Parent->begin();
   } else {
-SF.CurInst = Prev;
+SF.CurInst = me;
 ++SF.CurInst;
   }
   return;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-04-16 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.177 -> 1.178
---
Log message:

Implement @sext and @zext parameter attribute handling properly instead of
forcing every small argument of every function regardless of attributes or
calling convention to be expanded.


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

 Execution.cpp |   31 ---
 1 files changed, 20 insertions(+), 11 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.177 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.178
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.177Thu Mar  8 
17:37:24 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Mon Apr 16 16:50:40 2007
@@ -16,6 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
+#include "llvm/ParameterAttributes.h"
 #include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/ADT/APInt.h"
@@ -844,8 +845,8 @@
   ExecutionContext &SF = ECStack.back();
 
   // Check to see if this is an intrinsic function call...
-  if (Function *F = CS.getCalledFunction())
-   if (F->isDeclaration ())
+  Function *F = CS.getCalledFunction();
+  if (F && F->isDeclaration ())
 switch (F->getIntrinsicID()) {
 case Intrinsic::not_intrinsic:
   break;
@@ -880,21 +881,28 @@
   return;
 }
 
+
   SF.Caller = CS;
   std::vector ArgVals;
   const unsigned NumArgs = SF.Caller.arg_size();
   ArgVals.reserve(NumArgs);
+  uint16_t pNum = 1;
   for (CallSite::arg_iterator i = SF.Caller.arg_begin(),
- e = SF.Caller.arg_end(); i != e; ++i) {
+ e = SF.Caller.arg_end(); i != e; ++i, ++pNum) {
 Value *V = *i;
 ArgVals.push_back(getOperandValue(V, 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.
-const Type *Ty = V->getType();
-if (Ty->isInteger())
-  if (ArgVals.back().IntVal.getBitWidth() < 32)
-ArgVals.back().IntVal = ArgVals.back().IntVal.sext(32);
+if (F) {
+ // Promote all integral types whose size is < sizeof(i32) into i32.  
+ // We do this by zero or sign extending the value as appropriate 
+ // according to the parameter attributes
+  const Type *Ty = V->getType();
+  if (Ty->isInteger() && (ArgVals.back().IntVal.getBitWidth() < 32))
+if (const ParamAttrsList *PA = F->getParamAttrs())
+  if (PA->paramHasAttr(pNum, ParamAttr::ZExt))
+ArgVals.back().IntVal = ArgVals.back().IntVal.zext(32);
+  else if (PA->paramHasAttr(pNum, ParamAttr::SExt))
+ArgVals.back().IntVal = ArgVals.back().IntVal.sext(32);
+ }
   }
 
   // To handle indirect calls, we must get the pointer value from the argument
@@ -1317,7 +1325,8 @@
 
   // Handle non-varargs arguments...
   unsigned i = 0;
-  for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; 
++AI, ++i)
+  for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); 
+   AI != E; ++AI, ++i)
 SetValue(AI, ArgVals[i], StackFrame);
 
   // Handle varargs arguments...



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-08 Thread Reid Spencer
On Thu, 2007-03-08 at 15:38 -0800, Bill wrote:
> On 3/8/07, Chris Lattner <[EMAIL PROTECTED]> wrote:
> > On Mar 8, 2007, at 3:27 PM, Bill Wendling wrote:
> > > Changes in directory llvm/lib/ExecutionEngine/Interpreter:
> > > Execution.cpp updated: 1.175 -> 1.176
> > > ---
> > > Log message:
> > >
> > > Don't use a cast. It causes an error on some platforms.
> >
> > std::hex is sticky.  Please don't use it.
> >
> > I assume that this fails because memory is a pointer?  If so, try
> > casting to uintptr_t
> >
> What means you this "sticky"?

Its sticky because it sets a hex mode output for all subsequent numeric
<< operators. Of course, you can set it back with something like:

cerr << std::hex << hexValue << std::dec;

> 
> Done :-)
> 
> -bw
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-08 Thread Bill
On 3/8/07, Chris Lattner <[EMAIL PROTECTED]> wrote:
> On Mar 8, 2007, at 3:27 PM, Bill Wendling wrote:
> > Changes in directory llvm/lib/ExecutionEngine/Interpreter:
> > Execution.cpp updated: 1.175 -> 1.176
> > ---
> > Log message:
> >
> > Don't use a cast. It causes an error on some platforms.
>
> std::hex is sticky.  Please don't use it.
>
> I assume that this fails because memory is a pointer?  If so, try
> casting to uintptr_t
>
What means you this "sticky"?

Done :-)

-bw
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-08 Thread Bill Wendling


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.176 -> 1.177
---
Log message:

Don't use std::hex.


---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.176 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.177
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.176Thu Mar  8 
17:26:50 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu Mar  8 17:37:24 2007
@@ -753,7 +753,7 @@
 
   DOUT << "Allocated Type: " << *Ty << " (" << TypeSize << " bytes) x " 
<< NumElements << " (Total: " << MemToAlloc << ") at "
-   << std::hex << Memory << '\n';
+   << uintptr_t(Memory) << '\n';
 
   GenericValue Result = PTOGV(Memory);
   assert(Result.PointerVal != 0 && "Null pointer returned by malloc!");



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-08 Thread Chris Lattner
On Mar 8, 2007, at 3:27 PM, Bill Wendling wrote:
> Changes in directory llvm/lib/ExecutionEngine/Interpreter:
> Execution.cpp updated: 1.175 -> 1.176
> ---
> Log message:
>
> Don't use a cast. It causes an error on some platforms.

std::hex is sticky.  Please don't use it.

I assume that this fails because memory is a pointer?  If so, try  
casting to uintptr_t

-Chris

>
> ---
> Diffs of the changes:  (+1 -1)
>
>  Execution.cpp |2 +-
>  1 files changed, 1 insertion(+), 1 deletion(-)
>
>
> Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
> diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.175  
> llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.176
> --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.175  Mon  
> Mar  5 21:46:41 2007
> +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cppThu Mar  8  
> 17:26:50 2007
> @@ -753,7 +753,7 @@
>
>DOUT << "Allocated Type: " << *Ty << " (" << TypeSize << "  
> bytes) x "
> << NumElements << " (Total: " << MemToAlloc << ") at "
> -   << unsigned(Memory) << '\n';
> +   << std::hex << Memory << '\n';
>
>GenericValue Result = PTOGV(Memory);
>assert(Result.PointerVal != 0 && "Null pointer returned by  
> malloc!");
>
>
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-08 Thread Bill Wendling


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.175 -> 1.176
---
Log message:

Don't use a cast. It causes an error on some platforms.


---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.175 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.176
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.175Mon Mar  5 
21:46:41 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu Mar  8 17:26:50 2007
@@ -753,7 +753,7 @@
 
   DOUT << "Allocated Type: " << *Ty << " (" << TypeSize << " bytes) x " 
<< NumElements << " (Total: " << MemToAlloc << ") at "
-   << unsigned(Memory) << '\n';
+   << std::hex << Memory << '\n';
 
   GenericValue Result = PTOGV(Memory);
   assert(Result.PointerVal != 0 && "Null pointer returned by malloc!");



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-05 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.174 -> 1.175
---
Log message:

Fix some thinko's in the last patch. PtrSize has to be in bits and we 
might need to zext not just trunc the value.


---
Diffs of the changes:  (+2 -2)

 Execution.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.174 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.175
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.174Mon Mar  5 
21:41:50 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Mon Mar  5 21:46:41 2007
@@ -1058,9 +1058,9 @@
   GenericValue Dest, Src = getOperandValue(SrcVal, SF);
   assert(isa(DstTy) && "Invalid PtrToInt instruction");
 
-  uint32_t PtrSize = TD.getPointerSize();
+  uint32_t PtrSize = TD.getPointerSizeInBits();
   if (PtrSize != Src.IntVal.getBitWidth())
-Src.IntVal = Src.IntVal.trunc(PtrSize);
+Src.IntVal = Src.IntVal.zextOrTrunc(PtrSize);
 
   Dest.PointerVal = (PointerTy) Src.IntVal.getZExtValue();
   return Dest;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-05 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.173 -> 1.174
---
Log message:

Fix a bug in IntToPtr. Truncating to 64-bits only works if the integer
is larger. Adjust so that it truncates to pointer width, only if necessary.


---
Diffs of the changes:  (+5 -1)

 Execution.cpp |6 +-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.174
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173Mon Mar  5 
21:09:31 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Mon Mar  5 21:41:50 2007
@@ -1058,7 +1058,11 @@
   GenericValue Dest, Src = getOperandValue(SrcVal, SF);
   assert(isa(DstTy) && "Invalid PtrToInt instruction");
 
-  Dest.PointerVal = (PointerTy) Src.IntVal.trunc(64).getZExtValue();
+  uint32_t PtrSize = TD.getPointerSize();
+  if (PtrSize != Src.IntVal.getBitWidth())
+Src.IntVal = Src.IntVal.trunc(PtrSize);
+
+  Dest.PointerVal = (PointerTy) Src.IntVal.getZExtValue();
   return Dest;
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-05 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.172 -> 1.173
---
Log message:

Radically simplify execution. This patch gets rid of all the special
handling for integer of various sizes. GenericValue now has just a single
integer field of type APInt. We use its facilities directly in the
execution of all instructions.


---
Diffs of the changes:  (+128 -636)

 Execution.cpp |  764 +-
 1 files changed, 128 insertions(+), 636 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.172 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.172Sat Mar  3 
02:38:04 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Mon Mar  5 21:09:31 2007
@@ -32,12 +32,6 @@
 // Various Helper Functions
 
//===--===//
 
-inline void initializeAPInt(GenericValue &GV, const Type* Ty, 
- ExecutionContext &SF) {
-  if (const IntegerType *ITy = dyn_cast(Ty)) 
-GV.APIntVal = SF.getAPInt(ITy->getBitWidth());
-}
-
 static inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
   // Determine if the value is signed or not
   bool isSigned = (Val & (1 << (ITy->getBitWidth()-1))) != 0;
@@ -47,22 +41,6 @@
   return Val;
 }
 
-static inline void maskToBitWidth(GenericValue& GV, unsigned BitWidth) {
-  uint64_t BitMask = ~(uint64_t)(0ull) >> (64-BitWidth);
-  if (BitWidth <= 8)
-GV.Int8Val &= BitMask;
-  else if (BitWidth <= 16)
-GV.Int16Val &= BitMask;
-  else if (BitWidth <= 32)
-GV.Int32Val &= BitMask;
-  else if (BitWidth <= 64)
-GV.Int64Val &= BitMask;
-  else {
-assert(GV.APIntVal && "Unallocated GV.APIntVal");
-*(GV.APIntVal) &= APInt::getAllOnesValue(BitWidth);
-  }
-}
-
 static void SetValue(Value *V, GenericValue Val, ExecutionContext &SF) {
   SF.Values[V] = Val;
 }
@@ -76,79 +54,21 @@
 
//===--===//
 
 #define IMPLEMENT_BINARY_OPERATOR(OP, TY) \
-   case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; break
+   case Type::TY##TyID: \
+ Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; \
+ break
 
-#define IMPLEMENT_INTEGER_BINOP(OP, TY) \
+#define IMPLEMENT_INTEGER_BINOP1(OP, TY) \
case Type::IntegerTyID: { \
- unsigned BitWidth = cast(TY)->getBitWidth(); \
- if (BitWidth == 1) {\
-   Dest.Int1Val = Src1.Int1Val OP Src2.Int1Val; \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 8) {\
-   Dest.Int8Val = Src1.Int8Val OP Src2.Int8Val; \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 16) {\
-   Dest.Int16Val = Src1.Int16Val OP Src2.Int16Val; \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 32) {\
-   Dest.Int32Val = Src1.Int32Val OP Src2.Int32Val; \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 64) {\
-   Dest.Int64Val = Src1.Int64Val OP Src2.Int64Val; \
-   maskToBitWidth(Dest, BitWidth); \
- } else \
-   *(Dest.APIntVal) = *(Src1.APIntVal) OP *(Src2.APIntVal); \
+ Dest.IntVal = Src1.IntVal OP Src2.IntVal; \
  break; \
}
 
-#define IMPLEMENT_SIGNED_BINOP(OP, TY, APOP) \
-   if (const IntegerType *ITy = dyn_cast(TY)) { \
- unsigned BitWidth = ITy->getBitWidth(); \
- if (BitWidth <= 8) { \
-   Dest.Int8Val  = ((int8_t)Src1.Int8Val)   OP ((int8_t)Src2.Int8Val); \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 16) { \
-   Dest.Int16Val = ((int16_t)Src1.Int16Val) OP ((int16_t)Src2.Int16Val); \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 32) { \
-   Dest.Int32Val = ((int32_t)Src1.Int32Val) OP ((int32_t)Src2.Int32Val); \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 64) { \
-   Dest.Int64Val = ((int64_t)Src1.Int64Val) OP ((int64_t)Src2.Int64Val); \
-   maskToBitWidth(Dest, BitWidth); \
- } else \
-   *(Dest.APIntVal) = Src1.APIntVal->APOP(*(Src2.APIntVal)); \
-   } else { \
-cerr << "Unhandled type for " #OP " operator: " << *Ty << "\n"; \
-abort(); \
-   }
-
-#define IMPLEMENT_UNSIGNED_BINOP(OP, TY, APOP) \
-   if (const IntegerType *ITy = dyn_cast(TY)) { \
- unsigned BitWidth = ITy->getBitWidth(); \
- if (BitWidth <= 8) {\
-   Dest.Int8Val  = ((uint8_t)Src1.Int8Val)   OP ((uint8_t)Src2.Int8Val); \
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 16) {\
-   Dest.Int16Val = ((uint16_t)Src1.Int16Val) OP ((uint16_t)Src2.Int16Val); 
\
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 32) {\
-   Dest.Int32Val = ((uint32_t)Src1.Int32Val) OP ((uint32_t)Src2.Int32Val); 
\
-   maskToBitWidth(Dest, BitWidth); \
- } else if (BitWi

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-03 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.171 -> 1.172
---
Log message:

Complete the APIntification of the interpreter. All asserts for > 64 bits
have been removed and dealt with. The interpreter should now be able to
execute any LLVM program using any bit width.


---
Diffs of the changes:  (+209 -118)

 Execution.cpp |  327 +-
 1 files changed, 209 insertions(+), 118 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.171 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.172
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.171Sat Mar  3 
00:22:22 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Mar  3 02:38:04 2007
@@ -242,7 +242,7 @@
   IMPLEMENT_UNSIGNED_BINOP(^,Ty,Xor)
 }
 
-#define IMPLEMENT_SIGNED_ICMP(OP, TY) \
+#define IMPLEMENT_SIGNED_ICMP(OP, TY, APOP) \
case Type::IntegerTyID: {  \
  const IntegerType* ITy = cast(TY); \
  unsigned BitWidth = ITy->getBitWidth(); \
@@ -250,41 +250,46 @@
  if (BitWidth <= 8) { \
LHS = int64_t(doSignExtension(uint64_t(Src1.Int8Val), ITy)); \
RHS = int64_t(doSignExtension(uint64_t(Src2.Int8Val), ITy)); \
+   Dest.Int1Val = LHS OP RHS; \
  } else if (BitWidth <= 16) { \
LHS = int64_t(doSignExtension(uint64_t(Src1.Int16Val), ITy)); \
RHS = int64_t(doSignExtension(uint64_t(Src2.Int16Val), ITy)); \
+   Dest.Int1Val = LHS OP RHS; \
 } else if (BitWidth <= 32) { \
LHS = int64_t(doSignExtension(uint64_t(Src1.Int32Val), ITy)); \
RHS = int64_t(doSignExtension(uint64_t(Src2.Int32Val), ITy)); \
+   Dest.Int1Val = LHS OP RHS; \
 } else if (BitWidth <= 64) { \
LHS = int64_t(doSignExtension(uint64_t(Src1.Int64Val), ITy)); \
RHS = int64_t(doSignExtension(uint64_t(Src2.Int64Val), ITy)); \
+   Dest.Int1Val = LHS OP RHS; \
 } else { \
-  cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
-   abort(); \
- } \
- Dest.Int1Val = LHS OP RHS; \
- break; \
-   }
+  Dest.Int1Val = Src1.APIntVal->APOP(*(Src2.APIntVal)); \
+} \
+break; \
+  }
 
-#define IMPLEMENT_UNSIGNED_ICMP(OP, TY) \
+#define IMPLEMENT_UNSIGNED_ICMP(OP, TY, APOP) \
case Type::IntegerTyID: { \
  unsigned BitWidth = cast(TY)->getBitWidth(); \
- if (BitWidth == 1) \
+ if (BitWidth == 1) { \
Dest.Int1Val = ((uint8_t)Src1.Int1Val)   OP ((uint8_t)Src2.Int1Val); \
- else if (BitWidth <= 8) \
+   maskToBitWidth(Dest, BitWidth); \
+ } else if (BitWidth <= 8) { \
Dest.Int1Val = ((uint8_t)Src1.Int8Val)   OP ((uint8_t)Src2.Int8Val); \
- else if (BitWidth <= 16) \
+   maskToBitWidth(Dest, BitWidth); \
+ } else if (BitWidth <= 16) { \
Dest.Int1Val = ((uint16_t)Src1.Int16Val) OP ((uint16_t)Src2.Int16Val); \
- else if (BitWidth <= 32) \
+   maskToBitWidth(Dest, BitWidth); \
+ } else if (BitWidth <= 32) { \
Dest.Int1Val = ((uint32_t)Src1.Int32Val) OP ((uint32_t)Src2.Int32Val); \
- else if (BitWidth <= 64) \
+   maskToBitWidth(Dest, BitWidth); \
+ } else if (BitWidth <= 64) { \
Dest.Int1Val = ((uint64_t)Src1.Int64Val) OP ((uint64_t)Src2.Int64Val); \
- else { \
-  cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
-   abort(); \
+   maskToBitWidth(Dest, BitWidth); \
+ } else { \
+   Dest.Int1Val = Src1.APIntVal->APOP(*(Src2.APIntVal)); \
  } \
- maskToBitWidth(Dest, BitWidth); \
  break; \
}
 
@@ -301,7 +306,7 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_UNSIGNED_ICMP(==, Ty);
+IMPLEMENT_UNSIGNED_ICMP(==, Ty, eq);
 IMPLEMENT_POINTER_ICMP(==);
   default:
 cerr << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
@@ -314,7 +319,7 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_UNSIGNED_ICMP(!=, Ty);
+IMPLEMENT_UNSIGNED_ICMP(!=, Ty, ne);
 IMPLEMENT_POINTER_ICMP(!=);
   default:
 cerr << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
@@ -327,7 +332,7 @@
 const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_UNSIGNED_ICMP(<, Ty);
+IMPLEMENT_UNSIGNED_ICMP(<, Ty, ult);
 IMPLEMENT_POINTER_ICMP(<);
   default:
 cerr << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
@@ -340,7 +345,7 @@
 const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_SIGNED_ICMP(<, Ty);
+IMPLEMENT_SIGNED_ICMP(<, Ty, slt);
 IMPLEMENT_POINTER_ICMP(<);
   default:
 cerr << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
@@ -353,7 +358,7 @@
 const Type

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.170 -> 1.171
---
Log message:

Implement APInt support for the binary operators. 
Move the getConstantExpr function towards the end of the file so we don't 
need a dozen forward declarations.


---
Diffs of the changes:  (+240 -254)

 Execution.cpp |  494 --
 1 files changed, 240 insertions(+), 254 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.170 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.171
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.170Wed Feb 14 
00:20:04 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Mar  3 00:22:22 2007
@@ -18,6 +18,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
+#include "llvm/ADT/APInt.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
@@ -27,47 +28,17 @@
 STATISTIC(NumDynamicInsts, "Number of dynamic instructions executed");
 static Interpreter *TheEE = 0;
 
-
 
//===--===//
-// Value Manipulation code
+// Various Helper Functions
 
//===--===//
 
-static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeCmpInst(unsigned predicate, GenericValue Src1, 
-   GenericValue Src2, const Type *Ty);
-static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeAShrInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2,
-  GenericValue Src3);
+inline void initializeAPInt(GenericValue &GV, const Type* Ty, 
+ ExecutionContext &SF) {
+  if (const IntegerType *ITy = dyn_cast(Ty)) 
+GV.APIntVal = SF.getAPInt(ITy->getBitWidth());
+}
 
-inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
+static inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
   // Determine if the value is signed or not
   bool isSigned = (Val & (1 << (ITy->getBitWidth()-1))) != 0;
   // If its signed, extend the sign bits
@@ -76,122 +47,19 @@
   return Val;
 }
 
-GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
-ExecutionContext &SF) {
-  switch (CE->getOpcode()) {
-  case Instruction::Trunc:   
-  return executeTruncInst(CE->getOperand(0), CE->getType(), SF);
-  case Instruction::ZExt:
-  return executeZExtInst(CE->getOperand(0), CE->getType(), SF);
-  case Instruction::SExt:
-  return executeSExtInst(CE->getOperand(0), CE->getType(), SF);
-  case Instruction::FPTrunc:
-  return executeFPTruncInst(CE->getOperand(0), CE->getType(), SF);
-  case Instruction::FPExt:
-  return executeFPExtInst(CE->getOperand(0), CE->getType(), SF);
-  case Instruction::UIToFP:
-  return executeUIToFPInst(CE->getOperand(0), C

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-02-13 Thread Chris Lattner


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.169 -> 1.170
---
Log message:

>From Dan Gohman:

While preparing http://llvm.org/PR1198: http://llvm.org/PR1198  I noticed 
several asserts
protecting unprepared code from i128 types that weren't actually failing
when they should because they were written as assert("foo") instead of
something like assert(0 && "foo"). This patch fixes all the cases that a
quick grep found.



---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.169 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.170
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.169Sat Feb 10 
13:55:17 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Feb 14 00:20:04 2007
@@ -1690,7 +1690,7 @@
   else if (BitWidth <= 64)
 Dest.Int64Val = Src.Int64Val;
   else
-assert("Integer types > 64 bits not supported");
+assert(0 && "Integer types > 64 bits not supported");
   maskToBitWidth(Dest, BitWidth);
 }
 IMPLEMENT_VAARG(Pointer);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-02-10 Thread Chris Lattner


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.168 -> 1.169
---
Log message:

Privatize StructLayout::MemberOffsets, adding an accessor


---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.168 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.169
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.168Wed Feb  7 
18:29:31 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Feb 10 13:55:17 2007
@@ -1082,7 +1082,7 @@
   const ConstantInt *CPU = cast(I.getOperand());
   unsigned Index = unsigned(CPU->getZExtValue());
 
-  Total += (PointerTy)SLO->MemberOffsets[Index];
+  Total += (PointerTy)SLO->getElementOffset(Index);
 } else {
   const SequentialType *ST = cast(*I);
   // Get the index number for the array... which must be long type...



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.h

2007-02-07 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.167 -> 1.168
Interpreter.h updated: 1.82 -> 1.83
---
Log message:

For PR1188: http://llvm.org/PR1188 :
Compute BitMask correctly.

Patch by Leo ([EMAIL PROTECTED]).


---
Diffs of the changes:  (+2 -2)

 Execution.cpp |2 +-
 Interpreter.h |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.167 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.168
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.167Thu Feb  1 
20:16:22 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Feb  7 18:29:31 2007
@@ -1307,7 +1307,7 @@
 
 #define INTEGER_ASSIGN(DEST, BITWIDTH, VAL) \
   { \
-uint64_t Mask = (1ull << BITWIDTH) - 1; \
+uint64_t Mask = ~(uint64_t)(0ull) >> (64-BITWIDTH); \
 if (BITWIDTH == 1) {\
   Dest.Int1Val = (bool) (VAL & Mask);   \
 } else if (BITWIDTH <= 8) { \


Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.82 
llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.83
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.82 Thu Feb  1 
20:16:22 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h  Wed Feb  7 18:29:31 2007
@@ -236,7 +236,7 @@
 };
 
 inline void maskToBitWidth(GenericValue& GV, unsigned BitWidth) {
-  uint64_t BitMask = (1ull << BitWidth) - 1;
+  uint64_t BitMask = ~(uint64_t)(0ull) >> (64-BitWidth);
   if (BitWidth <= 8)
 GV.Int8Val &= BitMask;
   else if (BitWidth <= 16)



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.h

2007-02-01 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.166 -> 1.167
Interpreter.h updated: 1.81 -> 1.82
---
Log message:

Changes to support making the shift instructions be true BinaryOperators.
This feature is needed in order to support shifts of more than 255 bits
on large integer types.  This changes the syntax for llvm assembly to 
make shl, ashr and lshr instructions look like a binary operator:
   shl i32 %X, 1
instead of
   shl i32 %X, i8 1
Additionally, this should help a few passes perform additional optimizations.


---
Diffs of the changes:  (+7 -6)

 Execution.cpp |6 +++---
 Interpreter.h |7 ---
 2 files changed, 7 insertions(+), 6 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.166 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.167
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.166Tue Jan 30 
14:08:37 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu Feb  1 20:16:22 2007
@@ -1275,7 +1275,7 @@
   return Dest;
 }
 
-void Interpreter::visitShl(ShiftInst &I) {
+void Interpreter::visitShl(BinaryOperator &I) {
   ExecutionContext &SF = ECStack.back();
   const Type *Ty= I.getOperand(0)->getType();
   GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
@@ -1285,7 +1285,7 @@
   SetValue(&I, Dest, SF);
 }
 
-void Interpreter::visitLShr(ShiftInst &I) {
+void Interpreter::visitLShr(BinaryOperator &I) {
   ExecutionContext &SF = ECStack.back();
   const Type *Ty= I.getOperand(0)->getType();
   GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
@@ -1295,7 +1295,7 @@
   SetValue(&I, Dest, SF);
 }
 
-void Interpreter::visitAShr(ShiftInst &I) {
+void Interpreter::visitAShr(BinaryOperator &I) {
   ExecutionContext &SF = ECStack.back();
   const Type *Ty= I.getOperand(0)->getType();
   GenericValue Src1 = getOperandValue(I.getOperand(0), SF);


Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.81 
llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.82
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.81 Wed Jan 17 
20:12:10 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h  Thu Feb  1 20:16:22 2007
@@ -165,9 +165,10 @@
   void visitUnwindInst(UnwindInst &I);
   void visitUnreachableInst(UnreachableInst &I);
 
-  void visitShl(ShiftInst &I);
-  void visitLShr(ShiftInst &I);
-  void visitAShr(ShiftInst &I);
+  void visitShl(BinaryOperator &I);
+  void visitLShr(BinaryOperator &I);
+  void visitAShr(BinaryOperator &I);
+
   void visitVAArgInst(VAArgInst &I);
   void visitInstruction(Instruction &I) {
 cerr << I;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-30 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.165 -> 1.166
---
Log message:

For PR1136: http://llvm.org/PR1136 : Rename GlobalVariable::isExternal as 
isDeclaration to avoid
confusion with external linkage types.


---
Diffs of the changes:  (+2 -2)

 Execution.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.165 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.166
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.165Sat Jan 20 
18:29:25 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Tue Jan 30 14:08:37 2007
@@ -1137,7 +1137,7 @@
 
   // Check to see if this is an intrinsic function call...
   if (Function *F = CS.getCalledFunction())
-   if (F->isExternal ())
+   if (F->isDeclaration ())
 switch (F->getIntrinsicID()) {
 case Intrinsic::not_intrinsic:
   break;
@@ -1726,7 +1726,7 @@
   StackFrame.CurFunction = F;
 
   // Special handling for external functions.
-  if (F->isExternal()) {
+  if (F->isDeclaration()) {
 GenericValue Result = callExternalFunction (F, ArgVals);
 // Simulate a 'ret' instruction of the appropriate type.
 popStackAndReturnValueToCaller (F->getReturnType (), Result);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-20 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.164 -> 1.165
---
Log message:

For PR970: http://llvm.org/PR970 :
Clean up handling of isFloatingPoint() and dealing with PackedType.
Patch by Gordon Henriksen!


---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.164 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.165
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.164Sat Jan 20 
14:12:29 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Jan 20 18:29:25 2007
@@ -1498,7 +1498,7 @@
   const IntegerType *SITy = cast(SrcTy);
   unsigned SBitWidth = SITy->getBitWidth();
   assert(SBitWidth <= 64  && "Integer types > 64 bits not supported");
-  assert(DstTy->isFloatingPoint() && "Invalid UIToFP instruction");
+  assert(DstTy->isFloatingPoint() && "Invalid SIToFP instruction");
   int64_t Converted = 0;
   if (SBitWidth == 1)
 Converted = 0LL - Src.Int1Val;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-20 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.163 -> 1.164
---
Log message:

Implement the signed icmp instructions properly. To do this we introduce
a small inline function to sign extend a uint64_t value based on its 
type's bitwidth. This function is then used in both executeSExtInst and
the various executeICMP_S** functions.


---
Diffs of the changes:  (+27 -17)

 Execution.cpp |   44 +++-
 1 files changed, 27 insertions(+), 17 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.163 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.164
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.163Sat Jan 20 
02:32:52 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Jan 20 14:12:29 2007
@@ -67,6 +67,15 @@
 static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2,
   GenericValue Src3);
 
+inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
+  // Determine if the value is signed or not
+  bool isSigned = (Val & (1 << (ITy->getBitWidth()-1))) != 0;
+  // If its signed, extend the sign bits
+  if (isSigned)
+Val |= ~ITy->getBitMask();
+  return Val;
+}
+
 GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
 ExecutionContext &SF) {
   switch (CE->getOpcode()) {
@@ -385,22 +394,26 @@
 
 #define IMPLEMENT_SIGNED_ICMP(OP, TY) \
case Type::IntegerTyID: {  \
- unsigned BitWidth = cast(TY)->getBitWidth(); \
- if (BitWidth == 1) \
-   Dest.Int1Val = ((int8_t)Src1.Int1Val)   OP ((int8_t)Src2.Int1Val); \
- else if (BitWidth <= 8) \
-   Dest.Int1Val = ((int8_t)Src1.Int8Val)   OP ((int8_t)Src2.Int8Val); \
- else if (BitWidth <= 16) \
-   Dest.Int1Val = ((int16_t)Src1.Int16Val) OP ((int16_t)Src2.Int16Val); \
- else if (BitWidth <= 32) \
-   Dest.Int1Val = ((int32_t)Src1.Int32Val) OP ((int32_t)Src2.Int32Val); \
- else if (BitWidth <= 64) \
-   Dest.Int1Val = ((int64_t)Src1.Int64Val) OP ((int64_t)Src2.Int64Val); \
- else { \
+ const IntegerType* ITy = cast(TY); \
+ unsigned BitWidth = ITy->getBitWidth(); \
+ int64_t LHS = 0, RHS = 0; \
+ if (BitWidth <= 8) { \
+   LHS = int64_t(doSignExtension(uint64_t(Src1.Int8Val), ITy)); \
+   RHS = int64_t(doSignExtension(uint64_t(Src2.Int8Val), ITy)); \
+ } else if (BitWidth <= 16) { \
+   LHS = int64_t(doSignExtension(uint64_t(Src1.Int16Val), ITy)); \
+   RHS = int64_t(doSignExtension(uint64_t(Src2.Int16Val), ITy)); \
+} else if (BitWidth <= 32) { \
+   LHS = int64_t(doSignExtension(uint64_t(Src1.Int32Val), ITy)); \
+   RHS = int64_t(doSignExtension(uint64_t(Src2.Int32Val), ITy)); \
+} else if (BitWidth <= 64) { \
+   LHS = int64_t(doSignExtension(uint64_t(Src1.Int64Val), ITy)); \
+   RHS = int64_t(doSignExtension(uint64_t(Src2.Int64Val), ITy)); \
+} else { \
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
abort(); \
  } \
- maskToBitWidth(Dest, BitWidth); \
+ Dest.Int1Val = LHS OP RHS; \
  break; \
}
 
@@ -1359,10 +1372,7 @@
   else 
 Normalized = Src.Int64Val;
 
-  // Now do the bit-accurate sign extension manually.
-  bool isSigned = (Normalized & (1 << (SBitWidth-1))) != 0;
-  if (isSigned)
-Normalized |= ~SITy->getBitMask();
+  Normalized = doSignExtension(Normalized, SITy);
 
   // Now that we have a sign extended value, assign it to the destination
   INTEGER_ASSIGN(Dest, DBitWidth, Normalized);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-20 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.162 -> 1.163
---
Log message:

Implement bit-accurate sext instruction. 
This patch fixes test/Integer/2007-01-17-TruncSext.ll


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

 Execution.cpp |   24 ++--
 1 files changed, 14 insertions(+), 10 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.162 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.163
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.162Wed Jan 17 
20:12:51 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Jan 20 02:32:52 2007
@@ -1347,21 +1347,25 @@
   assert(SBitWidth <= 64 && DBitWidth <= 64  && 
  "Integer types > 64 bits not supported");
   assert(SBitWidth < DBitWidth && "Invalid sign extend");
-  int64_t Extended = 0;
-  if (SBitWidth == 1)
-// For sign extension from bool, we must extend the source bits.
-Extended = 0 - (Src.Int1Val & 1);
-  else if (SBitWidth <= 8)
-Extended = (int64_t) (int8_t)Src.Int8Val;
+
+  // Normalize to a 64-bit value.
+  uint64_t Normalized = 0;
+  if (SBitWidth <= 8)
+Normalized = Src.Int8Val;
   else if (SBitWidth <= 16)
-Extended = (int64_t) (int16_t)Src.Int16Val;
+Normalized = Src.Int16Val;
   else if (SBitWidth <= 32)
-Extended = (int64_t) (int32_t)Src.Int32Val;
+Normalized = Src.Int32Val;
   else 
-Extended = (int64_t) Src.Int64Val;
+Normalized = Src.Int64Val;
+
+  // Now do the bit-accurate sign extension manually.
+  bool isSigned = (Normalized & (1 << (SBitWidth-1))) != 0;
+  if (isSigned)
+Normalized |= ~SITy->getBitMask();
 
   // Now that we have a sign extended value, assign it to the destination
-  INTEGER_ASSIGN(Dest, DBitWidth, Extended);
+  INTEGER_ASSIGN(Dest, DBitWidth, Normalized);
   return Dest;
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-17 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.161 -> 1.162
---
Log message:

Use the new maskToBitWidth function to ensure that the results of 
computations do not overflow the intended bit width.


---
Diffs of the changes:  (+15 -10)

 Execution.cpp |   25 +++--
 1 files changed, 15 insertions(+), 10 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.161 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.162
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.161Wed Jan 17 
19:32:46 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Jan 17 20:12:51 2007
@@ -216,6 +216,7 @@
Dest.Int64Val = Src1.Int64Val OP Src2.Int64Val; \
  else \
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
+ maskToBitWidth(Dest, BitWidth); \
  break; \
}
 
@@ -234,6 +235,7 @@
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
abort(); \
  } \
+ maskToBitWidth(Dest, BitWidth); \
} else { \
 cerr << "Unhandled type for " #OP " operator: " << *Ty << "\n"; \
 abort(); \
@@ -254,6 +256,7 @@
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
abort(); \
  } \
+ maskToBitWidth(Dest, BitWidth); \
} else { \
 cerr << "Unhandled type for " #OP " operator: " << *Ty << "\n"; \
 abort(); \
@@ -397,6 +400,7 @@
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
abort(); \
  } \
+ maskToBitWidth(Dest, BitWidth); \
  break; \
}
 
@@ -417,6 +421,7 @@
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
abort(); \
  } \
+ maskToBitWidth(Dest, BitWidth); \
  break; \
}
 
@@ -1187,23 +1192,19 @@
   GenericValue Dest;
   if (const IntegerType *ITy = cast(Ty)) {
 unsigned BitWidth = ITy->getBitWidth();
-uint32_t BitMask = (1ull << BitWidth) - 1;
-if (BitWidth <= 8) {
+if (BitWidth <= 8)
   Dest.Int8Val  = ((uint8_t)Src1.Int8Val)   << ((uint32_t)Src2.Int8Val);
-  Dest.Int8Val &= BitMask;
-} else if (BitWidth <= 16) {
+else if (BitWidth <= 16)
   Dest.Int16Val = ((uint16_t)Src1.Int16Val) << ((uint32_t)Src2.Int8Val);
-  Dest.Int16Val &= BitMask;
-} else if (BitWidth <= 32) {
+else if (BitWidth <= 32)
   Dest.Int32Val = ((uint32_t)Src1.Int32Val) << ((uint32_t)Src2.Int8Val);
-  Dest.Int32Val &= BitMask;
-} else if (BitWidth <= 64) {
+else if (BitWidth <= 64)
   Dest.Int64Val = ((uint64_t)Src1.Int64Val) << ((uint32_t)Src2.Int8Val);
-  Dest.Int64Val &= BitMask;
-} else {
+else {
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n";
   abort();
 }
+maskToBitWidth(Dest, BitWidth);
   } else {
 cerr << "Unhandled type for Shl instruction: " << *Ty << "\n";
 abort();
@@ -1228,6 +1229,7 @@
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n";
   abort();
 }
+maskToBitWidth(Dest, BitWidth);
   } else {
 cerr << "Unhandled type for LShr instruction: " << *Ty << "\n";
 abort();
@@ -1252,6 +1254,7 @@
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n"; \
   abort();
 } 
+maskToBitWidth(Dest, BitWidth);
   } else { 
 cerr << "Unhandled type for AShr instruction: " << *Ty << "\n";
 abort();
@@ -1567,6 +1570,7 @@
 Dest.Int32Val = Src.Int32Val;
   else 
 Dest.Int64Val = Src.Int64Val;
+  maskToBitWidth(Dest, DBitWidth);
 } else 
   assert(0 && "Invalid BitCast");
   } else if (DstTy == Type::FloatTy) {
@@ -1673,6 +1677,7 @@
 Dest.Int64Val = Src.Int64Val;
   else
 assert("Integer types > 64 bits not supported");
+  maskToBitWidth(Dest, BitWidth);
 }
 IMPLEMENT_VAARG(Pointer);
 IMPLEMENT_VAARG(Float);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-17 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.160 -> 1.161
---
Log message:

Make shl instruction mask its result to the correct bitsize. This is 
sufficient to get llvm-test/SingleSource/UnitTests/Integer/general-test.ll
working with lli in interpreter mode.


---
Diffs of the changes:  (+10 -5)

 Execution.cpp |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.160 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.161
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.160Wed Jan 17 
19:25:42 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Jan 17 19:32:46 2007
@@ -1187,15 +1187,20 @@
   GenericValue Dest;
   if (const IntegerType *ITy = cast(Ty)) {
 unsigned BitWidth = ITy->getBitWidth();
-if (BitWidth <= 8)
+uint32_t BitMask = (1ull << BitWidth) - 1;
+if (BitWidth <= 8) {
   Dest.Int8Val  = ((uint8_t)Src1.Int8Val)   << ((uint32_t)Src2.Int8Val);
-else if (BitWidth <= 16)
+  Dest.Int8Val &= BitMask;
+} else if (BitWidth <= 16) {
   Dest.Int16Val = ((uint16_t)Src1.Int16Val) << ((uint32_t)Src2.Int8Val);
-else if (BitWidth <= 32)
+  Dest.Int16Val &= BitMask;
+} else if (BitWidth <= 32) {
   Dest.Int32Val = ((uint32_t)Src1.Int32Val) << ((uint32_t)Src2.Int8Val);
-else if (BitWidth <= 64)
+  Dest.Int32Val &= BitMask;
+} else if (BitWidth <= 64) {
   Dest.Int64Val = ((uint64_t)Src1.Int64Val) << ((uint32_t)Src2.Int8Val);
-else {
+  Dest.Int64Val &= BitMask;
+} else {
   cerr << "Integer types > 64 bits not supported: " << *Ty << "\n";
   abort();
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-17 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.159 -> 1.160
---
Log message:

Two changes:
1. Fix logic for executeGEP. Only 32-bit and 64-bit integer types are 
   acceptable as indices.
2. Ensure that all integer cast operations truncate their result to the
   integer size of the operand.


---
Diffs of the changes:  (+17 -18)

 Execution.cpp |   35 +--
 1 files changed, 17 insertions(+), 18 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.159 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.160
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.159Sun Jan 14 
20:27:26 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Jan 17 19:25:42 2007
@@ -1073,16 +1073,12 @@
   int64_t Idx;
   unsigned BitWidth = 
 cast(I.getOperand()->getType())->getBitWidth();
-  if (BitWidth <= 8)
-Idx = (int64_t)(int8_t)IdxGV.Int8Val;
-  else if (BitWidth <= 16)
-Idx = (int64_t)(int16_t)IdxGV.Int16Val;
-  else if (BitWidth <= 32)
+  if (BitWidth == 32)
 Idx = (int64_t)(int32_t)IdxGV.Int32Val;
-  else if (BitWidth <= 64)
+  else if (BitWidth == 64)
 Idx = (int64_t)IdxGV.Int64Val;
   else 
-assert(0 && "Integer types >64 bits not supported");
+assert(0 && "Invalid index type for getelementptr");
   Total += PointerTy(TD.getTypeSize(ST->getElementType())*Idx);
 }
   }
@@ -1288,17 +1284,20 @@
   SetValue(&I, Dest, SF);
 }
 
-#define INTEGER_ASSIGN(DEST, BITWIDTH, VAL)   \
-  if (BITWIDTH == 1) {\
-Dest.Int1Val = (bool) VAL;\
-  } else if (BITWIDTH <= 8) { \
-Dest.Int8Val = (uint8_t) VAL; \
-  } else if (BITWIDTH <= 16) {\
-Dest.Int16Val = (uint16_t) VAL;   \
-  } else if (BITWIDTH <= 32) {\
-Dest.Int32Val = (uint32_t) VAL;   \
-  } else  \
-Dest.Int64Val = (uint64_t) VAL;  
+#define INTEGER_ASSIGN(DEST, BITWIDTH, VAL) \
+  { \
+uint64_t Mask = (1ull << BITWIDTH) - 1; \
+if (BITWIDTH == 1) {\
+  Dest.Int1Val = (bool) (VAL & Mask);   \
+} else if (BITWIDTH <= 8) { \
+  Dest.Int8Val = (uint8_t) (VAL & Mask);\
+} else if (BITWIDTH <= 16) {\
+  Dest.Int16Val = (uint16_t) (VAL & Mask);  \
+} else if (BITWIDTH <= 32) {\
+  Dest.Int32Val = (uint32_t) (VAL & Mask);  \
+} else  \
+  Dest.Int64Val = (uint64_t) (VAL & Mask);  \
+  }
 
 GenericValue Interpreter::executeTruncInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-14 Thread Chris Lattner


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.158 -> 1.159
---
Log message:

rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.

This makes naming much more consistent.  For example, there are now no longer 
any
instances of IntegerType that are not considered isInteger! :)



---
Diffs of the changes:  (+6 -6)

 Execution.cpp |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.158 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.159
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.158Sun Jan 14 
20:03:16 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sun Jan 14 20:27:26 2007
@@ -891,7 +891,7 @@
   ECStack.pop_back();
 
   if (ECStack.empty()) {  // Finished main.  Put result into exit code...
-if (RetTy && RetTy->isIntegral()) {  // Nonvoid return type?
+if (RetTy && RetTy->isInteger()) {  // Nonvoid return type?
   ExitValue = Result;   // Capture the exit value of the program
 } else {
   memset(&ExitValue, 0, sizeof(ExitValue));
@@ -1170,7 +1170,7 @@
 // this by zero or sign extending the value as appropriate according to the
 // source type.
 const Type *Ty = V->getType();
-if (Ty->isIntegral()) {
+if (Ty->isInteger()) {
   if (Ty->getPrimitiveSizeInBits() == 1)
 ArgVals.back().Int32Val = ArgVals.back().Int1Val;
   else if (Ty->getPrimitiveSizeInBits() <= 8)
@@ -1541,14 +1541,14 @@
   if (isa(DstTy)) {
 assert(isa(SrcTy) && "Invalid BitCast");
 Dest.PointerVal = Src.PointerVal;
-  } else if (DstTy->isIntegral()) {
+  } else if (DstTy->isInteger()) {
 const IntegerType *DITy = cast(DstTy);
 unsigned DBitWidth = DITy->getBitWidth();
 if (SrcTy == Type::FloatTy) {
   Dest.Int32Val = FloatToBits(Src.FloatVal);
 } else if (SrcTy == Type::DoubleTy) {
   Dest.Int64Val = DoubleToBits(Src.DoubleVal);
-} else if (SrcTy->isIntegral()) {
+} else if (SrcTy->isInteger()) {
   const IntegerType *SITy = cast(SrcTy);
   unsigned SBitWidth = SITy->getBitWidth();
   assert(SBitWidth <= 64  && "Integer types > 64 bits not supported");
@@ -1566,12 +1566,12 @@
 } else 
   assert(0 && "Invalid BitCast");
   } else if (DstTy == Type::FloatTy) {
-if (SrcTy->isIntegral())
+if (SrcTy->isInteger())
   Dest.FloatVal = BitsToFloat(Src.Int32Val);
 else
   Dest.FloatVal = Src.FloatVal;
   } else if (DstTy == Type::DoubleTy) {
-if (SrcTy->isIntegral())
+if (SrcTy->isInteger())
   Dest.DoubleVal = BitsToDouble(Src.Int64Val);
 else
   Dest.DoubleVal = Src.DoubleVal;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-01-14 Thread Chris Lattner


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.157 -> 1.158
---
Log message:

eliminate calls to Type::isInteger, preferring isIntegral instead.


---
Diffs of the changes:  (+4 -4)

 Execution.cpp |8 
 1 files changed, 4 insertions(+), 4 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.157 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.158
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.157Fri Jan 12 
01:05:13 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sun Jan 14 20:03:16 2007
@@ -1541,14 +1541,14 @@
   if (isa(DstTy)) {
 assert(isa(SrcTy) && "Invalid BitCast");
 Dest.PointerVal = Src.PointerVal;
-  } else if (DstTy->isInteger()) {
+  } else if (DstTy->isIntegral()) {
 const IntegerType *DITy = cast(DstTy);
 unsigned DBitWidth = DITy->getBitWidth();
 if (SrcTy == Type::FloatTy) {
   Dest.Int32Val = FloatToBits(Src.FloatVal);
 } else if (SrcTy == Type::DoubleTy) {
   Dest.Int64Val = DoubleToBits(Src.DoubleVal);
-} else if (SrcTy->isInteger()) {
+} else if (SrcTy->isIntegral()) {
   const IntegerType *SITy = cast(SrcTy);
   unsigned SBitWidth = SITy->getBitWidth();
   assert(SBitWidth <= 64  && "Integer types > 64 bits not supported");
@@ -1566,12 +1566,12 @@
 } else 
   assert(0 && "Invalid BitCast");
   } else if (DstTy == Type::FloatTy) {
-if (SrcTy->isInteger())
+if (SrcTy->isIntegral())
   Dest.FloatVal = BitsToFloat(Src.Int32Val);
 else
   Dest.FloatVal = Src.FloatVal;
   } else if (DstTy == Type::DoubleTy) {
-if (SrcTy->isInteger())
+if (SrcTy->isIntegral())
   Dest.DoubleVal = BitsToDouble(Src.Int64Val);
 else
   Dest.DoubleVal = Src.DoubleVal;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp ExternalFunctions.cpp

2007-01-11 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.155 -> 1.156
ExternalFunctions.cpp updated: 1.93 -> 1.94
---
Log message:

Rename BoolTy as Int1Ty. Patch by Sheng Zhou.


---
Diffs of the changes:  (+27 -27)

 Execution.cpp |   52 +-
 ExternalFunctions.cpp |2 -
 2 files changed, 27 insertions(+), 27 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.155 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.156
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.155Sat Dec 30 
23:51:36 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu Jan 11 12:21:29 2007
@@ -339,7 +339,7 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(&, Bool);
+IMPLEMENT_BINARY_OPERATOR(&, Int1);
 IMPLEMENT_BINARY_OPERATOR(&, Int8);
 IMPLEMENT_BINARY_OPERATOR(&, Int16);
 IMPLEMENT_BINARY_OPERATOR(&, Int32);
@@ -355,7 +355,7 @@
   const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(|, Bool);
+IMPLEMENT_BINARY_OPERATOR(|, Int1);
 IMPLEMENT_BINARY_OPERATOR(|, Int8);
 IMPLEMENT_BINARY_OPERATOR(|, Int16);
 IMPLEMENT_BINARY_OPERATOR(|, Int32);
@@ -371,7 +371,7 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(^, Bool);
+IMPLEMENT_BINARY_OPERATOR(^, Int1);
 IMPLEMENT_BINARY_OPERATOR(^, Int8);
 IMPLEMENT_BINARY_OPERATOR(^, Int16);
 IMPLEMENT_BINARY_OPERATOR(^, Int32);
@@ -384,7 +384,7 @@
 }
 
 #define IMPLEMENT_ICMP(OP, TY, CAST) \
-   case Type::TY##TyID: Dest.BoolVal = \
+   case Type::TY##TyID: Dest.Int1Val = \
  ((CAST)Src1.TY##Val) OP ((CAST)Src2.TY##Val); break
 
 // Handle pointers specially because they must be compared with only as much
@@ -393,7 +393,7 @@
 // comparisons if they contain garbage.
 #define IMPLEMENT_POINTERCMP(OP) \
case Type::PointerTyID: \
-Dest.BoolVal = (void*)(intptr_t)Src1.PointerVal OP \
+Dest.Int1Val = (void*)(intptr_t)Src1.PointerVal OP \
(void*)(intptr_t)Src2.PointerVal; break
 
 static GenericValue executeICMP_EQ(GenericValue Src1, GenericValue Src2,
@@ -583,7 +583,7 @@
 }
 
 #define IMPLEMENT_FCMP(OP, TY) \
-   case Type::TY##TyID: Dest.BoolVal = Src1.TY##Val OP Src2.TY##Val; break
+   case Type::TY##TyID: Dest.Int1Val = Src1.TY##Val OP Src2.TY##Val; break
 
 static GenericValue executeFCMP_EQ(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
@@ -672,7 +672,7 @@
   GenericValue R;   // Result
   
   switch (I.getPredicate()) {
-  case FCmpInst::FCMP_FALSE: R.BoolVal = false;
+  case FCmpInst::FCMP_FALSE: R.Int1Val = false;
   case FCmpInst::FCMP_ORD:   R = executeFCMP_EQ(Src1, Src2, Ty); break; ///???
   case FCmpInst::FCMP_UNO:   R = executeFCMP_NE(Src1, Src2, Ty); break; ///???
   case FCmpInst::FCMP_OEQ:
@@ -687,7 +687,7 @@
   case FCmpInst::FCMP_ULE:   R = executeFCMP_LE(Src1, Src2, Ty); break;
   case FCmpInst::FCMP_OGE:
   case FCmpInst::FCMP_UGE:   R = executeFCMP_GE(Src1, Src2, Ty); break;
-  case FCmpInst::FCMP_TRUE:  R.BoolVal = true;
+  case FCmpInst::FCMP_TRUE:  R.Int1Val = true;
   default:
 cerr << "Don't know how to handle this FCmp predicate!\n-->" << I;
 abort();
@@ -726,12 +726,12 @@
   case FCmpInst::FCMP_UGE:   return executeFCMP_GE(Src1, Src2, Ty); break;
   case FCmpInst::FCMP_FALSE: { 
 GenericValue Result;
-Result.BoolVal = false; 
+Result.Int1Val = false; 
 return Result;
   }
   case FCmpInst::FCMP_TRUE: {
 GenericValue Result;
-Result.BoolVal = true;
+Result.Int1Val = true;
 return Result;
   }
   default:
@@ -770,7 +770,7 @@
 
 static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2,
   GenericValue Src3) {
-  return Src1.BoolVal ? Src2 : Src3;
+  return Src1.Int1Val ? Src2 : Src3;
 }
 
 void Interpreter::visitSelectInst(SelectInst &I) {
@@ -873,7 +873,7 @@
   Dest = I.getSuccessor(0);  // Uncond branches have a fixed dest...
   if (!I.isUnconditional()) {
 Value *Cond = I.getCondition();
-if (getOperandValue(Cond, SF).BoolVal == 0) // If false cond...
+if (getOperandValue(Cond, SF).Int1Val == 0) // If false cond...
   Dest = I.getSuccessor(1);
   }
   SwitchToNewBasicBlock(Dest, SF);
@@ -888,7 +888,7 @@
   BasicBlock *Dest = 0;
   for (unsigned i = 2, e = I.getNumOperands(); i != e; i += 2)
 if (executeICMP_EQ(CondVal,
-   getOperandValue(I.getOperand(i), SF), ElTy).BoolVal) {
+   getOperandValue(I.getOperand(i), SF), ElTy).Int1Val) {
   Dest = cast(I.getOperand(i+1));
   break;
 }
@@ -1089,8 +1089,8 @@
 Ar

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp ExternalFunctions.cpp

2006-12-30 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.154 -> 1.155
ExternalFunctions.cpp updated: 1.92 -> 1.93
---
Log message:

For PR950: http://llvm.org/PR950 :
Convert signed integer types to signless ones.


---
Diffs of the changes:  (+253 -369)

 Execution.cpp |  526 +++---
 ExternalFunctions.cpp |   96 -
 2 files changed, 253 insertions(+), 369 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.154 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.155
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.154Sat Dec 23 
00:05:41 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Dec 30 23:51:36 2006
@@ -194,14 +194,10 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(+, UByte);
-IMPLEMENT_BINARY_OPERATOR(+, SByte);
-IMPLEMENT_BINARY_OPERATOR(+, UShort);
-IMPLEMENT_BINARY_OPERATOR(+, Short);
-IMPLEMENT_BINARY_OPERATOR(+, UInt);
-IMPLEMENT_BINARY_OPERATOR(+, Int);
-IMPLEMENT_BINARY_OPERATOR(+, ULong);
-IMPLEMENT_BINARY_OPERATOR(+, Long);
+IMPLEMENT_BINARY_OPERATOR(+, Int8);
+IMPLEMENT_BINARY_OPERATOR(+, Int16);
+IMPLEMENT_BINARY_OPERATOR(+, Int32);
+IMPLEMENT_BINARY_OPERATOR(+, Int64);
 IMPLEMENT_BINARY_OPERATOR(+, Float);
 IMPLEMENT_BINARY_OPERATOR(+, Double);
   default:
@@ -215,14 +211,10 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(-, UByte);
-IMPLEMENT_BINARY_OPERATOR(-, SByte);
-IMPLEMENT_BINARY_OPERATOR(-, UShort);
-IMPLEMENT_BINARY_OPERATOR(-, Short);
-IMPLEMENT_BINARY_OPERATOR(-, UInt);
-IMPLEMENT_BINARY_OPERATOR(-, Int);
-IMPLEMENT_BINARY_OPERATOR(-, ULong);
-IMPLEMENT_BINARY_OPERATOR(-, Long);
+IMPLEMENT_BINARY_OPERATOR(-, Int8);
+IMPLEMENT_BINARY_OPERATOR(-, Int16);
+IMPLEMENT_BINARY_OPERATOR(-, Int32);
+IMPLEMENT_BINARY_OPERATOR(-, Int64);
 IMPLEMENT_BINARY_OPERATOR(-, Float);
 IMPLEMENT_BINARY_OPERATOR(-, Double);
   default:
@@ -236,14 +228,10 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(*, UByte);
-IMPLEMENT_BINARY_OPERATOR(*, SByte);
-IMPLEMENT_BINARY_OPERATOR(*, UShort);
-IMPLEMENT_BINARY_OPERATOR(*, Short);
-IMPLEMENT_BINARY_OPERATOR(*, UInt);
-IMPLEMENT_BINARY_OPERATOR(*, Int);
-IMPLEMENT_BINARY_OPERATOR(*, ULong);
-IMPLEMENT_BINARY_OPERATOR(*, Long);
+IMPLEMENT_BINARY_OPERATOR(*, Int8);
+IMPLEMENT_BINARY_OPERATOR(*, Int16);
+IMPLEMENT_BINARY_OPERATOR(*, Int32);
+IMPLEMENT_BINARY_OPERATOR(*, Int64);
 IMPLEMENT_BINARY_OPERATOR(*, Float);
 IMPLEMENT_BINARY_OPERATOR(*, Double);
   default:
@@ -253,17 +241,18 @@
   return Dest;
 }
 
-#define IMPLEMENT_SIGNLESS_BINOP(OP, TY1, TY2) \
-   case Type::TY2##TyID: IMPLEMENT_BINARY_OPERATOR(OP, TY1)
+#define IMPLEMENT_SIGNLESS_BINOP(OP, TY, CAST) \
+   case Type::TY##TyID: Dest.TY##Val = \
+((CAST)Src1.TY##Val) OP ((CAST)Src2.TY##Val); break
 
 static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_SIGNLESS_BINOP(/, UByte,  SByte);
-IMPLEMENT_SIGNLESS_BINOP(/, UShort, Short);
-IMPLEMENT_SIGNLESS_BINOP(/, UInt,   Int);
-IMPLEMENT_SIGNLESS_BINOP(/, ULong,  Long);
+IMPLEMENT_SIGNLESS_BINOP(/, Int8,  uint8_t);
+IMPLEMENT_SIGNLESS_BINOP(/, Int16, uint16_t);
+IMPLEMENT_SIGNLESS_BINOP(/, Int32, uint32_t);
+IMPLEMENT_SIGNLESS_BINOP(/, Int64, uint64_t);
   default:
 cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n";
 abort();
@@ -275,10 +264,10 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_SIGNLESS_BINOP(/, SByte, UByte);
-IMPLEMENT_SIGNLESS_BINOP(/, Short, UShort);
-IMPLEMENT_SIGNLESS_BINOP(/, Int,   UInt);
-IMPLEMENT_SIGNLESS_BINOP(/, Long,  ULong);
+IMPLEMENT_SIGNLESS_BINOP(/, Int8,  int8_t);
+IMPLEMENT_SIGNLESS_BINOP(/, Int16, int16_t);
+IMPLEMENT_SIGNLESS_BINOP(/, Int32, int32_t);
+IMPLEMENT_SIGNLESS_BINOP(/, Int64, int64_t);
   default:
 cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n";
 abort();
@@ -303,10 +292,10 @@
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_SIGNLESS_BINOP(%, UByte,  SByte);
-IMPLEMENT_SIGNLESS_BINOP(%, UShort, Short);
-IMPLEMENT_SIGNLESS_BINOP(%, UInt,   Int);
-IMPLEMENT_SIGNLESS_BINOP(%, ULong,  Long);
+IMPLEMENT_SIGNLESS_BINOP(%, Int8,  uint8_t);
+IMPLEMENT_SIGNLESS_BINOP(%, Int16, uint16_

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.h

2006-12-22 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.153 -> 1.154
Interpreter.h updated: 1.78 -> 1.79
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and 
been replaced with ICmpInst and FCmpInst.


---
Diffs of the changes:  (+331 -112)

 Execution.cpp |  441 +++---
 Interpreter.h |2 
 2 files changed, 331 insertions(+), 112 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.153 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.154
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.153Tue Dec 19 
16:56:53 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Dec 23 00:05:41 2006
@@ -55,18 +55,8 @@
const Type *Ty);
 static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
-static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
+static GenericValue executeCmpInst(unsigned predicate, GenericValue Src1, 
+   GenericValue Src2, const Type *Ty);
 static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
 static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2,
@@ -144,30 +134,12 @@
 return executeXorInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
   CE->getOperand(0)->getType());
-  case Instruction::SetEQ:
-return executeSetEQInst(getOperandValue(CE->getOperand(0), SF),
-getOperandValue(CE->getOperand(1), SF),
-CE->getOperand(0)->getType());
-  case Instruction::SetNE:
-return executeSetNEInst(getOperandValue(CE->getOperand(0), SF),
-getOperandValue(CE->getOperand(1), SF),
-CE->getOperand(0)->getType());
-  case Instruction::SetLE:
-return executeSetLEInst(getOperandValue(CE->getOperand(0), SF),
-getOperandValue(CE->getOperand(1), SF),
-CE->getOperand(0)->getType());
-  case Instruction::SetGE:
-return executeSetGEInst(getOperandValue(CE->getOperand(0), SF),
-getOperandValue(CE->getOperand(1), SF),
-CE->getOperand(0)->getType());
-  case Instruction::SetLT:
-return executeSetLTInst(getOperandValue(CE->getOperand(0), SF),
-getOperandValue(CE->getOperand(1), SF),
-CE->getOperand(0)->getType());
-  case Instruction::SetGT:
-return executeSetGTInst(getOperandValue(CE->getOperand(0), SF),
-getOperandValue(CE->getOperand(1), SF),
-CE->getOperand(0)->getType());
+  case Instruction::FCmp:
+  case Instruction::ICmp:
+return executeCmpInst(CE->getPredicate(),
+  getOperandValue(CE->getOperand(0), SF),
+  getOperandValue(CE->getOperand(1), SF),
+  CE->getOperand(0)->getType());
   case Instruction::Shl:
 return executeShlInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
@@ -434,33 +406,227 @@
   return Dest;
 }
 
-#define IMPLEMENT_SETCC(OP, TY) \
-   case Type::TY##TyID: Dest.BoolVal = Src1.TY##Val OP Src2.TY##Val; break
+#define IMPLEMENT_CMP(OP, TY1, TY2) \
+   case Type::TY1##TyID: Dest.BoolVal = Src1.TY2##Val OP Src2.TY2##Val; break
 
 // Handle pointers specially because they must be compared with only as much
 // width as the host has.  We _do not_ want to be comparing 64 bit values when
 // running on a 32-bit target, otherwise the upper 32 bits might mess up
 // comparisons if they contain garbage.
-#define IMPLEMENT_POINTERSETCC(OP) \
+#define IMPLEMENT_POINTERCMP(OP) \
case Type::PointerTyID: \
 Dest.BoolVal = (void*)(intptr_t)Src1.PointerVal OP \
   

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-12-19 Thread Chris Lattner


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.152 -> 1.153
---
Log message:

elimiante Statistic static ctors


---
Diffs of the changes:  (+2 -5)

 Execution.cpp |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.152 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.153
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.152Wed Dec  6 
19:30:31 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Tue Dec 19 16:56:53 2006
@@ -23,11 +23,8 @@
 #include 
 using namespace llvm;
 
-namespace {
-  Statistic NumDynamicInsts("lli", "Number of dynamic instructions executed");
-
-  Interpreter *TheEE = 0;
-}
+STATISTIC(NumDynamicInsts, "Number of dynamic instructions executed");
+static Interpreter *TheEE = 0;
 
 
 
//===--===//



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp ExternalFunctions.cpp

2006-12-06 Thread Bill Wendling


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.151 -> 1.152
ExternalFunctions.cpp updated: 1.91 -> 1.92
---
Log message:

Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.


---
Diffs of the changes:  (+35 -36)

 Execution.cpp |   57 --
 ExternalFunctions.cpp |   14 ++--
 2 files changed, 35 insertions(+), 36 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.151 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.152
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.151Wed Dec  6 
11:46:32 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Dec  6 19:30:31 2006
@@ -188,7 +188,7 @@
  getOperandValue(CE->getOperand(1), SF),
  getOperandValue(CE->getOperand(2), SF));
   default:
-llvm_cerr << "Unhandled ConstantExpr: " << *CE << "\n";
+cerr << "Unhandled ConstantExpr: " << *CE << "\n";
 abort();
 return GenericValue();
   }
@@ -236,7 +236,7 @@
 IMPLEMENT_BINARY_OPERATOR(+, Float);
 IMPLEMENT_BINARY_OPERATOR(+, Double);
   default:
-llvm_cerr << "Unhandled type for Add instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Add instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -257,7 +257,7 @@
 IMPLEMENT_BINARY_OPERATOR(-, Float);
 IMPLEMENT_BINARY_OPERATOR(-, Double);
   default:
-llvm_cerr << "Unhandled type for Sub instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Sub instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -278,7 +278,7 @@
 IMPLEMENT_BINARY_OPERATOR(*, Float);
 IMPLEMENT_BINARY_OPERATOR(*, Double);
   default:
-llvm_cerr << "Unhandled type for Mul instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Mul instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -296,7 +296,7 @@
 IMPLEMENT_SIGNLESS_BINOP(/, UInt,   Int);
 IMPLEMENT_SIGNLESS_BINOP(/, ULong,  Long);
   default:
-llvm_cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n";
+cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -311,7 +311,7 @@
 IMPLEMENT_SIGNLESS_BINOP(/, Int,   UInt);
 IMPLEMENT_SIGNLESS_BINOP(/, Long,  ULong);
   default:
-llvm_cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n";
+cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -324,7 +324,7 @@
 IMPLEMENT_BINARY_OPERATOR(/, Float);
 IMPLEMENT_BINARY_OPERATOR(/, Double);
   default:
-llvm_cerr << "Unhandled type for Div instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Div instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -339,7 +339,7 @@
 IMPLEMENT_SIGNLESS_BINOP(%, UInt,   Int);
 IMPLEMENT_SIGNLESS_BINOP(%, ULong,  Long);
   default:
-llvm_cerr << "Unhandled type for URem instruction: " << *Ty << "\n";
+cerr << "Unhandled type for URem instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -354,7 +354,7 @@
 IMPLEMENT_SIGNLESS_BINOP(%, Int,   UInt);
 IMPLEMENT_SIGNLESS_BINOP(%, Long,  ULong);
   default:
-llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -371,7 +371,7 @@
 Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal);
 break;
   default:
-llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -391,7 +391,7 @@
 IMPLEMENT_BINARY_OPERATOR(&, ULong);
 IMPLEMENT_BINARY_OPERATOR(&, Long);
   default:
-llvm_cerr << "Unhandled type for And instruction: " << *Ty << "\n";
+cerr << "Unhandled type for And instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -411,7 +411,7 @@
 IMPLEMENT_BINARY_OPERATOR(|, ULong);
 IMPLEMENT_BINARY_OPERATOR(|, Long);
   default:
-llvm_cerr << "Unhandled type for Or instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Or instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -431,7 +431,7 @@
 IMPLEMENT_BINARY_OPERATOR(^, ULong);
 IMPLEMENT_BINARY_OPERATOR(^, Long);
   default:
-llvm_cerr << "Unhandled type for Xor instruction: " << *Ty << "\n";
+cerr << "Unhandled type for Xor instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -465,7 +465,7 @@
 IMPLEMENT_SETCC(==, Double);
 IMPLEMENT_POINTERSETCC(==);
   default:
-llvm_cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n";
+cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n";
 abort();
   }
   return De

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-12-06 Thread Chris Lattner


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.150 -> 1.151
---
Log message:

Detemplatize the Statistic class.  The only type it is instantiated with
is 'unsigned'.



---
Diffs of the changes:  (+1 -1)

 Execution.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.150 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.151
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.150Fri Dec  1 
20:22:01 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Dec  6 11:46:32 2006
@@ -24,7 +24,7 @@
 using namespace llvm;
 
 namespace {
-  Statistic<> NumDynamicInsts("lli", "Number of dynamic instructions 
executed");
+  Statistic NumDynamicInsts("lli", "Number of dynamic instructions executed");
 
   Interpreter *TheEE = 0;
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp ExternalFunctions.cpp

2006-12-01 Thread Jeff Cohen


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.149 -> 1.150
ExternalFunctions.cpp updated: 1.90 -> 1.91
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+2 -0)

 Execution.cpp |1 +
 ExternalFunctions.cpp |1 +
 2 files changed, 2 insertions(+)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.149 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.150
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.149Mon Nov 27 
17:54:50 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Fri Dec  1 20:22:01 2006
@@ -20,6 +20,7 @@
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
+#include 
 using namespace llvm;
 
 namespace {


Index: llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.90 
llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.91
--- llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.90 Mon Nov 
27 17:54:50 2006
+++ llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp  Fri Dec  1 
20:22:01 2006
@@ -27,6 +27,7 @@
 #include "llvm/Target/TargetData.h"
 #include 
 #include 
+#include 
 using std::vector;
 
 using namespace llvm;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp ExternalFunctions.cpp

2006-11-27 Thread Bill Wendling


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.148 -> 1.149
ExternalFunctions.cpp updated: 1.89 -> 1.90
---
Log message:

Removed #include  and replaced streams with llvm streams.


---
Diffs of the changes:  (+36 -35)

 Execution.cpp |   58 +-
 ExternalFunctions.cpp |   13 ++-
 2 files changed, 36 insertions(+), 35 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.148 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.149
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.148Sun Nov 26 
19:05:10 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Mon Nov 27 17:54:50 2006
@@ -187,7 +187,7 @@
  getOperandValue(CE->getOperand(1), SF),
  getOperandValue(CE->getOperand(2), SF));
   default:
-std::cerr << "Unhandled ConstantExpr: " << *CE << "\n";
+llvm_cerr << "Unhandled ConstantExpr: " << *CE << "\n";
 abort();
 return GenericValue();
   }
@@ -235,7 +235,7 @@
 IMPLEMENT_BINARY_OPERATOR(+, Float);
 IMPLEMENT_BINARY_OPERATOR(+, Double);
   default:
-std::cout << "Unhandled type for Add instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Add instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -256,7 +256,7 @@
 IMPLEMENT_BINARY_OPERATOR(-, Float);
 IMPLEMENT_BINARY_OPERATOR(-, Double);
   default:
-std::cout << "Unhandled type for Sub instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Sub instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -277,7 +277,7 @@
 IMPLEMENT_BINARY_OPERATOR(*, Float);
 IMPLEMENT_BINARY_OPERATOR(*, Double);
   default:
-std::cout << "Unhandled type for Mul instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Mul instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -295,7 +295,7 @@
 IMPLEMENT_SIGNLESS_BINOP(/, UInt,   Int);
 IMPLEMENT_SIGNLESS_BINOP(/, ULong,  Long);
   default:
-std::cout << "Unhandled type for UDiv instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -310,7 +310,7 @@
 IMPLEMENT_SIGNLESS_BINOP(/, Int,   UInt);
 IMPLEMENT_SIGNLESS_BINOP(/, Long,  ULong);
   default:
-std::cout << "Unhandled type for SDiv instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -323,7 +323,7 @@
 IMPLEMENT_BINARY_OPERATOR(/, Float);
 IMPLEMENT_BINARY_OPERATOR(/, Double);
   default:
-std::cout << "Unhandled type for Div instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Div instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -338,7 +338,7 @@
 IMPLEMENT_SIGNLESS_BINOP(%, UInt,   Int);
 IMPLEMENT_SIGNLESS_BINOP(%, ULong,  Long);
   default:
-std::cout << "Unhandled type for URem instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for URem instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -353,7 +353,7 @@
 IMPLEMENT_SIGNLESS_BINOP(%, Int,   UInt);
 IMPLEMENT_SIGNLESS_BINOP(%, Long,  ULong);
   default:
-std::cout << "Unhandled type for Rem instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -370,7 +370,7 @@
 Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal);
 break;
   default:
-std::cout << "Unhandled type for Rem instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -390,7 +390,7 @@
 IMPLEMENT_BINARY_OPERATOR(&, ULong);
 IMPLEMENT_BINARY_OPERATOR(&, Long);
   default:
-std::cout << "Unhandled type for And instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for And instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -410,7 +410,7 @@
 IMPLEMENT_BINARY_OPERATOR(|, ULong);
 IMPLEMENT_BINARY_OPERATOR(|, Long);
   default:
-std::cout << "Unhandled type for Or instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Or instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -430,7 +430,7 @@
 IMPLEMENT_BINARY_OPERATOR(^, ULong);
 IMPLEMENT_BINARY_OPERATOR(^, Long);
   default:
-std::cout << "Unhandled type for Xor instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for Xor instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -464,7 +464,7 @@
 IMPLEMENT_SETCC(==, Double);
 IMPLEMENT_POINTERSETCC(==);
   default:
-std::cout << "Unhandled type for SetEQ instruction: " << *Ty << "\n";
+llvm_cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n";
 abort();
   }

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.h

2006-11-26 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.147 -> 1.148
Interpreter.h updated: 1.76 -> 1.77
---
Log message:

For PR950: http://llvm.org/PR950 :
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


---
Diffs of the changes:  (+182 -37)

 Execution.cpp |  215 --
 Interpreter.h |4 -
 2 files changed, 182 insertions(+), 37 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.147 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.148
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.147Wed Nov  8 
13:16:44 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sun Nov 26 19:05:10 2006
@@ -81,8 +81,20 @@
 GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
 ExecutionContext &SF) {
   switch (CE->getOpcode()) {
-  case Instruction::Cast:
-return executeCastOperation(CE->getOperand(0), CE->getType(), SF);
+  case Instruction::Trunc:
+  case Instruction::ZExt:
+  case Instruction::SExt:
+  case Instruction::FPTrunc:
+  case Instruction::FPExt:
+  case Instruction::UIToFP:
+  case Instruction::SIToFP:
+  case Instruction::FPToUI:
+  case Instruction::FPToSI:
+  case Instruction::PtrToInt:
+  case Instruction::IntToPtr:
+  case Instruction::BitCast:
+return executeCastOperation(Instruction::CastOps(CE->getOpcode()), 
+CE->getOperand(0), CE->getType(), SF);
   case Instruction::GetElementPtr:
 return executeGEPOperation(CE->getOperand(0), gep_type_begin(CE),
gep_type_end(CE), SF);
@@ -1030,12 +1042,15 @@
   SetValue(&I, Dest, SF);
 }
 
+#define IMPLEMENT_CAST_START \
+  switch (DstTy->getTypeID()) {
+
 #define IMPLEMENT_CAST(DTY, DCTY, STY) \
-   case Type::STY##TyID: Dest.DTY##Val = DCTY Src.STY##Val; break;
+ case Type::STY##TyID: Dest.DTY##Val = DCTY Src.STY##Val; break;
 
-#define IMPLEMENT_CAST_CASE_START(DESTTY, DESTCTY)\
+#define IMPLEMENT_CAST_CASE(DESTTY, DESTCTY)\
   case Type::DESTTY##TyID:  \
-switch (SrcTy->getTypeID()) {  \
+switch (SrcTy->getTypeID()) {   \
   IMPLEMENT_CAST(DESTTY, DESTCTY, Bool);\
   IMPLEMENT_CAST(DESTTY, DESTCTY, UByte);   \
   IMPLEMENT_CAST(DESTTY, DESTCTY, SByte);   \
@@ -1045,52 +1060,182 @@
   IMPLEMENT_CAST(DESTTY, DESTCTY, Int); \
   IMPLEMENT_CAST(DESTTY, DESTCTY, ULong);   \
   IMPLEMENT_CAST(DESTTY, DESTCTY, Long);\
-  IMPLEMENT_CAST(DESTTY, DESTCTY, Pointer);
-
-#define IMPLEMENT_CAST_CASE_FP_IMP(DESTTY, DESTCTY) \
+  IMPLEMENT_CAST(DESTTY, DESTCTY, Pointer); \
   IMPLEMENT_CAST(DESTTY, DESTCTY, Float);   \
-  IMPLEMENT_CAST(DESTTY, DESTCTY, Double)
-
-#define IMPLEMENT_CAST_CASE_END()\
-default: std::cout << "Unhandled cast: " << *SrcTy << " to " << *Ty << 
"\n"; \
+  IMPLEMENT_CAST(DESTTY, DESTCTY, Double)   \
+default:\
+  std::cout << "Unhandled cast: "   \
+<< *SrcTy << " to " << *DstTy << "\n";  \
   abort();  \
 }   \
 break
 
-#define IMPLEMENT_CAST_CASE(DESTTY, DESTCTY) \
-   IMPLEMENT_CAST_CASE_START(DESTTY, DESTCTY);   \
-   IMPLEMENT_CAST_CASE_FP_IMP(DESTTY, DESTCTY); \
-   IMPLEMENT_CAST_CASE_END()
+#define IMPLEMENT_CAST_END  \
+  default: std::cout\
+  << "Unhandled dest type for cast instruction: "  \
+  << *DstTy << "\n";\
+abort();\
+  }
 
-GenericValue Interpreter::executeCastOperation(Value *SrcVal, const Type *Ty,
+GenericValue Interpreter::executeCastOperation(Instruction::CastOps opcode,
+   Value *SrcVal, const Type 
*DstTy,
ExecutionContext &SF) {
   const Type *SrcTy = SrcVal->getType();
   GenericValue Dest, Src = getOperandValue(SrcVal, SF);
 
-  switch (Ty->getTypeID()) {
-IMPLEMENT_CAST_CASE(UByte  , (unsigned char));
-IMPLEMENT_CAST_CASE(SByte  , (  signed char));
-IMPLEMENT_CAST_CASE(UShort , (unsigned short));
-IMPLEMENT_CAST_CASE(Short  , (  signed short));
-IMPLEMENT_CAST_CASE(UInt   , (unsigned int ));
-IMPLEMENT_CAST_CASE(Int, (  signed int ));
-IMPLEMENT_CAST_CASE(ULong  , (uint64_t));
-IMPLEMENT_CAST_CASE(Long   , ( int64_t));
-IMPLEMENT_CAST_CASE(Pointer, (PointerTy));
-IMPLEMENT_CAST_CASE(Float  , (float));
-IMPLEMENT_CAST_CA

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp ExternalFunctions.cpp

2006-11-08 Thread Jim Laskey


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.146 -> 1.147
ExternalFunctions.cpp updated: 1.88 -> 1.89
---
Log message:

Remove redundant .

---
Diffs of the changes:  (+0 -2)

 Execution.cpp |1 -
 ExternalFunctions.cpp |1 -
 2 files changed, 2 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.146 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.147
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.146Wed Nov  8 
00:47:33 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Nov  8 13:16:44 2006
@@ -20,7 +20,6 @@
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
-#include   // For fmod
 using namespace llvm;
 
 namespace {


Index: llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.88 
llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.89
--- llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.88 Tue Aug 
15 20:24:12 2006
+++ llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp  Wed Nov  8 
13:16:44 2006
@@ -24,7 +24,6 @@
 #include "llvm/Module.h"
 #include "llvm/System/DynamicLibrary.h"
 #include "llvm/Target/TargetData.h"
-#include 
 #include 
 #include 
 using std::vector;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.h

2006-11-07 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.145 -> 1.146
Interpreter.h updated: 1.75 -> 1.76
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch converts the old SHR instruction into two instructions, 
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.


---
Diffs of the changes:  (+52 -20)

 Execution.cpp |   69 ++
 Interpreter.h |3 +-
 2 files changed, 52 insertions(+), 20 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.145 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.146
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.145Thu Nov  2 
02:12:02 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Nov  8 00:47:33 2006
@@ -72,8 +72,10 @@
const Type *Ty);
 static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
-static GenericValue executeShrInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
+static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
+static GenericValue executeAShrInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
 static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2,
   GenericValue Src3);
 
@@ -161,10 +163,14 @@
 return executeShlInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
   CE->getOperand(0)->getType());
-  case Instruction::Shr:
-return executeShrInst(getOperandValue(CE->getOperand(0), SF),
-  getOperandValue(CE->getOperand(1), SF),
-  CE->getOperand(0)->getType());
+  case Instruction::LShr:
+return executeLShrInst(getOperandValue(CE->getOperand(0), SF),
+   getOperandValue(CE->getOperand(1), SF),
+   CE->getOperand(0)->getType());
+  case Instruction::AShr:
+return executeAShrInst(getOperandValue(CE->getOperand(0), SF),
+   getOperandValue(CE->getOperand(1), SF),
+   CE->getOperand(0)->getType());
   case Instruction::Select:
 return executeSelectInst(getOperandValue(CE->getOperand(0), SF),
  getOperandValue(CE->getOperand(1), SF),
@@ -943,6 +949,10 @@
 #define IMPLEMENT_SHIFT(OP, TY) \
case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.UByteVal; break
 
+#define IMPLEMENT_SIGNLESS_SHIFT(OP, TY1, TY2) \
+   case Type::TY2##TyID: \
+   IMPLEMENT_SHIFT(OP, TY1) 
+
 static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
@@ -961,20 +971,31 @@
   return Dest;
 }
 
-static GenericValue executeShrInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty) {
+static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty) {
+  GenericValue Dest;
+  switch (Ty->getTypeID()) {
+IMPLEMENT_SIGNLESS_SHIFT(>>, UByte,  SByte);
+IMPLEMENT_SIGNLESS_SHIFT(>>, UShort, Short);
+IMPLEMENT_SIGNLESS_SHIFT(>>, UInt,   Int);
+IMPLEMENT_SIGNLESS_SHIFT(>>, ULong,  Long);
+  default:
+std::cout << "Unhandled type for LShr instruction: " << *Ty << "\n";
+abort();
+  }
+  return Dest;
+}
+
+static GenericValue executeAShrInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_SHIFT(>>, UByte);
-IMPLEMENT_SHIFT(>>, SByte);
-IMPLEMENT_SHIFT(>>, UShort);
-IMPLEMENT_SHIFT(>>, Short);
-IMPLEMENT_SHIFT(>>, UInt);
-IMPLEMENT_SHIFT(>>, Int);
-IMPLEMENT_SHIFT(>>, ULong);
-IMPLEMENT_SHIFT(>>, Long);
+IMPLEMENT_SIGNLESS_SHIFT(>>, SByte, UByte);
+IMPLEMENT_SIGNLESS_SHIFT(>>, Short, UShort);
+IMPLEMENT_SIGNLESS_SHIFT(>>, Int,   UInt);
+IMPLEMENT_SIGNLESS_SHIFT(>>, Long,  ULong);
   default:
-std::cout << "Unhandled type for Shr instruction: " << *Ty << "\n";
+std::cout << "Unhandled type for AShr instruction: " << *Ty << "\n";
 abort();
   }
   return Dest;
@@ -990,13 +1011,23 @@
   SetValue(&I, Dest, SF);
 }
 
-void Interpreter::visitShr(ShiftInst &I) {
+void Interpreter::visitLShr(ShiftInst &I) {
+  ExecutionContext &SF = ECStack.back();
+  const Type *Ty= I.getOperand(0)->getType();
+  GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
+  GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
+  GenericValue Dest;
+  Dest = executeLShrInst 

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-11-02 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.144 -> 1.145
---
Log message:

Remove a function prototype that is no longer needed (REM patch missed it)


---
Diffs of the changes:  (+0 -2)

 Execution.cpp |2 --
 1 files changed, 2 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.144 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.145
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.144Wed Nov  1 
19:53:58 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu Nov  2 02:12:02 2006
@@ -40,8 +40,6 @@
const Type *Ty);
 static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
-static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
 static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
 const Type *Ty);
 static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-11-01 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.143 -> 1.144
---
Log message:

For PR950: http://llvm.org/PR950 :
Replace the REM instruction with UREM, SREM and FREM.


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

 Execution.cpp |   62 ++
 1 files changed, 50 insertions(+), 12 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.143 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.144
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.143Tue Oct 31 
21:45:43 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Nov  1 19:53:58 2006
@@ -48,6 +48,12 @@
 const Type *Ty);
 static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
 const Type *Ty);
+static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
+static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
+static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
 static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
 static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
@@ -105,10 +111,18 @@
 return executeFDivInst(getOperandValue(CE->getOperand(0), SF),
getOperandValue(CE->getOperand(1), SF),
CE->getOperand(0)->getType());
-  case Instruction::Rem:
-return executeRemInst(getOperandValue(CE->getOperand(0), SF),
+  case Instruction::URem:
+return executeURemInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
   CE->getOperand(0)->getType());
+  case Instruction::SRem:
+return executeSRemInst(getOperandValue(CE->getOperand(0), SF),
+  getOperandValue(CE->getOperand(1), SF),
+  CE->getOperand(0)->getType());
+  case Instruction::FRem:
+return executeFRemInst(getOperandValue(CE->getOperand(0), SF),
+   getOperandValue(CE->getOperand(1), SF),
+   CE->getOperand(0)->getType());
   case Instruction::And:
 return executeAndInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
@@ -300,18 +314,40 @@
   return Dest;
 }
 
-static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2,
+static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2,
+   const Type *Ty) {
+  GenericValue Dest;
+  switch (Ty->getTypeID()) {
+IMPLEMENT_SIGNLESS_BINOP(%, UByte,  SByte);
+IMPLEMENT_SIGNLESS_BINOP(%, UShort, Short);
+IMPLEMENT_SIGNLESS_BINOP(%, UInt,   Int);
+IMPLEMENT_SIGNLESS_BINOP(%, ULong,  Long);
+  default:
+std::cout << "Unhandled type for URem instruction: " << *Ty << "\n";
+abort();
+  }
+  return Dest;
+}
+
+static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2,
+   const Type *Ty) {
+  GenericValue Dest;
+  switch (Ty->getTypeID()) {
+IMPLEMENT_SIGNLESS_BINOP(%, SByte, UByte);
+IMPLEMENT_SIGNLESS_BINOP(%, Short, UShort);
+IMPLEMENT_SIGNLESS_BINOP(%, Int,   UInt);
+IMPLEMENT_SIGNLESS_BINOP(%, Long,  ULong);
+  default:
+std::cout << "Unhandled type for Rem instruction: " << *Ty << "\n";
+abort();
+  }
+  return Dest;
+}
+
+static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(%, UByte);
-IMPLEMENT_BINARY_OPERATOR(%, SByte);
-IMPLEMENT_BINARY_OPERATOR(%, UShort);
-IMPLEMENT_BINARY_OPERATOR(%, Short);
-IMPLEMENT_BINARY_OPERATOR(%, UInt);
-IMPLEMENT_BINARY_OPERATOR(%, Int);
-IMPLEMENT_BINARY_OPERATOR(%, ULong);
-IMPLEMENT_BINARY_OPERATOR(%, Long);
   case Type::FloatTyID:
 Dest.FloatVal = fmod(Src1.FloatVal, Src2.FloatVal);
 break;
@@ -544,7 +580,9 @@
   case Instruction::UDiv:  R = executeUDivInst (Src1, Src2, Ty); break;
   case Instruction::SDiv:  R = executeSDivInst (Src1, Src2, Ty); break;
   case Instruction::FDiv:  R = executeFDivInst (Src1, Src2, Ty); break;
-  case Instruction::Rem:   R = executeRemInst  (Src1, Src2, Ty); break;
+  case Instruction::URem:  R = executeURemInst (Src1, Src2, Ty); break;
+  case Instruction::SRem:  R = executeSRemInst (Src1, Src2, Ty); break;
+  case Instruction::FRem:  R = executeFRemInst (Src1, Src2, Ty); break;
   case Instruction::And:   R = executeAndInst  (Src1, Src2, Ty); break;
   case Instructi

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-10-31 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.142 -> 1.143
---
Log message:

Remove unnecessary sign conversions made possible by last patch.


---
Diffs of the changes:  (+0 -4)

 Execution.cpp |4 
 1 files changed, 4 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.142 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.143
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.142Tue Oct 31 
21:41:05 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Tue Oct 31 21:45:43 2006
@@ -260,8 +260,6 @@
 static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
-  if (Ty->isSigned())
-Ty = Ty->getUnsignedVersion();
   switch (Ty->getTypeID()) {
 IMPLEMENT_SIGNLESS_BINOP(/, UByte,  SByte);
 IMPLEMENT_SIGNLESS_BINOP(/, UShort, Short);
@@ -277,8 +275,6 @@
 static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
-  if (Ty->isUnsigned())
-Ty = Ty->getSignedVersion();
   switch (Ty->getTypeID()) {
 IMPLEMENT_SIGNLESS_BINOP(/, SByte, UByte);
 IMPLEMENT_SIGNLESS_BINOP(/, Short, UShort);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-10-31 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.141 -> 1.142
---
Log message:

Fix a bug in the interpreter where divides of unmatched signed operands
would fail. E.g. udiv sint X, Y  or sdiv uint X, Y would fail to find a
type match in the switch statement and fail the operation.


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

 Execution.cpp |   19 +++
 1 files changed, 11 insertions(+), 8 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.141 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.142
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.141Thu Oct 26 
01:15:43 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Tue Oct 31 21:41:05 2006
@@ -254,16 +254,19 @@
   return Dest;
 }
 
+#define IMPLEMENT_SIGNLESS_BINOP(OP, TY1, TY2) \
+   case Type::TY2##TyID: IMPLEMENT_BINARY_OPERATOR(OP, TY1)
+
 static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
   if (Ty->isSigned())
 Ty = Ty->getUnsignedVersion();
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(/, UByte);
-IMPLEMENT_BINARY_OPERATOR(/, UShort);
-IMPLEMENT_BINARY_OPERATOR(/, UInt);
-IMPLEMENT_BINARY_OPERATOR(/, ULong);
+IMPLEMENT_SIGNLESS_BINOP(/, UByte,  SByte);
+IMPLEMENT_SIGNLESS_BINOP(/, UShort, Short);
+IMPLEMENT_SIGNLESS_BINOP(/, UInt,   Int);
+IMPLEMENT_SIGNLESS_BINOP(/, ULong,  Long);
   default:
 std::cout << "Unhandled type for UDiv instruction: " << *Ty << "\n";
 abort();
@@ -277,10 +280,10 @@
   if (Ty->isUnsigned())
 Ty = Ty->getSignedVersion();
   switch (Ty->getTypeID()) {
-IMPLEMENT_BINARY_OPERATOR(/, SByte);
-IMPLEMENT_BINARY_OPERATOR(/, Short);
-IMPLEMENT_BINARY_OPERATOR(/, Int);
-IMPLEMENT_BINARY_OPERATOR(/, Long);
+IMPLEMENT_SIGNLESS_BINOP(/, SByte, UByte);
+IMPLEMENT_SIGNLESS_BINOP(/, Short, UShort);
+IMPLEMENT_SIGNLESS_BINOP(/, Int,   UInt);
+IMPLEMENT_SIGNLESS_BINOP(/, Long,  ULong);
   default:
 std::cout << "Unhandled type for SDiv instruction: " << *Ty << "\n";
 abort();



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.140 -> 1.141
---
Log message:

For PR950: http://llvm.org/PR950 :
Make necessary changes to support DIV -> [SUF]Div. This changes llvm to
have three division instructions: signed, unsigned, floating point. The
bytecode and assembler are bacwards compatible, however.


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

 Execution.cpp |   62 +++---
 1 files changed, 51 insertions(+), 11 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.140 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.141
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.140Fri Oct 20 
02:07:24 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Thu Oct 26 01:15:43 2006
@@ -42,8 +42,12 @@
const Type *Ty);
 static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
-static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
+static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
+static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
+static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
 static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
 static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
@@ -89,10 +93,18 @@
 return executeMulInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
   CE->getOperand(0)->getType());
-  case Instruction::Div:
-return executeDivInst(getOperandValue(CE->getOperand(0), SF),
-  getOperandValue(CE->getOperand(1), SF),
-  CE->getOperand(0)->getType());
+  case Instruction::SDiv:
+return executeSDivInst(getOperandValue(CE->getOperand(0), SF),
+   getOperandValue(CE->getOperand(1), SF),
+   CE->getOperand(0)->getType());
+  case Instruction::UDiv:
+return executeUDivInst(getOperandValue(CE->getOperand(0), SF),
+   getOperandValue(CE->getOperand(1), SF),
+   CE->getOperand(0)->getType());
+  case Instruction::FDiv:
+return executeFDivInst(getOperandValue(CE->getOperand(0), SF),
+   getOperandValue(CE->getOperand(1), SF),
+   CE->getOperand(0)->getType());
   case Instruction::Rem:
 return executeRemInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
@@ -242,18 +254,44 @@
   return Dest;
 }
 
-static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
+static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
+  if (Ty->isSigned())
+Ty = Ty->getUnsignedVersion();
   switch (Ty->getTypeID()) {
 IMPLEMENT_BINARY_OPERATOR(/, UByte);
-IMPLEMENT_BINARY_OPERATOR(/, SByte);
 IMPLEMENT_BINARY_OPERATOR(/, UShort);
-IMPLEMENT_BINARY_OPERATOR(/, Short);
 IMPLEMENT_BINARY_OPERATOR(/, UInt);
-IMPLEMENT_BINARY_OPERATOR(/, Int);
 IMPLEMENT_BINARY_OPERATOR(/, ULong);
+  default:
+std::cout << "Unhandled type for UDiv instruction: " << *Ty << "\n";
+abort();
+  }
+  return Dest;
+}
+
+static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
+   const Type *Ty) {
+  GenericValue Dest;
+  if (Ty->isUnsigned())
+Ty = Ty->getSignedVersion();
+  switch (Ty->getTypeID()) {
+IMPLEMENT_BINARY_OPERATOR(/, SByte);
+IMPLEMENT_BINARY_OPERATOR(/, Short);
+IMPLEMENT_BINARY_OPERATOR(/, Int);
 IMPLEMENT_BINARY_OPERATOR(/, Long);
+  default:
+std::cout << "Unhandled type for SDiv instruction: " << *Ty << "\n";
+abort();
+  }
+  return Dest;
+}
+
+static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
+   const Type *Ty) {
+  GenericValue Dest;
+  switch (Ty->getTypeID()) {
 IMPLEMENT_BINARY_OPERATOR(/, Float);
 IMPLEMENT_BINARY_OPERATOR(/, Double);
   default:
@@ -504,7 +542,9 @@
   case Instruction::Add:   R = executeAddInst  (Src1, Src2, Ty); break;
   case Instruction::Sub:   R = executeSubInst  (Src1, Src2, Ty); break;
   case Instruction::Mul:   R = executeMulInst  (Src1, Src2, Ty); break;
-  case Instruction::Div:   R = executeDivInst  (Src1, Src2, Ty); break;
+  case Instruction::UDiv:  R = executeUDivInst (Src1

[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-10-20 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.139 -> 1.140
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.


---
Diffs of the changes:  (+2 -2)

 Execution.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.140
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139Mon Feb  6 
23:29:44 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Fri Oct 20 02:07:24 2006
@@ -735,8 +735,8 @@
 if (const StructType *STy = dyn_cast(*I)) {
   const StructLayout *SLO = TD.getStructLayout(STy);
 
-  const ConstantUInt *CPU = cast(I.getOperand());
-  unsigned Index = unsigned(CPU->getValue());
+  const ConstantInt *CPU = cast(I.getOperand());
+  unsigned Index = unsigned(CPU->getZExtValue());
 
   Total += (PointerTy)SLO->MemberOffsets[Index];
 } else {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.cpp Interpreter.h

2006-02-06 Thread Jeff Cohen


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.138 -> 1.139
Interpreter.cpp updated: 1.25 -> 1.26
Interpreter.h updated: 1.71 -> 1.72
---
Log message:

The interpreter assumes that the caller of runFunction() must be lli, and
therefore the function being called must be a main() returning an int.  The
consequences when these assumptions are false are not good, so don't assume
them.


---
Diffs of the changes:  (+7 -8)

 Execution.cpp   |6 +++---
 Interpreter.cpp |7 +++
 Interpreter.h   |2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.138 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.138Sat Jun 18 
13:34:52 2005
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Mon Feb  6 23:29:44 2006
@@ -553,7 +553,7 @@
 
 /// Pop the last stack frame off of ECStack and then copy the result
 /// back into the result variable if we are not returning void. The
-/// result variable may be the ExitCode, or the Value of the calling
+/// result variable may be the ExitValue, or the Value of the calling
 /// CallInst if there was a previous stack frame. This method may
 /// invalidate any ECStack iterators you have. This method also takes
 /// care of switching to the normal destination BB, if we are returning
@@ -566,9 +566,9 @@
 
   if (ECStack.empty()) {  // Finished main.  Put result into exit code...
 if (RetTy && RetTy->isIntegral()) {  // Nonvoid return type?
-  ExitCode = Result.IntVal;   // Capture the exit code of the program
+  ExitValue = Result;   // Capture the exit value of the program
 } else {
-  ExitCode = 0;
+  memset(&ExitValue, 0, sizeof(ExitValue));
 }
   } else {
 // If we have a previous stack frame, and we have a previous call,


Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.25 
llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.26
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.25   Wed Jul 27 
01:12:33 2005
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.cppMon Feb  6 
23:29:44 2006
@@ -50,10 +50,11 @@
 //
 Interpreter::Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
  IntrinsicLowering *il)
-  : ExecutionEngine(M), ExitCode(0),
+  : ExecutionEngine(M),
 TD("lli", isLittleEndian, isLongPointer ? 8 : 4, isLongPointer ? 8 : 4,
isLongPointer ? 8 : 4), IL(il) {
 
+  memset(&ExitValue, 0, sizeof(ExitValue));
   setTargetData(TD);
   // Initialize the "backend"
   initializeExecutionEngine();
@@ -100,8 +101,6 @@
   // Start executing the function.
   run();
 
-  GenericValue rv;
-  rv.IntVal = ExitCode;
-  return rv;
+  return ExitValue;
 }
 


Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.71 
llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.72
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.71 Sat Jun 18 
13:34:52 2005
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h  Mon Feb  6 23:29:44 2006
@@ -80,7 +80,7 @@
 // Interpreter - This class represents the entirety of the interpreter.
 //
 class Interpreter : public ExecutionEngine, public InstVisitor {
-  int ExitCode;// The exit code to be returned by the lli util
+  GenericValue ExitValue;  // The return value of the called function
   TargetData TD;
   IntrinsicLowering *IL;
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits