diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-07 01:56:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-07 01:56:04 +0000 |
commit | a98c679de05bedf3bb1bf7574abd1a84ce5041b1 (patch) | |
tree | 33f545cec3474907cff3c9be73e0600fd4214c8d /llvm/lib/Target/X86 | |
parent | 0ec92e9d648c9eb06a563bc84c211ec7329af507 (diff) | |
download | bcm5719-llvm-a98c679de05bedf3bb1bf7574abd1a84ce5041b1.tar.gz bcm5719-llvm-a98c679de05bedf3bb1bf7574abd1a84ce5041b1.zip |
Rename MachineInstr::getInstrDescriptor -> getDesc(), which reflects
that it is cheap and efficient to get.
Move a variety of predicates from TargetInstrInfo into
TargetInstrDescriptor, which makes it much easier to query a predicate
when you don't have TII around. Now you can use MI->getDesc()->isBranch()
instead of going through TII, and this is much more efficient anyway. Not
all of the predicates have been moved over yet.
Update old code that used MI->getInstrDescriptor()->Flags to use the
new predicates in many places.
llvm-svn: 45674
Diffstat (limited to 'llvm/lib/Target/X86')
-rw-r--r-- | llvm/lib/Target/X86/X86CodeEmitter.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86FloatingPoint.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.cpp | 23 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86RegisterInfo.cpp | 65 |
4 files changed, 20 insertions, 82 deletions
diff --git a/llvm/lib/Target/X86/X86CodeEmitter.cpp b/llvm/lib/Target/X86/X86CodeEmitter.cpp index bc2c007a6bc..3c67d625152 100644 --- a/llvm/lib/Target/X86/X86CodeEmitter.cpp +++ b/llvm/lib/Target/X86/X86CodeEmitter.cpp @@ -115,7 +115,7 @@ bool Emitter::runOnMachineFunction(MachineFunction &MF) { MCE.StartMachineBasicBlock(MBB); for (MachineBasicBlock::const_iterator I = MBB->begin(), E = MBB->end(); I != E; ++I) { - const TargetInstrDescriptor *Desc = I->getInstrDescriptor(); + const TargetInstrDescriptor *Desc = I->getDesc(); emitInstruction(*I, Desc); // MOVPC32r is basically a call plus a pop instruction. if (Desc->Opcode == X86::MOVPC32r) @@ -436,7 +436,7 @@ inline static bool isX86_64NonExtLowByteReg(unsigned reg) { /// size, and 3) use of X86-64 extended registers. unsigned Emitter::determineREX(const MachineInstr &MI) { unsigned REX = 0; - const TargetInstrDescriptor *Desc = MI.getInstrDescriptor(); + const TargetInstrDescriptor *Desc = MI.getDesc(); // Pseudo instructions do not need REX prefix byte. if ((Desc->TSFlags & X86II::FormMask) == X86II::Pseudo) diff --git a/llvm/lib/Target/X86/X86FloatingPoint.cpp b/llvm/lib/Target/X86/X86FloatingPoint.cpp index 354804ce5c1..8c5d569e382 100644 --- a/llvm/lib/Target/X86/X86FloatingPoint.cpp +++ b/llvm/lib/Target/X86/X86FloatingPoint.cpp @@ -205,7 +205,7 @@ bool FPS::processBasicBlock(MachineFunction &MF, MachineBasicBlock &BB) { for (MachineBasicBlock::iterator I = BB.begin(); I != BB.end(); ++I) { MachineInstr *MI = I; - unsigned Flags = MI->getInstrDescriptor()->TSFlags; + unsigned Flags = MI->getDesc()->TSFlags; if ((Flags & X86II::FPTypeMask) == X86II::NotFP) continue; // Efficiently ignore non-fp insts! @@ -597,7 +597,7 @@ void FPS::handleZeroArgFP(MachineBasicBlock::iterator &I) { /// void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) { MachineInstr *MI = I; - unsigned NumOps = MI->getInstrDescriptor()->numOperands; + unsigned NumOps = MI->getDesc()->numOperands; assert((NumOps == 5 || NumOps == 1) && "Can only handle fst* & ftst instructions!"); @@ -657,7 +657,7 @@ void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) { /// void FPS::handleOneArgFPRW(MachineBasicBlock::iterator &I) { MachineInstr *MI = I; - unsigned NumOps = MI->getInstrDescriptor()->numOperands; + unsigned NumOps = MI->getDesc()->numOperands; assert(NumOps >= 2 && "FPRW instructions must have 2 ops!!"); // Is this the last use of the source register? @@ -766,7 +766,7 @@ void FPS::handleTwoArgFP(MachineBasicBlock::iterator &I) { ASSERT_SORTED(ForwardSTiTable); ASSERT_SORTED(ReverseSTiTable); MachineInstr *MI = I; - unsigned NumOperands = MI->getInstrDescriptor()->numOperands; + unsigned NumOperands = MI->getDesc()->numOperands; assert(NumOperands == 3 && "Illegal TwoArgFP instruction!"); unsigned Dest = getFPReg(MI->getOperand(0)); unsigned Op0 = getFPReg(MI->getOperand(NumOperands-2)); @@ -864,7 +864,7 @@ void FPS::handleCompareFP(MachineBasicBlock::iterator &I) { ASSERT_SORTED(ForwardSTiTable); ASSERT_SORTED(ReverseSTiTable); MachineInstr *MI = I; - unsigned NumOperands = MI->getInstrDescriptor()->numOperands; + unsigned NumOperands = MI->getDesc()->numOperands; assert(NumOperands == 2 && "Illegal FUCOM* instruction!"); unsigned Op0 = getFPReg(MI->getOperand(NumOperands-2)); unsigned Op1 = getFPReg(MI->getOperand(NumOperands-1)); diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 42b25a91b8b..ea49b42c374 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -1243,16 +1243,15 @@ X86::CondCode X86::GetOppositeBranchCondition(X86::CondCode CC) { } bool X86InstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const { - const TargetInstrDescriptor *TID = MI->getInstrDescriptor(); - if (TID->Flags & M_TERMINATOR_FLAG) { - // Conditional branch is a special case. - if ((TID->Flags & M_BRANCH_FLAG) != 0 && (TID->Flags & M_BARRIER_FLAG) == 0) - return true; - if ((TID->Flags & M_PREDICABLE) == 0) - return true; - return !isPredicated(MI); - } - return false; + const TargetInstrDescriptor *TID = MI->getDesc(); + if (!TID->isTerminator()) return false; + + // Conditional branch is a special case. + if (TID->isBranch() && !TID->isBarrier()) + return true; + if (!TID->isPredicable()) + return true; + return !isPredicated(MI); } // For purposes of branch analysis do not count FP_REG_KILL as a terminator. @@ -1277,7 +1276,7 @@ bool X86InstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, // If there is only one terminator instruction, process it. if (I == MBB.begin() || !isBrAnalysisUnpredicatedTerminator(--I, *this)) { - if (!isBranch(LastInst->getOpcode())) + if (!LastInst->getDesc()->isBranch()) return true; // If the block ends with a branch there are 3 possibilities: @@ -1695,7 +1694,7 @@ X86InstrInfo::foldMemoryOperand(MachineInstr *MI, unsigned i, bool isTwoAddrFold = false; unsigned NumOps = getNumOperands(MI->getOpcode()); bool isTwoAddr = NumOps > 1 && - MI->getInstrDescriptor()->getOperandConstraint(1, TOI::TIED_TO) != -1; + MI->getDesc()->getOperandConstraint(1, TOI::TIED_TO) != -1; MachineInstr *NewMI = NULL; // Folding a memory location into the two-address part of a two-address diff --git a/llvm/lib/Target/X86/X86RegisterInfo.cpp b/llvm/lib/Target/X86/X86RegisterInfo.cpp index 34a860cf2a0..1e5441794a6 100644 --- a/llvm/lib/Target/X86/X86RegisterInfo.cpp +++ b/llvm/lib/Target/X86/X86RegisterInfo.cpp @@ -139,68 +139,6 @@ unsigned X86RegisterInfo::getX86RegNum(unsigned RegNo) { } } -static const MachineInstrBuilder &X86InstrAddOperand(MachineInstrBuilder &MIB, - MachineOperand &MO) { - if (MO.isRegister()) - MIB = MIB.addReg(MO.getReg(), MO.isDef(), MO.isImplicit(), - false, false, MO.getSubReg()); - else if (MO.isImmediate()) - MIB = MIB.addImm(MO.getImm()); - else if (MO.isFrameIndex()) - MIB = MIB.addFrameIndex(MO.getIndex()); - else if (MO.isGlobalAddress()) - MIB = MIB.addGlobalAddress(MO.getGlobal(), MO.getOffset()); - else if (MO.isConstantPoolIndex()) - MIB = MIB.addConstantPoolIndex(MO.getIndex(), MO.getOffset()); - else if (MO.isJumpTableIndex()) - MIB = MIB.addJumpTableIndex(MO.getIndex()); - else if (MO.isExternalSymbol()) - MIB = MIB.addExternalSymbol(MO.getSymbolName()); - else - assert(0 && "Unknown operand for X86InstrAddOperand!"); - - return MIB; -} - -static unsigned getStoreRegOpcode(const TargetRegisterClass *RC, - unsigned StackAlign) { - unsigned Opc = 0; - if (RC == &X86::GR64RegClass) { - Opc = X86::MOV64mr; - } else if (RC == &X86::GR32RegClass) { - Opc = X86::MOV32mr; - } else if (RC == &X86::GR16RegClass) { - Opc = X86::MOV16mr; - } else if (RC == &X86::GR8RegClass) { - Opc = X86::MOV8mr; - } else if (RC == &X86::GR32_RegClass) { - Opc = X86::MOV32_mr; - } else if (RC == &X86::GR16_RegClass) { - Opc = X86::MOV16_mr; - } else if (RC == &X86::RFP80RegClass) { - Opc = X86::ST_FpP80m; // pops - } else if (RC == &X86::RFP64RegClass) { - Opc = X86::ST_Fp64m; - } else if (RC == &X86::RFP32RegClass) { - Opc = X86::ST_Fp32m; - } else if (RC == &X86::FR32RegClass) { - Opc = X86::MOVSSmr; - } else if (RC == &X86::FR64RegClass) { - Opc = X86::MOVSDmr; - } else if (RC == &X86::VR128RegClass) { - // FIXME: Use movaps once we are capable of selectively - // aligning functions that spill SSE registers on 16-byte boundaries. - Opc = StackAlign >= 16 ? X86::MOVAPSmr : X86::MOVUPSmr; - } else if (RC == &X86::VR64RegClass) { - Opc = X86::MMX_MOVQ64mr; - } else { - assert(0 && "Unknown regclass"); - abort(); - } - - return Opc; -} - const TargetRegisterClass * X86RegisterInfo::getCrossCopyRegClass(const TargetRegisterClass *RC) const { if (RC == &X86::CCRRegClass) @@ -790,7 +728,8 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF, while (MBBI != MBB.begin()) { MachineBasicBlock::iterator PI = prior(MBBI); unsigned Opc = PI->getOpcode(); - if (Opc != X86::POP32r && Opc != X86::POP64r && !TII.isTerminatorInstr(Opc)) + if (Opc != X86::POP32r && Opc != X86::POP64r && + !PI->getDesc()->isTerminator()) break; --MBBI; } |