summaryrefslogtreecommitdiff
path: root/src/passes
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes')
-rw-r--r--src/passes/Asyncify.cpp6
-rw-r--r--src/passes/AvoidReinterprets.cpp11
-rw-r--r--src/passes/ConstHoisting.cpp2
-rw-r--r--src/passes/Print.cpp8
-rw-r--r--src/passes/SafeHeap.cpp4
-rw-r--r--src/passes/SpillPointers.cpp8
6 files changed, 20 insertions, 19 deletions
diff --git a/src/passes/Asyncify.cpp b/src/passes/Asyncify.cpp
index 8e583863c..8f929d9fe 100644
--- a/src/passes/Asyncify.cpp
+++ b/src/passes/Asyncify.cpp
@@ -1090,7 +1090,7 @@ private:
Index total = 0;
for (Index i = 0; i < numPreservableLocals; i++) {
auto type = func->getLocalType(i);
- auto size = getTypeSize(type);
+ auto size = type.getByteSize();
total += size;
}
auto* block = builder->makeBlock();
@@ -1101,7 +1101,7 @@ private:
Index offset = 0;
for (Index i = 0; i < numPreservableLocals; i++) {
auto type = func->getLocalType(i);
- auto size = getTypeSize(type);
+ auto size = type.getByteSize();
assert(size % STACK_ALIGN == 0);
// TODO: higher alignment?
block->list.push_back(builder->makeLocalSet(
@@ -1130,7 +1130,7 @@ private:
Index offset = 0;
for (Index i = 0; i < numPreservableLocals; i++) {
auto type = func->getLocalType(i);
- auto size = getTypeSize(type);
+ auto size = type.getByteSize();
assert(size % STACK_ALIGN == 0);
// TODO: higher alignment?
block->list.push_back(
diff --git a/src/passes/AvoidReinterprets.cpp b/src/passes/AvoidReinterprets.cpp
index 5aa1d338b..f1b3d96d8 100644
--- a/src/passes/AvoidReinterprets.cpp
+++ b/src/passes/AvoidReinterprets.cpp
@@ -32,7 +32,8 @@ static bool canReplaceWithReinterpret(Load* load) {
// a reinterpret of the same address. A partial load would see
// more bytes and possibly invalid data, and an unreachable
// pointer is just not interesting to handle.
- return load->type != unreachable && load->bytes == getTypeSize(load->type);
+ return load->type != Type::unreachable &&
+ load->bytes == load->type.getByteSize();
}
static Load* getSingleLoad(LocalGraph* localGraph, LocalGet* get) {
@@ -116,7 +117,7 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> {
// We should use another load here, to avoid reinterprets.
info.ptrLocal = Builder::addVar(func, i32);
info.reinterpretedLocal =
- Builder::addVar(func, reinterpretType(load->type));
+ Builder::addVar(func, load->type.reinterpret());
} else {
unoptimizables.insert(load);
}
@@ -150,8 +151,8 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> {
auto& info = iter->second;
// A reinterpret of a get of a load - use the new local.
Builder builder(*module);
- replaceCurrent(builder.makeLocalGet(
- info.reinterpretedLocal, reinterpretType(load->type)));
+ replaceCurrent(builder.makeLocalGet(info.reinterpretedLocal,
+ load->type.reinterpret()));
}
}
}
@@ -185,7 +186,7 @@ struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> {
load->offset,
load->align,
ptr,
- reinterpretType(load->type));
+ load->type.reinterpret());
}
} finalOptimizer(infos, localGraph, getModule());
diff --git a/src/passes/ConstHoisting.cpp b/src/passes/ConstHoisting.cpp
index 9eb853878..dbb3853d8 100644
--- a/src/passes/ConstHoisting.cpp
+++ b/src/passes/ConstHoisting.cpp
@@ -88,7 +88,7 @@ private:
}
case f32:
case f64: {
- size = getTypeSize(value.type);
+ size = value.type.getByteSize();
break;
}
case v128: // v128 not implemented yet
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 3bad8f960..5efd1fd28 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -186,7 +186,7 @@ struct PrintExpressionContents
o << ".atomic";
}
o << ".load";
- if (curr->type != unreachable && curr->bytes < getTypeSize(curr->type)) {
+ if (curr->type != unreachable && curr->bytes < curr->type.getByteSize()) {
if (curr->bytes == 1) {
o << '8';
} else if (curr->bytes == 2) {
@@ -233,7 +233,7 @@ struct PrintExpressionContents
}
static void printRMWSize(std::ostream& o, Type type, uint8_t bytes) {
prepareColor(o) << forceConcrete(type) << ".atomic.rmw";
- if (type != unreachable && bytes != getTypeSize(type)) {
+ if (type != unreachable && bytes != type.getByteSize()) {
if (bytes == 1) {
o << '8';
} else if (bytes == 2) {
@@ -269,7 +269,7 @@ struct PrintExpressionContents
o << "xchg";
break;
}
- if (curr->type != unreachable && curr->bytes != getTypeSize(curr->type)) {
+ if (curr->type != unreachable && curr->bytes != curr->type.getByteSize()) {
o << "_u";
}
restoreNormalColor(o);
@@ -281,7 +281,7 @@ struct PrintExpressionContents
prepareColor(o);
printRMWSize(o, curr->type, curr->bytes);
o << "cmpxchg";
- if (curr->type != unreachable && curr->bytes != getTypeSize(curr->type)) {
+ if (curr->type != unreachable && curr->bytes != curr->type.getByteSize()) {
o << "_u";
}
restoreNormalColor(o);
diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp
index 37610a90b..fc6706f3e 100644
--- a/src/passes/SafeHeap.cpp
+++ b/src/passes/SafeHeap.cpp
@@ -176,7 +176,7 @@ struct SafeHeap : public Pass {
load.type = type;
for (Index bytes : {1, 2, 4, 8, 16}) {
load.bytes = bytes;
- if (bytes > getTypeSize(type) || (type == f32 && bytes != 4) ||
+ if (bytes > type.getByteSize() || (type == f32 && bytes != 4) ||
(type == f64 && bytes != 8) || (type == v128 && bytes != 16)) {
continue;
}
@@ -212,7 +212,7 @@ struct SafeHeap : public Pass {
store.type = none;
for (Index bytes : {1, 2, 4, 8, 16}) {
store.bytes = bytes;
- if (bytes > getTypeSize(valueType) ||
+ if (bytes > valueType.getByteSize() ||
(valueType == f32 && bytes != 4) ||
(valueType == f64 && bytes != 8) ||
(valueType == v128 && bytes != 16)) {
diff --git a/src/passes/SpillPointers.cpp b/src/passes/SpillPointers.cpp
index 10fa58845..758ca3223 100644
--- a/src/passes/SpillPointers.cpp
+++ b/src/passes/SpillPointers.cpp
@@ -78,7 +78,7 @@ struct SpillPointers
PointerMap pointerMap;
for (Index i = 0; i < func->getNumLocals(); i++) {
if (func->getLocalType(i) == ABI::PointerType) {
- auto offset = pointerMap.size() * getTypeSize(ABI::PointerType);
+ auto offset = pointerMap.size() * ABI::PointerType.getByteSize();
pointerMap[i] = offset;
}
}
@@ -140,7 +140,7 @@ struct SpillPointers
// get the stack space, and set the local to it
ABI::getStackSpace(spillLocal,
func,
- getTypeSize(ABI::PointerType) * pointerMap.size(),
+ ABI::PointerType.getByteSize() * pointerMap.size(),
*getModule());
}
}
@@ -184,9 +184,9 @@ struct SpillPointers
// add the spills
for (auto index : toSpill) {
block->list.push_back(
- builder.makeStore(getTypeSize(ABI::PointerType),
+ builder.makeStore(ABI::PointerType.getByteSize(),
pointerMap[index],
- getTypeSize(ABI::PointerType),
+ ABI::PointerType.getByteSize(),
builder.makeLocalGet(spillLocal, ABI::PointerType),
builder.makeLocalGet(index, ABI::PointerType),
ABI::PointerType));