summaryrefslogtreecommitdiff
path: root/test/example/c-api-kitchen-sink.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-07-07 12:49:51 -0700
committerGitHub <noreply@github.com>2016-07-07 12:49:51 -0700
commite74dcc425dfb95bbf0bb296fa0d6c4494355b6e1 (patch)
tree79fdef328a97cc41bde7181c6b7124b27bd36373 /test/example/c-api-kitchen-sink.c
parent9455a8749e1bb2c4788c37495b9cd319f046f6ff (diff)
parent4215d5f76f151fe2c4609db7f6041c4354851af3 (diff)
downloadbinaryen-e74dcc425dfb95bbf0bb296fa0d6c4494355b6e1.tar.gz
binaryen-e74dcc425dfb95bbf0bb296fa0d6c4494355b6e1.tar.bz2
binaryen-e74dcc425dfb95bbf0bb296fa0d6c4494355b6e1.zip
Merge pull request #622 from WebAssembly/duffs-device-test
Add a relooper test for duff's device, and c api improvements
Diffstat (limited to 'test/example/c-api-kitchen-sink.c')
-rw-r--r--test/example/c-api-kitchen-sink.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index ace95177a..6fb095d20 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -395,6 +395,19 @@ void test_relooper() {
BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module);
BinaryenFunctionRef sinker = BinaryenAddFunction(module, "switch", v, localTypes, 1, body);
}
+ { // duff's device
+ RelooperRef relooper = RelooperCreate();
+ RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0));
+ RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1));
+ RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2));
+ RelooperAddBranch(block0, block1, makeInt32(module, 10), NULL);
+ RelooperAddBranch(block0, block2, NULL, NULL);
+ RelooperAddBranch(block1, block2, NULL, NULL);
+ RelooperAddBranch(block2, block1, NULL, NULL);
+ BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 3, module); // use $3 as the helper var
+ BinaryenType localTypes[] = { BinaryenInt32(), BinaryenInt32(), BinaryenInt64(), BinaryenInt32(), BinaryenFloat32(), BinaryenFloat64(), BinaryenInt32() };
+ BinaryenFunctionRef sinker = BinaryenAddFunction(module, "duffs-device", v, localTypes, sizeof(localTypes)/sizeof(BinaryenType), body);
+ }
BinaryenFunctionTypeRef i = BinaryenAddFunctionType(module, "i", BinaryenInt32(), NULL, 0);