6 This pass constrains the :ref:`gmir-gvregs` operands of generic
7 instructions to some :ref:`gmir-regbank`.
9 It iteratively maps instructions to a set of per-operand bank assignment.
10 The possible mappings are determined by the target-provided
11 :ref:`RegisterBankInfo <api-registerbankinfo>`.
12 The mapping is then applied, possibly introducing ``COPY`` instructions if
15 It traverses the ``MachineFunction`` top down so that all operands are already
16 mapped when analyzing an instruction.
18 This pass could also remap target-specific instructions when beneficial.
19 In the future, this could replace the ExeDepsFix pass, as we can directly
20 select the best variant for an instruction that's available on multiple banks.
22 .. _api-registerbankinfo:
27 The ``RegisterBankInfo`` class describes multiple aspects of register banks.
29 * **Banks**: ``addRegBankCoverage`` --- which register bank covers each
32 * **Cross-Bank Copies**: ``copyCost`` --- the cost of a ``COPY`` from one bank
35 * **Default Mapping**: ``getInstrMapping`` --- the default bank assignments for
38 * **Alternative Mapping**: ``getInstrAlternativeMapping`` --- the other
39 possible bank assignments for a given instruction.
42 All this information should eventually be static and generated by TableGen,
43 mostly using existing information augmented by bank descriptions.
46 ``getInstrMapping`` is currently separate from ``getInstrAlternativeMapping``
47 because the latter is more expensive: as we move to static mapping info,
48 both methods should be free, and we should merge them.
50 .. _regbankselect-modes:
55 ``RegBankSelect`` currently has two modes:
57 * **Fast** --- For each instruction, pick a target-provided "default" bank
58 assignment. This is the default at -O0.
60 * **Greedy** --- For each instruction, pick the cheapest of several
61 target-provided bank assignment alternatives.
63 We intend to eventually introduce an additional optimizing mode:
65 * **Global** --- Across multiple instructions, pick the cheapest combination of
69 On AArch64, we are considering using the Greedy mode even at -O0 (or perhaps at
70 backend -O1): because :ref:`gmir-llt` doesn't distinguish floating point from
71 integer scalars, the default assignment for loads and stores is the integer
72 bank, introducing cross-bank copies on most floating point operations.