summaryrefslogtreecommitdiff
path: root/src/asm2wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-05-18 15:49:41 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-05-18 16:38:16 -0700
commitb88e9de7df6a8b2ba9381e27dff3aa3dff64f764 (patch)
tree6c18d2d133e388a02b289471784822b5e29ac1f2 /src/asm2wasm.h
parentcf224aa34a3660aa5154091759d396936e946b28 (diff)
downloadbinaryen-b88e9de7df6a8b2ba9381e27dff3aa3dff64f764.tar.gz
binaryen-b88e9de7df6a8b2ba9381e27dff3aa3dff64f764.tar.bz2
binaryen-b88e9de7df6a8b2ba9381e27dff3aa3dff64f764.zip
use separate internal opcodes for unary variants
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r--src/asm2wasm.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 0f4852250..74b1aa8c4 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -1133,11 +1133,12 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
return ret;
}
auto ret = allocator.alloc<Unary>();
- ret->op = Neg;
ret->value = process(ast[2]);
if (asmType == ASM_DOUBLE) {
+ ret->op = NegFloat64;
ret->type = WasmType::f64;
} else if (asmType == ASM_FLOAT) {
+ ret->op = NegFloat32;
ret->type = WasmType::f32;
} else {
abort();
@@ -1188,7 +1189,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
return ret;
} else if (ast[1] == L_NOT) {
auto ret = allocator.alloc<Unary>();
- ret->op = EqZ;
+ ret->op = EqZInt32;
ret->value = process(ast[2]);
ret->type = i32;
return ret;
@@ -1215,7 +1216,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
if (name == Math_clz32 || name == llvm_cttz_i32) {
assert(ast[2]->size() == 1);
auto ret = allocator.alloc<Unary>();
- ret->op = name == Math_clz32 ? Clz : Ctz;
+ ret->op = name == Math_clz32 ? ClzInt32 : CtzInt32;
ret->value = process(ast[2][0]);
ret->type = WasmType::i32;
return ret;
@@ -1283,7 +1284,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
return block;
} else if (value->type == f32 || value->type == f64) {
auto ret = allocator.alloc<Unary>();
- ret->op = Abs;
+ ret->op = value->type == f32 ? AbsFloat32 : AbsFloat64;
ret->value = value;
ret->type = value->type;
return ret;
@@ -1294,15 +1295,18 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
if (name == Math_floor || name == Math_sqrt || name == Math_ceil) {
// overloaded on type: f32 or f64
Expression* value = process(ast[2][0]);
- if (value->type == f32 || value->type == f64) {
- auto ret = allocator.alloc<Unary>();
- ret->op = name == Math_floor ? Floor : name == Math_ceil ? Ceil : Sqrt;
- ret->value = value;
+ auto ret = allocator.alloc<Unary>();
+ ret->value = value;
+ if (value->type == f32) {
+ ret->op = name == Math_floor ? FloorFloat32 : name == Math_ceil ? CeilFloat32 : SqrtFloat32;
+ ret->type = value->type;
+ } else if (value->type == f64) {
+ ret->op = name == Math_floor ? FloorFloat64 : name == Math_ceil ? CeilFloat64 : SqrtFloat64;
ret->type = value->type;
- return ret;
} else {
abort();
}
+ return ret;
}
Expression* ret;
ExpressionList* operands;
@@ -1404,7 +1408,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
Break *breakOut = allocator.alloc<Break>();
breakOut->name = out;
If *condition = allocator.alloc<If>();
- condition->condition = builder.makeUnary(EqZ, process(ast[1]));
+ condition->condition = builder.makeUnary(EqZInt32, process(ast[1]));
condition->ifTrue = breakOut;
auto body = allocator.alloc<Block>();
body->list.push_back(condition);
@@ -1501,7 +1505,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
Break *breakOut = allocator.alloc<Break>();
breakOut->name = out;
If *condition = allocator.alloc<If>();
- condition->condition = builder.makeUnary(EqZ, process(fcond));
+ condition->condition = builder.makeUnary(EqZInt32, process(fcond));
condition->ifTrue = breakOut;
auto body = allocator.alloc<Block>();
body->list.push_back(condition);