summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-08-18 01:56:53 +0300
committerGitHub <noreply@github.com>2021-08-17 15:56:53 -0700
commitc0b126b7af2d3d9513b5cf8d541f5283984e902e (patch)
treef1fe0a3bd5a545b2e07050f560bd24585cb811f6
parentb82be0fe1abd3c56cc85150c76efbd66db6fe32e (diff)
downloadbinaryen-c0b126b7af2d3d9513b5cf8d541f5283984e902e.tar.gz
binaryen-c0b126b7af2d3d9513b5cf8d541f5283984e902e.tar.bz2
binaryen-c0b126b7af2d3d9513b5cf8d541f5283984e902e.zip
Add TrapsNeverHappen to SideEffects's API (#4086)
-rw-r--r--src/binaryen-c.cpp4
-rw-r--r--src/binaryen-c.h1
-rw-r--r--src/ir/effects.h7
-rw-r--r--src/js/binaryen.js-post.js1
-rw-r--r--test/binaryen.js/sideffects.js1
-rw-r--r--test/binaryen.js/sideffects.js.txt3
6 files changed, 15 insertions, 2 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index 7c826f0f2..49d485321 100644
--- a/src/binaryen-c.cpp
+++ b/src/binaryen-c.cpp
@@ -4309,6 +4309,10 @@ BinaryenSideEffects BinaryenSideEffectImplicitTrap(void) {
return static_cast<BinaryenSideEffects>(
EffectAnalyzer::SideEffects::ImplicitTrap);
}
+BinaryenSideEffects BinaryenSideEffectTrapsNeverHappen(void) {
+ return static_cast<BinaryenSideEffects>(
+ EffectAnalyzer::SideEffects::TrapsNeverHappen);
+}
BinaryenSideEffects BinaryenSideEffectIsAtomic(void) {
return static_cast<BinaryenSideEffects>(
EffectAnalyzer::SideEffects::IsAtomic);
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index 08cf12b90..d18c0e9ad 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -2620,6 +2620,7 @@ BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesGlobal(void);
BINARYEN_API BinaryenSideEffects BinaryenSideEffectReadsMemory(void);
BINARYEN_API BinaryenSideEffects BinaryenSideEffectWritesMemory(void);
BINARYEN_API BinaryenSideEffects BinaryenSideEffectImplicitTrap(void);
+BINARYEN_API BinaryenSideEffects BinaryenSideEffectTrapsNeverHappen(void);
BINARYEN_API BinaryenSideEffects BinaryenSideEffectIsAtomic(void);
BINARYEN_API BinaryenSideEffects BinaryenSideEffectThrows(void);
BINARYEN_API BinaryenSideEffects BinaryenSideEffectDanglingPop(void);
diff --git a/src/ir/effects.h b/src/ir/effects.h
index f5bb0e6cb..fd4c68cba 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -256,6 +256,7 @@ public:
writesHeap = writesHeap || other.writesHeap;
trap = trap || other.trap;
implicitTrap = implicitTrap || other.implicitTrap;
+ trapsNeverHappen = trapsNeverHappen || other.trapsNeverHappen;
isAtomic = isAtomic || other.isAtomic;
throws = throws || other.throws;
danglingPop = danglingPop || other.danglingPop;
@@ -687,7 +688,8 @@ public:
IsAtomic = 1 << 9,
Throws = 1 << 10,
DanglingPop = 1 << 11,
- Any = (1 << 12) - 1
+ TrapsNeverHappen = 1 << 12,
+ Any = (1 << 13) - 1
};
uint32_t getSideEffects() const {
uint32_t effects = 0;
@@ -718,6 +720,9 @@ public:
if (implicitTrap) {
effects |= SideEffects::ImplicitTrap;
}
+ if (trapsNeverHappen) {
+ effects |= SideEffects::TrapsNeverHappen;
+ }
if (isAtomic) {
effects |= SideEffects::IsAtomic;
}
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 8e41b4e7c..6ecfefee8 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -551,6 +551,7 @@ function initializeConstants() {
'IsAtomic',
'Throws',
'DanglingPop',
+ 'TrapsNeverHappen',
'Any'
].forEach(name => {
Module['SideEffects'][name] = Module['_BinaryenSideEffect' + name]();
diff --git a/test/binaryen.js/sideffects.js b/test/binaryen.js/sideffects.js
index cb0e8ac7f..f6a88b5f1 100644
--- a/test/binaryen.js/sideffects.js
+++ b/test/binaryen.js/sideffects.js
@@ -11,6 +11,7 @@ console.log("SideEffects.ImplicitTrap=" + binaryen.SideEffects.ImplicitTrap);
console.log("SideEffects.IsAtomic=" + binaryen.SideEffects.IsAtomic);
console.log("SideEffects.Throws=" + binaryen.SideEffects.Throws);
console.log("SideEffects.DanglingPop=" + binaryen.SideEffects.DanglingPop);
+console.log("SideEffects.TrapsNeverHappen=" + binaryen.SideEffects.TrapsNeverHappen);
console.log("SideEffects.Any=" + binaryen.SideEffects.Any);
var module = new binaryen.Module();
diff --git a/test/binaryen.js/sideffects.js.txt b/test/binaryen.js/sideffects.js.txt
index 53ee474e5..8e511d089 100644
--- a/test/binaryen.js/sideffects.js.txt
+++ b/test/binaryen.js/sideffects.js.txt
@@ -11,4 +11,5 @@ SideEffects.ImplicitTrap=256
SideEffects.IsAtomic=512
SideEffects.Throws=1024
SideEffects.DanglingPop=2048
-SideEffects.Any=4095
+SideEffects.TrapsNeverHappen=4096
+SideEffects.Any=8191