diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-07-18 00:38:32 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-07-18 00:38:32 +0000 |
commit | 8863f1814ba2c26910edb30857d10a8587f2f7de (patch) | |
tree | e6c4d8c224ba03635f233ecb2710963a48a4bd9d /lib/Target/X86/InstSelectSimple.cpp | |
parent | 2786542aad27f4456e551cd4ee744be6b6ae41ba (diff) | |
download | external_llvm-8863f1814ba2c26910edb30857d10a8587f2f7de.tar.gz external_llvm-8863f1814ba2c26910edb30857d10a8587f2f7de.tar.bz2 external_llvm-8863f1814ba2c26910edb30857d10a8587f2f7de.zip |
bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14950 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/InstSelectSimple.cpp')
-rw-r--r-- | lib/Target/X86/InstSelectSimple.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 06165e9f6e..3dced748bc 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -394,16 +394,10 @@ unsigned ISel::getReg(Value *V, MachineBasicBlock *MBB, 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 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB, } 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 @@ void ISel::SelectPHINodes() { // 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 @@ bool ISel::isGEPFoldable(MachineBasicBlock *MBB, 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 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB, 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. |