[WebAssembly] Check in an initial CFG Stackifier pass
[oota-llvm.git] / lib / Target / WebAssembly / WebAssemblyInstrInfo.td
1 // WebAssemblyInstrInfo.td-Describe the WebAssembly Instructions-*- 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 /// \file
11 /// \brief WebAssembly Instruction definitions.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 //===----------------------------------------------------------------------===//
16 // WebAssembly Instruction Predicate Definitions.
17 //===----------------------------------------------------------------------===//
18
19 def HasAddr32 : Predicate<"!Subtarget->hasAddr64()">;
20 def HasAddr64 : Predicate<"Subtarget->hasAddr64()">;
21 def HasSIMD128 : Predicate<"Subtarget->hasSIMD128()">,
22                            AssemblerPredicate<"FeatureSIMD128", "simd128">;
23
24 //===----------------------------------------------------------------------===//
25 // WebAssembly-specific DAG Node Types.
26 //===----------------------------------------------------------------------===//
27
28 def SDT_WebAssemblyCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>]>;
29 def SDT_WebAssemblyCallSeqEnd :
30     SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>;
31 def SDT_WebAssemblyCall0    : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
32 def SDT_WebAssemblyCall1    : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>;
33 def SDT_WebAssemblySwitch   : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
34 def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
35 def SDT_WebAssemblyReturn   : SDTypeProfile<0, -1, []>;
36 def SDT_WebAssemblyWrapper  : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
37                                                    SDTCisPtrTy<0>]>;
38
39 //===----------------------------------------------------------------------===//
40 // WebAssembly-specific DAG Nodes.
41 //===----------------------------------------------------------------------===//
42
43 def WebAssemblycallseq_start :
44     SDNode<"ISD::CALLSEQ_START", SDT_WebAssemblyCallSeqStart,
45            [SDNPHasChain, SDNPOutGlue]>;
46 def WebAssemblycallseq_end :
47     SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd,
48            [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
49 def WebAssemblycall0 : SDNode<"WebAssemblyISD::CALL0",
50                               SDT_WebAssemblyCall0,
51                               [SDNPHasChain, SDNPVariadic]>;
52 def WebAssemblycall1 : SDNode<"WebAssemblyISD::CALL1",
53                               SDT_WebAssemblyCall1,
54                               [SDNPHasChain, SDNPVariadic]>;
55 def WebAssemblyswitch : SDNode<"WebAssemblyISD::SWITCH",
56                                SDT_WebAssemblySwitch,
57                                [SDNPHasChain, SDNPVariadic]>;
58 def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT",
59                                  SDT_WebAssemblyArgument>;
60 def WebAssemblyreturn   : SDNode<"WebAssemblyISD::RETURN",
61                                  SDT_WebAssemblyReturn, [SDNPHasChain]>;
62 def WebAssemblywrapper  : SDNode<"WebAssemblyISD::Wrapper",
63                                  SDT_WebAssemblyWrapper>;
64
65 //===----------------------------------------------------------------------===//
66 // WebAssembly-specific Operands.
67 //===----------------------------------------------------------------------===//
68
69 /*
70  * TODO(jfb): Add the following.
71  *
72  * get_local: read the current value of a local variable
73  * set_local: set the current value of a local variable
74 */
75
76 def bb_op : Operand<OtherVT>;
77 def tjumptable_op : Operand<iPTR>;
78 def global : Operand<iPTR>;
79
80 //===----------------------------------------------------------------------===//
81 // WebAssembly Instruction Format Definitions.
82 //===----------------------------------------------------------------------===//
83
84 include "WebAssemblyInstrFormats.td"
85
86 multiclass ARGUMENT<WebAssemblyRegClass vt> {
87   def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno),
88                        [(set vt:$res, (WebAssemblyargument timm:$argno))]>;
89 }
90 defm : ARGUMENT<Int32>;
91 defm : ARGUMENT<Int64>;
92 defm : ARGUMENT<Float32>;
93 defm : ARGUMENT<Float64>;
94
95
96 def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm),
97                       [(set Int32:$res, imm:$imm)]>;
98 def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm),
99                       [(set Int64:$res, imm:$imm)]>;
100 def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm),
101                       [(set Float32:$res, fpimm:$imm)]>;
102 def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm),
103                       [(set Float64:$res, fpimm:$imm)]>;
104
105 // Special types of immediates. FIXME: Hard-coded as 32-bit for now.
106 def GLOBAL : I<(outs Int32:$dst), (ins global:$addr),
107                [(set Int32:$dst, (WebAssemblywrapper tglobaladdr:$addr))]>;
108 def JUMP_TABLE : I<(outs Int32:$dst), (ins tjumptable_op:$addr),
109                    [(set Int32:$dst, (WebAssemblywrapper tjumptable:$addr))]>;
110
111 //===----------------------------------------------------------------------===//
112 // Additional sets of instructions.
113 //===----------------------------------------------------------------------===//
114
115 include "WebAssemblyInstrMemory.td"
116 include "WebAssemblyInstrCall.td"
117 include "WebAssemblyInstrControl.td"
118 include "WebAssemblyInstrInteger.td"
119 include "WebAssemblyInstrFloat.td"
120 include "WebAssemblyInstrConv.td"
121 include "WebAssemblyInstrAtomics.td"
122 include "WebAssemblyInstrSIMD.td"