summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-06-24 09:17:47 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-06-24 09:17:47 +0000
commit2f6741f4f3a1ddec357963c91a16375fad82c5c8 (patch)
tree0b7c23e61f520aec52974812cb3efaed9131eb88 /llvm/lib
parentc605ae6754da05ca937d0119ec8364b60843f555 (diff)
downloadbcm5719-llvm-2f6741f4f3a1ddec357963c91a16375fad82c5c8.tar.gz
bcm5719-llvm-2f6741f4f3a1ddec357963c91a16375fad82c5c8.zip
Fix a dyn_cast in copyConstantToRegister which should have been a cast.
Compactify the code that emits copies of constant ints into registers. llvm-svn: 14365
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/SparcV8/InstSelectSimple.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/llvm/lib/Target/SparcV8/InstSelectSimple.cpp b/llvm/lib/Target/SparcV8/InstSelectSimple.cpp
index 9d79ae8a7b2..bbfe3cb65f5 100644
--- a/llvm/lib/Target/SparcV8/InstSelectSimple.cpp
+++ b/llvm/lib/Target/SparcV8/InstSelectSimple.cpp
@@ -253,33 +253,30 @@ void V8ISel::copyConstantToRegister(MachineBasicBlock *MBB,
if (C->getType() == Type::BoolTy) {
Val = (C == ConstantBool::True);
} else {
- ConstantInt *CI = dyn_cast<ConstantInt> (C);
+ ConstantInt *CI = cast<ConstantInt> (C);
Val = CI->getRawValue ();
}
switch (Class) {
- case cByte:
- BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (V8::G0).addSImm((uint8_t)Val);
- return;
- case cShort: {
- unsigned TmpReg = makeAnotherReg (C->getType ());
- BuildMI (*MBB, IP, V8::SETHIi, 1, TmpReg)
- .addSImm (((uint16_t) Val) >> 10);
- BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (TmpReg)
- .addSImm (((uint16_t) Val) & 0x03ff);
- return;
- }
- case cInt: {
- unsigned TmpReg = makeAnotherReg (C->getType ());
- BuildMI (*MBB, IP, V8::SETHIi, 1, TmpReg).addZImm(((uint32_t)Val) >> 10);
- BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (TmpReg)
- .addSImm (((uint32_t) Val) & 0x03ff);
- return;
- }
+ case cByte: Val = (int8_t) Val; break;
+ case cShort: Val = (int16_t) Val; break;
+ case cInt: Val = (int32_t) Val; break;
default:
std::cerr << "Offending constant: " << *C << "\n";
assert (0 && "Can't copy this kind of constant into register yet");
return;
}
+ if (Val == 0) {
+ BuildMI (*MBB, IP, V8::ORrr, 2, R).addReg (V8::G0).addReg(V8::G0);
+ } else if (((int64_t)Val >= -4096) && ((int64_t)Val <= 4095)) {
+ BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (V8::G0).addSImm(Val);
+ } else {
+ unsigned TmpReg = makeAnotherReg (C->getType ());
+ BuildMI (*MBB, IP, V8::SETHIi, 1, TmpReg)
+ .addSImm (((uint32_t) Val) >> 10);
+ BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (TmpReg)
+ .addSImm (((uint32_t) Val) & 0x03ff);
+ return;
+ }
} else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
// We need to spill the constant to memory...
MachineConstantPool *CP = F->getConstantPool();
OpenPOWER on IntegriCloud