WebAssembly: print immediates
[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_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
29 def SDT_WebAssemblyReturn   : SDTypeProfile<0, -1, []>;
30
31 //===----------------------------------------------------------------------===//
32 // WebAssembly-specific DAG Nodes.
33 //===----------------------------------------------------------------------===//
34
35 def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT",
36                                  SDT_WebAssemblyArgument>;
37 def WebAssemblyreturn   : SDNode<"WebAssemblyISD::RETURN",
38                                  SDT_WebAssemblyReturn,
39                                  [SDNPHasChain, SDNPSideEffect]>;
40
41 //===----------------------------------------------------------------------===//
42 // WebAssembly-specific Operands.
43 //===----------------------------------------------------------------------===//
44
45 /*
46  * TODO(jfb): Add the following.
47  *
48  * get_local: read the current value of a local variable
49  * set_local: set the current value of a local variable
50 */
51
52 //===----------------------------------------------------------------------===//
53 // WebAssembly Instruction Format Definitions.
54 //===----------------------------------------------------------------------===//
55
56 include "WebAssemblyInstrFormats.td"
57
58 multiclass ARGUMENT<WebAssemblyRegClass vt> {
59   def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno),
60                        [(set vt:$res, (WebAssemblyargument timm:$argno))]>;
61 }
62 defm : ARGUMENT<Int32>;
63 defm : ARGUMENT<Int64>;
64 defm : ARGUMENT<Float32>;
65 defm : ARGUMENT<Float64>;
66
67
68 def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm),
69                       [(set Int32:$res, imm:$imm)]>;
70 def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm),
71                       [(set Int64:$res, imm:$imm)]>;
72 def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm),
73                       [(set Float32:$res, fpimm:$imm)]>;
74 def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm),
75                       [(set Float64:$res, fpimm:$imm)]>;
76
77 //===----------------------------------------------------------------------===//
78 // Additional sets of instructions.
79 //===----------------------------------------------------------------------===//
80
81 include "WebAssemblyInstrMemory.td"
82 include "WebAssemblyInstrCall.td"
83 include "WebAssemblyInstrControl.td"
84 include "WebAssemblyInstrInteger.td"
85 include "WebAssemblyInstrFloat.td"
86 include "WebAssemblyInstrConv.td"
87 include "WebAssemblyInstrAtomics.td"
88 include "WebAssemblyInstrSIMD.td"