]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Target / GlobalISel / SelectionDAGCompat.td
1 //===- TargetGlobalISel.td - Common code for GlobalISel ----*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the target-independent interfaces used to support
11 // SelectionDAG instruction selection patterns (specified in
12 // TargetSelectionDAG.td) when generating GlobalISel instruction selectors.
13 //
14 // This is intended as a compatibility layer, to enable reuse of target
15 // descriptions written for SelectionDAG without requiring explicit GlobalISel
16 // support.  It will eventually supersede SelectionDAG patterns.
17 //
18 //===----------------------------------------------------------------------===//
19
20 // Declare that a generic Instruction is 'equivalent' to an SDNode, that is,
21 // SelectionDAG patterns involving the SDNode can be transformed to match the
22 // Instruction instead.
23 class GINodeEquiv<Instruction i, SDNode node> {
24   Instruction I = i;
25   SDNode Node = node;
26
27   // SelectionDAG has separate nodes for atomic and non-atomic memory operations
28   // (ISD::LOAD, ISD::ATOMIC_LOAD, ISD::STORE, ISD::ATOMIC_STORE) but GlobalISel
29   // stores this information in the MachineMemoryOperand.
30   bit CheckMMOIsNonAtomic = 0;
31
32   // SelectionDAG has one node for all loads and uses predicates to
33   // differentiate them. GlobalISel on the other hand uses separate opcodes.
34   // When this is true, the resulting opcode is G_LOAD/G_SEXTLOAD/G_ZEXTLOAD
35   // depending on the predicates on the node.
36   Instruction IfSignExtend = ?;
37   Instruction IfZeroExtend = ?;
38 }
39
40 // These are defined in the same order as the G_* instructions.
41 def : GINodeEquiv<G_ANYEXT, anyext>;
42 def : GINodeEquiv<G_SEXT, sext>;
43 def : GINodeEquiv<G_ZEXT, zext>;
44 def : GINodeEquiv<G_TRUNC, trunc>;
45 def : GINodeEquiv<G_BITCAST, bitconvert>;
46 // G_INTTOPTR - SelectionDAG has no equivalent.
47 // G_PTRTOINT - SelectionDAG has no equivalent.
48 def : GINodeEquiv<G_CONSTANT, imm>;
49 def : GINodeEquiv<G_FCONSTANT, fpimm>;
50 def : GINodeEquiv<G_ADD, add>;
51 def : GINodeEquiv<G_SUB, sub>;
52 def : GINodeEquiv<G_MUL, mul>;
53 def : GINodeEquiv<G_SDIV, sdiv>;
54 def : GINodeEquiv<G_UDIV, udiv>;
55 def : GINodeEquiv<G_SREM, srem>;
56 def : GINodeEquiv<G_UREM, urem>;
57 def : GINodeEquiv<G_AND, and>;
58 def : GINodeEquiv<G_OR, or>;
59 def : GINodeEquiv<G_XOR, xor>;
60 def : GINodeEquiv<G_SHL, shl>;
61 def : GINodeEquiv<G_LSHR, srl>;
62 def : GINodeEquiv<G_ASHR, sra>;
63 def : GINodeEquiv<G_SELECT, select>;
64 def : GINodeEquiv<G_FNEG, fneg>;
65 def : GINodeEquiv<G_FPEXT, fpextend>;
66 def : GINodeEquiv<G_FPTRUNC, fpround>;
67 def : GINodeEquiv<G_FPTOSI, fp_to_sint>;
68 def : GINodeEquiv<G_FPTOUI, fp_to_uint>;
69 def : GINodeEquiv<G_SITOFP, sint_to_fp>;
70 def : GINodeEquiv<G_UITOFP, uint_to_fp>;
71 def : GINodeEquiv<G_FADD, fadd>;
72 def : GINodeEquiv<G_FSUB, fsub>;
73 def : GINodeEquiv<G_FMA, fma>;
74 def : GINodeEquiv<G_FMUL, fmul>;
75 def : GINodeEquiv<G_FDIV, fdiv>;
76 def : GINodeEquiv<G_FREM, frem>;
77 def : GINodeEquiv<G_FPOW, fpow>;
78 def : GINodeEquiv<G_FEXP2, fexp2>;
79 def : GINodeEquiv<G_FLOG2, flog2>;
80 def : GINodeEquiv<G_INTRINSIC, intrinsic_wo_chain>;
81 // ISD::INTRINSIC_VOID can also be handled with G_INTRINSIC_W_SIDE_EFFECTS.
82 def : GINodeEquiv<G_INTRINSIC_W_SIDE_EFFECTS, intrinsic_void>;
83 def : GINodeEquiv<G_INTRINSIC_W_SIDE_EFFECTS, intrinsic_w_chain>;
84 def : GINodeEquiv<G_BR, br>;
85 def : GINodeEquiv<G_BSWAP, bswap>;
86
87 // Broadly speaking G_LOAD is equivalent to ISD::LOAD but there are some
88 // complications that tablegen must take care of. For example, Predicates such
89 // as isSignExtLoad require that this is not a perfect 1:1 mapping since a
90 // sign-extending load is (G_SEXTLOAD x) in GlobalISel. Additionally,
91 // G_LOAD handles both atomic and non-atomic loads where as SelectionDAG had
92 // separate nodes for them. This GINodeEquiv maps the non-atomic loads to
93 // G_LOAD with a non-atomic MachineMemOperand.
94 def : GINodeEquiv<G_LOAD, ld> {
95   let CheckMMOIsNonAtomic = 1;
96   let IfSignExtend = G_SEXTLOAD;
97   let IfZeroExtend = G_ZEXTLOAD;
98 }
99 // Broadly speaking G_STORE is equivalent to ISD::STORE but there are some
100 // complications that tablegen must take care of. For example, predicates such
101 // as isTruncStore require that this is not a perfect 1:1 mapping since a
102 // truncating store is (G_STORE (G_TRUNCATE x)) in GlobalISel. Additionally,
103 // G_STORE handles both atomic and non-atomic stores where as SelectionDAG had
104 // separate nodes for them. This GINodeEquiv maps the non-atomic stores to
105 // G_STORE with a non-atomic MachineMemOperand.
106 def : GINodeEquiv<G_STORE, st> { let CheckMMOIsNonAtomic = 1; }
107
108 def : GINodeEquiv<G_ATOMIC_CMPXCHG, atomic_cmp_swap>;
109 def : GINodeEquiv<G_ATOMICRMW_XCHG, atomic_swap>;
110 def : GINodeEquiv<G_ATOMICRMW_ADD, atomic_load_add>;
111 def : GINodeEquiv<G_ATOMICRMW_SUB, atomic_load_sub>;
112 def : GINodeEquiv<G_ATOMICRMW_AND, atomic_load_and>;
113 def : GINodeEquiv<G_ATOMICRMW_NAND, atomic_load_nand>;
114 def : GINodeEquiv<G_ATOMICRMW_OR, atomic_load_or>;
115 def : GINodeEquiv<G_ATOMICRMW_XOR, atomic_load_xor>;
116 def : GINodeEquiv<G_ATOMICRMW_MIN, atomic_load_min>;
117 def : GINodeEquiv<G_ATOMICRMW_MAX, atomic_load_max>;
118 def : GINodeEquiv<G_ATOMICRMW_UMIN, atomic_load_umin>;
119 def : GINodeEquiv<G_ATOMICRMW_UMAX, atomic_load_umax>;
120
121 // Specifies the GlobalISel equivalents for SelectionDAG's ComplexPattern.
122 // Should be used on defs that subclass GIComplexOperandMatcher<>.
123 class GIComplexPatternEquiv<ComplexPattern seldag> {
124   ComplexPattern SelDAGEquivalent = seldag;
125 }
126
127 // Specifies the GlobalISel equivalents for SelectionDAG's SDNodeXForm.
128 // Should be used on defs that subclass GICustomOperandRenderer<>.
129 class GISDNodeXFormEquiv<SDNodeXForm seldag> {
130   SDNodeXForm SelDAGEquivalent = seldag;
131 }