diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:31:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:37:19 +0000 |
commit | e8d8bef961a50d4dc22501cde4fb9fb0be1b2532 (patch) | |
tree | 94f04805f47bb7c59ae29690d8952b6074fff602 /contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | |
parent | bb130ff39747b94592cb26d71b7cb097b9a4ea6b (diff) | |
parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp index 1d4e2e3a8f9e..d474b9a2c1ee 100644 --- a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -123,7 +123,7 @@ static void convertImplicitDefToConstZero(MachineInstr *MI, } else if (RegClass == &WebAssembly::V128RegClass) { // TODO: Replace this with v128.const 0 once that is supported in V8 Register TempReg = MRI.createVirtualRegister(&WebAssembly::I32RegClass); - MI->setDesc(TII->get(WebAssembly::SPLAT_v4i32)); + MI->setDesc(TII->get(WebAssembly::SPLAT_I32x4)); MI->addOperand(MachineOperand::CreateReg(TempReg, false)); MachineInstr *Const = BuildMI(*MI->getParent(), MI, MI->getDebugLoc(), TII->get(WebAssembly::CONST_I32), TempReg) @@ -342,7 +342,7 @@ static bool isSafeToMove(const MachineOperand *Def, const MachineOperand *Use, // instruction in which the current value is used, we cannot // stackify. Stackifying in this case would require that def moving below the // current def in the stack, which cannot be achieved, even with locals. - for (const auto &SubsequentDef : drop_begin(DefI->defs(), 1)) { + for (const auto &SubsequentDef : drop_begin(DefI->defs())) { for (const auto &PriorUse : UseI->uses()) { if (&PriorUse == Use) break; @@ -359,10 +359,9 @@ static bool isSafeToMove(const MachineOperand *Def, const MachineOperand *Use, if (NextI == Insert) return true; - // 'catch' and 'extract_exception' should be the first instruction of a BB and - // cannot move. - if (DefI->getOpcode() == WebAssembly::CATCH || - DefI->getOpcode() == WebAssembly::EXTRACT_EXCEPTION_I32) + // 'catch' and 'catch_all' should be the first instruction of a BB and cannot + // move. + if (WebAssembly::isCatch(DefI->getOpcode())) return false; // Check for register dependencies. @@ -595,7 +594,7 @@ static MachineInstr *rematerializeCheapDef( if (IsDead) { LLVM_DEBUG(dbgs() << " - Deleting original\n"); SlotIndex Idx = LIS.getInstructionIndex(Def).getRegSlot(); - LIS.removePhysRegDefAt(WebAssembly::ARGUMENTS, Idx); + LIS.removePhysRegDefAt(MCRegister::from(WebAssembly::ARGUMENTS), Idx); LIS.removeInterval(Reg); LIS.RemoveMachineInstrFromMaps(Def); Def.eraseFromParent(); @@ -693,7 +692,7 @@ class TreeWalkerState { public: explicit TreeWalkerState(MachineInstr *Insert) { const iterator_range<mop_iterator> &Range = Insert->explicit_uses(); - if (Range.begin() != Range.end()) + if (!Range.empty()) Worklist.push_back(reverse(Range)); } @@ -702,11 +701,10 @@ public: MachineOperand &pop() { RangeTy &Range = Worklist.back(); MachineOperand &Op = *Range.begin(); - Range = drop_begin(Range, 1); - if (Range.begin() == Range.end()) + Range = drop_begin(Range); + if (Range.empty()) Worklist.pop_back(); - assert((Worklist.empty() || - Worklist.back().begin() != Worklist.back().end()) && + assert((Worklist.empty() || !Worklist.back().empty()) && "Empty ranges shouldn't remain in the worklist"); return Op; } @@ -714,7 +712,7 @@ public: /// Push Instr's operands onto the stack to be visited. void pushOperands(MachineInstr *Instr) { const iterator_range<mop_iterator> &Range(Instr->explicit_uses()); - if (Range.begin() != Range.end()) + if (!Range.empty()) Worklist.push_back(reverse(Range)); } @@ -733,7 +731,7 @@ public: if (Worklist.empty()) return false; const RangeTy &Range = Worklist.back(); - return Range.begin() != Range.end() && Range.begin()->getParent() == Instr; + return !Range.empty() && Range.begin()->getParent() == Instr; } /// Test whether the given register is present on the stack, indicating an @@ -865,24 +863,6 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) { if (WebAssembly::isArgument(DefI->getOpcode())) continue; - // Currently catch's return value register cannot be stackified, because - // the wasm LLVM backend currently does not support live-in values - // entering blocks, which is a part of multi-value proposal. - // - // Once we support live-in values of wasm blocks, this can be: - // catch ; push exnref value onto stack - // block exnref -> i32 - // br_on_exn $__cpp_exception ; pop the exnref value - // end_block - // - // But because we don't support it yet, the catch instruction's dst - // register should be assigned to a local to be propagated across - // 'block' boundary now. - // - // TODO: Fix this once we support the multivalue blocks - if (DefI->getOpcode() == WebAssembly::CATCH) - continue; - MachineOperand *Def = DefI->findRegisterDefOperand(Reg); assert(Def != nullptr); |