diff options
-rwxr-xr-x | build-js.sh | 2 | ||||
-rw-r--r-- | src/binaryen-c.cpp | 6 | ||||
-rw-r--r-- | src/binaryen-c.h | 2 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 2 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 13 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 4 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 10 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 4 |
8 files changed, 27 insertions, 16 deletions
diff --git a/build-js.sh b/build-js.sh index 9709752f9..61bed4b8f 100755 --- a/build-js.sh +++ b/build-js.sh @@ -231,6 +231,7 @@ export_function "_BinaryenExternalMemory" export_function "_BinaryenExternalGlobal" # Features +export_function "_BinaryenFeatureMVP" export_function "_BinaryenFeatureAtomics" export_function "_BinaryenFeatureBulkMemory" export_function "_BinaryenFeatureMutableGlobals" @@ -238,6 +239,7 @@ export_function "_BinaryenFeatureNontrappingFPToInt" export_function "_BinaryenFeatureSignExt" export_function "_BinaryenFeatureSIMD128" export_function "_BinaryenFeatureExceptionHandling" +export_function "_BinaryenFeatureAll" # Literals export_function "_BinaryenLiteralInt32" diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 6bf2e7d7c..da3485843 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -371,6 +371,9 @@ BinaryenExternalKind BinaryenExternalGlobal(void) { // Features +BinaryenFeatures BinaryenFeatureMVP(void) { + return static_cast<BinaryenFeatures>(FeatureSet::Feature::MVP); +} BinaryenFeatures BinaryenFeatureAtomics(void) { return static_cast<BinaryenFeatures>(FeatureSet::Feature::Atomics); } @@ -392,6 +395,9 @@ BinaryenFeatures BinaryenFeatureSIMD128(void) { BinaryenFeatures BinaryenFeatureExceptionHandling(void) { return static_cast<BinaryenFeatures>(FeatureSet::Feature::ExceptionHandling); } +BinaryenFeatures BinaryenFeatureAll(void) { + return static_cast<BinaryenFeatures>(FeatureSet::Feature::All); +} // Modules diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 03da33931..879d78498 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -142,6 +142,7 @@ BinaryenExternalKind BinaryenExternalGlobal(void); typedef uint32_t BinaryenFeatures; +BinaryenFeatures BinaryenFeatureMVP(void); BinaryenFeatures BinaryenFeatureAtomics(void); BinaryenFeatures BinaryenFeatureBulkMemory(void); BinaryenFeatures BinaryenFeatureMutableGlobals(void); @@ -149,6 +150,7 @@ BinaryenFeatures BinaryenFeatureNontrappingFPToInt(void); BinaryenFeatures BinaryenFeatureSignExt(void); BinaryenFeatures BinaryenFeatureSIMD128(void); BinaryenFeatures BinaryenFeatureExceptionHandling(void); +BinaryenFeatures BinaryenFeatureAll(void); // Modules // diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index c64d3caca..180d08bb5 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -87,6 +87,7 @@ Module['ExternalGlobal'] = Module['_BinaryenExternalGlobal'](); // Features Module['Features'] = { + 'MVP': Module['_BinaryenFeatureMVP'](), 'Atomics': Module['_BinaryenFeatureAtomics'](), 'BulkMemory': Module['_BinaryenFeatureBulkMemory'](), 'MutableGlobals': Module['_BinaryenFeatureMutableGlobals'](), @@ -94,6 +95,7 @@ Module['Features'] = { 'SignExt': Module['_BinaryenFeatureSignExt'](), 'SIMD128': Module['_BinaryenFeatureSIMD128'](), 'ExceptionHandling': Module['_BinaryenFeatureExceptionHandling'](), + 'All': Module['_BinaryenFeatureAll']() }; // Operations diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 38ce32876..649abfa4b 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -63,6 +63,7 @@ function test_types() { } function test_features() { + console.log("Binaryen.Features.MVP: " + Binaryen.Features.MVP); console.log("Binaryen.Features.Atomics: " + Binaryen.Features.Atomics); console.log("Binaryen.Features.BulkMemory: " + Binaryen.Features.BulkMemory); console.log("Binaryen.Features.MutableGlobals: " + Binaryen.Features.MutableGlobals); @@ -70,6 +71,7 @@ function test_features() { console.log("Binaryen.Features.SignExt: " + Binaryen.Features.SignExt); console.log("Binaryen.Features.SIMD128: " + Binaryen.Features.SIMD128); console.log("Binaryen.Features.ExceptionHandling: " + Binaryen.Features.ExceptionHandling); + console.log("Binaryen.Features.All: " + Binaryen.Features.All); } function test_ids() { @@ -464,13 +466,7 @@ function test_core() { // A bunch of our code needs drop, auto-add it module.autoDrop(); - var features = - Binaryen.Features.Atomics | - Binaryen.Features.BulkMemory | - Binaryen.Features.NontrappingFPToInt | - Binaryen.Features.SignExt | - Binaryen.Features.SIMD128; - + var features = Binaryen.Features.All; module.setFeatures(features); assert(module.getFeatures() == features); @@ -759,6 +755,9 @@ function test_parsing() { // create a module and write it to text module = new Binaryen.Module(); + + module.setFeatures(Binaryen.Features.All); + var iii = module.addFunctionType("iii", Binaryen.i32, [ Binaryen.i32, Binaryen.i32 ]); var x = module.local.get(0, Binaryen.i32), y = module.local.get(1, Binaryen.i32); diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index e68efda08..857950e6b 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -7,6 +7,7 @@ BinaryenTypeVec128: 5 BinaryenTypeExceptRef: 6 BinaryenTypeUnreachable: 7 BinaryenTypeAuto: -1 +Binaryen.Features.MVP: 0 Binaryen.Features.Atomics: 1 Binaryen.Features.BulkMemory: 16 Binaryen.Features.MutableGlobals: 2 @@ -14,6 +15,7 @@ Binaryen.Features.NontrappingFPToInt: 4 Binaryen.Features.SignExt: 32 Binaryen.Features.SIMD128: 8 Binaryen.Features.ExceptionHandling: 64 +Binaryen.Features.All: 127 BinaryenInvalidId: 0 BinaryenBlockId: 1 BinaryenIfId: 2 @@ -3390,7 +3392,7 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} functionTypes[3] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); - BinaryenModuleSetFeatures(the_module, 61); + BinaryenModuleSetFeatures(the_module, 127); BinaryenModuleGetFeatures(the_module); BinaryenModuleValidate(the_module); BinaryenModulePrint(the_module); diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 43069c865..e0b4a5ec4 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -161,6 +161,7 @@ void test_types() { } void test_features() { + printf("BinaryenFeatureMVP: %d\n", BinaryenFeatureMVP()); printf("BinaryenFeatureAtomics: %d\n", BinaryenFeatureAtomics()); printf("BinaryenFeatureBulkMemory: %d\n", BinaryenFeatureBulkMemory()); printf("BinaryenFeatureMutableGlobals: %d\n", BinaryenFeatureMutableGlobals()); @@ -168,6 +169,7 @@ void test_features() { printf("BinaryenFeatureSignExt: %d\n", BinaryenFeatureSignExt()); printf("BinaryenFeatureSIMD128: %d\n", BinaryenFeatureSIMD128()); printf("BinaryenFeatureExceptionHandling: %d\n", BinaryenFeatureExceptionHandling()); + printf("BinaryenFeatureAll: %d\n", BinaryenFeatureAll()); } void test_core() { @@ -521,13 +523,7 @@ void test_core() { // A bunch of our code needs drop(), auto-add it BinaryenModuleAutoDrop(module); - BinaryenFeatures features = - BinaryenFeatureAtomics() | - BinaryenFeatureBulkMemory() | - BinaryenFeatureNontrappingFPToInt() | - BinaryenFeatureSignExt() | - BinaryenFeatureSIMD128(); - + BinaryenFeatures features = BinaryenFeatureAll(); BinaryenModuleSetFeatures(module, features); assert(BinaryenModuleGetFeatures(module) == features); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index f1eba84b7..c9bcc4b68 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -7,6 +7,7 @@ BinaryenTypeVec128: 5 BinaryenTypeExceptRef: 6 BinaryenTypeUnreachable: 7 BinaryenTypeAuto: -1 +BinaryenFeatureMVP: 0 BinaryenFeatureAtomics: 1 BinaryenFeatureBulkMemory: 16 BinaryenFeatureMutableGlobals: 2 @@ -14,6 +15,7 @@ BinaryenFeatureNontrappingFPToInt: 4 BinaryenFeatureSignExt: 32 BinaryenFeatureSIMD128: 8 BinaryenFeatureExceptionHandling: 64 +BinaryenFeatureAll: 127 (f32.neg (f32.const -33.61199951171875) ) @@ -3341,7 +3343,7 @@ int main() { functionTypes[3] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); - BinaryenModuleSetFeatures(the_module, 61); + BinaryenModuleSetFeatures(the_module, 127); BinaryenModuleGetFeatures(the_module); BinaryenModuleValidate(the_module); BinaryenModulePrint(the_module); |