[llvm-commits] CVS: llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp

Reid Spencer reid at x10sys.com
Sun Nov 26 17:06:21 PST 2006



Changes in directory llvm/projects/Stacker/lib/compiler:

StackerCompiler.cpp updated: 1.23 -> 1.24
---
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:  (+19 -17)

 StackerCompiler.cpp |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)


Index: llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp
diff -u llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.23 llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.24
--- llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.23	Wed Nov  8 00:47:33 2006
+++ llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp	Sun Nov 26 19:05:10 2006
@@ -367,7 +367,7 @@
 
     // Increment the loaded index value
     if ( ival == 0 ) ival = One;
-    CastInst* caster = new CastInst( ival, Type::LongTy );
+    CastInst* caster = CastInst::createInferredCast( ival, Type::LongTy );
     bb->getInstList().push_back( caster );
     BinaryOperator* addop = BinaryOperator::create( Instruction::Add,
             loadop, caster);
@@ -388,7 +388,7 @@
 
     // Decrement the loaded index value
     if ( ival == 0 ) ival = One;
-    CastInst* caster = new CastInst( ival, Type::LongTy );
+    CastInst* caster = CastInst::createInferredCast( ival, Type::LongTy );
     bb->getInstList().push_back( caster );
     BinaryOperator* subop = BinaryOperator::create( Instruction::Sub,
             loadop, caster);
@@ -422,7 +422,7 @@
     }
     else
     {
-        CastInst* caster = new CastInst( index, Type::LongTy );
+        CastInst* caster = CastInst::createInferredCast( index, Type::LongTy );
         bb->getInstList().push_back( caster );
         BinaryOperator* subop = BinaryOperator::create(
             Instruction::Sub, loadop, caster );
@@ -448,7 +448,7 @@
             get_stack_pointer( bb ) );
 
     // Cast the value to a long .. hopefully it works
-    CastInst* cast_inst = new CastInst( val, Type::LongTy );
+    CastInst* cast_inst = CastInst::createInferredCast( val, Type::LongTy );
     bb->getInstList().push_back( cast_inst );
 
     // Store the value
@@ -522,7 +522,8 @@
     bb->getInstList().push_back( loader );
 
     // Cast the integer to a sbyte*
-    CastInst* caster = new CastInst( loader, PointerType::get(Type::SByteTy) );
+    CastInst* caster = 
+      CastInst::createInferredCast( loader, PointerType::get(Type::SByteTy) );
     bb->getInstList().push_back( caster );
 
     // Decrement stack index
@@ -574,7 +575,8 @@
     bb->getInstList().push_back( loader );
 
     // Cast the integer to a sbyte*
-    CastInst* caster = new CastInst( loader, PointerType::get(Type::SByteTy) );
+    CastInst* caster = 
+      CastInst::createInferredCast( loader, PointerType::get(Type::SByteTy) );
     bb->getInstList().push_back( caster );
 
     // Return the value
@@ -1243,7 +1245,7 @@
         if (echo) bb->setName("SHL");
         LoadInst* op1 = cast<LoadInst>(pop_integer(bb));
         LoadInst* op2 = cast<LoadInst>(pop_integer(bb));
-        CastInst* castop = new CastInst( op1, Type::UByteTy );
+        CastInst* castop = CastInst::createInferredCast( op1, Type::UByteTy );
         bb->getInstList().push_back( castop );
         ShiftInst* shlop = new ShiftInst( Instruction::Shl, op2, castop );
         bb->getInstList().push_back( shlop );
@@ -1255,7 +1257,7 @@
         if (echo) bb->setName("SHR");
         LoadInst* op1 = cast<LoadInst>(pop_integer(bb));
         LoadInst* op2 = cast<LoadInst>(pop_integer(bb));
-        CastInst* castop = new CastInst( op1, Type::UByteTy );
+        CastInst* castop = CastInst::createInferredCast( op1, Type::UByteTy );
         bb->getInstList().push_back( castop );
         ShiftInst* shrop = new ShiftInst( Instruction::AShr, op2, castop );
         bb->getInstList().push_back( shrop );
@@ -1477,7 +1479,7 @@
         LoadInst* op1 = cast<LoadInst>( pop_integer(bb) );
 
         // Make sure its a UIntTy
-        CastInst* caster = new CastInst( op1, Type::UIntTy );
+        CastInst* caster = CastInst::createInferredCast( op1, Type::UIntTy );
         bb->getInstList().push_back( caster );
 
         // Allocate the bytes
@@ -1505,7 +1507,7 @@
         if (echo) bb->setName("GET");
         // Get the character index
         LoadInst* op1 = cast<LoadInst>( stack_top(bb) );
-        CastInst* chr_idx = new CastInst( op1, Type::LongTy );
+        CastInst* chr_idx = CastInst::createInferredCast( op1, Type::LongTy );
         bb->getInstList().push_back( chr_idx );
 
         // Get the String pointer
@@ -1520,7 +1522,7 @@
         // Get the value and push it
         LoadInst* loader = new LoadInst( gep );
         bb->getInstList().push_back( loader );
-        CastInst* caster = new CastInst( loader, Type::IntTy );
+        CastInst* caster = CastInst::createInferredCast( loader, Type::IntTy );
         bb->getInstList().push_back( caster );
 
         // Push the result back on stack
@@ -1537,7 +1539,7 @@
 
         // Get the character index
         LoadInst* w2 = cast<LoadInst>( pop_integer(bb) );
-        CastInst* chr_idx = new CastInst( w2, Type::LongTy );
+        CastInst* chr_idx = CastInst::createInferredCast( w2, Type::LongTy );
         bb->getInstList().push_back( chr_idx );
 
         // Get the String pointer
@@ -1550,7 +1552,7 @@
         bb->getInstList().push_back( gep );
 
         // Cast the value and put it
-        CastInst* caster = new CastInst( w1, Type::SByteTy );
+        CastInst* caster = CastInst::createInferredCast( w1, Type::SByteTy );
         bb->getInstList().push_back( caster );
         StoreInst* storer = new StoreInst( caster, gep );
         bb->getInstList().push_back( storer );
@@ -1578,7 +1580,7 @@
         LoadInst* op1 = cast<LoadInst>(pop_integer(bb));
 
         // Cast down to an integer
-        CastInst* caster = new CastInst( op1, Type::IntTy );
+        CastInst* caster = CastInst::createInferredCast( op1, Type::IntTy );
         bb->getInstList().push_back( caster );
 
         // Call exit(3)
@@ -1660,9 +1662,9 @@
         // Make room for the value result
         incr_stack_index(bb);
         GetElementPtrInst* gep_value =
-            cast<GetElementPtrInst>(get_stack_pointer(bb));
-        CastInst* caster =
-            new CastInst( gep_value, PointerType::get( Type::SByteTy ) );
+          cast<GetElementPtrInst>(get_stack_pointer(bb));
+        CastInst* caster = 
+          new BitCastInst(gep_value, PointerType::get(Type::SByteTy));
 
         // Make room for the count result
         incr_stack_index(bb);






More information about the llvm-commits mailing list