blob: f4d16d39e646172f5763ea0df05751600b8abcad [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001// WebAssemblyInstrFormats.td - WebAssembly Instruction Formats -*- tblgen -*-//
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//===----------------------------------------------------------------------===//
JF Bastien5ca0bac2015-07-10 18:23:10 +00009///
10/// \file
11/// \brief WebAssembly instruction format definitions.
12///
Dan Gohman10e730a2015-06-29 23:51:55 +000013//===----------------------------------------------------------------------===//
14
15// WebAssembly Instruction Format
16class WebAssemblyInst<string cstr> : Instruction {
17 field bits<0> Inst; // Instruction encoding.
18 let Namespace = "WebAssembly";
19 let Pattern = [];
20 let Constraints = cstr;
21}
22
23// Normal instructions
24class I<dag oops, dag iops, list<dag> pattern, string cstr = "">
25 : WebAssemblyInst<cstr> {
26 dag OutOperandList = oops;
27 dag InOperandList = iops;
28 let Pattern = pattern;
29}
JF Bastiend9767a32015-07-14 21:13:29 +000030
31// Unary and binary instructions, for the local types that WebAssembly supports.
32multiclass UnaryInt<SDNode node> {
33 def _I32 : I<(outs Int32:$dst), (ins Int32:$src),
34 [(set Int32:$dst, (node Int32:$src))]>;
35 def _I64 : I<(outs Int64:$dst), (ins Int64:$src),
36 [(set Int64:$dst, (node Int64:$src))]>;
37}
38multiclass BinaryInt<SDNode node> {
39 def _I32 : I<(outs Int32:$dst), (ins Int32:$lhs, Int32:$rhs),
40 [(set Int32:$dst, (node Int32:$lhs, Int32:$rhs))]>;
41 def _I64 : I<(outs Int64:$dst), (ins Int64:$lhs, Int64:$rhs),
42 [(set Int64:$dst, (node Int64:$lhs, Int64:$rhs))]>;
43}
44multiclass UnaryFP<SDNode node> {
45 def _F32 : I<(outs Float32:$dst), (ins Float32:$src),
46 [(set Float32:$dst, (node Float32:$src))]>;
47 def _F64 : I<(outs Float64:$dst), (ins Float64:$src),
48 [(set Float64:$dst, (node Float64:$src))]>;
49}
50multiclass BinaryFP<SDNode node> {
51 def _F32 : I<(outs Float32:$dst), (ins Float32:$lhs, Float32:$rhs),
52 [(set Float32:$dst, (node Float32:$lhs, Float32:$rhs))]>;
53 def _F64 : I<(outs Float64:$dst), (ins Float64:$lhs, Float64:$rhs),
54 [(set Float64:$dst, (node Float64:$lhs, Float64:$rhs))]>;
55}
JF Bastienda06bce2015-08-11 21:02:46 +000056multiclass ComparisonInt<CondCode cond> {
57 def _I32 : I<(outs Int32:$dst), (ins Int32:$lhs, Int32:$rhs),
58 [(set Int32:$dst, (setcc Int32:$lhs, Int32:$rhs, cond))]>;
59 def _I64 : I<(outs Int32:$dst), (ins Int64:$lhs, Int64:$rhs),
60 [(set Int32:$dst, (setcc Int64:$lhs, Int64:$rhs, cond))]>;
61}
62multiclass ComparisonFP<CondCode cond> {
63 def _F32 : I<(outs Int32:$dst), (ins Float32:$lhs, Float32:$rhs),
64 [(set Int32:$dst, (setcc Float32:$lhs, Float32:$rhs, cond))]>;
65 def _F64 : I<(outs Int32:$dst), (ins Float64:$lhs, Float64:$rhs),
66 [(set Int32:$dst, (setcc Float64:$lhs, Float64:$rhs, cond))]>;
67}