1 //===- Target.td - Define GlobalISel rules -----------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the target-independent interfaces used to support
10 // SelectionDAG instruction selection patterns (specified in
11 // TargetSelectionDAG.td) when generating GlobalISel instruction selectors.
13 // This is intended as a compatibility layer, to enable reuse of target
14 // descriptions written for SelectionDAG without requiring explicit GlobalISel
15 // support. It will eventually supersede SelectionDAG patterns.
17 //===----------------------------------------------------------------------===//
19 // Definitions that inherit from LLT define types that will be used in the
20 // GlobalISel matcher.
26 // Defines a matcher for complex operands. This is analogous to ComplexPattern
29 // Definitions that inherit from this may also inherit from
30 // GIComplexPatternEquiv to enable the import of SelectionDAG patterns involving
31 // those ComplexPatterns.
32 class GIComplexOperandMatcher<LLT type, string matcherfn> {
33 // The expected type of the root of the match.
35 // TODO: We should probably support, any-type, any-scalar, and multiple types
39 // The function that determines whether the operand matches. It should be of
41 // bool select(const MatchOperand &Root, MatchOperand &Result1)
42 // and should have the same number of ResultX arguments as the number of
43 // result operands. It must return true on successful match and false
44 // otherwise. If it returns true, then all the ResultX arguments must be
46 string MatcherFn = matcherfn;
49 // Defines a custom renderer. This is analogous to SDNodeXForm from
50 // SelectionDAG. Unlike SDNodeXForm, this matches a MachineInstr and
51 // renders directly to the result instruction without an intermediate node.
53 // Definitions that inherit from this may also inherit from GISDNodeXFormEquiv
54 // to enable the import of SelectionDAG patterns involving those SDNodeXForms.
55 class GICustomOperandRenderer<string rendererfn> {
56 // The function renders the operand(s) of the matched instruction to
57 // the specified instruction. It should be of the form:
58 // void render(MachineInstrBuilder &MIB, const MachineInstr &MI)
59 string RendererFn = rendererfn;