llvm.org GIT mirror llvm / 31b628b
Change createInferredCast calls to more accurate cast creation calls. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32520 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 12 years ago
1 changed file(s) with 18 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
366366
367367 // Increment the loaded index value
368368 if ( ival == 0 ) ival = One;
369 CastInst* caster = CastInst::createInferredCast( ival, Type::LongTy );
369 CastInst* caster = CastInst::createSExtOrBitCast( ival, Type::LongTy );
370370 bb->getInstList().push_back( caster );
371371 BinaryOperator* addop = BinaryOperator::create( Instruction::Add,
372372 loadop, caster);
387387
388388 // Decrement the loaded index value
389389 if ( ival == 0 ) ival = One;
390 CastInst* caster = CastInst::createInferredCast( ival, Type::LongTy );
390 CastInst* caster = CastInst::createSExtOrBitCast( ival, Type::LongTy );
391391 bb->getInstList().push_back( caster );
392392 BinaryOperator* subop = BinaryOperator::create( Instruction::Sub,
393393 loadop, caster);
421421 }
422422 else
423423 {
424 CastInst* caster = CastInst::createInferredCast( index, Type::LongTy );
424 CastInst* caster = CastInst::createSExtOrBitCast( index, Type::LongTy );
425425 bb->getInstList().push_back( caster );
426426 BinaryOperator* subop = BinaryOperator::create(
427427 Instruction::Sub, loadop, caster );
447447 get_stack_pointer( bb ) );
448448
449449 // Cast the value to a long .. hopefully it works
450 CastInst* cast_inst = CastInst::createInferredCast( val, Type::LongTy );
450 Instruction::CastOps opcode =
451 (isa(val->getType()) ? Instruction::PtrToInt :
452 (val->getType()->getPrimitiveSizeInBits() < 64 ? Instruction::SExt :
453 Instruction::BitCast));
454 CastInst* cast_inst = CastInst::create(opcode, val, Type::LongTy );
451455 bb->getInstList().push_back( cast_inst );
452456
453457 // Store the value
522526
523527 // Cast the integer to a sbyte*
524528 CastInst* caster =
525 CastInst::createInferredCast( loader, PointerType::get(Type::SByteTy) );
529 new IntToPtrInst(loader, PointerType::get(Type::SByteTy));
526530 bb->getInstList().push_back( caster );
527531
528532 // Decrement stack index
575579
576580 // Cast the integer to a sbyte*
577581 CastInst* caster =
578 CastInst::createInferredCast( loader, PointerType::get(Type::SByteTy) );
582 new IntToPtrInst(loader, PointerType::get(Type::SByteTy) );
579583 bb->getInstList().push_back( caster );
580584
581585 // Return the value
12441248 if (echo) bb->setName("SHL");
12451249 LoadInst* op1 = cast(pop_integer(bb));
12461250 LoadInst* op2 = cast(pop_integer(bb));
1247 CastInst* castop = CastInst::createInferredCast( op1, Type::UByteTy );
1251 CastInst* castop = new TruncInst( op1, Type::UByteTy );
12481252 bb->getInstList().push_back( castop );
12491253 ShiftInst* shlop = new ShiftInst( Instruction::Shl, op2, castop );
12501254 bb->getInstList().push_back( shlop );
12561260 if (echo) bb->setName("SHR");
12571261 LoadInst* op1 = cast(pop_integer(bb));
12581262 LoadInst* op2 = cast(pop_integer(bb));
1259 CastInst* castop = CastInst::createInferredCast( op1, Type::UByteTy );
1263 CastInst* castop = new TruncInst( op1, Type::UByteTy );
12601264 bb->getInstList().push_back( castop );
12611265 ShiftInst* shrop = new ShiftInst( Instruction::AShr, op2, castop );
12621266 bb->getInstList().push_back( shrop );
14781482 LoadInst* op1 = cast( pop_integer(bb) );
14791483
14801484 // Make sure its a UIntTy
1481 CastInst* caster = CastInst::createInferredCast( op1, Type::UIntTy );
1485 CastInst* caster = CastInst::createTruncOrBitCast( op1, Type::UIntTy );
14821486 bb->getInstList().push_back( caster );
14831487
14841488 // Allocate the bytes
15061510 if (echo) bb->setName("GET");
15071511 // Get the character index
15081512 LoadInst* op1 = cast( stack_top(bb) );
1509 CastInst* chr_idx = CastInst::createInferredCast( op1, Type::LongTy );
1513 CastInst* chr_idx = CastInst::createSExtOrBitCast( op1, Type::LongTy );
15101514 bb->getInstList().push_back( chr_idx );
15111515
15121516 // Get the String pointer
15211525 // Get the value and push it
15221526 LoadInst* loader = new LoadInst( gep );
15231527 bb->getInstList().push_back( loader );
1524 CastInst* caster = CastInst::createInferredCast( loader, Type::IntTy );
1528 CastInst* caster = CastInst::createTruncOrBitCast(loader, Type::IntTy);
15251529 bb->getInstList().push_back( caster );
15261530
15271531 // Push the result back on stack
15381542
15391543 // Get the character index
15401544 LoadInst* w2 = cast( pop_integer(bb) );
1541 CastInst* chr_idx = CastInst::createInferredCast( w2, Type::LongTy );
1545 CastInst* chr_idx = CastInst::createSExtOrBitCast( w2, Type::LongTy );
15421546 bb->getInstList().push_back( chr_idx );
15431547
15441548 // Get the String pointer
15511555 bb->getInstList().push_back( gep );
15521556
15531557 // Cast the value and put it
1554 CastInst* caster = CastInst::createInferredCast( w1, Type::SByteTy );
1558 CastInst* caster = new TruncInst( w1, Type::SByteTy );
15551559 bb->getInstList().push_back( caster );
15561560 StoreInst* storer = new StoreInst( caster, gep );
15571561 bb->getInstList().push_back( storer );
15791583 LoadInst* op1 = cast(pop_integer(bb));
15801584
15811585 // Cast down to an integer
1582 CastInst* caster = CastInst::createInferredCast( op1, Type::IntTy );
1586 CastInst* caster = new TruncInst( op1, Type::IntTy );
15831587 bb->getInstList().push_back( caster );
15841588
15851589 // Call exit(3)