To help assist in debugging ISEL or to prioritize GlobalISel backend work, this patch adds two more tables to <Target>GenISelDAGISel.inc - one which contains the patterns that are used during selection (The text comment Src and Dst comment you see in MatcherTable for each of the MorphNode and EmitNode cases.
It adds another Tablegen OpcodeType called OPC_Coverage. We encode the offset of the pattern (in the table) with OPC_Coverage.
It also modifies the CheckComplexPattern to also print the ComplexPattern that returned true.
Sometimes, due to several layers of defm instantiations, to make it easier to identify where a particular pattern came from, the source locations have also been encoded in another table. This would get printed as
COMPLEX_PATTERN: SelectNegArithImmed
MORPHTO: (add:i32 GPR32:i32:$Rn, neg_addsub_shifted_imm32:i32:$imm) -> (SUBSWri:i32:i32 GPR32:i32:$Rn, neg_addsub_shifted_imm32:i32:$imm)
INCLUDED: /Volumes/Data/workspace/gpu/compiler_checkouts/open_source/llvm/lib/Target/AArch64/AArch64InstrInfo.td:659
.....
It's currently enabled through CMAKE variable DAG_PRINT_USED_ISEL_PATTERNS which passes a -instrument-coverage flag to table gen for emitting the *GenDAGISel.inc file.
This information can also be used (with a python script which greps/counts patterns) for building a test-suite(such as llvm-test-suite) and see which instructions/patterns need to be selected (say for global isel work prioritization) and can also print the tablegen emitted patterns that are unused during the compilation of the llvm-test-suite.
Looking forward to feedback.
I'd still prefix the name with 'LLVM_ENABLE_': it makes it easier to figure out where individual options come from in ccmake or CMakeCache.txt.
Maybe LLVM_ENABLE_DAGISEL_COV or something?