1//===- Target.td - Define GlobalISel rules -----------------*- tablegen -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
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.
12//
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.
16//
17//===----------------------------------------------------------------------===//
18
19// Definitions that inherit from LLT define types that will be used in the
20// GlobalISel matcher.
21class LLT;
22
23def s32 : LLT;
24def s64 : LLT;
25def v2s32 : LLT;
26def v4s16 : LLT;
27
28// Defines a matcher for complex operands. This is analogous to ComplexPattern
29// from SelectionDAG.
30//
31// Definitions that inherit from this may also inherit from
32// GIComplexPatternEquiv to enable the import of SelectionDAG patterns involving
33// those ComplexPatterns.
34class GIComplexOperandMatcher<LLT type, string matcherfn> {
35  // The expected type of the root of the match.
36  //
37  // TODO: We should probably support, any-type, any-scalar, and multiple types
38  //       in the future.
39  LLT Type = type;
40
41  // The function that determines whether the operand matches. It should be of
42  // the form:
43  //   ComplexRendererFn select(MachineOperand &Root) const;
44  // where Root is the root of the match.  The function should return nullptr
45  // on match failure, or a ComplexRendererFn that renders the operand in case
46  // of a successful match.
47  string MatcherFn = matcherfn;
48}
49
50// Defines a custom renderer. This is analogous to SDNodeXForm from
51// SelectionDAG. Unlike SDNodeXForm, this matches a MachineInstr and
52// renders directly to the result instruction without an intermediate node.
53//
54// Definitions that inherit from this may also inherit from GISDNodeXFormEquiv
55// to enable the import of SelectionDAG patterns involving those SDNodeXForms.
56class GICustomOperandRenderer<string rendererfn> {
57  // The function renders the operand(s) of the matched instruction to
58  // the specified instruction. It should be of the form:
59  //   void render(MachineInstrBuilder &MIB, const MachineInstr &MI,
60  //               int OpIdx = -1)
61  //
62  // If OpIdx is specified (i.e. not invalid/negative), this
63  // references the source operand MI.getOperand(OpIdx). Otherwise,
64  // this is the value defined by MI. This is to support the case
65  // where there is no corresponding instruction to match.
66  string RendererFn = rendererfn;
67}
68