For PR950:

Convert signed integer types to signless.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer
2006-12-31 05:50:28 +00:00
parent c5b206b6be
commit db8d2bed6a
6 changed files with 65 additions and 65 deletions

View File

@ -38,15 +38,15 @@ using namespace llvm;
static Function *CreateFibFunction(Module *M) { static Function *CreateFibFunction(Module *M) {
// Create the fib function and insert it into module M. This function is said // Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter. // to return an int and take an int parameter.
Function *FibF = M->getOrInsertFunction("fib", Type::IntTy, Type::IntTy, Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
(Type *)0); (Type *)0);
// Add a basic block to the function. // Add a basic block to the function.
BasicBlock *BB = new BasicBlock("EntryBlock", FibF); BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
// Get pointers to the constants. // Get pointers to the constants.
Value *One = ConstantInt::get(Type::IntTy, 1); Value *One = ConstantInt::get(Type::Int32Ty, 1);
Value *Two = ConstantInt::get(Type::IntTy, 2); Value *Two = ConstantInt::get(Type::Int32Ty, 2);
// Get pointer to the integer argument of the add1 function... // Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg. Argument *ArgX = FibF->arg_begin(); // Get the arg.
@ -111,10 +111,10 @@ int main(int argc, char **argv) {
// Call the Fibonacci function with argument n: // Call the Fibonacci function with argument n:
std::vector<GenericValue> Args(1); std::vector<GenericValue> Args(1);
Args[0].IntVal = n; Args[0].Int32Val = n;
GenericValue GV = EE->runFunction(FibF, Args); GenericValue GV = EE->runFunction(FibF, Args);
// import result of execution // import result of execution
std::cout << "Result: " << GV.IntVal << "\n"; std::cout << "Result: " << GV.Int32Val << "\n";
return 0; return 0;
} }

View File

@ -52,7 +52,7 @@ int main() {
// Create the add1 function entry and insert this entry into module M. The // Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int". // function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types. // The '0' terminates the list of argument types.
Function *Add1F = M->getOrInsertFunction("add1", Type::IntTy, Type::IntTy, Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
(Type *)0); (Type *)0);
// Add a basic block to the function. As before, it automatically inserts // Add a basic block to the function. As before, it automatically inserts
@ -60,7 +60,7 @@ int main() {
BasicBlock *BB = new BasicBlock("EntryBlock", Add1F); BasicBlock *BB = new BasicBlock("EntryBlock", Add1F);
// Get pointers to the constant `1'. // Get pointers to the constant `1'.
Value *One = ConstantInt::get(Type::IntTy, 1); Value *One = ConstantInt::get(Type::Int32Ty, 1);
// Get pointers to the integer argument of the add1 function... // Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@ -78,13 +78,13 @@ int main() {
// Now we going to create function `foo', which returns an int and takes no // Now we going to create function `foo', which returns an int and takes no
// arguments. // arguments.
Function *FooF = M->getOrInsertFunction("foo", Type::IntTy, (Type *)0); Function *FooF = M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0);
// Add a basic block to the FooF function. // Add a basic block to the FooF function.
BB = new BasicBlock("EntryBlock", FooF); BB = new BasicBlock("EntryBlock", FooF);
// Get pointers to the constant `10'. // Get pointers to the constant `10'.
Value *Ten = ConstantInt::get(Type::IntTy, 10); Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
// Pass Ten to the call call: // Pass Ten to the call call:
std::vector<Value*> Params; std::vector<Value*> Params;
@ -107,6 +107,6 @@ int main() {
GenericValue gv = EE->runFunction(FooF, noargs); GenericValue gv = EE->runFunction(FooF, noargs);
// Import result of execution: // Import result of execution:
std::cout << "Result: " << gv.IntVal << "\n"; std::cout << "Result: " << gv.Int32Val << "\n";
return 0; return 0;
} }

View File

@ -27,7 +27,7 @@ int main() {
Module *M = new Module("test"); Module *M = new Module("test");
// Create the main function: first create the type 'int ()' // Create the main function: first create the type 'int ()'
FunctionType *FT = FunctionType::get(Type::IntTy, std::vector<const Type*>(), FunctionType *FT = FunctionType::get(Type::Int32Ty, std::vector<const Type*>(),
/*not vararg*/false); /*not vararg*/false);
// By passing a module as the last parameter to the Function constructor, // By passing a module as the last parameter to the Function constructor,
@ -39,8 +39,8 @@ int main() {
BasicBlock *BB = new BasicBlock("EntryBlock", F); BasicBlock *BB = new BasicBlock("EntryBlock", F);
// Get pointers to the constant integers... // Get pointers to the constant integers...
Value *Two = ConstantInt::get(Type::IntTy, 2); Value *Two = ConstantInt::get(Type::Int32Ty, 2);
Value *Three = ConstantInt::get(Type::IntTy, 3); Value *Three = ConstantInt::get(Type::Int32Ty, 3);
// Create the add instruction... does not insert... // Create the add instruction... does not insert...
Instruction *Add = BinaryOperator::create(Instruction::Add, Two, Three, Instruction *Add = BinaryOperator::create(Instruction::Add, Two, Three,

View File

@ -34,7 +34,7 @@ static Function* createAdd1(Module* M)
// Create the add1 function entry and insert this entry into module M. The // Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int". // function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types. // The '0' terminates the list of argument types.
Function *Add1F = M->getOrInsertFunction("add1", Type::IntTy, Type::IntTy, Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
(Type *)0); (Type *)0);
// Add a basic block to the function. As before, it automatically inserts // Add a basic block to the function. As before, it automatically inserts
@ -42,7 +42,7 @@ static Function* createAdd1(Module* M)
BasicBlock *BB = new BasicBlock("EntryBlock", Add1F); BasicBlock *BB = new BasicBlock("EntryBlock", Add1F);
// Get pointers to the constant `1'. // Get pointers to the constant `1'.
Value *One = ConstantInt::get(Type::IntTy, 1); Value *One = ConstantInt::get(Type::Int32Ty, 1);
// Get pointers to the integer argument of the add1 function... // Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@ -63,15 +63,15 @@ static Function *CreateFibFunction(Module *M)
{ {
// Create the fib function and insert it into module M. This function is said // Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter. // to return an int and take an int parameter.
Function *FibF = M->getOrInsertFunction("fib", Type::IntTy, Type::IntTy, Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
(Type *)0); (Type *)0);
// Add a basic block to the function. // Add a basic block to the function.
BasicBlock *BB = new BasicBlock("EntryBlock", FibF); BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
// Get pointers to the constants. // Get pointers to the constants.
Value *One = ConstantInt::get(Type::IntTy, 1); Value *One = ConstantInt::get(Type::Int32Ty, 1);
Value *Two = ConstantInt::get(Type::IntTy, 2); Value *Two = ConstantInt::get(Type::Int32Ty, 2);
// Get pointer to the integer argument of the add1 function... // Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg. Argument *ArgX = FibF->arg_begin(); // Get the arg.
@ -221,12 +221,12 @@ void* callFunc( void* param )
// Call the `foo' function with no arguments: // Call the `foo' function with no arguments:
std::vector<GenericValue> Args(1); std::vector<GenericValue> Args(1);
Args[0].IntVal = p->value; Args[0].Int32Val = p->value;
synchronize.block(); // wait until other threads are at this point synchronize.block(); // wait until other threads are at this point
GenericValue gv = p->EE->runFunction(p->F, Args); GenericValue gv = p->EE->runFunction(p->F, Args);
return (void*) intptr_t(gv.IntVal); return (void*) intptr_t(gv.Int32Val);
} }
int main() int main()

View File

@ -122,7 +122,7 @@ StackerCompiler::compile(
// Create a type to represent the stack. This is the same as the LLVM // Create a type to represent the stack. This is the same as the LLVM
// Assembly type [ 256 x long ] // Assembly type [ 256 x long ]
stack_type = ArrayType::get( Type::LongTy, stack_size ); stack_type = ArrayType::get( Type::Int64Ty, stack_size );
// Create a global variable for the stack. Note the use of appending // Create a global variable for the stack. Note the use of appending
// linkage linkage so that multiple modules will make the stack larger. // linkage linkage so that multiple modules will make the stack larger.
@ -141,10 +141,10 @@ StackerCompiler::compile(
// of LinkOnce linkage. Only one copy of _index_ will be retained // of LinkOnce linkage. Only one copy of _index_ will be retained
// after linking // after linking
TheIndex = new GlobalVariable( TheIndex = new GlobalVariable(
/*type=*/Type::LongTy, /*type=*/Type::Int64Ty,
/*isConstant=*/false, /*isConstant=*/false,
/*Linkage=*/GlobalValue::LinkOnceLinkage, /*Linkage=*/GlobalValue::LinkOnceLinkage,
/*initializer=*/ Constant::getNullValue(Type::LongTy), /*initializer=*/ Constant::getNullValue(Type::Int64Ty),
/*name=*/"_index_", /*name=*/"_index_",
/*parent=*/TheModule /*parent=*/TheModule
); );
@ -155,9 +155,9 @@ StackerCompiler::compile(
DefinitionType = FunctionType::get( Type::VoidTy, params, false ); DefinitionType = FunctionType::get( Type::VoidTy, params, false );
// Create a function for printf(3) // Create a function for printf(3)
params.push_back( PointerType::get( Type::SByteTy ) ); params.push_back( PointerType::get( Type::Int8Ty ) );
FunctionType* printf_type = FunctionType* printf_type =
FunctionType::get( Type::IntTy, params, true ); FunctionType::get( Type::Int32Ty, params, true );
ThePrintf = new Function( ThePrintf = new Function(
printf_type, GlobalValue::ExternalLinkage, "printf", TheModule); printf_type, GlobalValue::ExternalLinkage, "printf", TheModule);
@ -167,7 +167,7 @@ StackerCompiler::compile(
// Create a function for exit(3) // Create a function for exit(3)
params.clear(); params.clear();
params.push_back( Type::IntTy ); params.push_back( Type::Int32Ty );
FunctionType* exit_type = FunctionType* exit_type =
FunctionType::get( Type::VoidTy, params, false ); FunctionType::get( Type::VoidTy, params, false );
TheExit = new Function( TheExit = new Function(
@ -175,7 +175,7 @@ StackerCompiler::compile(
Constant* str_format = ConstantArray::get("%s"); Constant* str_format = ConstantArray::get("%s");
StrFormat = new GlobalVariable( StrFormat = new GlobalVariable(
/*type=*/ArrayType::get( Type::SByteTy, 3 ), /*type=*/ArrayType::get( Type::Int8Ty, 3 ),
/*isConstant=*/true, /*isConstant=*/true,
/*Linkage=*/GlobalValue::LinkOnceLinkage, /*Linkage=*/GlobalValue::LinkOnceLinkage,
/*initializer=*/str_format, /*initializer=*/str_format,
@ -185,7 +185,7 @@ StackerCompiler::compile(
Constant* in_str_format = ConstantArray::get(" %as"); Constant* in_str_format = ConstantArray::get(" %as");
InStrFormat = new GlobalVariable( InStrFormat = new GlobalVariable(
/*type=*/ArrayType::get( Type::SByteTy, 5 ), /*type=*/ArrayType::get( Type::Int8Ty, 5 ),
/*isConstant=*/true, /*isConstant=*/true,
/*Linkage=*/GlobalValue::LinkOnceLinkage, /*Linkage=*/GlobalValue::LinkOnceLinkage,
/*initializer=*/in_str_format, /*initializer=*/in_str_format,
@ -195,7 +195,7 @@ StackerCompiler::compile(
Constant* num_format = ConstantArray::get("%d"); Constant* num_format = ConstantArray::get("%d");
NumFormat = new GlobalVariable( NumFormat = new GlobalVariable(
/*type=*/ArrayType::get( Type::SByteTy, 3 ), /*type=*/ArrayType::get( Type::Int8Ty, 3 ),
/*isConstant=*/true, /*isConstant=*/true,
/*Linkage=*/GlobalValue::LinkOnceLinkage, /*Linkage=*/GlobalValue::LinkOnceLinkage,
/*initializer=*/num_format, /*initializer=*/num_format,
@ -205,7 +205,7 @@ StackerCompiler::compile(
Constant* in_num_format = ConstantArray::get(" %d"); Constant* in_num_format = ConstantArray::get(" %d");
InNumFormat = new GlobalVariable( InNumFormat = new GlobalVariable(
/*type=*/ArrayType::get( Type::SByteTy, 4 ), /*type=*/ArrayType::get( Type::Int8Ty, 4 ),
/*isConstant=*/true, /*isConstant=*/true,
/*Linkage=*/GlobalValue::LinkOnceLinkage, /*Linkage=*/GlobalValue::LinkOnceLinkage,
/*initializer=*/in_num_format, /*initializer=*/in_num_format,
@ -215,7 +215,7 @@ StackerCompiler::compile(
Constant* chr_format = ConstantArray::get("%c"); Constant* chr_format = ConstantArray::get("%c");
ChrFormat = new GlobalVariable( ChrFormat = new GlobalVariable(
/*type=*/ArrayType::get( Type::SByteTy, 3 ), /*type=*/ArrayType::get( Type::Int8Ty, 3 ),
/*isConstant=*/true, /*isConstant=*/true,
/*Linkage=*/GlobalValue::LinkOnceLinkage, /*Linkage=*/GlobalValue::LinkOnceLinkage,
/*initializer=*/chr_format, /*initializer=*/chr_format,
@ -225,7 +225,7 @@ StackerCompiler::compile(
Constant* in_chr_format = ConstantArray::get(" %c"); Constant* in_chr_format = ConstantArray::get(" %c");
InChrFormat = new GlobalVariable( InChrFormat = new GlobalVariable(
/*type=*/ArrayType::get( Type::SByteTy, 4 ), /*type=*/ArrayType::get( Type::Int8Ty, 4 ),
/*isConstant=*/true, /*isConstant=*/true,
/*Linkage=*/GlobalValue::LinkOnceLinkage, /*Linkage=*/GlobalValue::LinkOnceLinkage,
/*initializer=*/in_chr_format, /*initializer=*/in_chr_format,
@ -234,12 +234,12 @@ StackerCompiler::compile(
); );
// Get some constants so we aren't always creating them // Get some constants so we aren't always creating them
Zero = ConstantInt::get( Type::LongTy, 0 ); Zero = ConstantInt::get( Type::Int64Ty, 0 );
One = ConstantInt::get( Type::LongTy, 1 ); One = ConstantInt::get( Type::Int64Ty, 1 );
Two = ConstantInt::get( Type::LongTy, 2 ); Two = ConstantInt::get( Type::Int64Ty, 2 );
Three = ConstantInt::get( Type::LongTy, 3 ); Three = ConstantInt::get( Type::Int64Ty, 3 );
Four = ConstantInt::get( Type::LongTy, 4 ); Four = ConstantInt::get( Type::Int64Ty, 4 );
Five = ConstantInt::get( Type::LongTy, 5 ); Five = ConstantInt::get( Type::Int64Ty, 5 );
// Reset the current line number // Reset the current line number
Stackerlineno = 1; Stackerlineno = 1;
@ -363,7 +363,7 @@ StackerCompiler::incr_stack_index( BasicBlock* bb, Value* ival = 0 )
// Increment the loaded index value // Increment the loaded index value
if ( ival == 0 ) ival = One; if ( ival == 0 ) ival = One;
CastInst* caster = CastInst::createSExtOrBitCast( ival, Type::LongTy ); CastInst* caster = CastInst::createSExtOrBitCast( ival, Type::Int64Ty );
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
BinaryOperator* addop = BinaryOperator::create( Instruction::Add, BinaryOperator* addop = BinaryOperator::create( Instruction::Add,
loadop, caster); loadop, caster);
@ -384,7 +384,7 @@ StackerCompiler::decr_stack_index( BasicBlock* bb, Value* ival = 0 )
// Decrement the loaded index value // Decrement the loaded index value
if ( ival == 0 ) ival = One; if ( ival == 0 ) ival = One;
CastInst* caster = CastInst::createSExtOrBitCast( ival, Type::LongTy ); CastInst* caster = CastInst::createSExtOrBitCast( ival, Type::Int64Ty );
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
BinaryOperator* subop = BinaryOperator::create( Instruction::Sub, BinaryOperator* subop = BinaryOperator::create( Instruction::Sub,
loadop, caster); loadop, caster);
@ -418,7 +418,7 @@ StackerCompiler::get_stack_pointer( BasicBlock* bb, Value* index = 0 )
} }
else else
{ {
CastInst* caster = CastInst::createSExtOrBitCast( index, Type::LongTy ); CastInst* caster = CastInst::createSExtOrBitCast( index, Type::Int64Ty );
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
BinaryOperator* subop = BinaryOperator::create( BinaryOperator* subop = BinaryOperator::create(
Instruction::Sub, loadop, caster ); Instruction::Sub, loadop, caster );
@ -448,7 +448,7 @@ StackerCompiler::push_value( BasicBlock* bb, Value* val )
(isa<PointerType>(val->getType()) ? Instruction::PtrToInt : (isa<PointerType>(val->getType()) ? Instruction::PtrToInt :
(val->getType()->getPrimitiveSizeInBits() < 64 ? Instruction::SExt : (val->getType()->getPrimitiveSizeInBits() < 64 ? Instruction::SExt :
Instruction::BitCast)); Instruction::BitCast));
CastInst* cast_inst = CastInst::create(opcode, val, Type::LongTy ); CastInst* cast_inst = CastInst::create(opcode, val, Type::Int64Ty );
bb->getInstList().push_back( cast_inst ); bb->getInstList().push_back( cast_inst );
// Store the value // Store the value
@ -462,7 +462,7 @@ Instruction*
StackerCompiler::push_integer(BasicBlock* bb, int64_t value ) StackerCompiler::push_integer(BasicBlock* bb, int64_t value )
{ {
// Just push a constant integer value // Just push a constant integer value
return push_value( bb, ConstantInt::get( Type::LongTy, value ) ); return push_value( bb, ConstantInt::get( Type::Int64Ty, value ) );
} }
Instruction* Instruction*
@ -491,7 +491,7 @@ StackerCompiler::push_string( BasicBlock* bb, const char* value )
// Create a type for the string constant. Length is +1 for // Create a type for the string constant. Length is +1 for
// the terminating 0. // the terminating 0.
ArrayType* char_array = ArrayType::get( Type::SByteTy, len + 1 ); ArrayType* char_array = ArrayType::get( Type::Int8Ty, len + 1 );
// Create an initializer for the value // Create an initializer for the value
Constant* initVal = ConstantArray::get( value ); Constant* initVal = ConstantArray::get( value );
@ -523,7 +523,7 @@ StackerCompiler::pop_string( BasicBlock* bb )
// Cast the integer to a sbyte* // Cast the integer to a sbyte*
CastInst* caster = CastInst* caster =
new IntToPtrInst(loader, PointerType::get(Type::SByteTy)); new IntToPtrInst(loader, PointerType::get(Type::Int8Ty));
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
// Decrement stack index // Decrement stack index
@ -576,7 +576,7 @@ StackerCompiler::stack_top_string( BasicBlock* bb, Value* index = 0 )
// Cast the integer to a sbyte* // Cast the integer to a sbyte*
CastInst* caster = CastInst* caster =
new IntToPtrInst(loader, PointerType::get(Type::SByteTy) ); new IntToPtrInst(loader, PointerType::get(Type::Int8Ty) );
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
// Return the value // Return the value
@ -652,7 +652,7 @@ StackerCompiler::handle_main_definition( Function* func )
TheStack->setLinkage( GlobalValue::LinkOnceLinkage ); TheStack->setLinkage( GlobalValue::LinkOnceLinkage );
// Turn "_index_" into an intialized variable for the same reason. // Turn "_index_" into an intialized variable for the same reason.
TheIndex->setInitializer( Constant::getNullValue(Type::LongTy) ); TheIndex->setInitializer( Constant::getNullValue(Type::Int64Ty) );
TheIndex->setLinkage( GlobalValue::LinkOnceLinkage ); TheIndex->setLinkage( GlobalValue::LinkOnceLinkage );
return func; return func;
@ -722,7 +722,7 @@ StackerCompiler::handle_if( char* ifTrue, char* ifFalse )
// Compare the condition against 0 // Compare the condition against 0
ICmpInst* cond_inst = new ICmpInst( ICmpInst::ICMP_NE, cond, ICmpInst* cond_inst = new ICmpInst( ICmpInst::ICMP_NE, cond,
ConstantInt::get( Type::LongTy, 0) ); ConstantInt::get( Type::Int64Ty, 0) );
bb->getInstList().push_back( cond_inst ); bb->getInstList().push_back( cond_inst );
// Create an exit block // Create an exit block
@ -806,7 +806,7 @@ StackerCompiler::handle_while( char* todo )
// Compare the condition against 0 // Compare the condition against 0
ICmpInst* cond_inst = new ICmpInst( ICmpInst* cond_inst = new ICmpInst(
ICmpInst::ICMP_NE, cond, ConstantInt::get( Type::LongTy, 0)); ICmpInst::ICMP_NE, cond, ConstantInt::get( Type::Int64Ty, 0));
test->getInstList().push_back( cond_inst ); test->getInstList().push_back( cond_inst );
// Add the branch instruction // Add the branch instruction
@ -1020,7 +1020,7 @@ StackerCompiler::handle_word( int tkn )
if (echo) bb->setName("DECR"); if (echo) bb->setName("DECR");
LoadInst* op1 = cast<LoadInst>(pop_integer(bb)); LoadInst* op1 = cast<LoadInst>(pop_integer(bb));
BinaryOperator* subop = BinaryOperator::create( Instruction::Sub, op1, BinaryOperator* subop = BinaryOperator::create( Instruction::Sub, op1,
ConstantInt::get( Type::LongTy, 1 ) ); ConstantInt::get( Type::Int64Ty, 1 ) );
bb->getInstList().push_back( subop ); bb->getInstList().push_back( subop );
push_value( bb, subop ); push_value( bb, subop );
break; break;
@ -1090,7 +1090,7 @@ StackerCompiler::handle_word( int tkn )
// bb->getInstList().push_back( negop ); // bb->getInstList().push_back( negop );
// So we'll multiply by -1 (ugh) // So we'll multiply by -1 (ugh)
BinaryOperator* multop = BinaryOperator::create( Instruction::Mul, op1, BinaryOperator* multop = BinaryOperator::create( Instruction::Mul, op1,
ConstantInt::get( Type::LongTy, -1 ) ); ConstantInt::get( Type::Int64Ty, -1 ) );
bb->getInstList().push_back( multop ); bb->getInstList().push_back( multop );
push_value( bb, multop ); push_value( bb, multop );
break; break;
@ -1245,7 +1245,7 @@ StackerCompiler::handle_word( int tkn )
if (echo) bb->setName("SHL"); if (echo) bb->setName("SHL");
LoadInst* op1 = cast<LoadInst>(pop_integer(bb)); LoadInst* op1 = cast<LoadInst>(pop_integer(bb));
LoadInst* op2 = cast<LoadInst>(pop_integer(bb)); LoadInst* op2 = cast<LoadInst>(pop_integer(bb));
CastInst* castop = new TruncInst( op1, Type::UByteTy ); CastInst* castop = new TruncInst( op1, Type::Int8Ty );
bb->getInstList().push_back( castop ); bb->getInstList().push_back( castop );
ShiftInst* shlop = new ShiftInst( Instruction::Shl, op2, castop ); ShiftInst* shlop = new ShiftInst( Instruction::Shl, op2, castop );
bb->getInstList().push_back( shlop ); bb->getInstList().push_back( shlop );
@ -1257,7 +1257,7 @@ StackerCompiler::handle_word( int tkn )
if (echo) bb->setName("SHR"); if (echo) bb->setName("SHR");
LoadInst* op1 = cast<LoadInst>(pop_integer(bb)); LoadInst* op1 = cast<LoadInst>(pop_integer(bb));
LoadInst* op2 = cast<LoadInst>(pop_integer(bb)); LoadInst* op2 = cast<LoadInst>(pop_integer(bb));
CastInst* castop = new TruncInst( op1, Type::UByteTy ); CastInst* castop = new TruncInst( op1, Type::Int8Ty );
bb->getInstList().push_back( castop ); bb->getInstList().push_back( castop );
ShiftInst* shrop = new ShiftInst( Instruction::AShr, op2, castop ); ShiftInst* shrop = new ShiftInst( Instruction::AShr, op2, castop );
bb->getInstList().push_back( shrop ); bb->getInstList().push_back( shrop );
@ -1479,11 +1479,11 @@ StackerCompiler::handle_word( int tkn )
LoadInst* op1 = cast<LoadInst>( pop_integer(bb) ); LoadInst* op1 = cast<LoadInst>( pop_integer(bb) );
// Make sure its a UIntTy // Make sure its a UIntTy
CastInst* caster = CastInst::createTruncOrBitCast( op1, Type::UIntTy ); CastInst* caster = CastInst::createTruncOrBitCast( op1, Type::Int32Ty );
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
// Allocate the bytes // Allocate the bytes
MallocInst* mi = new MallocInst( Type::SByteTy, caster ); MallocInst* mi = new MallocInst( Type::Int8Ty, caster );
bb->getInstList().push_back( mi ); bb->getInstList().push_back( mi );
// Push the pointer // Push the pointer
@ -1507,7 +1507,7 @@ StackerCompiler::handle_word( int tkn )
if (echo) bb->setName("GET"); if (echo) bb->setName("GET");
// Get the character index // Get the character index
LoadInst* op1 = cast<LoadInst>( stack_top(bb) ); LoadInst* op1 = cast<LoadInst>( stack_top(bb) );
CastInst* chr_idx = CastInst::createSExtOrBitCast( op1, Type::LongTy ); CastInst* chr_idx = CastInst::createSExtOrBitCast( op1, Type::Int64Ty );
bb->getInstList().push_back( chr_idx ); bb->getInstList().push_back( chr_idx );
// Get the String pointer // Get the String pointer
@ -1522,7 +1522,7 @@ StackerCompiler::handle_word( int tkn )
// Get the value and push it // Get the value and push it
LoadInst* loader = new LoadInst( gep ); LoadInst* loader = new LoadInst( gep );
bb->getInstList().push_back( loader ); bb->getInstList().push_back( loader );
CastInst* caster = CastInst::createTruncOrBitCast(loader, Type::IntTy); CastInst* caster = CastInst::createTruncOrBitCast(loader, Type::Int32Ty);
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
// Push the result back on stack // Push the result back on stack
@ -1539,7 +1539,7 @@ StackerCompiler::handle_word( int tkn )
// Get the character index // Get the character index
LoadInst* w2 = cast<LoadInst>( pop_integer(bb) ); LoadInst* w2 = cast<LoadInst>( pop_integer(bb) );
CastInst* chr_idx = CastInst::createSExtOrBitCast( w2, Type::LongTy ); CastInst* chr_idx = CastInst::createSExtOrBitCast( w2, Type::Int64Ty );
bb->getInstList().push_back( chr_idx ); bb->getInstList().push_back( chr_idx );
// Get the String pointer // Get the String pointer
@ -1552,7 +1552,7 @@ StackerCompiler::handle_word( int tkn )
bb->getInstList().push_back( gep ); bb->getInstList().push_back( gep );
// Cast the value and put it // Cast the value and put it
CastInst* caster = new TruncInst( w1, Type::SByteTy ); CastInst* caster = new TruncInst( w1, Type::Int8Ty );
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
StoreInst* storer = new StoreInst( caster, gep ); StoreInst* storer = new StoreInst( caster, gep );
bb->getInstList().push_back( storer ); bb->getInstList().push_back( storer );
@ -1580,7 +1580,7 @@ StackerCompiler::handle_word( int tkn )
LoadInst* op1 = cast<LoadInst>(pop_integer(bb)); LoadInst* op1 = cast<LoadInst>(pop_integer(bb));
// Cast down to an integer // Cast down to an integer
CastInst* caster = new TruncInst( op1, Type::IntTy ); CastInst* caster = new TruncInst( op1, Type::Int32Ty );
bb->getInstList().push_back( caster ); bb->getInstList().push_back( caster );
// Call exit(3) // Call exit(3)
@ -1602,7 +1602,7 @@ StackerCompiler::handle_word( int tkn )
bb->getInstList().push_back( format_gep ); bb->getInstList().push_back( format_gep );
// Get the character to print (a tab) // Get the character to print (a tab)
ConstantInt* newline = ConstantInt::get(Type::IntTy, ConstantInt* newline = ConstantInt::get(Type::Int32Ty,
static_cast<int>('\t')); static_cast<int>('\t'));
// Call printf // Call printf
@ -1624,7 +1624,7 @@ StackerCompiler::handle_word( int tkn )
bb->getInstList().push_back( format_gep ); bb->getInstList().push_back( format_gep );
// Get the character to print (a space) // Get the character to print (a space)
ConstantInt* newline = ConstantInt::get(Type::IntTy, ConstantInt* newline = ConstantInt::get(Type::Int32Ty,
static_cast<int>(' ')); static_cast<int>(' '));
// Call printf // Call printf
@ -1646,7 +1646,7 @@ StackerCompiler::handle_word( int tkn )
bb->getInstList().push_back( format_gep ); bb->getInstList().push_back( format_gep );
// Get the character to print (a newline) // Get the character to print (a newline)
ConstantInt* newline = ConstantInt::get(Type::IntTy, ConstantInt* newline = ConstantInt::get(Type::Int32Ty,
static_cast<int>('\n')); static_cast<int>('\n'));
// Call printf // Call printf
@ -1664,7 +1664,7 @@ StackerCompiler::handle_word( int tkn )
GetElementPtrInst* gep_value = GetElementPtrInst* gep_value =
cast<GetElementPtrInst>(get_stack_pointer(bb)); cast<GetElementPtrInst>(get_stack_pointer(bb));
CastInst* caster = CastInst* caster =
new BitCastInst(gep_value, PointerType::get(Type::SByteTy)); new BitCastInst(gep_value, PointerType::get(Type::Int8Ty));
// Make room for the count result // Make room for the count result
incr_stack_index(bb); incr_stack_index(bb);

View File

@ -31,7 +31,7 @@ namespace llvm {
std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics. std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics.
/// ArgTypes - The type primitive enum value for the return value and all /// ArgTypes - The type primitive enum value for the return value and all
/// of the arguments. These are things like Type::UIntTyID. /// of the arguments. These are things like Type::Int32TyID.
std::vector<std::string> ArgTypes; std::vector<std::string> ArgTypes;
/// ArgVTs - The MVT::ValueType for each argument type. Note that this list /// ArgVTs - The MVT::ValueType for each argument type. Note that this list