[llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Printer.cpp X86SimpInstrSelector.cpp
LLVM
llvm at cs.uiuc.edu
Sat Jul 17 17:33:48 PDT 2004
Changes in directory llvm/lib/Target/X86:
InstSelectSimple.cpp updated: 1.271 -> 1.272
Printer.cpp updated: 1.103 -> 1.104
X86SimpInstrSelector.cpp updated: 1.6 -> 1.7
---
Log message:
bug 122: http://llvm.cs.uiuc.edu/PR122 :
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass
---
Diffs of the changes: (+12 -28)
Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.271 llvm/lib/Target/X86/InstSelectSimple.cpp:1.272
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.271 Wed Jul 14 21:14:23 2004
+++ llvm/lib/Target/X86/InstSelectSimple.cpp Sat Jul 17 19:33:38 2004
@@ -394,16 +394,10 @@
MachineBasicBlock::iterator IPt) {
// If this operand is a constant, emit the code to copy the constant into
// the register here...
- //
if (Constant *C = dyn_cast<Constant>(V)) {
unsigned Reg = makeAnotherReg(V->getType());
copyConstantToRegister(MBB, IPt, C, Reg);
return Reg;
- } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
- unsigned Reg = makeAnotherReg(V->getType());
- // Move the address of the global into the register
- BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV);
- return Reg;
} else if (CastInst *CI = dyn_cast<CastInst>(V)) {
// Do not emit noop casts at all, unless it's a double -> float cast.
if (getClassB(CI->getType()) == getClassB(CI->getOperand(0)->getType()) &&
@@ -554,8 +548,8 @@
} else if (isa<ConstantPointerNull>(C)) {
// Copy zero (null pointer) to the register.
BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addImm(0);
- } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
- BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue());
+ } else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) {
+ BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(GV);
} else {
std::cerr << "Offending constant: " << *C << "\n";
assert(0 && "Type not handled yet!");
@@ -688,8 +682,7 @@
// If this is a constant or GlobalValue, we may have to insert code
// into the basic block to compute it into a virtual register.
- if ((isa<Constant>(Val) && !isa<ConstantExpr>(Val)) ||
- isa<GlobalValue>(Val)) {
+ if ((isa<Constant>(Val) && !isa<ConstantExpr>(Val))) {
// Simple constants get emitted at the end of the basic block,
// before any terminator instructions. We "know" that the code to
// move a constant into a register will never clobber any flags.
@@ -3635,8 +3628,6 @@
Value *Src, User::op_iterator IdxBegin,
User::op_iterator IdxEnd, unsigned &BaseReg,
unsigned &Scale, unsigned &IndexReg, unsigned &Disp) {
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src))
- Src = CPR->getValue();
std::vector<Value*> GEPOps;
GEPOps.resize(IdxEnd-IdxBegin+1);
@@ -3660,8 +3651,6 @@
Value *Src, User::op_iterator IdxBegin,
User::op_iterator IdxEnd, unsigned TargetReg) {
const TargetData &TD = TM.getTargetData();
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src))
- Src = CPR->getValue();
// If this is a getelementptr null, with all constant integer indices, just
// replace it with TargetReg = 42.
Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.103 llvm/lib/Target/X86/Printer.cpp:1.104
--- llvm/lib/Target/X86/Printer.cpp:1.103 Tue Jun 29 14:43:20 2004
+++ llvm/lib/Target/X86/Printer.cpp Sat Jul 17 19:33:38 2004
@@ -178,10 +178,10 @@
O << (unsigned long long)CI->getValue();
else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
O << CI->getValue();
- else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CV))
+ else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
// This is a constant address for a global variable or function. Use the
// name of the variable or function as the address value.
- O << Mang->getValueName(CPR->getValue());
+ O << Mang->getValueName(GV);
else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
const TargetData &TD = TM.getTargetData();
switch(CE->getOpcode()) {
Index: llvm/lib/Target/X86/X86SimpInstrSelector.cpp
diff -u llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.6 llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.7
--- llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.6 Wed Jul 14 21:14:24 2004
+++ llvm/lib/Target/X86/X86SimpInstrSelector.cpp Sat Jul 17 19:33:38 2004
@@ -316,13 +316,13 @@
// If this operand is a constant, emit the code to copy the constant into
// the register here...
//
- if (Constant *C = dyn_cast<Constant>(V)) {
- copyConstantToRegister(MBB, IPt, C, Reg);
- RegMap.erase(V); // Assign a new name to this constant if ref'd again
- } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
// Move the address of the global into the register
BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV);
RegMap.erase(V); // Assign a new name to this address if ref'd again
+ } else if (Constant *C = dyn_cast<Constant>(V)) {
+ copyConstantToRegister(MBB, IPt, C, Reg);
+ RegMap.erase(V); // Assign a new name to this constant if ref'd again
}
return Reg;
@@ -480,8 +480,8 @@
} else if (isa<ConstantPointerNull>(C)) {
// Copy zero (null pointer) to the register.
BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addImm(0);
- } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
- BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue());
+ } else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) {
+ BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(GV);
} else {
std::cerr << "Offending constant: " << *C << "\n";
assert(0 && "Type not handled yet!");
@@ -602,7 +602,7 @@
// If this is a constant or GlobalValue, we may have to insert code
// into the basic block to compute it into a virtual register.
- if (isa<Constant>(Val) || isa<GlobalValue>(Val)) {
+ if (isa<Constant>(Val)) {
// Because we don't want to clobber any values which might be in
// physical registers with the computation of this constant (which
// might be arbitrarily complex if it is a constant expression),
@@ -2589,9 +2589,6 @@
Value *Src, User::op_iterator IdxBegin,
User::op_iterator IdxEnd, unsigned &BaseReg,
unsigned &Scale, unsigned &IndexReg, unsigned &Disp) {
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src))
- Src = CPR->getValue();
-
std::vector<Value*> GEPOps;
GEPOps.resize(IdxEnd-IdxBegin+1);
GEPOps[0] = Src;
@@ -2614,8 +2611,6 @@
Value *Src, User::op_iterator IdxBegin,
User::op_iterator IdxEnd, unsigned TargetReg) {
const TargetData &TD = TM.getTargetData();
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src))
- Src = CPR->getValue();
std::vector<Value*> GEPOps;
GEPOps.resize(IdxEnd-IdxBegin+1);
More information about the llvm-commits
mailing list