summaryrefslogtreecommitdiff
path: root/src/passes
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes')
-rw-r--r--src/passes/Asyncify.cpp2
-rw-r--r--src/passes/CodeFolding.cpp4
-rw-r--r--src/passes/DataFlowOpts.cpp2
-rw-r--r--src/passes/DeadArgumentElimination.cpp2
-rw-r--r--src/passes/Flatten.cpp20
-rw-r--r--src/passes/I64ToI32Lowering.cpp2
-rw-r--r--src/passes/Inlining.cpp4
-rw-r--r--src/passes/LocalCSE.cpp2
-rw-r--r--src/passes/MergeBlocks.cpp10
-rw-r--r--src/passes/OptimizeInstructions.cpp10
-rw-r--r--src/passes/Precompute.cpp8
-rw-r--r--src/passes/Print.cpp77
-rw-r--r--src/passes/RemoveUnusedBrs.cpp16
-rw-r--r--src/passes/SafeHeap.cpp8
-rw-r--r--src/passes/Souperify.cpp10
-rw-r--r--src/passes/StackIR.cpp2
-rw-r--r--src/passes/Vacuum.cpp13
17 files changed, 87 insertions, 105 deletions
diff --git a/src/passes/Asyncify.cpp b/src/passes/Asyncify.cpp
index dd8845577..818d61907 100644
--- a/src/passes/Asyncify.cpp
+++ b/src/passes/Asyncify.cpp
@@ -948,7 +948,7 @@ private:
builder->makeLocalGet(oldState, i32)),
builder->makeUnreachable());
Expression* rep;
- if (isConcreteType(call->type)) {
+ if (call->type.isConcrete()) {
auto temp = builder->addVar(func, call->type);
rep = builder->makeBlock({
builder->makeLocalSet(temp, call),
diff --git a/src/passes/CodeFolding.cpp b/src/passes/CodeFolding.cpp
index d60bc76d1..818bb33b8 100644
--- a/src/passes/CodeFolding.cpp
+++ b/src/passes/CodeFolding.cpp
@@ -139,7 +139,7 @@ struct CodeFolding : public WalkerPass<ControlFlowWalker<CodeFolding>> {
// elements out of it if there is a value being returned)
Block* parent = controlFlowStack.back()->dynCast<Block>();
if (parent && curr == parent->list.back() &&
- !isConcreteType(parent->list.back()->type)) {
+ !parent->list.back()->type.isConcrete()) {
breakTails[curr->name].push_back(Tail(curr, parent));
} else {
unoptimizables.insert(curr->name);
@@ -189,7 +189,7 @@ struct CodeFolding : public WalkerPass<ControlFlowWalker<CodeFolding>> {
return;
}
// we can't optimize a fallthrough value
- if (isConcreteType(curr->list.back()->type)) {
+ if (curr->list.back()->type.isConcrete()) {
return;
}
auto iter = breakTails.find(curr->name);
diff --git a/src/passes/DataFlowOpts.cpp b/src/passes/DataFlowOpts.cpp
index 62d2e5f24..dc8f6ca94 100644
--- a/src/passes/DataFlowOpts.cpp
+++ b/src/passes/DataFlowOpts.cpp
@@ -103,7 +103,7 @@ struct DataFlowOpts : public WalkerPass<PostWalker<DataFlowOpts>> {
assert(!node->isConst());
// If this is a concrete value (not e.g. an eqz of unreachable),
// it can definitely be precomputed into a constant.
- if (isConcreteType(node->expr->type)) {
+ if (node->expr->type.isConcrete()) {
// This can be precomputed.
// TODO not just all-constant inputs? E.g. i32.mul of 0 and X.
optimizeExprToConstant(node);
diff --git a/src/passes/DeadArgumentElimination.cpp b/src/passes/DeadArgumentElimination.cpp
index 9ef762f98..8e1da3ac5 100644
--- a/src/passes/DeadArgumentElimination.cpp
+++ b/src/passes/DeadArgumentElimination.cpp
@@ -458,7 +458,7 @@ private:
}
} returnUpdater(func, module);
// Remove any value flowing out.
- if (isConcreteType(func->body->type)) {
+ if (func->body->type.isConcrete()) {
func->body = builder.makeDrop(func->body);
}
// Remove the drops on the calls.
diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp
index 9caf6cae8..ee7a93b72 100644
--- a/src/passes/Flatten.cpp
+++ b/src/passes/Flatten.cpp
@@ -84,7 +84,7 @@ struct Flatten
block->list.swap(newList);
// remove a block return value
auto type = block->type;
- if (isConcreteType(type)) {
+ if (type.isConcrete()) {
// if there is a temp index for breaking to the block, use that
Index temp;
auto iter = breakTemps.find(block->name);
@@ -94,7 +94,7 @@ struct Flatten
temp = builder.addVar(getFunction(), type);
}
auto*& last = block->list.back();
- if (isConcreteType(last->type)) {
+ if (last->type.isConcrete()) {
last = builder.makeLocalSet(temp, last);
}
block->finalize(none);
@@ -114,12 +114,12 @@ struct Flatten
auto* originalIfFalse = iff->ifFalse;
auto type = iff->type;
Expression* prelude = nullptr;
- if (isConcreteType(type)) {
+ if (type.isConcrete()) {
Index temp = builder.addVar(getFunction(), type);
- if (isConcreteType(iff->ifTrue->type)) {
+ if (iff->ifTrue->type.isConcrete()) {
iff->ifTrue = builder.makeLocalSet(temp, iff->ifTrue);
}
- if (iff->ifFalse && isConcreteType(iff->ifFalse->type)) {
+ if (iff->ifFalse && iff->ifFalse->type.isConcrete()) {
iff->ifFalse = builder.makeLocalSet(temp, iff->ifFalse);
}
// the whole if (+any preludes from the condition) is now a prelude
@@ -143,7 +143,7 @@ struct Flatten
Expression* rep = loop;
auto* originalBody = loop->body;
auto type = loop->type;
- if (isConcreteType(type)) {
+ if (type.isConcrete()) {
Index temp = builder.addVar(getFunction(), type);
loop->body = builder.makeLocalSet(temp, loop->body);
// and we leave just a get of the value
@@ -180,14 +180,14 @@ struct Flatten
} else if (auto* br = curr->dynCast<Break>()) {
if (br->value) {
auto type = br->value->type;
- if (isConcreteType(type)) {
+ if (type.isConcrete()) {
// we are sending a value. use a local instead
Index temp = getTempForBreakTarget(br->name, type);
ourPreludes.push_back(builder.makeLocalSet(temp, br->value));
if (br->condition) {
// the value must also flow out
ourPreludes.push_back(br);
- if (isConcreteType(br->type)) {
+ if (br->type.isConcrete()) {
replaceCurrent(builder.makeLocalGet(temp, type));
} else {
assert(br->type == unreachable);
@@ -205,7 +205,7 @@ struct Flatten
} else if (auto* sw = curr->dynCast<Switch>()) {
if (sw->value) {
auto type = sw->value->type;
- if (isConcreteType(type)) {
+ if (type.isConcrete()) {
// we are sending a value. use a local instead
Index temp = builder.addVar(getFunction(), type);
ourPreludes.push_back(builder.makeLocalSet(temp, sw->value));
@@ -266,7 +266,7 @@ struct Flatten
void visitFunction(Function* curr) {
auto* originalBody = curr->body;
// if the body is a block with a result, turn that into a return
- if (isConcreteType(curr->body->type)) {
+ if (curr->body->type.isConcrete()) {
curr->body = Builder(*getModule()).makeReturn(curr->body);
}
// the body may have preludes
diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp
index 5d7d5998c..b51858474 100644
--- a/src/passes/I64ToI32Lowering.cpp
+++ b/src/passes/I64ToI32Lowering.cpp
@@ -1504,7 +1504,7 @@ private:
std::vector<Expression*> children;
bool hasUnreachable = false;
for (auto* child : ChildIterator(curr)) {
- if (isConcreteType(child->type)) {
+ if (child->type.isConcrete()) {
child = builder->makeDrop(child);
} else if (child->type == unreachable) {
hasUnreachable = true;
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index 53a57cfeb..10b41abc0 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -190,7 +190,7 @@ struct Updater : public PostWalker<Updater> {
template<typename T> void handleReturnCall(T* curr, Type targetType) {
curr->isReturn = false;
curr->type = targetType;
- if (isConcreteType(targetType)) {
+ if (targetType.isConcrete()) {
replaceCurrent(builder->makeBreak(returnName, curr));
} else {
replaceCurrent(builder->blockify(curr, builder->makeBreak(returnName)));
@@ -226,7 +226,7 @@ doInlining(Module* module, Function* into, const InliningAction& action) {
auto* block = builder.makeBlock();
block->name = Name(std::string("__inlined_func$") + from->name.str);
if (call->isReturn) {
- if (isConcreteType(retType)) {
+ if (retType.isConcrete()) {
*action.callSite = builder.makeReturn(block);
} else {
*action.callSite = builder.makeSequence(block, builder.makeReturn());
diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp
index f3e03d95d..afd30c040 100644
--- a/src/passes/LocalCSE.cpp
+++ b/src/passes/LocalCSE.cpp
@@ -208,7 +208,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> {
if (value->is<LocalGet>()) {
return false; // trivial, this is what we optimize to!
}
- if (!isConcreteType(value->type)) {
+ if (!value->type.isConcrete()) {
return false; // don't bother with unreachable etc.
}
if (EffectAnalyzer(getPassOptions(), value).hasSideEffects()) {
diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp
index bba64c381..babbf77ba 100644
--- a/src/passes/MergeBlocks.cpp
+++ b/src/passes/MergeBlocks.cpp
@@ -164,7 +164,7 @@ struct BreakValueDropper : public ControlFlowWalker<BreakValueDropper> {
// (block (drop value) (br_if)) with type none, which does not need a drop
// likewise, unreachable does not need to be dropped, so we just leave drops
// of concrete values
- if (!isConcreteType(curr->value->type)) {
+ if (!curr->value->type.isConcrete()) {
replaceCurrent(curr->value);
}
}
@@ -240,7 +240,7 @@ optimizeBlock(Block* curr, Module* module, PassOptions& passOptions) {
// we can do it!
// reuse the drop, if we still need it
auto* last = childBlock->list.back();
- if (isConcreteType(last->type)) {
+ if (last->type.isConcrete()) {
drop->value = last;
drop->finalize();
childBlock->list.back() = drop;
@@ -281,7 +281,7 @@ optimizeBlock(Block* curr, Module* module, PassOptions& passOptions) {
if (childBlock->name.is()) {
// If it has a concrete value, then breaks may be sending it a value,
// and we'd need to handle that. TODO
- if (isConcreteType(childBlock->type)) {
+ if (childBlock->type.isConcrete()) {
continue;
}
auto childName = childBlock->name;
@@ -311,7 +311,7 @@ optimizeBlock(Block* curr, Module* module, PassOptions& passOptions) {
// value, we would need special handling for that - not worth it,
// probably TODO
// FIXME is this not handled by the drop later down?
- if (keepEnd < childSize && isConcreteType(childList.back()->type)) {
+ if (keepEnd < childSize && childList.back()->type.isConcrete()) {
continue;
}
}
@@ -362,7 +362,7 @@ optimizeBlock(Block* curr, Module* module, PassOptions& passOptions) {
if (!merged.empty()) {
auto* last = merged.back();
for (auto*& item : merged) {
- if (item != last && isConcreteType(item->type)) {
+ if (item != last && item->type.isConcrete()) {
Builder builder(*module);
item = builder.makeDrop(item);
}
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 729a42ada..64c49fc96 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -762,7 +762,7 @@ struct OptimizeInstructions
} else {
// the types diff. as the condition is reachable, that means the
// if must be concrete while the arm is not
- assert(isConcreteType(iff->type) &&
+ assert(iff->type.isConcrete() &&
iff->ifTrue->type == unreachable);
// emit a block with a forced type
auto* ret = builder.makeBlock();
@@ -1298,7 +1298,7 @@ private:
Expression* optimizeWithConstantOnRight(Binary* binary) {
auto type = binary->right->type;
auto* right = binary->right->cast<Const>();
- if (isIntegerType(type)) {
+ if (type.isInteger()) {
// operations on zero
if (right->value == Literal::makeFromInt32(0, type)) {
if (binary->op == Abstract::getBinary(type, Abstract::Shl) ||
@@ -1351,7 +1351,7 @@ private:
}
}
}
- if (isIntegerType(type) || isFloatType(type)) {
+ if (type.isInteger() || type.isFloat()) {
// note that this is correct even on floats with a NaN on the left,
// as a NaN would skip the computation and just return the NaN,
// and that is precisely what we do here. but, the same with -1
@@ -1375,7 +1375,7 @@ private:
Expression* optimizeWithConstantOnLeft(Binary* binary) {
auto type = binary->left->type;
auto* left = binary->left->cast<Const>();
- if (isIntegerType(type)) {
+ if (type.isInteger()) {
// operations on zero
if (left->value == Literal::makeFromInt32(0, type)) {
if ((binary->op == Abstract::getBinary(type, Abstract::Shl) ||
@@ -1397,7 +1397,7 @@ private:
// x + 5 == 7
// =>
// x == 2
- if (isIntegerType(binary->left->type)) {
+ if (binary->left->type.isInteger()) {
if (binary->op == Abstract::getBinary(type, Abstract::Eq) ||
binary->op == Abstract::getBinary(type, Abstract::Ne)) {
if (auto* left = binary->left->dynCast<Binary>()) {
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp
index 43ecadf7f..57a3ab27f 100644
--- a/src/passes/Precompute.cpp
+++ b/src/passes/Precompute.cpp
@@ -100,7 +100,7 @@ public:
// If we don't need to replace the whole expression, see if there
// is a value flowing through a tee.
if (!replaceExpression) {
- if (isConcreteType(curr->type)) {
+ if (curr->type.isConcrete()) {
assert(curr->isTee());
return visit(curr->value);
}
@@ -183,12 +183,12 @@ struct Precompute
// Until engines implement v128.const and we have SIMD-aware optimizations
// that can break large v128.const instructions into smaller consts and
// splats, do not try to precompute v128 expressions.
- if (isVectorType(curr->type)) {
+ if (curr->type.isVector()) {
return;
}
// try to evaluate this into a const
Flow flow = precomputeExpression(curr);
- if (isVectorType(flow.value.type)) {
+ if (flow.value.type.isVector()) {
return;
}
if (flow.breaking()) {
@@ -248,7 +248,7 @@ struct Precompute
return;
}
// this was precomputed
- if (isConcreteType(flow.value.type)) {
+ if (flow.value.type.isConcrete()) {
replaceCurrent(Builder(*getModule()).makeConst(flow.value));
worked = true;
} else {
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index bfd12dc94..f51bccf27 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -57,9 +57,7 @@ static Name printableLocal(Index index, Function* func) {
// Printing "unreachable" as a instruction prefix type is not valid in wasm text
// format. Print something else to make it pass.
-static Type forceConcrete(Type type) {
- return isConcreteType(type) ? type : i32;
-}
+static Type forceConcrete(Type type) { return type.isConcrete() ? type : i32; }
// Prints the internal contents of an expression: everything but
// the children.
@@ -77,14 +75,14 @@ struct PrintExpressionContents
o << ' ';
printName(curr->name, o);
}
- if (isConcreteType(curr->type)) {
- o << " (result " << printType(curr->type) << ')';
+ if (curr->type.isConcrete()) {
+ o << ' ' << ResultType(curr->type);
}
}
void visitIf(If* curr) {
printMedium(o, "if");
- if (isConcreteType(curr->type)) {
- o << " (result " << printType(curr->type) << ')';
+ if (curr->type.isConcrete()) {
+ o << ' ' << ResultType(curr->type);
}
}
void visitLoop(Loop* curr) {
@@ -92,8 +90,8 @@ struct PrintExpressionContents
if (curr->name.is()) {
o << ' ' << curr->name;
}
- if (isConcreteType(curr->type)) {
- o << " (result " << printType(curr->type) << ')';
+ if (curr->type.isConcrete()) {
+ o << ' ' << ResultType(curr->type);
}
}
void visitBreak(Break* curr) {
@@ -147,7 +145,7 @@ struct PrintExpressionContents
printName(curr->name, o);
}
void visitLoad(Load* curr) {
- prepareColor(o) << printType(forceConcrete(curr->type));
+ prepareColor(o) << forceConcrete(curr->type);
if (curr->isAtomic) {
o << ".atomic";
}
@@ -173,7 +171,7 @@ struct PrintExpressionContents
}
}
void visitStore(Store* curr) {
- prepareColor(o) << printType(forceConcrete(curr->valueType));
+ prepareColor(o) << forceConcrete(curr->valueType);
if (curr->isAtomic) {
o << ".atomic";
}
@@ -198,7 +196,7 @@ struct PrintExpressionContents
}
}
static void printRMWSize(std::ostream& o, Type type, uint8_t bytes) {
- prepareColor(o) << printType(forceConcrete(type)) << ".atomic.rmw";
+ prepareColor(o) << forceConcrete(type) << ".atomic.rmw";
if (type != unreachable && bytes != getTypeSize(type)) {
if (bytes == 1) {
o << '8';
@@ -257,7 +255,7 @@ struct PrintExpressionContents
}
void visitAtomicWait(AtomicWait* curr) {
prepareColor(o);
- o << printType(forceConcrete(curr->expectedType)) << ".atomic.wait";
+ o << forceConcrete(curr->expectedType) << ".atomic.wait";
if (curr->offset) {
o << " offset=" << curr->offset;
}
@@ -1306,8 +1304,8 @@ struct PrintExpressionContents
}
void visitTry(Try* curr) {
printMedium(o, "try");
- if (isConcreteType(curr->type)) {
- o << " (result " << printType(curr->type) << ')';
+ if (curr->type.isConcrete()) {
+ o << ' ' << ResultType(curr->type);
}
}
void visitThrow(Throw* curr) {
@@ -1325,7 +1323,7 @@ struct PrintExpressionContents
void visitUnreachable(Unreachable* curr) { printMinor(o, "unreachable"); }
void visitPush(Push* curr) { prepareColor(o) << "push"; }
void visitPop(Pop* curr) {
- prepareColor(o) << printType(curr->type);
+ prepareColor(o) << curr->type;
o << ".pop";
restoreNormalColor(o);
}
@@ -1413,7 +1411,7 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
void printFullLine(Expression* expression) {
!minify && doIndent(o, indent);
if (full) {
- o << "[" << printType(expression->type) << "] ";
+ o << "[" << expression->type << "] ";
}
visit(expression);
o << maybeNewLine;
@@ -1444,7 +1442,7 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
}
stack.push_back(curr);
if (full) {
- o << "[" << printType(curr->type) << "] ";
+ o << "[" << curr->type << "] ";
}
o << '(';
PrintExpressionContents(currFunction, o).visit(curr);
@@ -1872,17 +1870,11 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
}
if (curr->params.size() > 0) {
o << maybeSpace;
- o << '(';
- printMinor(o, "param");
- for (auto& param : curr->params) {
- o << ' ' << printType(param);
- }
- o << ')';
+ o << ParamType(Type(curr->params));
}
if (curr->result != none) {
o << maybeSpace;
- o << '(';
- printMinor(o, "result ") << printType(curr->result) << ')';
+ o << ResultType(curr->result);
}
o << ")";
}
@@ -1926,9 +1918,9 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
}
void emitGlobalType(Global* curr) {
if (curr->mutable_) {
- o << "(mut " << printType(curr->type) << ')';
+ o << "(mut " << curr->type << ')';
} else {
- o << printType(curr->type);
+ o << curr->type;
}
}
void visitImportedGlobal(Global* curr) {
@@ -2002,20 +1994,19 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
o << maybeSpace;
o << '(';
printMinor(o, "param ") << printableLocal(i, currFunction) << ' '
- << printType(curr->getLocalType(i)) << ')';
+ << curr->getLocalType(i) << ')';
}
}
if (curr->result != none) {
o << maybeSpace;
- o << '(';
- printMinor(o, "result ") << printType(curr->result) << ')';
+ o << ResultType(curr->result);
}
incIndent();
for (size_t i = curr->getVarIndexBase(); i < curr->getNumLocals(); i++) {
doIndent(o, indent);
o << '(';
printMinor(o, "local ") << printableLocal(i, currFunction) << ' '
- << printType(curr->getLocalType(i)) << ')';
+ << curr->getLocalType(i) << ')';
o << maybeNewLine;
}
// Print the body.
@@ -2064,12 +2055,9 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
emitImportHeader(curr);
o << "(event ";
printName(curr->name, o);
- o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace << '(';
- printMinor(o, "param");
- for (auto& param : curr->params) {
- o << ' ' << printType(param);
- }
- o << ")))";
+ o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace;
+ o << ParamType(Type(curr->params));
+ o << "))";
o << maybeNewLine;
}
void visitDefinedEvent(Event* curr) {
@@ -2077,12 +2065,9 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
o << '(';
printMedium(o, "event ");
printName(curr->name, o);
- o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace << '(';
- printMinor(o, "param");
- for (auto& param : curr->params) {
- o << ' ' << printType(param);
- }
- o << "))" << maybeNewLine;
+ o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace;
+ o << ParamType(Type(curr->params));
+ o << ")" << maybeNewLine;
}
void printTableHeader(Table* curr) {
o << '(';
@@ -2372,7 +2357,7 @@ std::ostream& WasmPrinter::printExpression(Expression* expression,
print.setMinify(minify);
if (full || isFullForced()) {
print.setFull(true);
- o << "[" << printType(expression->type) << "] ";
+ o << "[" << expression->type << "] ";
}
print.visit(expression);
return o;
@@ -2394,7 +2379,7 @@ WasmPrinter::printStackInst(StackInst* inst, std::ostream& o, Function* func) {
case StackInst::BlockEnd:
case StackInst::IfEnd:
case StackInst::LoopEnd: {
- o << "end (" << printType(inst->type) << ')';
+ o << "end (" << inst->type << ')';
break;
}
case StackInst::IfElse: {
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index 7f3a9965d..d8668196d 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -435,7 +435,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
// append to the other, if there is no returned value to concern us
// can't be, since in the middle of a block
- assert(!isConcreteType(iff->type));
+ assert(!iff->type.isConcrete());
// ensures the first node is a block, if it isn't already, and merges
// in the second, either as a single element or, if a block, by
@@ -454,7 +454,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
if (!block || block->name.is()) {
block = builder.makeBlock(any);
} else {
- assert(!isConcreteType(block->type));
+ assert(!block->type.isConcrete());
}
auto* other = append->dynCast<Block>();
if (!other) {
@@ -910,8 +910,8 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
// Convert an if into a select, if possible and beneficial to do so.
Select* selectify(If* iff) {
- if (!iff->ifFalse || !isConcreteType(iff->ifTrue->type) ||
- !isConcreteType(iff->ifFalse->type)) {
+ if (!iff->ifFalse || !iff->ifTrue->type.isConcrete() ||
+ !iff->ifFalse->type.isConcrete()) {
return nullptr;
}
// This is always helpful for code size, but can be a tradeoff with
@@ -972,8 +972,8 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
bool optimizeSetIfWithBrArm(Expression** currp) {
auto* set = (*currp)->cast<LocalSet>();
auto* iff = set->value->dynCast<If>();
- if (!iff || !isConcreteType(iff->type) ||
- !isConcreteType(iff->condition->type)) {
+ if (!iff || !iff->type.isConcrete() ||
+ !iff->condition->type.isConcrete()) {
return false;
}
auto tryToOptimize =
@@ -1047,8 +1047,8 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
bool optimizeSetIfWithCopyArm(Expression** currp) {
auto* set = (*currp)->cast<LocalSet>();
auto* iff = set->value->dynCast<If>();
- if (!iff || !isConcreteType(iff->type) ||
- !isConcreteType(iff->condition->type)) {
+ if (!iff || !iff->type.isConcrete() ||
+ !iff->condition->type.isConcrete()) {
return false;
}
Builder builder(*getModule());
diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp
index 169c129b4..f29a1cf66 100644
--- a/src/passes/SafeHeap.cpp
+++ b/src/passes/SafeHeap.cpp
@@ -41,7 +41,7 @@ static const Name ALIGNFAULT_IMPORT("alignfault");
static Name getLoadName(Load* curr) {
std::string ret = "SAFE_HEAP_LOAD_";
- ret += printType(curr->type);
+ ret += curr->type.toString();
ret += "_" + std::to_string(curr->bytes) + "_";
if (LoadUtils::isSignRelevant(curr) && !curr->signed_) {
ret += "U_";
@@ -56,7 +56,7 @@ static Name getLoadName(Load* curr) {
static Name getStoreName(Store* curr) {
std::string ret = "SAFE_HEAP_STORE_";
- ret += printType(curr->valueType);
+ ret += curr->valueType.toString();
ret += "_" + std::to_string(curr->bytes) + "_";
if (curr->isAtomic) {
ret += "A";
@@ -170,7 +170,7 @@ struct SafeHeap : public Pass {
bool
isPossibleAtomicOperation(Index align, Index bytes, bool shared, Type type) {
- return align == bytes && shared && isIntegerType(type);
+ return align == bytes && shared && type.isInteger();
}
void addGlobals(Module* module, FeatureSet features) {
@@ -189,7 +189,7 @@ struct SafeHeap : public Pass {
}
for (auto signed_ : {true, false}) {
load.signed_ = signed_;
- if (isFloatType(type) && signed_) {
+ if (type.isFloat() && signed_) {
continue;
}
for (Index align : {1, 2, 4, 8, 16}) {
diff --git a/src/passes/Souperify.cpp b/src/passes/Souperify.cpp
index 199db727e..c5dca51fa 100644
--- a/src/passes/Souperify.cpp
+++ b/src/passes/Souperify.cpp
@@ -254,7 +254,7 @@ struct Trace {
(node != toInfer &&
excludeAsChildren.find(node) != excludeAsChildren.end())) {
auto type = node->getWasmType();
- assert(isConcreteType(type));
+ assert(type.isConcrete());
auto* var = Node::makeVar(type);
replacements[node] = std::unique_ptr<Node>(var);
node = var;
@@ -458,8 +458,7 @@ struct Printer {
assert(node);
switch (node->type) {
case Node::Type::Var: {
- std::cout << "%" << indexing[node] << ":" << printType(node->wasmType)
- << " = var";
+ std::cout << "%" << indexing[node] << ":" << node->wasmType << " = var";
break; // nothing more to add
}
case Node::Type::Expr: {
@@ -496,8 +495,7 @@ struct Printer {
}
case Node::Type::Zext: {
auto* child = node->getValue(0);
- std::cout << "%" << indexing[node] << ':'
- << printType(child->getWasmType());
+ std::cout << "%" << indexing[node] << ':' << child->getWasmType();
std::cout << " = zext ";
printInternal(child);
break;
@@ -523,7 +521,7 @@ struct Printer {
}
void print(Literal value) {
- std::cout << value.getInteger() << ':' << printType(value.type);
+ std::cout << value.getInteger() << ':' << value.type;
}
void printInternal(Node* node) {
diff --git a/src/passes/StackIR.cpp b/src/passes/StackIR.cpp
index 52ea061a3..2434c44f6 100644
--- a/src/passes/StackIR.cpp
+++ b/src/passes/StackIR.cpp
@@ -169,7 +169,7 @@ private:
values.clear();
}
// This is something we should handle, look into it.
- if (isConcreteType(inst->type)) {
+ if (inst->type.isConcrete()) {
bool optimized = false;
if (auto* get = inst->origin->dynCast<LocalGet>()) {
// This is a potential optimization opportunity! See if we
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp
index 82d904701..d97ce461b 100644
--- a/src/passes/Vacuum.cpp
+++ b/src/passes/Vacuum.cpp
@@ -216,11 +216,11 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> {
auto* child = list[z];
// The last element may be used.
bool used =
- z == size - 1 && isConcreteType(curr->type) &&
+ z == size - 1 && curr->type.isConcrete() &&
ExpressionAnalyzer::isResultUsed(expressionStack, getFunction());
auto* optimized = optimize(child, used, true);
if (!optimized) {
- if (isConcreteType(child->type)) {
+ if (child->type.isConcrete()) {
// We can't just skip a final concrete element, even if it isn't used.
// Instead, replace it with something that's easy to optimize out (for
// example, code-folding can merge out identical zeros at the end of
@@ -357,7 +357,7 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> {
// note that the last element may be concrete but not the block, if the
// block has an unreachable element in the middle, making the block
// unreachable despite later elements and in particular the last
- if (isConcreteType(last->type) && block->type == last->type) {
+ if (last->type.isConcrete() && block->type == last->type) {
last = optimize(last, false, false);
if (!last) {
// we may be able to remove this, if there are no brs
@@ -393,16 +393,15 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> {
// unreachable, as it if is a branch, this can make that branch optimizable
// and more vaccuming possible
auto* iff = curr->value->dynCast<If>();
- if (iff && iff->ifFalse && isConcreteType(iff->type)) {
+ if (iff && iff->ifFalse && iff->type.isConcrete()) {
// reuse the drop in both cases
- if (iff->ifTrue->type == unreachable &&
- isConcreteType(iff->ifFalse->type)) {
+ if (iff->ifTrue->type == unreachable && iff->ifFalse->type.isConcrete()) {
curr->value = iff->ifFalse;
iff->ifFalse = curr;
iff->type = none;
replaceCurrent(iff);
} else if (iff->ifFalse->type == unreachable &&
- isConcreteType(iff->ifTrue->type)) {
+ iff->ifTrue->type.isConcrete()) {
curr->value = iff->ifTrue;
iff->ifTrue = curr;
iff->type = none;