1 //=== Target/TargetRegisterInfo.h - Target Register Information -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes an abstract interface used to get information about a
11 // target machines register file. This information is used for a variety of
12 // purposed, especially register allocation.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TARGET_TARGETREGISTERINFO_H
17 #define LLVM_TARGET_TARGETREGISTERINFO_H
19 #include "llvm/MC/MCRegisterInfo.h"
20 #include "llvm/CodeGen/MachineBasicBlock.h"
21 #include "llvm/CodeGen/ValueTypes.h"
22 #include "llvm/ADT/ArrayRef.h"
29 class MachineFunction;
31 template<class T> class SmallVectorImpl;
34 class TargetRegisterClass {
36 typedef const unsigned* iterator;
37 typedef const unsigned* const_iterator;
38 typedef const EVT* vt_iterator;
39 typedef const TargetRegisterClass* const * sc_iterator;
41 const MCRegisterClass *MC;
42 const vt_iterator VTs;
43 const unsigned *SubClassMask;
44 const sc_iterator SuperClasses;
45 const sc_iterator SubRegClasses;
46 const sc_iterator SuperRegClasses;
48 TargetRegisterClass(const MCRegisterClass *MC, const EVT *vts,
49 const unsigned *subcm,
50 const TargetRegisterClass * const *supcs,
51 const TargetRegisterClass * const *subregcs,
52 const TargetRegisterClass * const *superregcs)
53 : MC(MC), VTs(vts), SubClassMask(subcm), SuperClasses(supcs),
54 SubRegClasses(subregcs), SuperRegClasses(superregcs) {}
56 virtual ~TargetRegisterClass() {} // Allow subclasses
58 /// getID() - Return the register class ID number.
60 unsigned getID() const { return MC->getID(); }
62 /// getName() - Return the register class name for debugging.
64 const char *getName() const { return MC->getName(); }
66 /// begin/end - Return all of the registers in this class.
68 iterator begin() const { return MC->begin(); }
69 iterator end() const { return MC->end(); }
71 /// getNumRegs - Return the number of registers in this class.
73 unsigned getNumRegs() const { return MC->getNumRegs(); }
75 /// getRegister - Return the specified register in the class.
77 unsigned getRegister(unsigned i) const {
78 return MC->getRegister(i);
81 /// contains - Return true if the specified register is included in this
82 /// register class. This does not include virtual registers.
83 bool contains(unsigned Reg) const {
84 return MC->contains(Reg);
87 /// contains - Return true if both registers are in this class.
88 bool contains(unsigned Reg1, unsigned Reg2) const {
89 return MC->contains(Reg1, Reg2);
92 /// getSize - Return the size of the register in bytes, which is also the size
93 /// of a stack slot allocated to hold a spilled copy of this register.
94 unsigned getSize() const { return MC->getSize(); }
96 /// getAlignment - Return the minimum required alignment for a register of
98 unsigned getAlignment() const { return MC->getAlignment(); }
100 /// getCopyCost - Return the cost of copying a value between two registers in
101 /// this class. A negative number means the register class is very expensive
102 /// to copy e.g. status flag register classes.
103 int getCopyCost() const { return MC->getCopyCost(); }
105 /// isAllocatable - Return true if this register class may be used to create
106 /// virtual registers.
107 bool isAllocatable() const { return MC->isAllocatable(); }
109 /// hasType - return true if this TargetRegisterClass has the ValueType vt.
111 bool hasType(EVT vt) const {
112 for(int i = 0; VTs[i] != MVT::Other; ++i)
118 /// vt_begin / vt_end - Loop over all of the value types that can be
119 /// represented by values in this register class.
120 vt_iterator vt_begin() const {
124 vt_iterator vt_end() const {
126 while (*I != MVT::Other) ++I;
130 /// subregclasses_begin / subregclasses_end - Loop over all of
131 /// the subreg register classes of this register class.
132 sc_iterator subregclasses_begin() const {
133 return SubRegClasses;
136 sc_iterator subregclasses_end() const {
137 sc_iterator I = SubRegClasses;
138 while (*I != NULL) ++I;
142 /// getSubRegisterRegClass - Return the register class of subregisters with
143 /// index SubIdx, or NULL if no such class exists.
144 const TargetRegisterClass* getSubRegisterRegClass(unsigned SubIdx) const {
145 assert(SubIdx>0 && "Invalid subregister index");
146 return SubRegClasses[SubIdx-1];
149 /// superregclasses_begin / superregclasses_end - Loop over all of
150 /// the superreg register classes of this register class.
151 sc_iterator superregclasses_begin() const {
152 return SuperRegClasses;
155 sc_iterator superregclasses_end() const {
156 sc_iterator I = SuperRegClasses;
157 while (*I != NULL) ++I;
161 /// hasSubClass - return true if the specified TargetRegisterClass
162 /// is a proper sub-class of this TargetRegisterClass.
163 bool hasSubClass(const TargetRegisterClass *RC) const {
164 return RC != this && hasSubClassEq(RC);
167 /// hasSubClassEq - Returns true if RC is a sub-class of or equal to this
169 bool hasSubClassEq(const TargetRegisterClass *RC) const {
170 unsigned ID = RC->getID();
171 return (SubClassMask[ID / 32] >> (ID % 32)) & 1;
174 /// hasSuperClass - return true if the specified TargetRegisterClass is a
175 /// proper super-class of this TargetRegisterClass.
176 bool hasSuperClass(const TargetRegisterClass *RC) const {
177 return RC->hasSubClass(this);
180 /// hasSuperClassEq - Returns true if RC is a super-class of or equal to this
182 bool hasSuperClassEq(const TargetRegisterClass *RC) const {
183 return RC->hasSubClassEq(this);
186 /// getSubClassMask - Returns a bit vector of subclasses, including this one.
187 /// The vector is indexed by class IDs, see hasSubClassEq() above for how to
189 const unsigned *getSubClassMask() const {
193 /// getSuperClasses - Returns a NULL terminated list of super-classes. The
194 /// classes are ordered by ID which is also a topological ordering from large
195 /// to small classes. The list does NOT include the current class.
196 sc_iterator getSuperClasses() const {
200 /// isASubClass - return true if this TargetRegisterClass is a subset
201 /// class of at least one other TargetRegisterClass.
202 bool isASubClass() const {
203 return SuperClasses[0] != 0;
206 /// getRawAllocationOrder - Returns the preferred order for allocating
207 /// registers from this register class in MF. The raw order comes directly
208 /// from the .td file and may include reserved registers that are not
209 /// allocatable. Register allocators should also make sure to allocate
210 /// callee-saved registers only after all the volatiles are used. The
211 /// RegisterClassInfo class provides filtered allocation orders with
212 /// callee-saved registers moved to the end.
214 /// The MachineFunction argument can be used to tune the allocatable
215 /// registers based on the characteristics of the function, subtarget, or
218 /// By default, this method returns all registers in the class.
221 ArrayRef<unsigned> getRawAllocationOrder(const MachineFunction &MF) const {
222 return makeArrayRef(begin(), getNumRegs());
226 /// TargetRegisterInfoDesc - Extra information, not in MCRegisterDesc, about
227 /// registers. These are used by codegen, not by MC.
228 struct TargetRegisterInfoDesc {
229 unsigned CostPerUse; // Extra cost of instructions using register.
230 bool inAllocatableClass; // Register belongs to an allocatable regclass.
233 /// TargetRegisterInfo base class - We assume that the target defines a static
234 /// array of TargetRegisterDesc objects that represent all of the machine
235 /// registers that the target has. As such, we simply have to track a pointer
236 /// to this array so that we can turn register number into a register
239 class TargetRegisterInfo : public MCRegisterInfo {
241 typedef const TargetRegisterClass * const * regclass_iterator;
243 const TargetRegisterInfoDesc *InfoDesc; // Extra desc array for codegen
244 const char *const *SubRegIndexNames; // Names of subreg indexes.
245 regclass_iterator RegClassBegin, RegClassEnd; // List of regclasses
248 TargetRegisterInfo(const TargetRegisterInfoDesc *ID,
249 regclass_iterator RegClassBegin,
250 regclass_iterator RegClassEnd,
251 const char *const *subregindexnames);
252 virtual ~TargetRegisterInfo();
255 // Register numbers can represent physical registers, virtual registers, and
256 // sometimes stack slots. The unsigned values are divided into these ranges:
258 // 0 Not a register, can be used as a sentinel.
259 // [1;2^30) Physical registers assigned by TableGen.
260 // [2^30;2^31) Stack slots. (Rarely used.)
261 // [2^31;2^32) Virtual registers assigned by MachineRegisterInfo.
263 // Further sentinels can be allocated from the small negative integers.
264 // DenseMapInfo<unsigned> uses -1u and -2u.
266 /// isStackSlot - Sometimes it is useful the be able to store a non-negative
267 /// frame index in a variable that normally holds a register. isStackSlot()
268 /// returns true if Reg is in the range used for stack slots.
270 /// Note that isVirtualRegister() and isPhysicalRegister() cannot handle stack
271 /// slots, so if a variable may contains a stack slot, always check
272 /// isStackSlot() first.
274 static bool isStackSlot(unsigned Reg) {
275 return int(Reg) >= (1 << 30);
278 /// stackSlot2Index - Compute the frame index from a register value
279 /// representing a stack slot.
280 static int stackSlot2Index(unsigned Reg) {
281 assert(isStackSlot(Reg) && "Not a stack slot");
282 return int(Reg - (1u << 30));
285 /// index2StackSlot - Convert a non-negative frame index to a stack slot
287 static unsigned index2StackSlot(int FI) {
288 assert(FI >= 0 && "Cannot hold a negative frame index.");
289 return FI + (1u << 30);
292 /// isPhysicalRegister - Return true if the specified register number is in
293 /// the physical register namespace.
294 static bool isPhysicalRegister(unsigned Reg) {
295 assert(!isStackSlot(Reg) && "Not a register! Check isStackSlot() first.");
299 /// isVirtualRegister - Return true if the specified register number is in
300 /// the virtual register namespace.
301 static bool isVirtualRegister(unsigned Reg) {
302 assert(!isStackSlot(Reg) && "Not a register! Check isStackSlot() first.");
306 /// virtReg2Index - Convert a virtual register number to a 0-based index.
307 /// The first virtual register in a function will get the index 0.
308 static unsigned virtReg2Index(unsigned Reg) {
309 assert(isVirtualRegister(Reg) && "Not a virtual register");
310 return Reg & ~(1u << 31);
313 /// index2VirtReg - Convert a 0-based index to a virtual register number.
314 /// This is the inverse operation of VirtReg2IndexFunctor below.
315 static unsigned index2VirtReg(unsigned Index) {
316 return Index | (1u << 31);
319 /// getMinimalPhysRegClass - Returns the Register Class of a physical
320 /// register of the given type, picking the most sub register class of
321 /// the right type that contains this physreg.
322 const TargetRegisterClass *
323 getMinimalPhysRegClass(unsigned Reg, EVT VT = MVT::Other) const;
325 /// getAllocatableSet - Returns a bitset indexed by register number
326 /// indicating if a register is allocatable or not. If a register class is
327 /// specified, returns the subset for the class.
328 BitVector getAllocatableSet(const MachineFunction &MF,
329 const TargetRegisterClass *RC = NULL) const;
331 /// getCostPerUse - Return the additional cost of using this register instead
332 /// of other registers in its class.
333 unsigned getCostPerUse(unsigned RegNo) const {
334 return InfoDesc[RegNo].CostPerUse;
337 /// isInAllocatableClass - Return true if the register is in the allocation
338 /// of any register class.
339 bool isInAllocatableClass(unsigned RegNo) const {
340 return InfoDesc[RegNo].inAllocatableClass;
343 /// getSubRegIndexName - Return the human-readable symbolic target-specific
344 /// name for the specified SubRegIndex.
345 const char *getSubRegIndexName(unsigned SubIdx) const {
346 assert(SubIdx && "This is not a subregister index");
347 return SubRegIndexNames[SubIdx-1];
350 /// regsOverlap - Returns true if the two registers are equal or alias each
351 /// other. The registers may be virtual register.
352 bool regsOverlap(unsigned regA, unsigned regB) const {
353 if (regA == regB) return true;
354 if (isVirtualRegister(regA) || isVirtualRegister(regB))
356 for (const unsigned *regList = getOverlaps(regA)+1; *regList; ++regList) {
357 if (*regList == regB) return true;
362 /// isSubRegister - Returns true if regB is a sub-register of regA.
364 bool isSubRegister(unsigned regA, unsigned regB) const {
365 return isSuperRegister(regB, regA);
368 /// isSuperRegister - Returns true if regB is a super-register of regA.
370 bool isSuperRegister(unsigned regA, unsigned regB) const {
371 for (const unsigned *regList = getSuperRegisters(regA); *regList;++regList){
372 if (*regList == regB) return true;
377 /// getCalleeSavedRegs - Return a null-terminated list of all of the
378 /// callee saved registers on this target. The register should be in the
379 /// order of desired callee-save stack frame offset. The first register is
380 /// closed to the incoming stack pointer if stack grows down, and vice versa.
381 virtual const unsigned* getCalleeSavedRegs(const MachineFunction *MF = 0)
385 /// getReservedRegs - Returns a bitset indexed by physical register number
386 /// indicating if a register is a special register that has particular uses
387 /// and should be considered unavailable at all times, e.g. SP, RA. This is
388 /// used by register scavenger to determine what registers are free.
389 virtual BitVector getReservedRegs(const MachineFunction &MF) const = 0;
391 /// getSubReg - Returns the physical register number of sub-register "Index"
392 /// for physical register RegNo. Return zero if the sub-register does not
394 virtual unsigned getSubReg(unsigned RegNo, unsigned Index) const = 0;
396 /// getSubRegIndex - For a given register pair, return the sub-register index
397 /// if the second register is a sub-register of the first. Return zero
399 virtual unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const = 0;
401 /// getMatchingSuperReg - Return a super-register of the specified register
402 /// Reg so its sub-register of index SubIdx is Reg.
403 unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx,
404 const TargetRegisterClass *RC) const {
405 for (const unsigned *SRs = getSuperRegisters(Reg); unsigned SR = *SRs;++SRs)
406 if (Reg == getSubReg(SR, SubIdx) && RC->contains(SR))
411 /// canCombineSubRegIndices - Given a register class and a list of
412 /// subregister indices, return true if it's possible to combine the
413 /// subregister indices into one that corresponds to a larger
414 /// subregister. Return the new subregister index by reference. Note the
415 /// new index may be zero if the given subregisters can be combined to
416 /// form the whole register.
417 virtual bool canCombineSubRegIndices(const TargetRegisterClass *RC,
418 SmallVectorImpl<unsigned> &SubIndices,
419 unsigned &NewSubIdx) const {
423 /// getMatchingSuperRegClass - Return a subclass of the specified register
424 /// class A so that each register in it has a sub-register of the
425 /// specified sub-register index which is in the specified register class B.
426 virtual const TargetRegisterClass *
427 getMatchingSuperRegClass(const TargetRegisterClass *A,
428 const TargetRegisterClass *B, unsigned Idx) const {
432 /// composeSubRegIndices - Return the subregister index you get from composing
433 /// two subregister indices.
435 /// If R:a:b is the same register as R:c, then composeSubRegIndices(a, b)
436 /// returns c. Note that composeSubRegIndices does not tell you about illegal
437 /// compositions. If R does not have a subreg a, or R:a does not have a subreg
438 /// b, composeSubRegIndices doesn't tell you.
440 /// The ARM register Q0 has two D subregs dsub_0:D0 and dsub_1:D1. It also has
441 /// ssub_0:S0 - ssub_3:S3 subregs.
442 /// If you compose subreg indices dsub_1, ssub_0 you get ssub_2.
444 virtual unsigned composeSubRegIndices(unsigned a, unsigned b) const {
445 // This default implementation is correct for most targets.
449 //===--------------------------------------------------------------------===//
450 // Register Class Information
453 /// Register class iterators
455 regclass_iterator regclass_begin() const { return RegClassBegin; }
456 regclass_iterator regclass_end() const { return RegClassEnd; }
458 unsigned getNumRegClasses() const {
459 return (unsigned)(regclass_end()-regclass_begin());
462 /// getRegClass - Returns the register class associated with the enumeration
463 /// value. See class MCOperandInfo.
464 const TargetRegisterClass *getRegClass(unsigned i) const {
465 assert(i < getNumRegClasses() && "Register Class ID out of range");
466 return RegClassBegin[i];
469 /// getCommonSubClass - find the largest common subclass of A and B. Return
470 /// NULL if there is no common subclass.
471 const TargetRegisterClass *
472 getCommonSubClass(const TargetRegisterClass *A,
473 const TargetRegisterClass *B) const;
475 /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
476 /// values. If a target supports multiple different pointer register classes,
477 /// kind specifies which one is indicated.
478 virtual const TargetRegisterClass *getPointerRegClass(unsigned Kind=0) const {
479 assert(0 && "Target didn't implement getPointerRegClass!");
480 return 0; // Must return a value in order to compile with VS 2005
483 /// getCrossCopyRegClass - Returns a legal register class to copy a register
484 /// in the specified class to or from. If it is possible to copy the register
485 /// directly without using a cross register class copy, return the specified
486 /// RC. Returns NULL if it is not possible to copy between a two registers of
487 /// the specified class.
488 virtual const TargetRegisterClass *
489 getCrossCopyRegClass(const TargetRegisterClass *RC) const {
493 /// getLargestLegalSuperClass - Returns the largest super class of RC that is
494 /// legal to use in the current sub-target and has the same spill size.
495 /// The returned register class can be used to create virtual registers which
496 /// means that all its registers can be copied and spilled.
497 virtual const TargetRegisterClass*
498 getLargestLegalSuperClass(const TargetRegisterClass *RC) const {
499 /// The default implementation is very conservative and doesn't allow the
500 /// register allocator to inflate register classes.
504 /// getRegPressureLimit - Return the register pressure "high water mark" for
505 /// the specific register class. The scheduler is in high register pressure
506 /// mode (for the specific register class) if it goes over the limit.
507 virtual unsigned getRegPressureLimit(const TargetRegisterClass *RC,
508 MachineFunction &MF) const {
512 /// getRawAllocationOrder - Returns the register allocation order for a
513 /// specified register class with a target-dependent hint. The returned list
514 /// may contain reserved registers that cannot be allocated.
516 /// Register allocators need only call this function to resolve
517 /// target-dependent hints, but it should work without hinting as well.
518 virtual ArrayRef<unsigned>
519 getRawAllocationOrder(const TargetRegisterClass *RC,
520 unsigned HintType, unsigned HintReg,
521 const MachineFunction &MF) const {
522 return RC->getRawAllocationOrder(MF);
525 /// ResolveRegAllocHint - Resolves the specified register allocation hint
526 /// to a physical register. Returns the physical register if it is successful.
527 virtual unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg,
528 const MachineFunction &MF) const {
529 if (Type == 0 && Reg && isPhysicalRegister(Reg))
534 /// avoidWriteAfterWrite - Return true if the register allocator should avoid
535 /// writing a register from RC in two consecutive instructions.
536 /// This can avoid pipeline stalls on certain architectures.
537 /// It does cause increased register pressure, though.
538 virtual bool avoidWriteAfterWrite(const TargetRegisterClass *RC) const {
542 /// UpdateRegAllocHint - A callback to allow target a chance to update
543 /// register allocation hints when a register is "changed" (e.g. coalesced)
544 /// to another register. e.g. On ARM, some virtual registers should target
545 /// register pairs, if one of pair is coalesced to another register, the
546 /// allocation hint of the other half of the pair should be changed to point
547 /// to the new register.
548 virtual void UpdateRegAllocHint(unsigned Reg, unsigned NewReg,
549 MachineFunction &MF) const {
553 /// requiresRegisterScavenging - returns true if the target requires (and can
554 /// make use of) the register scavenger.
555 virtual bool requiresRegisterScavenging(const MachineFunction &MF) const {
559 /// useFPForScavengingIndex - returns true if the target wants to use
560 /// frame pointer based accesses to spill to the scavenger emergency spill
562 virtual bool useFPForScavengingIndex(const MachineFunction &MF) const {
566 /// requiresFrameIndexScavenging - returns true if the target requires post
567 /// PEI scavenging of registers for materializing frame index constants.
568 virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const {
572 /// requiresVirtualBaseRegisters - Returns true if the target wants the
573 /// LocalStackAllocation pass to be run and virtual base registers
574 /// used for more efficient stack access.
575 virtual bool requiresVirtualBaseRegisters(const MachineFunction &MF) const {
579 /// hasReservedSpillSlot - Return true if target has reserved a spill slot in
580 /// the stack frame of the given function for the specified register. e.g. On
581 /// x86, if the frame register is required, the first fixed stack object is
582 /// reserved as its spill slot. This tells PEI not to create a new stack frame
583 /// object for the given register. It should be called only after
584 /// processFunctionBeforeCalleeSavedScan().
585 virtual bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg,
586 int &FrameIdx) const {
590 /// needsStackRealignment - true if storage within the function requires the
591 /// stack pointer to be aligned more than the normal calling convention calls
593 virtual bool needsStackRealignment(const MachineFunction &MF) const {
597 /// getFrameIndexInstrOffset - Get the offset from the referenced frame
598 /// index in the instruction, if there is one.
599 virtual int64_t getFrameIndexInstrOffset(const MachineInstr *MI,
604 /// needsFrameBaseReg - Returns true if the instruction's frame index
605 /// reference would be better served by a base register other than FP
606 /// or SP. Used by LocalStackFrameAllocation to determine which frame index
607 /// references it should create new base registers for.
608 virtual bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const {
612 /// materializeFrameBaseRegister - Insert defining instruction(s) for
613 /// BaseReg to be a pointer to FrameIdx before insertion point I.
614 virtual void materializeFrameBaseRegister(MachineBasicBlock *MBB,
615 unsigned BaseReg, int FrameIdx,
616 int64_t Offset) const {
617 assert(0 && "materializeFrameBaseRegister does not exist on this target");
620 /// resolveFrameIndex - Resolve a frame index operand of an instruction
621 /// to reference the indicated base register plus offset instead.
622 virtual void resolveFrameIndex(MachineBasicBlock::iterator I,
623 unsigned BaseReg, int64_t Offset) const {
624 assert(0 && "resolveFrameIndex does not exist on this target");
627 /// isFrameOffsetLegal - Determine whether a given offset immediate is
628 /// encodable to resolve a frame index.
629 virtual bool isFrameOffsetLegal(const MachineInstr *MI,
630 int64_t Offset) const {
631 assert(0 && "isFrameOffsetLegal does not exist on this target");
632 return false; // Must return a value in order to compile with VS 2005
635 /// eliminateCallFramePseudoInstr - This method is called during prolog/epilog
636 /// code insertion to eliminate call frame setup and destroy pseudo
637 /// instructions (but only if the Target is using them). It is responsible
638 /// for eliminating these instructions, replacing them with concrete
639 /// instructions. This method need only be implemented if using call frame
640 /// setup/destroy pseudo instructions.
643 eliminateCallFramePseudoInstr(MachineFunction &MF,
644 MachineBasicBlock &MBB,
645 MachineBasicBlock::iterator MI) const {
646 assert(0 && "Call Frame Pseudo Instructions do not exist on this target!");
650 /// saveScavengerRegister - Spill the register so it can be used by the
651 /// register scavenger. Return true if the register was spilled, false
652 /// otherwise. If this function does not spill the register, the scavenger
653 /// will instead spill it to the emergency spill slot.
655 virtual bool saveScavengerRegister(MachineBasicBlock &MBB,
656 MachineBasicBlock::iterator I,
657 MachineBasicBlock::iterator &UseMI,
658 const TargetRegisterClass *RC,
659 unsigned Reg) const {
663 /// eliminateFrameIndex - This method must be overriden to eliminate abstract
664 /// frame indices from instructions which may use them. The instruction
665 /// referenced by the iterator contains an MO_FrameIndex operand which must be
666 /// eliminated by this method. This method may modify or replace the
667 /// specified instruction, as long as it keeps the iterator pointing at the
668 /// finished product. SPAdj is the SP adjustment due to call frame setup
670 virtual void eliminateFrameIndex(MachineBasicBlock::iterator MI,
671 int SPAdj, RegScavenger *RS=NULL) const = 0;
673 //===--------------------------------------------------------------------===//
674 /// Debug information queries.
676 /// getFrameRegister - This method should return the register used as a base
677 /// for values allocated in the current stack frame.
678 virtual unsigned getFrameRegister(const MachineFunction &MF) const = 0;
680 /// getCompactUnwindRegNum - This function maps the register to the number for
681 /// compact unwind encoding. Return -1 if the register isn't valid.
682 virtual int getCompactUnwindRegNum(unsigned, bool) const {
688 // This is useful when building IndexedMaps keyed on virtual registers
689 struct VirtReg2IndexFunctor : public std::unary_function<unsigned, unsigned> {
690 unsigned operator()(unsigned Reg) const {
691 return TargetRegisterInfo::virtReg2Index(Reg);
695 /// PrintReg - Helper class for printing registers on a raw_ostream.
696 /// Prints virtual and physical registers with or without a TRI instance.
699 /// %noreg - NoRegister
700 /// %vreg5 - a virtual register.
701 /// %vreg5:sub_8bit - a virtual register with sub-register index (with TRI).
702 /// %EAX - a physical register
703 /// %physreg17 - a physical register when no TRI instance given.
705 /// Usage: OS << PrintReg(Reg, TRI) << '\n';
708 const TargetRegisterInfo *TRI;
712 PrintReg(unsigned reg, const TargetRegisterInfo *tri = 0, unsigned subidx = 0)
713 : TRI(tri), Reg(reg), SubIdx(subidx) {}
714 void print(raw_ostream&) const;
717 static inline raw_ostream &operator<<(raw_ostream &OS, const PrintReg &PR) {
722 } // End llvm namespace