2015-12-08 11:36:00 +08:00
|
|
|
//=- WebAssemblyInstrFormats.td - WebAssembly Instr. Formats -*- tablegen -*-=//
|
2015-06-30 07:51:55 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2015-07-11 02:23:10 +08:00
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief WebAssembly instruction format definitions.
|
|
|
|
///
|
2015-06-30 07:51:55 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-08-25 06:16:48 +08:00
|
|
|
// WebAssembly Instruction Format.
|
2015-11-06 04:42:30 +08:00
|
|
|
class WebAssemblyInst<string asmstr> : Instruction {
|
2015-06-30 07:51:55 +08:00
|
|
|
field bits<0> Inst; // Instruction encoding.
|
|
|
|
let Namespace = "WebAssembly";
|
|
|
|
let Pattern = [];
|
2015-11-06 04:42:30 +08:00
|
|
|
let AsmString = asmstr;
|
2015-06-30 07:51:55 +08:00
|
|
|
}
|
|
|
|
|
2015-08-25 06:16:48 +08:00
|
|
|
// Normal instructions.
|
2015-11-06 04:42:30 +08:00
|
|
|
class I<dag oops, dag iops, list<dag> pattern, string asmstr = "">
|
|
|
|
: WebAssemblyInst<asmstr> {
|
2015-06-30 07:51:55 +08:00
|
|
|
dag OutOperandList = oops;
|
|
|
|
dag InOperandList = iops;
|
|
|
|
let Pattern = pattern;
|
|
|
|
}
|
2015-07-15 05:13:29 +08:00
|
|
|
|
|
|
|
// Unary and binary instructions, for the local types that WebAssembly supports.
|
2015-11-06 04:42:30 +08:00
|
|
|
multiclass UnaryInt<SDNode node, string name> {
|
2015-09-26 09:09:44 +08:00
|
|
|
def _I32 : I<(outs I32:$dst), (ins I32:$src),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I32:$dst, (node I32:$src))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("i32.", !strconcat(name, "\t$dst, $src"))>;
|
2015-09-26 09:09:44 +08:00
|
|
|
def _I64 : I<(outs I64:$dst), (ins I64:$src),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I64:$dst, (node I64:$src))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("i64.", !strconcat(name, "\t$dst, $src"))>;
|
2015-07-15 05:13:29 +08:00
|
|
|
}
|
2015-11-06 04:42:30 +08:00
|
|
|
multiclass BinaryInt<SDNode node, string name> {
|
2015-09-26 09:09:44 +08:00
|
|
|
def _I32 : I<(outs I32:$dst), (ins I32:$lhs, I32:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I32:$dst, (node I32:$lhs, I32:$rhs))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("i32.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-09-26 09:09:44 +08:00
|
|
|
def _I64 : I<(outs I64:$dst), (ins I64:$lhs, I64:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I64:$dst, (node I64:$lhs, I64:$rhs))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("i64.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-07-15 05:13:29 +08:00
|
|
|
}
|
2015-11-06 04:42:30 +08:00
|
|
|
multiclass UnaryFP<SDNode node, string name> {
|
2015-09-26 09:09:44 +08:00
|
|
|
def _F32 : I<(outs F32:$dst), (ins F32:$src),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set F32:$dst, (node F32:$src))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("f32.", !strconcat(name, "\t$dst, $src"))>;
|
2015-09-26 09:09:44 +08:00
|
|
|
def _F64 : I<(outs F64:$dst), (ins F64:$src),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set F64:$dst, (node F64:$src))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("f64.", !strconcat(name, "\t$dst, $src"))>;
|
2015-07-15 05:13:29 +08:00
|
|
|
}
|
2015-11-06 04:42:30 +08:00
|
|
|
multiclass BinaryFP<SDNode node, string name> {
|
2015-09-26 09:09:44 +08:00
|
|
|
def _F32 : I<(outs F32:$dst), (ins F32:$lhs, F32:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set F32:$dst, (node F32:$lhs, F32:$rhs))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("f32.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-09-26 09:09:44 +08:00
|
|
|
def _F64 : I<(outs F64:$dst), (ins F64:$lhs, F64:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set F64:$dst, (node F64:$lhs, F64:$rhs))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("f64.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-07-15 05:13:29 +08:00
|
|
|
}
|
2015-11-06 04:42:30 +08:00
|
|
|
multiclass ComparisonInt<CondCode cond, string name> {
|
2015-09-26 09:09:44 +08:00
|
|
|
def _I32 : I<(outs I32:$dst), (ins I32:$lhs, I32:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I32:$dst, (setcc I32:$lhs, I32:$rhs, cond))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("i32.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-09-26 09:09:44 +08:00
|
|
|
def _I64 : I<(outs I32:$dst), (ins I64:$lhs, I64:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I32:$dst, (setcc I64:$lhs, I64:$rhs, cond))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("i64.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-08-12 05:02:46 +08:00
|
|
|
}
|
2015-11-06 04:42:30 +08:00
|
|
|
multiclass ComparisonFP<CondCode cond, string name> {
|
2015-09-26 09:09:44 +08:00
|
|
|
def _F32 : I<(outs I32:$dst), (ins F32:$lhs, F32:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I32:$dst, (setcc F32:$lhs, F32:$rhs, cond))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("f32.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-09-26 09:09:44 +08:00
|
|
|
def _F64 : I<(outs I32:$dst), (ins F64:$lhs, F64:$rhs),
|
2015-11-06 04:42:30 +08:00
|
|
|
[(set I32:$dst, (setcc F64:$lhs, F64:$rhs, cond))],
|
2015-11-15 23:34:19 +08:00
|
|
|
!strconcat("f64.", !strconcat(name, "\t$dst, $lhs, $rhs"))>;
|
2015-08-12 05:02:46 +08:00
|
|
|
}
|