summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xauto_update_tests.py2
-rwxr-xr-xcheck.py2
-rw-r--r--src/s2wasm.h32
-rw-r--r--test/dot_s/f32.wast14
-rw-r--r--test/dot_s/f64.wast14
5 files changed, 45 insertions, 19 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py
index b00023c65..69691aa07 100755
--- a/auto_update_tests.py
+++ b/auto_update_tests.py
@@ -32,7 +32,7 @@ for t in sorted(os.listdir('test')):
open(t, 'w').write(actual)
-for s in ['minimal.s', 'basics.s', 'call.s', 'conv.s', 'fast-isel.s', 'i64.s', 'load.s', 'phi.s', 'select.s', 'unreachable.s', 'cfg-stackify.s', 'cpus.s', 'frem.s', 'immediates.s', 'load-store-i1.s', 'reg-stackify.s', 'unused-argument.s', 'comparisons_f32.s', 'dead-vreg.s', 'func.s', 'import.s', 'memory-addr32.s', 'store-results.s', 'varargs.s', 'comparisons_f64.s', 'exit.s', 'global.s', 'memory-addr64.s', 'returned.s', 'store.s', 'comparisons_i32.s', 'f32.s', 'globl.s', 'legalize.s', 'offset-folding.s', 'return-int32.s', 'store-trunc.s', 'comparisons_i64.s', 'f64.s', 'i32.s', 'load-ext.s', 'permute.s', 'return-void.s', 'signext-zeroext.s']: # TODO: 'relocation.s', 'inline-asm.s', 'switch.s'
+for s in ['minimal.s', 'basics.s', 'call.s', 'conv.s', 'fast-isel.s', 'i64.s', 'load.s', 'phi.s', 'select.s', 'unreachable.s', 'cpus.s', 'frem.s', 'immediates.s', 'load-store-i1.s', 'reg-stackify.s', 'unused-argument.s', 'comparisons_f32.s', 'dead-vreg.s', 'func.s', 'import.s', 'memory-addr32.s', 'store-results.s', 'varargs.s', 'comparisons_f64.s', 'exit.s', 'global.s', 'memory-addr64.s', 'returned.s', 'store.s', 'comparisons_i32.s', 'f32.s', 'globl.s', 'legalize.s', 'offset-folding.s', 'return-int32.s', 'store-trunc.s', 'comparisons_i64.s', 'f64.s', 'i32.s', 'load-ext.s', 'permute.s', 'return-void.s', 'signext-zeroext.s']: # TODO: 'relocation.s', 'inline-asm.s', 'switch.s', 'cfg-stackify.s'
print '..', s
wasm = s.replace('.s', '.wast')
full = os.path.join('test', 'dot_s', s)
diff --git a/check.py b/check.py
index d2d617d7f..816a874ff 100755
--- a/check.py
+++ b/check.py
@@ -214,7 +214,7 @@ for t in spec_tests:
print '\n[ checking .s testcases... ]\n'
-for s in ['minimal.s', 'basics.s', 'call.s', 'conv.s', 'fast-isel.s', 'i64.s', 'load.s', 'phi.s', 'select.s', 'unreachable.s', 'cfg-stackify.s', 'cpus.s', 'frem.s', 'immediates.s', 'load-store-i1.s', 'reg-stackify.s', 'unused-argument.s', 'comparisons_f32.s', 'dead-vreg.s', 'func.s', 'import.s', 'memory-addr32.s', 'store-results.s', 'varargs.s', 'comparisons_f64.s', 'exit.s', 'global.s', 'memory-addr64.s', 'returned.s', 'store.s', 'comparisons_i32.s', 'f32.s', 'globl.s', 'legalize.s', 'offset-folding.s', 'return-int32.s', 'store-trunc.s', 'comparisons_i64.s', 'f64.s', 'i32.s', 'load-ext.s', 'permute.s', 'return-void.s', 'signext-zeroext.s']: # TODO: 'relocation.s', 'inline-asm.s', 'switch.s'
+for s in ['minimal.s', 'basics.s', 'call.s', 'conv.s', 'fast-isel.s', 'i64.s', 'load.s', 'phi.s', 'select.s', 'unreachable.s', 'cpus.s', 'frem.s', 'immediates.s', 'load-store-i1.s', 'reg-stackify.s', 'unused-argument.s', 'comparisons_f32.s', 'dead-vreg.s', 'func.s', 'import.s', 'memory-addr32.s', 'store-results.s', 'varargs.s', 'comparisons_f64.s', 'exit.s', 'global.s', 'memory-addr64.s', 'returned.s', 'store.s', 'comparisons_i32.s', 'f32.s', 'globl.s', 'legalize.s', 'offset-folding.s', 'return-int32.s', 'store-trunc.s', 'comparisons_i64.s', 'f64.s', 'i32.s', 'load-ext.s', 'permute.s', 'return-void.s', 'signext-zeroext.s']: # TODO: 'relocation.s', 'inline-asm.s', 'switch.s', 'cfg-stackify.s'
print '..', s
wasm = s.replace('.s', '.wast')
full = os.path.join('test', 'dot_s', s)
diff --git a/src/s2wasm.h b/src/s2wasm.h
index 62a4a77f8..8dac81b4c 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -618,6 +618,7 @@ private:
// fixups
std::vector<Block*> loopBlocks; // we need to clear their names
std::set<Name> seenLabels; // if we already used a label, we don't need it in a loop (there is a block above it, with that label)
+ Name lastLabel; // A loop has an 'in' label which appears before it. There might also be a block in between it and the loop, so we have to remember the last label
// main loop
while (1) {
skipWhitespace();
@@ -638,35 +639,32 @@ private:
seenLabels.insert(curr->name);
} else if (match("BB")) {
s -= 2;
- Name name = getStrToColon();
+ lastLabel = getStrToColon();
s++;
skipWhitespace();
// pop all blocks/loops that reach this target
// pop all targets with this label
while (!bstack.empty()) {
auto curr = bstack.back();
- if (curr->name == name) {
+ if (curr->name == lastLabel) {
bstack.pop_back();
continue;
}
break;
}
- // this may also be a loop beginning
- if (*s == 'l') {
- auto curr = allocator.alloc<Loop>();
- bstack.back()->list.push_back(curr);
- curr->in = name;
- mustMatch("loop");
- Name out = getStr();
- if (seenLabels.count(out) == 0) {
- curr->out = out;
- }
- auto block = allocator.alloc<Block>();
- block->name = out; // temporary, fake
- curr->body = block;
- loopBlocks.push_back(block);
- bstack.push_back(block);
+ } else if (match("loop")) {
+ auto curr = allocator.alloc<Loop>();
+ bstack.back()->list.push_back(curr);
+ curr->in = lastLabel;
+ Name out = getStr();
+ if (seenLabels.count(out) == 0) {
+ curr->out = out;
}
+ auto block = allocator.alloc<Block>();
+ block->name = out; // temporary, fake
+ curr->body = block;
+ loopBlocks.push_back(block);
+ bstack.push_back(block);
} else if (match("br")) {
auto curr = allocator.alloc<Break>();
if (*s == '_') {
diff --git a/test/dot_s/f32.wast b/test/dot_s/f32.wast
index 610e1cd98..316dd263e 100644
--- a/test/dot_s/f32.wast
+++ b/test/dot_s/f32.wast
@@ -15,6 +15,7 @@
(export "nearest32_via_rint" $nearest32_via_rint)
(export "fmin32" $fmin32)
(export "fmax32" $fmax32)
+ (export "fma32" $fma32)
(func $fadd32 (param $$0 f32) (param $$1 f32) (result f32)
(block $fake_return_waka123
(block
@@ -187,4 +188,17 @@
)
)
)
+ (func $fma32 (param $$0 f32) (param $$1 f32) (param $$2 f32) (result f32)
+ (block $fake_return_waka123
+ (block
+ (br $fake_return_waka123
+ (call $fmaf
+ (get_local $$2)
+ (get_local $$1)
+ (get_local $$0)
+ )
+ )
+ )
+ )
+ )
)
diff --git a/test/dot_s/f64.wast b/test/dot_s/f64.wast
index 73e31cfe1..5d2549fb0 100644
--- a/test/dot_s/f64.wast
+++ b/test/dot_s/f64.wast
@@ -15,6 +15,7 @@
(export "nearest64_via_rint" $nearest64_via_rint)
(export "fmin64" $fmin64)
(export "fmax64" $fmax64)
+ (export "fma64" $fma64)
(func $fadd64 (param $$0 f64) (param $$1 f64) (result f64)
(block $fake_return_waka123
(block
@@ -187,4 +188,17 @@
)
)
)
+ (func $fma64 (param $$0 f64) (param $$1 f64) (param $$2 f64) (result f64)
+ (block $fake_return_waka123
+ (block
+ (br $fake_return_waka123
+ (call $fma
+ (get_local $$2)
+ (get_local $$1)
+ (get_local $$0)
+ )
+ )
+ )
+ )
+ )
)