aboutsummaryrefslogtreecommitdiff
path: root/projects
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-11-27 01:05:10 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-11-27 01:05:10 +0000
commit3da59db637a887474c1b1346c1f3ccf53b6c4663 (patch)
treeb061e2133efdb9ea9bb334c1b15ceea881bb88f8 /projects
parent5fed9b90447a9a95a1f670ccd9c23aea8c937451 (diff)
For 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'projects')
-rw-r--r--projects/Stacker/lib/compiler/StackerCompiler.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/projects/Stacker/lib/compiler/StackerCompiler.cpp b/projects/Stacker/lib/compiler/StackerCompiler.cpp
index 9b0cabb2fb..aaf7812ca1 100644
--- a/projects/Stacker/lib/compiler/StackerCompiler.cpp
+++ b/projects/Stacker/lib/compiler/StackerCompiler.cpp
@@ -367,7 +367,7 @@ StackerCompiler::incr_stack_index( BasicBlock* bb, Value* ival = 0 )
// 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 @@ StackerCompiler::decr_stack_index( BasicBlock* bb, Value* ival = 0 )
// 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 @@ StackerCompiler::get_stack_pointer( BasicBlock* bb, Value* index = 0 )
}
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 @@ StackerCompiler::push_value( BasicBlock* bb, Value* val )
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 @@ StackerCompiler::pop_string( BasicBlock* bb )
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 @@ StackerCompiler::stack_top_string( BasicBlock* bb, Value* index = 0 )
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 @@ StackerCompiler::handle_word( int tkn )
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 @@ StackerCompiler::handle_word( int tkn )
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 @@ StackerCompiler::handle_word( int tkn )
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 @@ StackerCompiler::handle_word( int tkn )
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 @@ StackerCompiler::handle_word( int tkn )
// 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 @@ StackerCompiler::handle_word( int tkn )
// 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 @@ StackerCompiler::handle_word( int tkn )
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 @@ StackerCompiler::handle_word( int tkn )
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 @@ StackerCompiler::handle_word( int tkn )
// 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);