LLVM API Documentation
#include <RegisterCoalescer.h>
Public Types | |
| typedef SmallPtrSet< const LiveInterval *, 8 > | IntervalSet |
Public Member Functions | |
| virtual | ~RegallocQuery () |
| virtual bool | interfere (const LiveInterval &a, const LiveInterval &b) const |
| Return whether two live ranges interfere. | |
| virtual void | getInterferences (IntervalSet &interferences, const LiveInterval &a) const =0 |
| Return the set of intervals that interfere with this one. | |
| virtual int | getNumberOfInterferences (const LiveInterval &a) const =0 |
| virtual void | updateDataForMerge (const LiveInterval &a, const LiveInterval &b, const MachineInstr ©) |
| virtual bool | isLegalToCoalesce (const MachineInstr &inst) const |
Example:
This is simply an example of how to use the RegallocQuery interface. It is not meant to be used in production.
class LinearScanRegallocQuery : public RegallocQuery { private: const LiveIntervals
public: LinearScanRegallocQuery(LiveIntervals &intervals) : li(intervals) {};
/ This is pretty slow and conservative, but since linear scan / allocation doesn't pre-compute interference information it's / the best we can do. Coalescers are always free to ignore this / and implement their own discovery strategy. See / SimpleRegisterCoalescing for an example. void getInterferences(IntervalSet &interferences, const LiveInterval &a) const { for(LiveIntervals::const_iterator iv = li.begin(), ivend = li.end(); iv != ivend; ++iv) { if (interfere(a, iv->second)) { interferences.insert(&iv->second); } } };
/ This is *really* slow and stupid. See above. int getNumberOfInterferences(const LiveInterval &a) const { IntervalSet intervals; getInterferences(intervals, a); return intervals.size(); }; };
In the allocator:
RegisterCoalescer &coalescer = getAnalysis<RegisterCoalescer>();
We don't reset the coalescer so if it's already been run this takes almost no time. LinearScanRegallocQuery ifd(*li_); coalescer.coalesceFunction(fn, ifd);
Definition at line 107 of file RegisterCoalescer.h.
| typedef SmallPtrSet<const LiveInterval *, 8> llvm::RegallocQuery::IntervalSet |
Definition at line 109 of file RegisterCoalescer.h.
| virtual llvm::RegallocQuery::~RegallocQuery | ( | ) | [inline, virtual] |
Definition at line 111 of file RegisterCoalescer.h.
| virtual bool llvm::RegallocQuery::interfere | ( | const LiveInterval & | a, | |
| const LiveInterval & | b | |||
| ) | const [inline, virtual] |
Return whether two live ranges interfere.
Definition at line 114 of file RegisterCoalescer.h.
References llvm::LiveInterval::overlaps().
| virtual void llvm::RegallocQuery::getInterferences | ( | IntervalSet & | interferences, | |
| const LiveInterval & | a | |||
| ) | const [pure virtual] |
Return the set of intervals that interfere with this one.
| virtual int llvm::RegallocQuery::getNumberOfInterferences | ( | const LiveInterval & | a | ) | const [pure virtual] |
This can often be cheaper than actually returning the interferences.
| virtual void llvm::RegallocQuery::updateDataForMerge | ( | const LiveInterval & | a, | |
| const LiveInterval & | b, | |||
| const MachineInstr & | copy | |||
| ) | [inline, virtual] |
Make any data structure updates necessary to reflect coalescing or other modifications.
Definition at line 130 of file RegisterCoalescer.h.
| virtual bool llvm::RegallocQuery::isLegalToCoalesce | ( | const MachineInstr & | inst | ) | const [inline, virtual] |
Allow the register allocator to communicate when it doesn't want a copy coalesced. This may be due to assumptions made by the allocator about various invariants and so this question is a matter of legality, not performance. Performance decisions about which copies to coalesce should be made by the coalescer.
Definition at line 140 of file RegisterCoalescer.h.