llvm.org GIT mirror llvm / 86274cd
[globalisel] Add very brief docs summarizing the ISel part of the LLVMDev tutorial. Also added links to the talks available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316350 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 1 year, 9 months ago
1 changed file(s) with 69 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
502502 This target-provided method is responsible for mutating (or replacing) a
503503 possibly-generic MI into a fully target-specific equivalent.
504504 It is also responsible for doing the necessary constraining of gvregs into the
505 appropriate register classes.
505 appropriate register classes as well as passing through COPY instructions to
506 the register allocator.
507508 The ``InstructionSelector`` can fold other instructions into the selected MI,
508509 by walking the use-def chain of the vreg operands.
509510 As GlobalISel is Global, this folding can occur across basic blocks.
511 ``TODO``:
512 Currently, the Select pass is implemented with hand-written c++, similar to
513 FastISel, rather than backed by tblgen'erated pattern-matching.
514 We intend to eventually reuse SelectionDAG patterns.
512 SelectionDAG Rule Imports
513 ^^^^^^^^^^^^^^^^^^^^^^^^^
515 TableGen will import SelectionDAG rules and provide the following function to
516 execute them:
518 .. code-block:: c++
520 bool selectImpl(MachineInstr &MI)
522 The ``--stats`` option can be used to determine what proportion of rules were
523 successfully imported. The easiest way to use this is to copy the
524 ``-gen-globalisel`` tablegen command from ``ninja -v`` and modify it.
526 Similarly, the ``--warn-on-skipped-patterns`` option can be used to obtain the
527 reasons that rules weren't imported. This can be used to focus on the most
528 important rejection reasons.
530 PatLeaf Predicates
531 ^^^^^^^^^^^^^^^^^^
533 PatLeafs cannot be imported because their C++ is implemented in terms of
534 ``SDNode`` objects. PatLeafs that handle immediate predicates should be
535 replaced by ``ImmLeaf``, ``IntImmLeaf``, or ``FPImmLeaf`` as appropriate.
537 There's no standard answer for other PatLeafs. Some standard predicates have
538 been baked into TableGen but this should not generally be done.
540 Custom SDNodes
541 ^^^^^^^^^^^^^^
543 Custom SDNodes should be mapped to Target Pseudos using ``GINodeEquiv``. This
544 will cause the instruction selector to import them but you will also need to
545 ensure the target pseudo is introduced to the MIR before the instruction
546 selector. Any preceeding pass is suitable but the legalizer will be a
547 particularly common choice.
549 ComplexPatterns
550 ^^^^^^^^^^^^^^^
552 ComplexPatterns cannot be imported because their C++ is implemented in terms of
553 ``SDNode`` objects. GlobalISel versions should be defined with
554 ``GIComplexOperandMatcher`` and mapped to ComplexPattern with
555 ``GIComplexPatternEquiv``.
557 The following predicates are useful for porting ComplexPattern:
559 * isBaseWithConstantOffset() - Check for base+offset structures
560 * isOperandImmEqual() - Check for a particular constant
561 * isObviouslySafeToFold() - Check for reasons an instruction can't be sunk and folded into another.
563 There are some important points for the C++ implementation:
565 * Don't modify MIR in the predicate
566 * Renderer lambdas should capture by value to avoid use-after-free. They will be used after the predicate returns.
567 * Only create instructions in a renderer lambda. GlobalISel won't clean up things you create but don't use.
517570 .. _maintainability:
636689 * ``TargetPassConfig`` --- create the passes constituting the pipeline,
637690 including additional passes not included in the :ref:`pipeline`.
692 .. _other_resources:
694 Resources
695 =========
697 * `Global Instruction Selection - A Proposal by Quentin Colombet @LLVMDevMeeting 2015 `_
698 * `Global Instruction Selection - Status by Quentin Colombet, Ahmed Bougacha, and Tim Northover @LLVMDevMeeting 2016 `_
699 * `GlobalISel - LLVM's Latest Instruction Selection Framework by Diana Picus @FOSDEM17 `_
700 * GlobalISel: Past, Present, and Future by Quentin Colombet and Ahmed Bougacha @LLVMDevMeeting 2017
701 * Head First into GlobalISel by Daniel Sanders, Aditya Nandakumar, and Justin Bogner @LLVMDevMeeting 2017