summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2016-03-09 17:02:00 -0800
committerDerek Schuff <dschuff@chromium.org>2016-03-09 17:24:18 -0800
commitac9d61d45fec988640b57dc6b9de97e7d46c41f5 (patch)
treec2cb837f4285b06b47bbb017a909df718673b7c1 /src/wasm.h
parent0c0850ed5e2a2e82ad42f803894defcc53692ccd (diff)
downloadbinaryen-ac9d61d45fec988640b57dc6b9de97e7d46c41f5.tar.gz
binaryen-ac9d61d45fec988640b57dc6b9de97e7d46c41f5.tar.bz2
binaryen-ac9d61d45fec988640b57dc6b9de97e7d46c41f5.zip
Move rol/ror to src/support/bits.h
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 26b5e18e1..4bcb4bc87 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -45,7 +45,6 @@
#include <cassert>
#include <cmath>
-#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstring>
@@ -504,29 +503,17 @@ public:
default: WASM_UNREACHABLE();
}
}
- template <typename T>
- static T rol(T val, T count) {
- T mask = sizeof(T) * CHAR_BIT - 1;
- count &= mask;
- return (val << count) | (val >> (-count & mask));
- }
Literal rotL(const Literal& other) const {
switch (type) {
- case WasmType::i32: return Literal(rol(uint32_t(i32), uint32_t(other.i32)));
- case WasmType::i64: return Literal(rol(uint64_t(i64), uint64_t(other.i64)));
+ case WasmType::i32: return Literal(RotateLeft(uint32_t(i32), uint32_t(other.i32)));
+ case WasmType::i64: return Literal(RotateLeft(uint64_t(i64), uint64_t(other.i64)));
default: WASM_UNREACHABLE();
}
}
- template <typename T>
- static T ror (T val, T count) {
- T mask = sizeof(T) * CHAR_BIT - 1;
- count &= mask;
- return (val >> count) | (val << (-count & mask));
- }
Literal rotR(const Literal& other) const {
switch (type) {
- case WasmType::i32: return Literal(ror(uint32_t(i32), uint32_t(other.i32)));
- case WasmType::i64: return Literal(ror(uint64_t(i64), uint64_t(other.i64)));
+ case WasmType::i32: return Literal(RotateRight(uint32_t(i32), uint32_t(other.i32)));
+ case WasmType::i64: return Literal(RotateRight(uint64_t(i64), uint64_t(other.i64)));
default: WASM_UNREACHABLE();
}
}