This patch adds an outliner for AArch64. It adds the outliner target hooks to AArch64InstrInfo.cpp and AArch64InstrInfo.cpp. This allows for outlining using the -mno-red-zone and -enable-machine-outliner flags.
The main difference from the X86-64 outliner is the inclusion of post-outlining stack fixups. A function, getPostOutliningFixup is added to determine if an instruction that uses SP can be fixed up post-outlining. After each outlined function is created, fixupPostOutline is called on the MachineBasicBlock in that function, and recalculates stack offsets using getPostOutliningFixup.
For a simpler example of how this works, see https://reviews.llvm.org/D30797
We should only put short and performance critical functions into a header (and well templates force you sometimes).
It shouldn't be too hard to share code with getMemOpBaseRegImmOfsWidth() and for maintenance reasons we really should do so:
/// Returns true if opcode \p Opc is a memory operation and set \p Scale and \p Width /// accordingly. bool getMemOpInfo(unsigned Opcode, unsigned &Scale, unsigned &Width) { switch (Opc) { // Move stuff from getMemOpBaseRegImmOfsWidth() here } } bool AArch64InstrInfo::getMemOpBaseRegImmOfsWidth(...) { // ... keep the beginning as is ... unsigned Scale = 0; if (!getMemOpInfo(LdSt.getOpcode(), Width, Scale)) return false; // ... keep end as is ... } // Every use of getScale() can now call getMemOpInfo() and just ignore the Width value