diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-10-23 09:48:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 09:48:40 -0700 |
commit | 83a05025ee883f86cabdf92a9891d6c5ef5afbd4 (patch) | |
tree | 27d3966a4b1797ec14c2896e80aab61c9d76c33e /src/ast/load-utils.h | |
parent | 1005b1267f70a5a7cf7a8774af6c12d813464720 (diff) | |
download | binaryen-83a05025ee883f86cabdf92a9891d6c5ef5afbd4.tar.gz binaryen-83a05025ee883f86cabdf92a9891d6c5ef5afbd4.tar.bz2 binaryen-83a05025ee883f86cabdf92a9891d6c5ef5afbd4.zip |
only look at the |signed| field of loads if it is relevant (#1235)
Diffstat (limited to 'src/ast/load-utils.h')
-rw-r--r-- | src/ast/load-utils.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/ast/load-utils.h b/src/ast/load-utils.h new file mode 100644 index 000000000..d5817ff51 --- /dev/null +++ b/src/ast/load-utils.h @@ -0,0 +1,40 @@ +/* + * Copyright 2017 WebAssembly Community Group participants + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef wasm_ast_load_h +#define wasm_ast_load_h + +#include "wasm.h" + +namespace wasm { + +namespace LoadUtils { + +// checks if the sign of a load matters, which is when an integer +// load is of fewer bytes than the size of the type (so we must +// fill in bits either signed or unsigned wise) +inline bool isSignRelevant(Load* load) { + auto type = load->type; + if (load->type == unreachable) return false; + return !isWasmTypeFloat(type) && load->bytes < getWasmTypeSize(type); +} + +} // namespace LoadUtils + +} // namespace wasm + +#endif // wasm_ast_load_h + |