74 lines · plain
1.. _regbankselect:2 3RegBankSelect4-------------5 6This pass constrains the :ref:`gmir-gvregs` operands of generic7instructions to some :ref:`gmir-regbank`.8 9It iteratively maps instructions to a set of per-operand bank assignment.10The possible mappings are determined by the target-provided11:ref:`RegisterBankInfo <api-registerbankinfo>`.12The mapping is then applied, possibly introducing ``COPY`` instructions if13necessary.14 15It traverses the ``MachineFunction`` top down so that all operands are already16mapped when analyzing an instruction.17 18This pass could also remap target-specific instructions when beneficial.19In the future, this could replace the ExeDepsFix pass, as we can directly20select the best variant for an instruction that's available on multiple banks.21 22.. _api-registerbankinfo:23 24API: RegisterBankInfo25^^^^^^^^^^^^^^^^^^^^^26 27The ``RegisterBankInfo`` class describes multiple aspects of register banks.28 29* **Banks**: ``addRegBankCoverage`` --- which register bank covers each30 register class.31 32* **Cross-Bank Copies**: ``copyCost`` --- the cost of a ``COPY`` from one bank33 to another.34 35* **Default Mapping**: ``getInstrMapping`` --- the default bank assignments for36 a given instruction.37 38* **Alternative Mapping**: ``getInstrAlternativeMapping`` --- the other39 possible bank assignments for a given instruction.40 41``TODO``:42All this information should eventually be static and generated by TableGen,43mostly using existing information augmented by bank descriptions.44 45``TODO``:46``getInstrMapping`` is currently separate from ``getInstrAlternativeMapping``47because the latter is more expensive: as we move to static mapping info,48both methods should be free, and we should merge them.49 50.. _regbankselect-modes:51 52RegBankSelect Modes53^^^^^^^^^^^^^^^^^^^54 55``RegBankSelect`` currently has two modes:56 57* **Fast** --- For each instruction, pick a target-provided "default" bank58 assignment. This is the default at -O0.59 60* **Greedy** --- For each instruction, pick the cheapest of several61 target-provided bank assignment alternatives.62 63We intend to eventually introduce an additional optimizing mode:64 65* **Global** --- Across multiple instructions, pick the cheapest combination of66 bank assignments.67 68``NOTE``:69On AArch64, we are considering using the Greedy mode even at -O0 (or perhaps at70backend -O1): because :ref:`gmir-llt` doesn't distinguish floating point from71integer scalars, the default assignment for loads and stores is the integer72bank, introducing cross-bank copies on most floating point operations.73 74