diff options
Diffstat (limited to 'src/passes')
-rw-r--r-- | src/passes/CoalesceLocals.cpp | 2 | ||||
-rw-r--r-- | src/passes/CodeFolding.cpp | 4 | ||||
-rw-r--r-- | src/passes/ConstHoisting.cpp | 2 | ||||
-rw-r--r-- | src/passes/DeadCodeElimination.cpp | 2 | ||||
-rw-r--r-- | src/passes/Flatten.cpp | 22 | ||||
-rw-r--r-- | src/passes/I64ToI32Lowering.cpp | 12 | ||||
-rw-r--r-- | src/passes/LocalCSE.cpp | 2 | ||||
-rw-r--r-- | src/passes/MergeBlocks.cpp | 4 | ||||
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 6 | ||||
-rw-r--r-- | src/passes/Precompute.cpp | 2 | ||||
-rw-r--r-- | src/passes/Print.cpp | 46 | ||||
-rw-r--r-- | src/passes/RemoveImports.cpp | 2 | ||||
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 8 | ||||
-rw-r--r-- | src/passes/SSAify.cpp | 2 | ||||
-rw-r--r-- | src/passes/SafeHeap.cpp | 16 | ||||
-rw-r--r-- | src/passes/SpillPointers.cpp | 8 | ||||
-rw-r--r-- | src/passes/TrapMode.cpp | 8 | ||||
-rw-r--r-- | src/passes/Vacuum.cpp | 10 |
18 files changed, 79 insertions, 79 deletions
diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index b6c96902b..e5c5585f4 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -201,7 +201,7 @@ void CoalesceLocals::pickIndicesFromOrder(std::vector<Index>& order, std::vector } #endif // TODO: take into account distribution (99-1 is better than 50-50 with two registers, for gzip) - std::vector<WasmType> types; + std::vector<Type> types; std::vector<bool> newInterferences; // new index * numLocals => list of all interferences of locals merged to it std::vector<uint8_t> newCopies; // new index * numLocals => list of all copies of locals merged to it indices.resize(numLocals); diff --git a/src/passes/CodeFolding.cpp b/src/passes/CodeFolding.cpp index 05ae93f73..c2ad07595 100644 --- a/src/passes/CodeFolding.cpp +++ b/src/passes/CodeFolding.cpp @@ -132,7 +132,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() && - !isConcreteWasmType(parent->list.back()->type)) { + !isConcreteType(parent->list.back()->type)) { breakTails[curr->name].push_back(Tail(curr, parent)); } else { unoptimizables.insert(curr->name); @@ -175,7 +175,7 @@ struct CodeFolding : public WalkerPass<ControlFlowWalker<CodeFolding>> { if (!curr->name.is()) return; if (unoptimizables.count(curr->name) > 0) return; // we can't optimize a fallthrough value - if (isConcreteWasmType(curr->list.back()->type)) { + if (isConcreteType(curr->list.back()->type)) { return; } auto iter = breakTails.find(curr->name); diff --git a/src/passes/ConstHoisting.cpp b/src/passes/ConstHoisting.cpp index bddc0b5c5..e808f7af4 100644 --- a/src/passes/ConstHoisting.cpp +++ b/src/passes/ConstHoisting.cpp @@ -84,7 +84,7 @@ private: } case f32: case f64: { - size = getWasmTypeSize(value.type); + size = getTypeSize(value.type); break; } default: WASM_UNREACHABLE(); diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp index 97c63baf5..a2f3b895c 100644 --- a/src/passes/DeadCodeElimination.cpp +++ b/src/passes/DeadCodeElimination.cpp @@ -331,7 +331,7 @@ struct DeadCodeElimination : public WalkerPass<PostWalker<DeadCodeElimination>> // Append the reachable operands of the current node to a block, and replace // it with the block - void blockifyReachableOperands(std::vector<Expression*>&& list, WasmType type) { + void blockifyReachableOperands(std::vector<Expression*>&& list, Type type) { for (size_t i = 0; i < list.size(); ++i) { auto* elem = list[i]; if (isUnreachable(elem)) { diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp index 53fd6a02b..b3266e89b 100644 --- a/src/passes/Flatten.cpp +++ b/src/passes/Flatten.cpp @@ -109,7 +109,7 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress block->list.swap(newList); // remove a block return value auto type = block->type; - if (isConcreteWasmType(type)) { + if (isConcreteType(type)) { // if there is a temp index for breaking to the block, use that Index temp; auto iter = breakTemps.find(block->name); @@ -119,7 +119,7 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress temp = builder.addVar(getFunction(), type); } auto*& last = block->list.back(); - if (isConcreteWasmType(last->type)) { + if (isConcreteType(last->type)) { last = builder.makeSetLocal(temp, last); } block->finalize(none); @@ -139,12 +139,12 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress auto* originalIfFalse = iff->ifFalse; auto type = iff->type; Expression* prelude = nullptr; - if (isConcreteWasmType(type)) { + if (isConcreteType(type)) { Index temp = builder.addVar(getFunction(), type); - if (isConcreteWasmType(iff->ifTrue->type)) { + if (isConcreteType(iff->ifTrue->type)) { iff->ifTrue = builder.makeSetLocal(temp, iff->ifTrue); } - if (iff->ifFalse && isConcreteWasmType(iff->ifFalse->type)) { + if (iff->ifFalse && isConcreteType(iff->ifFalse->type)) { iff->ifFalse = builder.makeSetLocal(temp, iff->ifFalse); } // the whole if (+any preludes from the condition) is now a prelude @@ -165,7 +165,7 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress Expression* rep = loop; auto* originalBody = loop->body; auto type = loop->type; - if (isConcreteWasmType(type)) { + if (isConcreteType(type)) { Index temp = builder.addVar(getFunction(), type); loop->body = builder.makeSetLocal(temp, loop->body); // and we leave just a get of the value @@ -202,14 +202,14 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress } else if (auto* br = curr->dynCast<Break>()) { if (br->value) { auto type = br->value->type; - if (isConcreteWasmType(type)) { + if (isConcreteType(type)) { // we are sending a value. use a local instead Index temp = getTempForBreakTarget(br->name, type); ourPreludes.push_back(builder.makeSetLocal(temp, br->value)); if (br->condition) { // the value must also flow out ourPreludes.push_back(br); - if (isConcreteWasmType(br->type)) { + if (isConcreteType(br->type)) { replaceCurrent(builder.makeGetLocal(temp, type)); } else { assert(br->type == unreachable); @@ -227,7 +227,7 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress } else if (auto* sw = curr->dynCast<Switch>()) { if (sw->value) { auto type = sw->value->type; - if (isConcreteWasmType(type)) { + if (isConcreteType(type)) { // we are sending a value. use a local instead Index temp = builder.addVar(getFunction(), type); ourPreludes.push_back(builder.makeSetLocal(temp, sw->value)); @@ -299,7 +299,7 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress void visitFunction(Function* curr) { auto* originalBody = curr->body; // if the body is a block with a result, turn that into a return - if (isConcreteWasmType(curr->body->type)) { + if (isConcreteType(curr->body->type)) { curr->body = Builder(*getModule()).makeReturn(curr->body); } // the body may have preludes @@ -333,7 +333,7 @@ private: // get the temp local to be used for breaks to that target. allocates // one if there isn't one yet - Index getTempForBreakTarget(Name name, WasmType type) { + Index getTempForBreakTarget(Name name, Type type) { auto iter = breakTemps.find(name); if (iter != breakTemps.end()) { return iter->second; diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp index e617c3b83..4135cb154 100644 --- a/src/passes/I64ToI32Lowering.cpp +++ b/src/passes/I64ToI32Lowering.cpp @@ -113,7 +113,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } void visitFunctionType(FunctionType* curr) { - std::vector<WasmType> params; + std::vector<Type> params; for (auto t : curr->params) { if (t == i64) { params.push_back(i32); @@ -146,10 +146,10 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { assert(oldFunc.hasLocalName(i)); Name lowName = oldFunc.getLocalName(i); Name highName = makeHighName(lowName); - WasmType paramType = oldFunc.getLocalType(i); + Type paramType = oldFunc.getLocalType(i); auto builderFunc = (i < oldFunc.getVarIndexBase()) ? Builder::addParam : - static_cast<Index (*)(Function*, Name, WasmType)>(Builder::addVar); + static_cast<Index (*)(Function*, Name, Type)>(Builder::addVar); if (paramType == i64) { builderFunc(func, lowName, i32); builderFunc(func, highName, i32); @@ -312,7 +312,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } template <typename T> - using BuilderFunc = std::function<T*(std::vector<Expression*>&, WasmType)>; + using BuilderFunc = std::function<T*(std::vector<Expression*>&, Type)>; template <typename T> void visitGenericCall(T* curr, BuilderFunc<T> callBuilder) { @@ -346,7 +346,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { void visitCall(Call* curr) { visitGenericCall<Call>( curr, - [&](std::vector<Expression*>& args, WasmType ty) { + [&](std::vector<Expression*>& args, Type ty) { return builder->makeCall(curr->target, args, ty); } ); @@ -360,7 +360,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { void visitCallIndirect(CallIndirect* curr) { visitGenericCall<CallIndirect>( curr, - [&](std::vector<Expression*>& args, WasmType ty) { + [&](std::vector<Expression*>& args, Type ty) { return builder->makeCallIndirect( curr->fullType, curr->target, diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp index 7b27e06d3..7524ad0fa 100644 --- a/src/passes/LocalCSE.cpp +++ b/src/passes/LocalCSE.cpp @@ -118,7 +118,7 @@ struct LocalCSE : public WalkerPass<LinearExecutionWalker<LocalCSE>> { if (curr->is<GetLocal>()) { return false; // trivial, this is what we optimize to! } - if (!isConcreteWasmType(curr->type)) { + if (!isConcreteType(curr->type)) { return false; // don't bother with unreachable etc. } if (EffectAnalyzer(getPassOptions(), curr).hasSideEffects()) { diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp index 798ad927f..2f59de539 100644 --- a/src/passes/MergeBlocks.cpp +++ b/src/passes/MergeBlocks.cpp @@ -148,7 +148,7 @@ struct BreakValueDropper : public ControlFlowWalker<BreakValueDropper> { void visitDrop(Drop* curr) { // if we dropped a br_if whose value we removed, then we are now dropping a (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 (!isConcreteWasmType(curr->value->type)) { + if (!isConcreteType(curr->value->type)) { replaceCurrent(curr->value); } } @@ -228,7 +228,7 @@ static void optimizeBlock(Block* curr, Module* module, PassOptions& passOptions) if (!merged.empty()) { auto* last = merged.back(); for (auto*& item : merged) { - if (item != last && isConcreteWasmType(item->type)) { + if (item != last && isConcreteType(item->type)) { Builder builder(*module); item = builder.makeDrop(item); } diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index efea99247..7bd7aaa51 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -116,7 +116,7 @@ struct Match { if (!call || call->operands.size() != 1 || call->operands[0]->type != i32 || !call->operands[0]->is<Const>()) return false; Index index = call->operands[0]->cast<Const>()->value.geti32(); // handle our special functions - auto checkMatch = [&](WasmType type) { + auto checkMatch = [&](Type type) { if (type != none && subSeen->type != type) return false; while (index >= wildcards.size()) { wildcards.push_back(nullptr); @@ -338,7 +338,7 @@ struct LocalScanner : PostWalker<LocalScanner> { return getBitsForType(get->type); } - Index getBitsForType(WasmType type) { + Index getBitsForType(Type type) { switch (type) { case i32: return 32; case i64: return 64; @@ -704,7 +704,7 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions, } else { // the types diff. as the condition is reachable, that means the if must be // concrete while the arm is not - assert(isConcreteWasmType(iff->type) && iff->ifTrue->type == unreachable); + assert(isConcreteType(iff->type) && iff->ifTrue->type == unreachable); // emit a block with a forced type auto* ret = builder.makeBlock(); if (needCondition) { diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp index 68133edca..ed3d51701 100644 --- a/src/passes/Precompute.cpp +++ b/src/passes/Precompute.cpp @@ -181,7 +181,7 @@ struct Precompute : public WalkerPass<PostWalker<Precompute, UnifiedExpressionVi return; } // this was precomputed - if (isConcreteWasmType(flow.value.type)) { + if (isConcreteType(flow.value.type)) { replaceCurrent(Builder(*getModule()).makeConst(flow.value)); } else { ExpressionManipulator::nop(curr); diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 66b0fa8f5..700ddf734 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -95,7 +95,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { void printFullLine(Expression *expression) { !minify && doIndent(o, indent); if (full) { - o << "[" << printWasmType(expression->type) << "] "; + o << "[" << printType(expression->type) << "] "; } visit(expression); o << maybeNewLine; @@ -129,15 +129,15 @@ struct PrintSExpression : public Visitor<PrintSExpression> { if (stack.size() > 0) doIndent(o, indent); stack.push_back(curr); if (full) { - o << "[" << printWasmType(curr->type) << "] "; + o << "[" << printType(curr->type) << "] "; } printOpening(o, "block"); if (curr->name.is()) { o << ' '; printName(curr->name); } - if (isConcreteWasmType(curr->type)) { - o << " (result " << printWasmType(curr->type) << ')'; + if (isConcreteType(curr->type)) { + o << " (result " << printType(curr->type) << ')'; } incIndent(); if (curr->list.size() > 0 && curr->list[0]->is<Block>()) { @@ -167,8 +167,8 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } void visitIf(If *curr) { printOpening(o, "if"); - if (isConcreteWasmType(curr->type)) { - o << " (result " << printWasmType(curr->type) << ')'; + if (isConcreteType(curr->type)) { + o << " (result " << printType(curr->type) << ')'; } incIndent(); printFullLine(curr->condition); @@ -192,8 +192,8 @@ struct PrintSExpression : public Visitor<PrintSExpression> { if (curr->name.is()) { o << ' ' << curr->name; } - if (isConcreteWasmType(curr->type)) { - o << " (result " << printWasmType(curr->type) << ')'; + if (isConcreteType(curr->type)) { + o << " (result " << printType(curr->type) << ')'; } incIndent(); auto block = curr->body->dynCast<Block>(); @@ -299,7 +299,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } void visitLoad(Load *curr) { o << '('; - prepareColor(o) << printWasmType(curr->type); + prepareColor(o) << printType(curr->type); if (curr->isAtomic) o << ".atomic"; o << ".load"; if (curr->bytes < 4 || (curr->type == i64 && curr->bytes < 8)) { @@ -327,7 +327,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } void visitStore(Store *curr) { o << '('; - prepareColor(o) << printWasmType(curr->valueType); + prepareColor(o) << printType(curr->valueType); if (curr->isAtomic) o << ".atomic"; o << ".store"; if (curr->bytes < 4 || (curr->valueType == i64 && curr->bytes < 8)) { @@ -353,11 +353,11 @@ struct PrintSExpression : public Visitor<PrintSExpression> { printFullLine(curr->value); decIndent(); } - static void printRMWSize(std::ostream& o, WasmType type, uint8_t bytes) { - prepareColor(o) << printWasmType(type) << ".atomic.rmw"; + static void printRMWSize(std::ostream& o, Type type, uint8_t bytes) { + prepareColor(o) << printType(type) << ".atomic.rmw"; if (type == unreachable) { o << '?'; - } else if (bytes != getWasmTypeSize(type)) { + } else if (bytes != getTypeSize(type)) { if (bytes == 1) { o << '8'; } else if (bytes == 2) { @@ -410,7 +410,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { void visitAtomicWait(AtomicWait* curr) { o << '(' ; prepareColor(o); - o << printWasmType(curr->expectedType) << ".wait"; + o << printType(curr->expectedType) << ".wait"; if (curr->offset) { o << " offset=" << curr->offset; } @@ -643,13 +643,13 @@ struct PrintSExpression : public Visitor<PrintSExpression> { o << maybeSpace; printMinorOpening(o, "param"); for (auto& param : curr->params) { - o << ' ' << printWasmType(param); + o << ' ' << printType(param); } o << ')'; } if (curr->result != none) { o << maybeSpace; - printMinorOpening(o, "result ") << printWasmType(curr->result) << ')'; + printMinorOpening(o, "result ") << printType(curr->result) << ')'; } o << ")"; } @@ -661,7 +661,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { case ExternalKind::Function: if (curr->functionType.is()) visitFunctionType(currModule->getFunctionType(curr->functionType), &curr->name); break; case ExternalKind::Table: printTableHeader(&currModule->table); break; case ExternalKind::Memory: printMemoryHeader(&currModule->memory); break; - case ExternalKind::Global: o << "(global " << curr->name << ' ' << printWasmType(curr->globalType) << ")"; break; + case ExternalKind::Global: o << "(global " << curr->name << ' ' << printType(curr->globalType) << ")"; break; default: WASM_UNREACHABLE(); } o << ')'; @@ -683,9 +683,9 @@ struct PrintSExpression : public Visitor<PrintSExpression> { printOpening(o, "global "); printName(curr->name) << ' '; if (curr->mutable_) { - o << "(mut " << printWasmType(curr->type) << ") "; + o << "(mut " << printType(curr->type) << ") "; } else { - o << printWasmType(curr->type) << ' '; + o << printType(curr->type) << ' '; } visit(curr->init); o << ')'; @@ -709,17 +709,17 @@ struct PrintSExpression : public Visitor<PrintSExpression> { if (curr->params.size() > 0) { for (size_t i = 0; i < curr->params.size(); i++) { o << maybeSpace; - printMinorOpening(o, "param ") << printableLocal(i) << ' ' << printWasmType(curr->getLocalType(i)) << ')'; + printMinorOpening(o, "param ") << printableLocal(i) << ' ' << printType(curr->getLocalType(i)) << ')'; } } if (curr->result != none) { o << maybeSpace; - printMinorOpening(o, "result ") << printWasmType(curr->result) << ')'; + printMinorOpening(o, "result ") << printType(curr->result) << ')'; } incIndent(); for (size_t i = curr->getVarIndexBase(); i < curr->getNumLocals(); i++) { doIndent(o, indent); - printMinorOpening(o, "local ") << printableLocal(i) << ' ' << printWasmType(curr->getLocalType(i)) << ')'; + printMinorOpening(o, "local ") << printableLocal(i) << ' ' << printType(curr->getLocalType(i)) << ')'; o << maybeNewLine; } // It is ok to emit a block here, as a function can directly contain a list, even if our @@ -913,7 +913,7 @@ std::ostream& WasmPrinter::printExpression(Expression* expression, std::ostream& print.setMinify(minify); if (full || isFullForced()) { print.setFull(true); - o << "[" << printWasmType(expression->type) << "] "; + o << "[" << printType(expression->type) << "] "; } print.visit(expression); return o; diff --git a/src/passes/RemoveImports.cpp b/src/passes/RemoveImports.cpp index 6de151230..116cd3296 100644 --- a/src/passes/RemoveImports.cpp +++ b/src/passes/RemoveImports.cpp @@ -29,7 +29,7 @@ namespace wasm { struct RemoveImports : public WalkerPass<PostWalker<RemoveImports>> { void visitCallImport(CallImport *curr) { - WasmType type = getModule()->getFunctionType(getModule()->getImport(curr->target)->functionType)->result; + Type type = getModule()->getFunctionType(getModule()->getImport(curr->target)->functionType)->result; if (type == none) { replaceCurrent(getModule()->allocator.alloc<Nop>()); } else { diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 9145e5e2c..8bf1588e0 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -260,7 +260,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { } else { // this is already an if-else. if one side is a dead end, we can append to the other, if // there is no returned value to concern us - assert(!isConcreteWasmType(iff->type)); // can't be, since in the middle of a block + assert(!isConcreteType(iff->type)); // can't be, since in the middle of a block // 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 appending to the first block. this @@ -275,7 +275,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { if (!block || block->name.is()) { block = builder.makeBlock(any); } else { - assert(!isConcreteWasmType(block->type)); + assert(!isConcreteType(block->type)); } auto* other = append->dynCast<Block>(); if (!other) { @@ -461,7 +461,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { auto& list = curr->list; for (Index i = 0; i < list.size(); i++) { auto* iff = list[i]->dynCast<If>(); - if (!iff || !iff->ifFalse || isConcreteWasmType(iff->type)) continue; // if it lacked an if-false, it would already be a br_if, as that's the easy case + if (!iff || !iff->ifFalse || isConcreteType(iff->type)) continue; // if it lacked an if-false, it would already be a br_if, as that's the easy case auto* ifTrueBreak = iff->ifTrue->dynCast<Break>(); if (ifTrueBreak && !ifTrueBreak->condition && canTurnIfIntoBrIf(iff->condition, ifTrueBreak->value, passOptions)) { // we are an if-else where the ifTrue is a break without a condition, so we can do this @@ -542,7 +542,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { // we may have simplified ifs enough to turn them into selects // this is helpful for code size, but can be a tradeoff with performance as we run both code paths if (!shrink) return; - if (curr->ifFalse && isConcreteWasmType(curr->ifTrue->type) && isConcreteWasmType(curr->ifFalse->type)) { + if (curr->ifFalse && isConcreteType(curr->ifTrue->type) && isConcreteType(curr->ifFalse->type)) { // if with else, consider turning it into a select if there is no control flow // TODO: estimate cost EffectAnalyzer condition(passOptions, curr->condition); diff --git a/src/passes/SSAify.cpp b/src/passes/SSAify.cpp index 5271087a9..9c680b942 100644 --- a/src/passes/SSAify.cpp +++ b/src/passes/SSAify.cpp @@ -167,7 +167,7 @@ struct SSAify : public Pass { } } - Index addLocal(WasmType type) { + Index addLocal(Type type) { return Builder::addVar(func, type); } diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp index 3349f983a..61db334a0 100644 --- a/src/passes/SafeHeap.cpp +++ b/src/passes/SafeHeap.cpp @@ -36,9 +36,9 @@ const Name DYNAMICTOP_PTR_IMPORT("DYNAMICTOP_PTR"), static Name getLoadName(Load* curr) { std::string ret = "SAFE_HEAP_LOAD_"; - ret += printWasmType(curr->type); + ret += printType(curr->type); ret += "_" + std::to_string(curr->bytes) + "_"; - if (!isWasmTypeFloat(curr->type) && !curr->signed_) { + if (!isTypeFloat(curr->type) && !curr->signed_) { ret += "U_"; } if (curr->isAtomic) { @@ -51,7 +51,7 @@ static Name getLoadName(Load* curr) { static Name getStoreName(Store* curr) { std::string ret = "SAFE_HEAP_STORE_"; - ret += printWasmType(curr->valueType); + ret += printType(curr->valueType); ret += "_" + std::to_string(curr->bytes) + "_"; if (curr->isAtomic) { ret += "A"; @@ -157,10 +157,10 @@ struct SafeHeap : public Pass { load.type = type; for (Index bytes : { 1, 2, 4, 8 }) { load.bytes = bytes; - if (bytes > getWasmTypeSize(type)) continue; + if (bytes > getTypeSize(type)) continue; for (auto signed_ : { true, false }) { load.signed_ = signed_; - if (isWasmTypeFloat(type) && signed_) continue; + if (isTypeFloat(type) && signed_) continue; for (Index align : { 1, 2, 4, 8 }) { load.align = align; if (align > bytes) continue; @@ -181,7 +181,7 @@ struct SafeHeap : public Pass { store.type = none; for (Index bytes : { 1, 2, 4, 8 }) { store.bytes = bytes; - if (bytes > getWasmTypeSize(valueType)) continue; + if (bytes > getTypeSize(valueType)) continue; for (Index align : { 1, 2, 4, 8 }) { store.align = align; if (align > bytes) continue; @@ -295,7 +295,7 @@ struct SafeHeap : public Pass { ); } - Expression* makeBoundsCheck(WasmType type, Builder& builder, Index local) { + Expression* makeBoundsCheck(Type type, Builder& builder, Index local) { return builder.makeIf( builder.makeBinary( OrInt32, @@ -309,7 +309,7 @@ struct SafeHeap : public Pass { builder.makeBinary( AddInt32, builder.makeGetLocal(local, i32), - builder.makeConst(Literal(int32_t(getWasmTypeSize(type)))) + builder.makeConst(Literal(int32_t(getTypeSize(type)))) ), builder.makeLoad(4, false, 0, 4, builder.makeGetGlobal(dynamicTopPtr, i32), i32 diff --git a/src/passes/SpillPointers.cpp b/src/passes/SpillPointers.cpp index 492a90501..d65c89d3e 100644 --- a/src/passes/SpillPointers.cpp +++ b/src/passes/SpillPointers.cpp @@ -83,7 +83,7 @@ struct SpillPointers : public WalkerPass<LivenessWalker<SpillPointers, Visitor<S PointerMap pointerMap; for (Index i = 0; i < func->getNumLocals(); i++) { if (func->getLocalType(i) == ABI::PointerType) { - auto offset = pointerMap.size() * getWasmTypeSize(ABI::PointerType); + auto offset = pointerMap.size() * getTypeSize(ABI::PointerType); pointerMap[i] = offset; } } @@ -136,7 +136,7 @@ struct SpillPointers : public WalkerPass<LivenessWalker<SpillPointers, Visitor<S } if (spilled) { // get the stack space, and set the local to it - ABI::getStackSpace(spillLocal, func, getWasmTypeSize(ABI::PointerType) * pointerMap.size(), *getModule()); + ABI::getStackSpace(spillLocal, func, getTypeSize(ABI::PointerType) * pointerMap.size(), *getModule()); } } @@ -176,9 +176,9 @@ struct SpillPointers : public WalkerPass<LivenessWalker<SpillPointers, Visitor<S // add the spills for (auto index : toSpill) { block->list.push_back(builder.makeStore( - getWasmTypeSize(ABI::PointerType), + getTypeSize(ABI::PointerType), pointerMap[index], - getWasmTypeSize(ABI::PointerType), + getTypeSize(ABI::PointerType), builder.makeGetLocal(spillLocal, ABI::PointerType), builder.makeGetLocal(index, ABI::PointerType), ABI::PointerType diff --git a/src/passes/TrapMode.cpp b/src/passes/TrapMode.cpp index 727d61102..68d6aad4b 100644 --- a/src/passes/TrapMode.cpp +++ b/src/passes/TrapMode.cpp @@ -78,7 +78,7 @@ bool isTruncOpSigned(UnaryOp op) { Function* generateBinaryFunc(Module& wasm, Binary *curr) { BinaryOp op = curr->op; - WasmType type = curr->type; + Type type = curr->type; bool isI64 = type == i64; Builder builder(wasm); Expression* result = builder.makeBinary(op, @@ -134,8 +134,8 @@ void makeClampLimitLiterals(Literal& iMin, Literal& fMin, Literal& fMax) { } Function* generateUnaryFunc(Module& wasm, Unary *curr) { - WasmType type = curr->value->type; - WasmType retType = curr->type; + Type type = curr->value->type; + Type retType = curr->type; UnaryOp truncOp = curr->op; bool isF64 = type == f64; @@ -238,7 +238,7 @@ Expression* makeTrappingBinary(Binary* curr, TrappingFunctionContainer &trapping } // the wasm operation might trap if done over 0, so generate a safe call - WasmType type = curr->type; + Type type = curr->type; Module& wasm = trappingFunctions.getModule(); Builder builder(wasm); ensureBinaryFunc(curr, wasm, trappingFunctions); diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 4326bbc3b..f24f76881 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -174,7 +174,7 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> { size_t size = list.size(); for (size_t z = 0; z < size; z++) { auto* child = list[z]; - auto* optimized = optimize(child, z == size - 1 && isConcreteWasmType(curr->type)); + auto* optimized = optimize(child, z == size - 1 && isConcreteType(curr->type)); if (!optimized) { typeUpdater.noteRecursiveRemoval(child); skip++; @@ -294,7 +294,7 @@ struct Vacuum : public WalkerPass<PostWalker<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 (isConcreteWasmType(last->type) && block->type == last->type) { + if (isConcreteType(last->type) && block->type == last->type) { last = optimize(last, false); if (!last) { // we may be able to remove this, if there are no brs @@ -327,14 +327,14 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> { } // sink a drop into an arm of an if-else if the other arm ends in an 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 && isConcreteWasmType(iff->type)) { + if (iff && iff->ifFalse && isConcreteType(iff->type)) { // reuse the drop in both cases - if (iff->ifTrue->type == unreachable && isConcreteWasmType(iff->ifFalse->type)) { + if (iff->ifTrue->type == unreachable && isConcreteType(iff->ifFalse->type)) { curr->value = iff->ifFalse; iff->ifFalse = curr; iff->type = none; replaceCurrent(iff); - } else if (iff->ifFalse->type == unreachable && isConcreteWasmType(iff->ifTrue->type)) { + } else if (iff->ifFalse->type == unreachable && isConcreteType(iff->ifTrue->type)) { curr->value = iff->ifTrue; iff->ifTrue = curr; iff->type = none; |