[RFC][GISel] Add a way to ignore COPY instructions in InstructionSelector
authorPierre van Houtryve <pierre.vanhoutryve@amd.com>
Wed, 25 Jan 2023 13:06:09 +0000 (14:06 +0100)
committerpvanhout <pierre.vanhoutryve@amd.com>
Fri, 10 Feb 2023 07:37:42 +0000 (08:37 +0100)
commit70924673af680303d64e540d7767c0eeda5217fc
tree2a62d3ea58c25914aa69e4666fabd0695eeabb83
parentd9a6fc82f56f1e4ebb6ba053a57a5839c3907a7e
[RFC][GISel] Add a way to ignore COPY instructions in InstructionSelector

RFC to add a way to ignore COPY instructions when pattern-matching MIR in GISel.
    - Add a new "GISelFlags" class to TableGen. Both `Pattern`  and `PatFrags` defs can use it to alter matching behaviour.
    - Flags start at zero and are scoped: the setter returns a `SaveAndRestore` object so that when the current scope ends, the flags are restored to their previous values. This allows child patterns to modify the flags without affecting the parent pattern.
    - Child patterns always reuse the parent's pattern, but they can override its values. For more examples, see `GlobalISelEmitterFlags.td` tests.
    - [AMDGPU] Use the IgnoreCopies flag in BFI patterns, which are known to be bothered by cross-regbank copies.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D136234
llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
llvm/include/llvm/Target/TargetSelectionDAG.td
llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
llvm/lib/Target/AMDGPU/SIInstructions.td
llvm/test/CodeGen/AMDGPU/bfi_int.ll
llvm/test/TableGen/GlobalISelEmitterFlags.td [new file with mode: 0644]
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
llvm/utils/TableGen/GlobalISelEmitter.cpp