summaryrefslogtreecommitdiff
path: root/src/binaryen-c.h
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2018-01-17 18:25:49 +0100
committerAlon Zakai <alonzakai@gmail.com>2018-01-17 09:25:49 -0800
commit01b23987405d8d7b2f13e40ef906169163ac2a5f (patch)
tree7b76946e0392eb65ad773cbb6524ad0fdbddde38 /src/binaryen-c.h
parent3d8358f8e10a01869ef59189539ab1d17d52cb10 (diff)
downloadbinaryen-01b23987405d8d7b2f13e40ef906169163ac2a5f.tar.gz
binaryen-01b23987405d8d7b2f13e40ef906169163ac2a5f.tar.bz2
binaryen-01b23987405d8d7b2f13e40ef906169163ac2a5f.zip
Add optimize, shrink level and debug info options to C/JS (#1357)
* Add optimize, shrink level and debug info options to C/JS * Add instantiate functionality for creating additional unique instances of the API * Use a workaround when running tests in node Tests misuse a module as a script by concatenating, so instead of catching this case in the library, catch it there * Update sieve test Seems optimized output changed due to running with optimize levels 2/1 now * Use the options with all pass runners * Update relooper-fuzz C-API test * Share defaults between tools and the C-API * Add a test for optimize levels * Unify node test support in check.by and auto_update_tests.py * Also add getters for optimize levels and test them * Also test debugInfo * Add debug info to C tests that used it as well * Fix missing NODEJS import in auto_update_tests * Detect node.js version (WASM support) * Update hello-world JS test (now also runs with node) * feature-test WebAssembly in node instead * Document that these options apply globally, and where * Make sure hello-world.js output doesn't differ between mozjs/node
Diffstat (limited to 'src/binaryen-c.h')
-rw-r--r--src/binaryen-c.h39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index 78866d189..b17715a4b 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -48,6 +48,7 @@
#include <stdint.h>
#include "compiler-support.h"
+#include "support/defaults.h"
#ifdef __cplusplus
extern "C" {
@@ -656,10 +657,36 @@ void BinaryenModulePrintAsmjs(BinaryenModuleRef module);
// @return 0 if an error occurred, 1 if validated succesfully
int BinaryenModuleValidate(BinaryenModuleRef module);
-// Runs the standard optimization passes on the module.
+// Runs the standard optimization passes on the module. Uses the currently set
+// global optimize and shrink level.
void BinaryenModuleOptimize(BinaryenModuleRef module);
-// Runs the specified passes on the module.
+// Gets the currently set optimize level. Applies to all modules, globally.
+// 0, 1, 2 correspond to -O0, -O1, -O2 (default), etc.
+int BinaryenGetOptimizeLevel();
+
+// Sets the optimization level to use. Applies to all modules, globally.
+// 0, 1, 2 correspond to -O0, -O1, -O2 (default), etc.
+void BinaryenSetOptimizeLevel(int level);
+
+// Gets the currently set shrink level. Applies to all modules, globally.
+// 0, 1, 2 correspond to -O0, -Os (default), -Oz.
+int BinaryenGetShrinkLevel();
+
+// Sets the shrink level to use. Applies to all modules, globally.
+// 0, 1, 2 correspond to -O0, -Os (default), -Oz.
+void BinaryenSetShrinkLevel(int level);
+
+// Gets whether generating debug information is currently enabled or not.
+// Applies to all modules, globally.
+int BinaryenGetDebugInfo();
+
+// Enables or disables debug information in emitted binaries.
+// Applies to all modules, globally.
+void BinaryenSetDebugInfo(int on);
+
+// Runs the specified passes on the module. Uses the currently set global
+// optimize and shrink level.
void BinaryenModuleRunPasses(BinaryenModuleRef module, const char **passes, BinaryenIndex numPasses);
// Auto-generate drop() operations where needed. This lets you generate code without
@@ -667,7 +694,7 @@ void BinaryenModuleRunPasses(BinaryenModuleRef module, const char **passes, Bina
// but simpler to use autodrop).
void BinaryenModuleAutoDrop(BinaryenModuleRef module);
-// Serialize a module into binary form.
+// Serialize a module into binary form. Uses the currently set global debugInfo option.
// @return how many bytes were written. This will be less than or equal to outputSize
size_t BinaryenModuleWrite(BinaryenModuleRef module, char* output, size_t outputSize);
@@ -713,10 +740,12 @@ BinaryenType BinaryenFunctionGetVar(BinaryenFunctionRef func, BinaryenIndex inde
// Gets the body of the specified `Function`.
BinaryenExpressionRef BinaryenFunctionGetBody(BinaryenFunctionRef func);
-// Runs the standard optimization passes on the function.
+// Runs the standard optimization passes on the function. Uses the currently set
+// global optimize and shrink level.
void BinaryenFunctionOptimize(BinaryenFunctionRef func, BinaryenModuleRef module);
-// Runs the specified passes on the function.
+// Runs the specified passes on the function. Uses the currently set global
+// optimize and shrink level.
void BinaryenFunctionRunPasses(BinaryenFunctionRef func, BinaryenModuleRef module, const char **passes, BinaryenIndex numPasses);
//