[llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Apr 5 20:21:28 PDT 2004
Changes in directory llvm/lib/Target/X86:
InstSelectSimple.cpp updated: 1.204 -> 1.205
---
Log message:
Two changes:
* In promote32, if we can just promote a constant value, do so instead of
promoting a constant dynamically.
* In visitReturn inst, actually USE the promote32 argument that takes a
Value*
The end result of this is that we now generate this:
test:
mov %EAX, 0
ret
instead of...
test:
mov %AX, 0
movzx %EAX, %AX
ret
for:
ushort %test() {
ret ushort 0
}
---
Diffs of the changes: (+17 -6)
Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.204 llvm/lib/Target/X86/InstSelectSimple.cpp:1.205
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.204 Sun Apr 4 20:29:31 2004
+++ llvm/lib/Target/X86/InstSelectSimple.cpp Mon Apr 5 20:21:00 2004
@@ -1107,10 +1107,18 @@
void ISel::promote32(unsigned targetReg, const ValueRecord &VR) {
bool isUnsigned = VR.Ty->isUnsigned();
+ Value *Val = VR.Val;
+ const Type *Ty = VR.Ty;
+ if (Val)
+ if (Constant *C = dyn_cast<Constant>(Val)) {
+ Val = ConstantExpr::getCast(C, Type::IntTy);
+ Ty = Type::IntTy;
+ }
+
// Make sure we have the register number for this value...
- unsigned Reg = VR.Val ? getReg(VR.Val) : VR.Reg;
+ unsigned Reg = Val ? getReg(Val) : VR.Reg;
- switch (getClassB(VR.Ty)) {
+ switch (getClassB(Ty)) {
case cByte:
// Extend value into target register (8->32)
if (isUnsigned)
@@ -1152,27 +1160,30 @@
}
Value *RetVal = I.getOperand(0);
- unsigned RetReg = getReg(RetVal);
switch (getClassB(RetVal->getType())) {
case cByte: // integral return values: extend or move into EAX and return
case cShort:
case cInt:
- promote32(X86::EAX, ValueRecord(RetReg, RetVal->getType()));
+ promote32(X86::EAX, ValueRecord(RetVal));
// Declare that EAX is live on exit
BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::EAX).addReg(X86::ESP);
break;
- case cFP: // Floats & Doubles: Return in ST(0)
+ case cFP: { // Floats & Doubles: Return in ST(0)
+ unsigned RetReg = getReg(RetVal);
BuildMI(BB, X86::FpSETRESULT, 1).addReg(RetReg);
// Declare that top-of-stack is live on exit
BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::ST0).addReg(X86::ESP);
break;
- case cLong:
+ }
+ case cLong: {
+ unsigned RetReg = getReg(RetVal);
BuildMI(BB, X86::MOV32rr, 1, X86::EAX).addReg(RetReg);
BuildMI(BB, X86::MOV32rr, 1, X86::EDX).addReg(RetReg+1);
// Declare that EAX & EDX are live on exit
BuildMI(BB, X86::IMPLICIT_USE, 3).addReg(X86::EAX).addReg(X86::EDX)
.addReg(X86::ESP);
break;
+ }
default:
visitInstruction(I);
}
More information about the llvm-commits
mailing list