summaryrefslogtreecommitdiff
path: root/test/example/c-api-kitchen-sink.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/example/c-api-kitchen-sink.c')
-rw-r--r--test/example/c-api-kitchen-sink.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index feffc9d4c..fa245c102 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -377,6 +377,20 @@ void test_relooper() {
BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module);
BinaryenFunctionRef sinker = BinaryenAddFunction(module, "nontrivial-loop-plus-phi-to-head", v, localTypes, 1, body);
}
+ { // switch
+ RelooperRef relooper = RelooperCreate();
+ RelooperBlockRef block0 = RelooperAddBlockWithSwitch(relooper, makeInt32(module, 0), makeInt32(module, -99));
+ RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1));
+ RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2));
+ RelooperBlockRef block3 = RelooperAddBlock(relooper, makeInt32(module, 3));
+ BinaryenIndex to_block1[] = { 2, 5 };
+ RelooperAddBranchForSwitch(block0, block1, to_block1, 2, NULL);
+ BinaryenIndex to_block2[] = { 4 };
+ RelooperAddBranchForSwitch(block0, block2, to_block2, 1, makeInt32(module, 55));
+ RelooperAddBranchForSwitch(block0, block3, NULL, 0, NULL);
+ BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module);
+ BinaryenFunctionRef sinker = BinaryenAddFunction(module, "switch", v, localTypes, 1, body);
+ }
BinaryenFunctionTypeRef i = BinaryenAddFunctionType(module, "i", BinaryenInt32(), NULL, 0);
@@ -389,11 +403,11 @@ void test_relooper() {
BinaryenFunctionRef sinker = BinaryenAddFunction(module, "return", i, localTypes, 1, body);
}
- assert(BinaryenModuleValidate(module));
-
printf("raw:\n");
BinaryenModulePrint(module);
+ assert(BinaryenModuleValidate(module));
+
BinaryenModuleOptimize(module);
assert(BinaryenModuleValidate(module));