]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/WebAssembly/WebAssemblyInstrFormats.td
Update the GNU DTS file from Linux 4.11
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / WebAssembly / WebAssemblyInstrFormats.td
1 //=- WebAssemblyInstrFormats.td - WebAssembly Instr. Formats -*- 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 format definitions.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 // WebAssembly Instruction Format.
16 class WebAssemblyInst<bits<32> inst, string asmstr> : Instruction {
17   field bits<32> Inst = inst; // Instruction encoding.
18   let Namespace   = "WebAssembly";
19   let Pattern     = [];
20   let AsmString   = asmstr;
21 }
22
23 // Normal instructions.
24 class I<dag oops, dag iops, list<dag> pattern, string asmstr = "", bits<32> inst = -1>
25     : WebAssemblyInst<inst, asmstr> {
26   dag OutOperandList = oops;
27   dag InOperandList  = iops;
28   let Pattern        = pattern;
29 }
30
31 class SIMD_I<dag oops, dag iops, list<dag> pattern,
32              string asmstr = "", bits<32> inst = -1>
33     : I<oops, iops, pattern, asmstr, inst>, Requires<[HasSIMD128]>;
34
35 // Unary and binary instructions, for the local types that WebAssembly supports.
36 multiclass UnaryInt<SDNode node, string name, bits<32> i32Inst, bits<32> i64Inst> {
37   def _I32 : I<(outs I32:$dst), (ins I32:$src),
38                [(set I32:$dst, (node I32:$src))],
39                !strconcat("i32.", !strconcat(name, "\t$dst, $src")), i32Inst>;
40   def _I64 : I<(outs I64:$dst), (ins I64:$src),
41                [(set I64:$dst, (node I64:$src))],
42                !strconcat("i64.", !strconcat(name, "\t$dst, $src")), i64Inst>;
43 }
44 multiclass BinaryInt<SDNode node, string name, bits<32> i32Inst, bits<32> i64Inst> {
45   def _I32 : I<(outs I32:$dst), (ins I32:$lhs, I32:$rhs),
46                [(set I32:$dst, (node I32:$lhs, I32:$rhs))],
47                !strconcat("i32.", !strconcat(name, "\t$dst, $lhs, $rhs")), i32Inst>;
48   def _I64 : I<(outs I64:$dst), (ins I64:$lhs, I64:$rhs),
49                [(set I64:$dst, (node I64:$lhs, I64:$rhs))],
50                !strconcat("i64.", !strconcat(name, "\t$dst, $lhs, $rhs")), i64Inst>;
51 }
52 multiclass UnaryFP<SDNode node, string name, bits<32> f32Inst, bits<32> f64Inst> {
53   def _F32 : I<(outs F32:$dst), (ins F32:$src),
54                [(set F32:$dst, (node F32:$src))],
55                !strconcat("f32.", !strconcat(name, "\t$dst, $src")), f32Inst>;
56   def _F64 : I<(outs F64:$dst), (ins F64:$src),
57                [(set F64:$dst, (node F64:$src))],
58                !strconcat("f64.", !strconcat(name, "\t$dst, $src")), f64Inst>;
59 }
60 multiclass BinaryFP<SDNode node, string name, bits<32> f32Inst, bits<32> f64Inst> {
61   def _F32 : I<(outs F32:$dst), (ins F32:$lhs, F32:$rhs),
62                [(set F32:$dst, (node F32:$lhs, F32:$rhs))],
63                !strconcat("f32.", !strconcat(name, "\t$dst, $lhs, $rhs")), f32Inst>;
64   def _F64 : I<(outs F64:$dst), (ins F64:$lhs, F64:$rhs),
65                [(set F64:$dst, (node F64:$lhs, F64:$rhs))],
66                !strconcat("f64.", !strconcat(name, "\t$dst, $lhs, $rhs")), f64Inst>;
67 }
68 multiclass SIMDBinary<SDNode node, SDNode fnode, string name> {
69   def _I8x16 : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs),
70                       [(set (v16i8 V128:$dst), (node V128:$lhs, V128:$rhs))],
71                       !strconcat("i8x16.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
72   def _I16x8 : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs),
73                       [(set (v8i16 V128:$dst), (node V128:$lhs, V128:$rhs))],
74                       !strconcat("i16x8.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
75   def _I32x4 : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs),
76                       [(set (v4i32 V128:$dst), (node V128:$lhs, V128:$rhs))],
77                       !strconcat("i32x4.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
78   def _F32x4 : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs),
79                       [(set (v4f32 V128:$dst), (fnode V128:$lhs, V128:$rhs))],
80                       !strconcat("f32x4.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
81
82 }
83 multiclass ComparisonInt<CondCode cond, string name, bits<32> i32Inst, bits<32> i64Inst> {
84   def _I32 : I<(outs I32:$dst), (ins I32:$lhs, I32:$rhs),
85                [(set I32:$dst, (setcc I32:$lhs, I32:$rhs, cond))],
86                !strconcat("i32.", !strconcat(name, "\t$dst, $lhs, $rhs")),
87                i32Inst>;
88   def _I64 : I<(outs I32:$dst), (ins I64:$lhs, I64:$rhs),
89                [(set I32:$dst, (setcc I64:$lhs, I64:$rhs, cond))],
90                !strconcat("i64.", !strconcat(name, "\t$dst, $lhs, $rhs")),
91                i64Inst>;
92 }
93 multiclass ComparisonFP<CondCode cond, string name, bits<32> f32Inst, bits<32> f64Inst> {
94   def _F32 : I<(outs I32:$dst), (ins F32:$lhs, F32:$rhs),
95                [(set I32:$dst, (setcc F32:$lhs, F32:$rhs, cond))],
96                !strconcat("f32.", !strconcat(name, "\t$dst, $lhs, $rhs")),
97                f32Inst>;
98   def _F64 : I<(outs I32:$dst), (ins F64:$lhs, F64:$rhs),
99                [(set I32:$dst, (setcc F64:$lhs, F64:$rhs, cond))],
100                !strconcat("f64.", !strconcat(name, "\t$dst, $lhs, $rhs")),
101                f64Inst>;
102 }