Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 1 | //===-- WebAssemblyExplicitLocals.cpp - Make Locals Explicit --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 11 | /// This file converts any remaining registers into WebAssembly locals. |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 12 | /// |
| 13 | /// After register stackification and register coloring, convert non-stackified |
| 14 | /// registers into locals, inserting explicit get_local and set_local |
| 15 | /// instructions. |
| 16 | /// |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
| 19 | #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" |
| 20 | #include "WebAssembly.h" |
| 21 | #include "WebAssemblyMachineFunctionInfo.h" |
| 22 | #include "WebAssemblySubtarget.h" |
| 23 | #include "WebAssemblyUtilities.h" |
| 24 | #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" |
| 25 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 26 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
| 27 | #include "llvm/CodeGen/Passes.h" |
| 28 | #include "llvm/Support/Debug.h" |
| 29 | #include "llvm/Support/raw_ostream.h" |
| 30 | using namespace llvm; |
| 31 | |
| 32 | #define DEBUG_TYPE "wasm-explicit-locals" |
| 33 | |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 34 | // A command-line option to disable this pass, and keep implicit locals and |
| 35 | // stackified registers for the purpose of testing with lit/llc ONLY. |
| 36 | // This produces output which is not valid WebAssembly, and is not supported |
| 37 | // by assemblers/disassemblers and other MC based tools. |
| 38 | static cl::opt<bool> RegisterCodeGenTestMode( |
| 39 | "wasm-register-codegen-test-mode", cl::Hidden, |
| 40 | cl::desc("WebAssembly: output stack registers and implicit locals in" |
| 41 | " instruction output for test purposes only."), |
| 42 | cl::init(false)); |
| 43 | // This one does explicit locals but keeps stackified registers, as required |
| 44 | // by some current tests. |
| 45 | static cl::opt<bool> ExplicitLocalsCodeGenTestMode( |
| 46 | "wasm-explicit-locals-codegen-test-mode", cl::Hidden, |
| 47 | cl::desc("WebAssembly: output stack registers and explicit locals in" |
| 48 | " instruction output for test purposes only."), |
Dan Gohman | 7d7409e | 2017-02-28 23:37:04 +0000 | [diff] [blame] | 49 | cl::init(false)); |
| 50 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 51 | namespace { |
| 52 | class WebAssemblyExplicitLocals final : public MachineFunctionPass { |
| 53 | StringRef getPassName() const override { |
| 54 | return "WebAssembly Explicit Locals"; |
| 55 | } |
| 56 | |
| 57 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 58 | AU.setPreservesCFG(); |
| 59 | AU.addPreserved<MachineBlockFrequencyInfo>(); |
| 60 | MachineFunctionPass::getAnalysisUsage(AU); |
| 61 | } |
| 62 | |
| 63 | bool runOnMachineFunction(MachineFunction &MF) override; |
| 64 | |
| 65 | public: |
| 66 | static char ID; // Pass identification, replacement for typeid |
| 67 | WebAssemblyExplicitLocals() : MachineFunctionPass(ID) {} |
| 68 | }; |
| 69 | } // end anonymous namespace |
| 70 | |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 71 | unsigned regInstructionToStackInstruction(unsigned OpCode); |
| 72 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 73 | char WebAssemblyExplicitLocals::ID = 0; |
Jacob Gravelle | 4092645 | 2018-03-30 20:36:58 +0000 | [diff] [blame] | 74 | INITIALIZE_PASS(WebAssemblyExplicitLocals, DEBUG_TYPE, |
| 75 | "Convert registers to WebAssembly locals", false, false) |
| 76 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 77 | FunctionPass *llvm::createWebAssemblyExplicitLocals() { |
| 78 | return new WebAssemblyExplicitLocals(); |
| 79 | } |
| 80 | |
| 81 | /// Return a local id number for the given register, assigning it a new one |
| 82 | /// if it doesn't yet have one. |
| 83 | static unsigned getLocalId(DenseMap<unsigned, unsigned> &Reg2Local, |
| 84 | unsigned &CurLocal, unsigned Reg) { |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 85 | auto P = Reg2Local.insert(std::make_pair(Reg, CurLocal)); |
| 86 | if (P.second) |
| 87 | ++CurLocal; |
| 88 | return P.first->second; |
| 89 | } |
| 90 | |
| 91 | /// Get the appropriate drop opcode for the given register class. |
| 92 | static unsigned getDropOpcode(const TargetRegisterClass *RC) { |
| 93 | if (RC == &WebAssembly::I32RegClass) |
| 94 | return WebAssembly::DROP_I32; |
| 95 | if (RC == &WebAssembly::I64RegClass) |
| 96 | return WebAssembly::DROP_I64; |
| 97 | if (RC == &WebAssembly::F32RegClass) |
| 98 | return WebAssembly::DROP_F32; |
| 99 | if (RC == &WebAssembly::F64RegClass) |
| 100 | return WebAssembly::DROP_F64; |
| 101 | if (RC == &WebAssembly::V128RegClass) |
| 102 | return WebAssembly::DROP_V128; |
Heejin Ahn | 0de5872 | 2018-03-08 04:05:37 +0000 | [diff] [blame] | 103 | if (RC == &WebAssembly::EXCEPT_REFRegClass) |
| 104 | return WebAssembly::DROP_EXCEPT_REF; |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 105 | llvm_unreachable("Unexpected register class"); |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /// Get the appropriate get_local opcode for the given register class. |
| 109 | static unsigned getGetLocalOpcode(const TargetRegisterClass *RC) { |
| 110 | if (RC == &WebAssembly::I32RegClass) |
| 111 | return WebAssembly::GET_LOCAL_I32; |
| 112 | if (RC == &WebAssembly::I64RegClass) |
| 113 | return WebAssembly::GET_LOCAL_I64; |
| 114 | if (RC == &WebAssembly::F32RegClass) |
| 115 | return WebAssembly::GET_LOCAL_F32; |
| 116 | if (RC == &WebAssembly::F64RegClass) |
| 117 | return WebAssembly::GET_LOCAL_F64; |
| 118 | if (RC == &WebAssembly::V128RegClass) |
| 119 | return WebAssembly::GET_LOCAL_V128; |
Heejin Ahn | 0de5872 | 2018-03-08 04:05:37 +0000 | [diff] [blame] | 120 | if (RC == &WebAssembly::EXCEPT_REFRegClass) |
| 121 | return WebAssembly::GET_LOCAL_EXCEPT_REF; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 122 | llvm_unreachable("Unexpected register class"); |
| 123 | } |
| 124 | |
| 125 | /// Get the appropriate set_local opcode for the given register class. |
| 126 | static unsigned getSetLocalOpcode(const TargetRegisterClass *RC) { |
| 127 | if (RC == &WebAssembly::I32RegClass) |
| 128 | return WebAssembly::SET_LOCAL_I32; |
| 129 | if (RC == &WebAssembly::I64RegClass) |
| 130 | return WebAssembly::SET_LOCAL_I64; |
| 131 | if (RC == &WebAssembly::F32RegClass) |
| 132 | return WebAssembly::SET_LOCAL_F32; |
| 133 | if (RC == &WebAssembly::F64RegClass) |
| 134 | return WebAssembly::SET_LOCAL_F64; |
| 135 | if (RC == &WebAssembly::V128RegClass) |
| 136 | return WebAssembly::SET_LOCAL_V128; |
Heejin Ahn | 0de5872 | 2018-03-08 04:05:37 +0000 | [diff] [blame] | 137 | if (RC == &WebAssembly::EXCEPT_REFRegClass) |
| 138 | return WebAssembly::SET_LOCAL_EXCEPT_REF; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 139 | llvm_unreachable("Unexpected register class"); |
| 140 | } |
| 141 | |
| 142 | /// Get the appropriate tee_local opcode for the given register class. |
| 143 | static unsigned getTeeLocalOpcode(const TargetRegisterClass *RC) { |
| 144 | if (RC == &WebAssembly::I32RegClass) |
| 145 | return WebAssembly::TEE_LOCAL_I32; |
| 146 | if (RC == &WebAssembly::I64RegClass) |
| 147 | return WebAssembly::TEE_LOCAL_I64; |
| 148 | if (RC == &WebAssembly::F32RegClass) |
| 149 | return WebAssembly::TEE_LOCAL_F32; |
| 150 | if (RC == &WebAssembly::F64RegClass) |
| 151 | return WebAssembly::TEE_LOCAL_F64; |
| 152 | if (RC == &WebAssembly::V128RegClass) |
| 153 | return WebAssembly::TEE_LOCAL_V128; |
Heejin Ahn | 0de5872 | 2018-03-08 04:05:37 +0000 | [diff] [blame] | 154 | if (RC == &WebAssembly::EXCEPT_REFRegClass) |
| 155 | return WebAssembly::TEE_LOCAL_EXCEPT_REF; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 156 | llvm_unreachable("Unexpected register class"); |
| 157 | } |
| 158 | |
| 159 | /// Get the type associated with the given register class. |
Dan Gohman | 3acb187 | 2016-10-24 23:27:49 +0000 | [diff] [blame] | 160 | static MVT typeForRegClass(const TargetRegisterClass *RC) { |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 161 | if (RC == &WebAssembly::I32RegClass) |
Dan Gohman | 3acb187 | 2016-10-24 23:27:49 +0000 | [diff] [blame] | 162 | return MVT::i32; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 163 | if (RC == &WebAssembly::I64RegClass) |
Dan Gohman | 3acb187 | 2016-10-24 23:27:49 +0000 | [diff] [blame] | 164 | return MVT::i64; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 165 | if (RC == &WebAssembly::F32RegClass) |
Dan Gohman | 3acb187 | 2016-10-24 23:27:49 +0000 | [diff] [blame] | 166 | return MVT::f32; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 167 | if (RC == &WebAssembly::F64RegClass) |
Dan Gohman | 3acb187 | 2016-10-24 23:27:49 +0000 | [diff] [blame] | 168 | return MVT::f64; |
Heejin Ahn | 0de5872 | 2018-03-08 04:05:37 +0000 | [diff] [blame] | 169 | if (RC == &WebAssembly::EXCEPT_REFRegClass) |
| 170 | return MVT::ExceptRef; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 171 | llvm_unreachable("unrecognized register class"); |
| 172 | } |
| 173 | |
| 174 | /// Given a MachineOperand of a stackified vreg, return the instruction at the |
| 175 | /// start of the expression tree. |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 176 | static MachineInstr *findStartOfTree(MachineOperand &MO, |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 177 | MachineRegisterInfo &MRI, |
| 178 | WebAssemblyFunctionInfo &MFI) { |
| 179 | unsigned Reg = MO.getReg(); |
| 180 | assert(MFI.isVRegStackified(Reg)); |
| 181 | MachineInstr *Def = MRI.getVRegDef(Reg); |
| 182 | |
| 183 | // Find the first stackified use and proceed from there. |
| 184 | for (MachineOperand &DefMO : Def->explicit_uses()) { |
| 185 | if (!DefMO.isReg()) |
| 186 | continue; |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 187 | return findStartOfTree(DefMO, MRI, MFI); |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | // If there were no stackified uses, we've reached the start. |
| 191 | return Def; |
| 192 | } |
| 193 | |
| 194 | bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 195 | LLVM_DEBUG(dbgs() << "********** Make Locals Explicit **********\n" |
| 196 | "********** Function: " |
| 197 | << MF.getName() << '\n'); |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 198 | |
Dan Gohman | 7d7409e | 2017-02-28 23:37:04 +0000 | [diff] [blame] | 199 | // Disable this pass if directed to do so. |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 200 | if (RegisterCodeGenTestMode) |
Dan Gohman | 7d7409e | 2017-02-28 23:37:04 +0000 | [diff] [blame] | 201 | return false; |
| 202 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 203 | bool Changed = false; |
| 204 | MachineRegisterInfo &MRI = MF.getRegInfo(); |
| 205 | WebAssemblyFunctionInfo &MFI = *MF.getInfo<WebAssemblyFunctionInfo>(); |
| 206 | const auto *TII = MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo(); |
| 207 | |
| 208 | // Map non-stackified virtual registers to their local ids. |
| 209 | DenseMap<unsigned, unsigned> Reg2Local; |
| 210 | |
| 211 | // Handle ARGUMENTS first to ensure that they get the designated numbers. |
| 212 | for (MachineBasicBlock::iterator I = MF.begin()->begin(), |
| 213 | E = MF.begin()->end(); |
| 214 | I != E;) { |
| 215 | MachineInstr &MI = *I++; |
| 216 | if (!WebAssembly::isArgument(MI)) |
| 217 | break; |
| 218 | unsigned Reg = MI.getOperand(0).getReg(); |
| 219 | assert(!MFI.isVRegStackified(Reg)); |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 220 | Reg2Local[Reg] = static_cast<unsigned>(MI.getOperand(1).getImm()); |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 221 | MI.eraseFromParent(); |
| 222 | Changed = true; |
| 223 | } |
| 224 | |
| 225 | // Start assigning local numbers after the last parameter. |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 226 | unsigned CurLocal = static_cast<unsigned>(MFI.getParams().size()); |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 227 | |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 228 | // Precompute the set of registers that are unused, so that we can insert |
| 229 | // drops to their defs. |
| 230 | BitVector UseEmpty(MRI.getNumVirtRegs()); |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 231 | for (unsigned I = 0, E = MRI.getNumVirtRegs(); I < E; ++I) |
| 232 | UseEmpty[I] = MRI.use_empty(TargetRegisterInfo::index2VirtReg(I)); |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 233 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 234 | // Visit each instruction in the function. |
| 235 | for (MachineBasicBlock &MBB : MF) { |
| 236 | for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E;) { |
| 237 | MachineInstr &MI = *I++; |
| 238 | assert(!WebAssembly::isArgument(MI)); |
| 239 | |
Shiva Chen | 801bf7e | 2018-05-09 02:42:00 +0000 | [diff] [blame] | 240 | if (MI.isDebugInstr() || MI.isLabel()) |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 241 | continue; |
| 242 | |
| 243 | // Replace tee instructions with tee_local. The difference is that tee |
| 244 | // instructins have two defs, while tee_local instructions have one def |
| 245 | // and an index of a local to write to. |
| 246 | if (WebAssembly::isTee(MI)) { |
| 247 | assert(MFI.isVRegStackified(MI.getOperand(0).getReg())); |
| 248 | assert(!MFI.isVRegStackified(MI.getOperand(1).getReg())); |
| 249 | unsigned OldReg = MI.getOperand(2).getReg(); |
| 250 | const TargetRegisterClass *RC = MRI.getRegClass(OldReg); |
| 251 | |
| 252 | // Stackify the input if it isn't stackified yet. |
| 253 | if (!MFI.isVRegStackified(OldReg)) { |
| 254 | unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg); |
| 255 | unsigned NewReg = MRI.createVirtualRegister(RC); |
| 256 | unsigned Opc = getGetLocalOpcode(RC); |
| 257 | BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(Opc), NewReg) |
| 258 | .addImm(LocalId); |
| 259 | MI.getOperand(2).setReg(NewReg); |
| 260 | MFI.stackifyVReg(NewReg); |
| 261 | } |
| 262 | |
| 263 | // Replace the TEE with a TEE_LOCAL. |
| 264 | unsigned LocalId = |
| 265 | getLocalId(Reg2Local, CurLocal, MI.getOperand(1).getReg()); |
| 266 | unsigned Opc = getTeeLocalOpcode(RC); |
| 267 | BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(Opc), |
| 268 | MI.getOperand(0).getReg()) |
| 269 | .addImm(LocalId) |
| 270 | .addReg(MI.getOperand(2).getReg()); |
| 271 | |
| 272 | MI.eraseFromParent(); |
| 273 | Changed = true; |
| 274 | continue; |
| 275 | } |
| 276 | |
| 277 | // Insert set_locals for any defs that aren't stackified yet. Currently |
| 278 | // we handle at most one def. |
| 279 | assert(MI.getDesc().getNumDefs() <= 1); |
| 280 | if (MI.getDesc().getNumDefs() == 1) { |
| 281 | unsigned OldReg = MI.getOperand(0).getReg(); |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 282 | if (!MFI.isVRegStackified(OldReg)) { |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 283 | const TargetRegisterClass *RC = MRI.getRegClass(OldReg); |
| 284 | unsigned NewReg = MRI.createVirtualRegister(RC); |
| 285 | auto InsertPt = std::next(MachineBasicBlock::iterator(&MI)); |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 286 | if (MI.getOpcode() == WebAssembly::IMPLICIT_DEF) { |
| 287 | MI.eraseFromParent(); |
| 288 | Changed = true; |
| 289 | continue; |
| 290 | } |
| 291 | if (UseEmpty[TargetRegisterInfo::virtReg2Index(OldReg)]) { |
| 292 | unsigned Opc = getDropOpcode(RC); |
Heejin Ahn | 891a747 | 2018-06-19 20:30:42 +0000 | [diff] [blame] | 293 | MachineInstr *Drop = |
| 294 | BuildMI(MBB, InsertPt, MI.getDebugLoc(), TII->get(Opc)) |
| 295 | .addReg(NewReg); |
| 296 | // After the drop instruction, this reg operand will not be used |
| 297 | Drop->getOperand(0).setIsKill(); |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 298 | } else { |
| 299 | unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg); |
| 300 | unsigned Opc = getSetLocalOpcode(RC); |
| 301 | BuildMI(MBB, InsertPt, MI.getDebugLoc(), TII->get(Opc)) |
| 302 | .addImm(LocalId) |
| 303 | .addReg(NewReg); |
| 304 | } |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 305 | MI.getOperand(0).setReg(NewReg); |
Heejin Ahn | 891a747 | 2018-06-19 20:30:42 +0000 | [diff] [blame] | 306 | // This register operand is now being used by the inserted drop |
| 307 | // instruction, so make it undead. |
| 308 | MI.getOperand(0).setIsDead(false); |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 309 | MFI.stackifyVReg(NewReg); |
| 310 | Changed = true; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | // Insert get_locals for any uses that aren't stackified yet. |
| 315 | MachineInstr *InsertPt = &MI; |
| 316 | for (MachineOperand &MO : reverse(MI.explicit_uses())) { |
| 317 | if (!MO.isReg()) |
| 318 | continue; |
| 319 | |
| 320 | unsigned OldReg = MO.getReg(); |
| 321 | |
Dan Gohman | b465aa0 | 2017-11-08 19:18:08 +0000 | [diff] [blame] | 322 | // Inline asm may have a def in the middle of the operands. Our contract |
| 323 | // with inline asm register operands is to provide local indices as |
| 324 | // immediates. |
| 325 | if (MO.isDef()) { |
| 326 | assert(MI.getOpcode() == TargetOpcode::INLINEASM); |
| 327 | unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg); |
| 328 | MRI.removeRegOperandFromUseList(&MO); |
| 329 | MO = MachineOperand::CreateImm(LocalId); |
| 330 | continue; |
| 331 | } |
| 332 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 333 | // If we see a stackified register, prepare to insert subsequent |
| 334 | // get_locals before the start of its tree. |
| 335 | if (MFI.isVRegStackified(OldReg)) { |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 336 | InsertPt = findStartOfTree(MO, MRI, MFI); |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 337 | continue; |
| 338 | } |
| 339 | |
Dan Gohman | b465aa0 | 2017-11-08 19:18:08 +0000 | [diff] [blame] | 340 | // Our contract with inline asm register operands is to provide local |
| 341 | // indices as immediates. |
| 342 | if (MI.getOpcode() == TargetOpcode::INLINEASM) { |
| 343 | unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg); |
| 344 | MRI.removeRegOperandFromUseList(&MO); |
| 345 | MO = MachineOperand::CreateImm(LocalId); |
| 346 | continue; |
| 347 | } |
| 348 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 349 | // Insert a get_local. |
| 350 | unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg); |
| 351 | const TargetRegisterClass *RC = MRI.getRegClass(OldReg); |
| 352 | unsigned NewReg = MRI.createVirtualRegister(RC); |
| 353 | unsigned Opc = getGetLocalOpcode(RC); |
| 354 | InsertPt = |
| 355 | BuildMI(MBB, InsertPt, MI.getDebugLoc(), TII->get(Opc), NewReg) |
| 356 | .addImm(LocalId); |
| 357 | MO.setReg(NewReg); |
| 358 | MFI.stackifyVReg(NewReg); |
| 359 | Changed = true; |
| 360 | } |
| 361 | |
| 362 | // Coalesce and eliminate COPY instructions. |
| 363 | if (WebAssembly::isCopy(MI)) { |
| 364 | MRI.replaceRegWith(MI.getOperand(1).getReg(), |
| 365 | MI.getOperand(0).getReg()); |
| 366 | MI.eraseFromParent(); |
| 367 | Changed = true; |
| 368 | } |
| 369 | } |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 370 | |
| 371 | if (!ExplicitLocalsCodeGenTestMode) { |
| 372 | // Remove all uses of stackified registers to bring the instruction format |
| 373 | // into its final stack form, and transition opcodes to their _S variant. |
| 374 | // We do this in a seperate loop, since the previous loop adds/removes |
| 375 | // instructions. |
| 376 | // See comments in lib/Target/WebAssembly/WebAssemblyInstrFormats.td for |
| 377 | // details. |
| 378 | // TODO: the code above creates new registers which are then removed here. |
| 379 | // That code could be slightly simplified by not doing that, though maybe |
| 380 | // it is simpler conceptually to keep the code above in "register mode" |
| 381 | // until this transition point. |
| 382 | for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); |
| 383 | I != E;) { |
| 384 | MachineInstr &MI = *I++; |
| 385 | // FIXME: we are not processing inline assembly, which contains register |
| 386 | // operands, because it is used by later target generic code. |
| 387 | if (MI.isDebugInstr() || MI.isLabel() || MI.isInlineAsm()) |
| 388 | continue; |
| 389 | auto RegOpcode = MI.getOpcode(); |
| 390 | auto StackOpcode = regInstructionToStackInstruction(RegOpcode); |
| 391 | MI.setDesc(TII->get(StackOpcode)); |
| 392 | // Now remove all register operands. |
| 393 | for (auto I = MI.getNumOperands(); I; --I) { |
| 394 | auto &MO = MI.getOperand(I - 1); |
| 395 | if (MO.isReg()) { |
| 396 | MI.RemoveOperand(I - 1); |
| 397 | // TODO: we should also update the MFI here or below to reflect the |
| 398 | // removed registers? The MFI is about to be deleted anyway, so |
| 399 | // maybe that is not worth it? |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | } |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 404 | } |
| 405 | |
Dan Gohman | 3acb187 | 2016-10-24 23:27:49 +0000 | [diff] [blame] | 406 | // Define the locals. |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 407 | // TODO: Sort the locals for better compression. |
| 408 | MFI.setNumLocals(CurLocal - MFI.getParams().size()); |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 409 | for (unsigned I = 0, E = MRI.getNumVirtRegs(); I < E; ++I) { |
| 410 | unsigned Reg = TargetRegisterInfo::index2VirtReg(I); |
| 411 | auto RL = Reg2Local.find(Reg); |
| 412 | if (RL == Reg2Local.end() || RL->second < MFI.getParams().size()) |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 413 | continue; |
| 414 | |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 415 | MFI.setLocal(RL->second - MFI.getParams().size(), |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 416 | typeForRegClass(MRI.getRegClass(Reg))); |
Dan Gohman | 3acb187 | 2016-10-24 23:27:49 +0000 | [diff] [blame] | 417 | Changed = true; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 418 | } |
| 419 | |
Wouter van Oortmerssen | a90d24d | 2018-07-27 23:19:51 +0000 | [diff] [blame] | 420 | return Changed; |
Wouter van Oortmerssen | a67c413 | 2018-07-27 20:56:43 +0000 | [diff] [blame] | 421 | } |
Wouter van Oortmerssen | ab26bd0 | 2018-08-10 21:32:47 +0000 | [diff] [blame] | 422 | |
| 423 | unsigned regInstructionToStackInstruction(unsigned OpCode) { |
| 424 | switch (OpCode) { |
| 425 | default: |
| 426 | // You may hit this if you add new instructions, please add them below. |
| 427 | // For most of these opcodes, this function could have been implemented |
| 428 | // as "return OpCode + 1", but since table-gen alphabetically sorts them, |
| 429 | // this cannot be guaranteed (see e.g. BR and BR_IF). |
| 430 | // The approach below is the same as what the x87 backend does. |
| 431 | // TODO(wvo): to make this code cleaner, create a custom tablegen |
| 432 | // code generator that emits the table below automatically. |
| 433 | llvm_unreachable( |
| 434 | "unknown WebAssembly instruction in Explicit Locals pass"); |
| 435 | case WebAssembly::ABS_F32: return WebAssembly::ABS_F32_S; |
| 436 | case WebAssembly::ABS_F64: return WebAssembly::ABS_F64_S; |
| 437 | case WebAssembly::ADD_F32: return WebAssembly::ADD_F32_S; |
| 438 | case WebAssembly::ADD_F32x4: return WebAssembly::ADD_F32x4_S; |
| 439 | case WebAssembly::ADD_F64: return WebAssembly::ADD_F64_S; |
| 440 | case WebAssembly::ADD_I16x8: return WebAssembly::ADD_I16x8_S; |
| 441 | case WebAssembly::ADD_I32: return WebAssembly::ADD_I32_S; |
| 442 | case WebAssembly::ADD_I32x4: return WebAssembly::ADD_I32x4_S; |
| 443 | case WebAssembly::ADD_I64: return WebAssembly::ADD_I64_S; |
| 444 | case WebAssembly::ADD_I8x16: return WebAssembly::ADD_I8x16_S; |
| 445 | case WebAssembly::ADJCALLSTACKDOWN: return WebAssembly::ADJCALLSTACKDOWN_S; |
| 446 | case WebAssembly::ADJCALLSTACKUP: return WebAssembly::ADJCALLSTACKUP_S; |
| 447 | case WebAssembly::AND_I32: return WebAssembly::AND_I32_S; |
| 448 | case WebAssembly::AND_I64: return WebAssembly::AND_I64_S; |
| 449 | case WebAssembly::ARGUMENT_EXCEPT_REF: return WebAssembly::ARGUMENT_EXCEPT_REF_S; |
| 450 | case WebAssembly::ARGUMENT_F32: return WebAssembly::ARGUMENT_F32_S; |
| 451 | case WebAssembly::ARGUMENT_F64: return WebAssembly::ARGUMENT_F64_S; |
| 452 | case WebAssembly::ARGUMENT_I32: return WebAssembly::ARGUMENT_I32_S; |
| 453 | case WebAssembly::ARGUMENT_I64: return WebAssembly::ARGUMENT_I64_S; |
| 454 | case WebAssembly::ARGUMENT_v16i8: return WebAssembly::ARGUMENT_v16i8_S; |
| 455 | case WebAssembly::ARGUMENT_v4f32: return WebAssembly::ARGUMENT_v4f32_S; |
| 456 | case WebAssembly::ARGUMENT_v4i32: return WebAssembly::ARGUMENT_v4i32_S; |
| 457 | case WebAssembly::ARGUMENT_v8i16: return WebAssembly::ARGUMENT_v8i16_S; |
| 458 | case WebAssembly::ARGUMENT_v2f64: return WebAssembly::ARGUMENT_v2f64_S; |
| 459 | case WebAssembly::ARGUMENT_v2i64: return WebAssembly::ARGUMENT_v2i64_S; |
| 460 | case WebAssembly::ATOMIC_LOAD16_U_I32: return WebAssembly::ATOMIC_LOAD16_U_I32_S; |
| 461 | case WebAssembly::ATOMIC_LOAD16_U_I64: return WebAssembly::ATOMIC_LOAD16_U_I64_S; |
| 462 | case WebAssembly::ATOMIC_LOAD32_U_I64: return WebAssembly::ATOMIC_LOAD32_U_I64_S; |
| 463 | case WebAssembly::ATOMIC_LOAD8_U_I32: return WebAssembly::ATOMIC_LOAD8_U_I32_S; |
| 464 | case WebAssembly::ATOMIC_LOAD8_U_I64: return WebAssembly::ATOMIC_LOAD8_U_I64_S; |
| 465 | case WebAssembly::ATOMIC_LOAD_I32: return WebAssembly::ATOMIC_LOAD_I32_S; |
| 466 | case WebAssembly::ATOMIC_LOAD_I64: return WebAssembly::ATOMIC_LOAD_I64_S; |
| 467 | case WebAssembly::ATOMIC_STORE16_I32: return WebAssembly::ATOMIC_STORE16_I32_S; |
| 468 | case WebAssembly::ATOMIC_STORE16_I64: return WebAssembly::ATOMIC_STORE16_I64_S; |
| 469 | case WebAssembly::ATOMIC_STORE32_I64: return WebAssembly::ATOMIC_STORE32_I64_S; |
| 470 | case WebAssembly::ATOMIC_STORE8_I32: return WebAssembly::ATOMIC_STORE8_I32_S; |
| 471 | case WebAssembly::ATOMIC_STORE8_I64: return WebAssembly::ATOMIC_STORE8_I64_S; |
| 472 | case WebAssembly::ATOMIC_STORE_I32: return WebAssembly::ATOMIC_STORE_I32_S; |
| 473 | case WebAssembly::ATOMIC_STORE_I64: return WebAssembly::ATOMIC_STORE_I64_S; |
| 474 | case WebAssembly::BLOCK: return WebAssembly::BLOCK_S; |
| 475 | case WebAssembly::BR: return WebAssembly::BR_S; |
| 476 | case WebAssembly::BR_IF: return WebAssembly::BR_IF_S; |
| 477 | case WebAssembly::BR_TABLE_I32: return WebAssembly::BR_TABLE_I32_S; |
| 478 | case WebAssembly::BR_TABLE_I64: return WebAssembly::BR_TABLE_I64_S; |
| 479 | case WebAssembly::BR_UNLESS: return WebAssembly::BR_UNLESS_S; |
| 480 | case WebAssembly::CALL_EXCEPT_REF: return WebAssembly::CALL_EXCEPT_REF_S; |
| 481 | case WebAssembly::CALL_F32: return WebAssembly::CALL_F32_S; |
| 482 | case WebAssembly::CALL_F64: return WebAssembly::CALL_F64_S; |
| 483 | case WebAssembly::CALL_I32: return WebAssembly::CALL_I32_S; |
| 484 | case WebAssembly::CALL_I64: return WebAssembly::CALL_I64_S; |
| 485 | case WebAssembly::CALL_INDIRECT_EXCEPT_REF: return WebAssembly::CALL_INDIRECT_EXCEPT_REF_S; |
| 486 | case WebAssembly::CALL_INDIRECT_F32: return WebAssembly::CALL_INDIRECT_F32_S; |
| 487 | case WebAssembly::CALL_INDIRECT_F64: return WebAssembly::CALL_INDIRECT_F64_S; |
| 488 | case WebAssembly::CALL_INDIRECT_I32: return WebAssembly::CALL_INDIRECT_I32_S; |
| 489 | case WebAssembly::CALL_INDIRECT_I64: return WebAssembly::CALL_INDIRECT_I64_S; |
| 490 | case WebAssembly::CALL_INDIRECT_VOID: return WebAssembly::CALL_INDIRECT_VOID_S; |
| 491 | case WebAssembly::CALL_INDIRECT_v16i8: return WebAssembly::CALL_INDIRECT_v16i8_S; |
| 492 | case WebAssembly::CALL_INDIRECT_v4f32: return WebAssembly::CALL_INDIRECT_v4f32_S; |
| 493 | case WebAssembly::CALL_INDIRECT_v4i32: return WebAssembly::CALL_INDIRECT_v4i32_S; |
| 494 | case WebAssembly::CALL_INDIRECT_v8i16: return WebAssembly::CALL_INDIRECT_v8i16_S; |
| 495 | case WebAssembly::CALL_VOID: return WebAssembly::CALL_VOID_S; |
| 496 | case WebAssembly::CALL_v16i8: return WebAssembly::CALL_v16i8_S; |
| 497 | case WebAssembly::CALL_v4f32: return WebAssembly::CALL_v4f32_S; |
| 498 | case WebAssembly::CALL_v4i32: return WebAssembly::CALL_v4i32_S; |
| 499 | case WebAssembly::CALL_v8i16: return WebAssembly::CALL_v8i16_S; |
| 500 | case WebAssembly::CATCHRET: return WebAssembly::CATCHRET_S; |
| 501 | case WebAssembly::CATCH_ALL: return WebAssembly::CATCH_ALL_S; |
| 502 | case WebAssembly::CATCH_I32: return WebAssembly::CATCH_I32_S; |
| 503 | case WebAssembly::CATCH_I64: return WebAssembly::CATCH_I64_S; |
| 504 | case WebAssembly::CEIL_F32: return WebAssembly::CEIL_F32_S; |
| 505 | case WebAssembly::CEIL_F64: return WebAssembly::CEIL_F64_S; |
| 506 | case WebAssembly::CLEANUPRET: return WebAssembly::CLEANUPRET_S; |
| 507 | case WebAssembly::CLZ_I32: return WebAssembly::CLZ_I32_S; |
| 508 | case WebAssembly::CLZ_I64: return WebAssembly::CLZ_I64_S; |
| 509 | case WebAssembly::CONST_F32: return WebAssembly::CONST_F32_S; |
| 510 | case WebAssembly::CONST_F64: return WebAssembly::CONST_F64_S; |
| 511 | case WebAssembly::CONST_I32: return WebAssembly::CONST_I32_S; |
| 512 | case WebAssembly::CONST_I64: return WebAssembly::CONST_I64_S; |
| 513 | case WebAssembly::COPYSIGN_F32: return WebAssembly::COPYSIGN_F32_S; |
| 514 | case WebAssembly::COPYSIGN_F64: return WebAssembly::COPYSIGN_F64_S; |
| 515 | case WebAssembly::COPY_EXCEPT_REF: return WebAssembly::COPY_EXCEPT_REF_S; |
| 516 | case WebAssembly::COPY_F32: return WebAssembly::COPY_F32_S; |
| 517 | case WebAssembly::COPY_F64: return WebAssembly::COPY_F64_S; |
| 518 | case WebAssembly::COPY_I32: return WebAssembly::COPY_I32_S; |
| 519 | case WebAssembly::COPY_I64: return WebAssembly::COPY_I64_S; |
| 520 | case WebAssembly::COPY_V128: return WebAssembly::COPY_V128_S; |
| 521 | case WebAssembly::CTZ_I32: return WebAssembly::CTZ_I32_S; |
| 522 | case WebAssembly::CTZ_I64: return WebAssembly::CTZ_I64_S; |
| 523 | case WebAssembly::CURRENT_MEMORY_I32: return WebAssembly::CURRENT_MEMORY_I32_S; |
| 524 | case WebAssembly::DIV_F32: return WebAssembly::DIV_F32_S; |
| 525 | case WebAssembly::DIV_F64: return WebAssembly::DIV_F64_S; |
| 526 | case WebAssembly::DIV_S_I32: return WebAssembly::DIV_S_I32_S; |
| 527 | case WebAssembly::DIV_S_I64: return WebAssembly::DIV_S_I64_S; |
| 528 | case WebAssembly::DIV_U_I32: return WebAssembly::DIV_U_I32_S; |
| 529 | case WebAssembly::DIV_U_I64: return WebAssembly::DIV_U_I64_S; |
| 530 | case WebAssembly::DROP_EXCEPT_REF: return WebAssembly::DROP_EXCEPT_REF_S; |
| 531 | case WebAssembly::DROP_F32: return WebAssembly::DROP_F32_S; |
| 532 | case WebAssembly::DROP_F64: return WebAssembly::DROP_F64_S; |
| 533 | case WebAssembly::DROP_I32: return WebAssembly::DROP_I32_S; |
| 534 | case WebAssembly::DROP_I64: return WebAssembly::DROP_I64_S; |
| 535 | case WebAssembly::DROP_V128: return WebAssembly::DROP_V128_S; |
| 536 | case WebAssembly::END_BLOCK: return WebAssembly::END_BLOCK_S; |
| 537 | case WebAssembly::END_FUNCTION: return WebAssembly::END_FUNCTION_S; |
| 538 | case WebAssembly::END_LOOP: return WebAssembly::END_LOOP_S; |
| 539 | case WebAssembly::END_TRY: return WebAssembly::END_TRY_S; |
| 540 | case WebAssembly::EQZ_I32: return WebAssembly::EQZ_I32_S; |
| 541 | case WebAssembly::EQZ_I64: return WebAssembly::EQZ_I64_S; |
| 542 | case WebAssembly::EQ_F32: return WebAssembly::EQ_F32_S; |
| 543 | case WebAssembly::EQ_F64: return WebAssembly::EQ_F64_S; |
| 544 | case WebAssembly::EQ_I32: return WebAssembly::EQ_I32_S; |
| 545 | case WebAssembly::EQ_I64: return WebAssembly::EQ_I64_S; |
| 546 | case WebAssembly::F32_CONVERT_S_I32: return WebAssembly::F32_CONVERT_S_I32_S; |
| 547 | case WebAssembly::F32_CONVERT_S_I64: return WebAssembly::F32_CONVERT_S_I64_S; |
| 548 | case WebAssembly::F32_CONVERT_U_I32: return WebAssembly::F32_CONVERT_U_I32_S; |
| 549 | case WebAssembly::F32_CONVERT_U_I64: return WebAssembly::F32_CONVERT_U_I64_S; |
| 550 | case WebAssembly::F32_DEMOTE_F64: return WebAssembly::F32_DEMOTE_F64_S; |
| 551 | case WebAssembly::F32_REINTERPRET_I32: return WebAssembly::F32_REINTERPRET_I32_S; |
| 552 | case WebAssembly::F64_CONVERT_S_I32: return WebAssembly::F64_CONVERT_S_I32_S; |
| 553 | case WebAssembly::F64_CONVERT_S_I64: return WebAssembly::F64_CONVERT_S_I64_S; |
| 554 | case WebAssembly::F64_CONVERT_U_I32: return WebAssembly::F64_CONVERT_U_I32_S; |
| 555 | case WebAssembly::F64_CONVERT_U_I64: return WebAssembly::F64_CONVERT_U_I64_S; |
| 556 | case WebAssembly::F64_PROMOTE_F32: return WebAssembly::F64_PROMOTE_F32_S; |
| 557 | case WebAssembly::F64_REINTERPRET_I64: return WebAssembly::F64_REINTERPRET_I64_S; |
| 558 | case WebAssembly::FALLTHROUGH_RETURN_EXCEPT_REF: return WebAssembly::FALLTHROUGH_RETURN_EXCEPT_REF_S; |
| 559 | case WebAssembly::FALLTHROUGH_RETURN_F32: return WebAssembly::FALLTHROUGH_RETURN_F32_S; |
| 560 | case WebAssembly::FALLTHROUGH_RETURN_F64: return WebAssembly::FALLTHROUGH_RETURN_F64_S; |
| 561 | case WebAssembly::FALLTHROUGH_RETURN_I32: return WebAssembly::FALLTHROUGH_RETURN_I32_S; |
| 562 | case WebAssembly::FALLTHROUGH_RETURN_I64: return WebAssembly::FALLTHROUGH_RETURN_I64_S; |
| 563 | case WebAssembly::FALLTHROUGH_RETURN_VOID: return WebAssembly::FALLTHROUGH_RETURN_VOID_S; |
| 564 | case WebAssembly::FALLTHROUGH_RETURN_v16i8: return WebAssembly::FALLTHROUGH_RETURN_v16i8_S; |
| 565 | case WebAssembly::FALLTHROUGH_RETURN_v4f32: return WebAssembly::FALLTHROUGH_RETURN_v4f32_S; |
| 566 | case WebAssembly::FALLTHROUGH_RETURN_v4i32: return WebAssembly::FALLTHROUGH_RETURN_v4i32_S; |
| 567 | case WebAssembly::FALLTHROUGH_RETURN_v8i16: return WebAssembly::FALLTHROUGH_RETURN_v8i16_S; |
| 568 | case WebAssembly::FALLTHROUGH_RETURN_v2f64: return WebAssembly::FALLTHROUGH_RETURN_v2f64_S; |
| 569 | case WebAssembly::FALLTHROUGH_RETURN_v2i64: return WebAssembly::FALLTHROUGH_RETURN_v2i64_S; |
| 570 | case WebAssembly::FLOOR_F32: return WebAssembly::FLOOR_F32_S; |
| 571 | case WebAssembly::FLOOR_F64: return WebAssembly::FLOOR_F64_S; |
| 572 | case WebAssembly::FP_TO_SINT_I32_F32: return WebAssembly::FP_TO_SINT_I32_F32_S; |
| 573 | case WebAssembly::FP_TO_SINT_I32_F64: return WebAssembly::FP_TO_SINT_I32_F64_S; |
| 574 | case WebAssembly::FP_TO_SINT_I64_F32: return WebAssembly::FP_TO_SINT_I64_F32_S; |
| 575 | case WebAssembly::FP_TO_SINT_I64_F64: return WebAssembly::FP_TO_SINT_I64_F64_S; |
| 576 | case WebAssembly::FP_TO_UINT_I32_F32: return WebAssembly::FP_TO_UINT_I32_F32_S; |
| 577 | case WebAssembly::FP_TO_UINT_I32_F64: return WebAssembly::FP_TO_UINT_I32_F64_S; |
| 578 | case WebAssembly::FP_TO_UINT_I64_F32: return WebAssembly::FP_TO_UINT_I64_F32_S; |
| 579 | case WebAssembly::FP_TO_UINT_I64_F64: return WebAssembly::FP_TO_UINT_I64_F64_S; |
| 580 | case WebAssembly::GET_GLOBAL_EXCEPT_REF: return WebAssembly::GET_GLOBAL_EXCEPT_REF_S; |
| 581 | case WebAssembly::GET_GLOBAL_F32: return WebAssembly::GET_GLOBAL_F32_S; |
| 582 | case WebAssembly::GET_GLOBAL_F64: return WebAssembly::GET_GLOBAL_F64_S; |
| 583 | case WebAssembly::GET_GLOBAL_I32: return WebAssembly::GET_GLOBAL_I32_S; |
| 584 | case WebAssembly::GET_GLOBAL_I64: return WebAssembly::GET_GLOBAL_I64_S; |
| 585 | case WebAssembly::GET_GLOBAL_V128: return WebAssembly::GET_GLOBAL_V128_S; |
| 586 | case WebAssembly::GET_LOCAL_EXCEPT_REF: return WebAssembly::GET_LOCAL_EXCEPT_REF_S; |
| 587 | case WebAssembly::GET_LOCAL_F32: return WebAssembly::GET_LOCAL_F32_S; |
| 588 | case WebAssembly::GET_LOCAL_F64: return WebAssembly::GET_LOCAL_F64_S; |
| 589 | case WebAssembly::GET_LOCAL_I32: return WebAssembly::GET_LOCAL_I32_S; |
| 590 | case WebAssembly::GET_LOCAL_I64: return WebAssembly::GET_LOCAL_I64_S; |
| 591 | case WebAssembly::GET_LOCAL_V128: return WebAssembly::GET_LOCAL_V128_S; |
| 592 | case WebAssembly::GE_F32: return WebAssembly::GE_F32_S; |
| 593 | case WebAssembly::GE_F64: return WebAssembly::GE_F64_S; |
| 594 | case WebAssembly::GE_S_I32: return WebAssembly::GE_S_I32_S; |
| 595 | case WebAssembly::GE_S_I64: return WebAssembly::GE_S_I64_S; |
| 596 | case WebAssembly::GE_U_I32: return WebAssembly::GE_U_I32_S; |
| 597 | case WebAssembly::GE_U_I64: return WebAssembly::GE_U_I64_S; |
| 598 | case WebAssembly::GROW_MEMORY_I32: return WebAssembly::GROW_MEMORY_I32_S; |
| 599 | case WebAssembly::GT_F32: return WebAssembly::GT_F32_S; |
| 600 | case WebAssembly::GT_F64: return WebAssembly::GT_F64_S; |
| 601 | case WebAssembly::GT_S_I32: return WebAssembly::GT_S_I32_S; |
| 602 | case WebAssembly::GT_S_I64: return WebAssembly::GT_S_I64_S; |
| 603 | case WebAssembly::GT_U_I32: return WebAssembly::GT_U_I32_S; |
| 604 | case WebAssembly::GT_U_I64: return WebAssembly::GT_U_I64_S; |
| 605 | case WebAssembly::I32_EXTEND16_S_I32: return WebAssembly::I32_EXTEND16_S_I32_S; |
| 606 | case WebAssembly::I32_EXTEND8_S_I32: return WebAssembly::I32_EXTEND8_S_I32_S; |
| 607 | case WebAssembly::I32_REINTERPRET_F32: return WebAssembly::I32_REINTERPRET_F32_S; |
| 608 | case WebAssembly::I32_TRUNC_S_F32: return WebAssembly::I32_TRUNC_S_F32_S; |
| 609 | case WebAssembly::I32_TRUNC_S_F64: return WebAssembly::I32_TRUNC_S_F64_S; |
| 610 | case WebAssembly::I32_TRUNC_S_SAT_F32: return WebAssembly::I32_TRUNC_S_SAT_F32_S; |
| 611 | case WebAssembly::I32_TRUNC_S_SAT_F64: return WebAssembly::I32_TRUNC_S_SAT_F64_S; |
| 612 | case WebAssembly::I32_TRUNC_U_F32: return WebAssembly::I32_TRUNC_U_F32_S; |
| 613 | case WebAssembly::I32_TRUNC_U_F64: return WebAssembly::I32_TRUNC_U_F64_S; |
| 614 | case WebAssembly::I32_TRUNC_U_SAT_F32: return WebAssembly::I32_TRUNC_U_SAT_F32_S; |
| 615 | case WebAssembly::I32_TRUNC_U_SAT_F64: return WebAssembly::I32_TRUNC_U_SAT_F64_S; |
| 616 | case WebAssembly::I32_WRAP_I64: return WebAssembly::I32_WRAP_I64_S; |
| 617 | case WebAssembly::I64_EXTEND16_S_I64: return WebAssembly::I64_EXTEND16_S_I64_S; |
| 618 | case WebAssembly::I64_EXTEND32_S_I64: return WebAssembly::I64_EXTEND32_S_I64_S; |
| 619 | case WebAssembly::I64_EXTEND8_S_I64: return WebAssembly::I64_EXTEND8_S_I64_S; |
| 620 | case WebAssembly::I64_EXTEND_S_I32: return WebAssembly::I64_EXTEND_S_I32_S; |
| 621 | case WebAssembly::I64_EXTEND_U_I32: return WebAssembly::I64_EXTEND_U_I32_S; |
| 622 | case WebAssembly::I64_REINTERPRET_F64: return WebAssembly::I64_REINTERPRET_F64_S; |
| 623 | case WebAssembly::I64_TRUNC_S_F32: return WebAssembly::I64_TRUNC_S_F32_S; |
| 624 | case WebAssembly::I64_TRUNC_S_F64: return WebAssembly::I64_TRUNC_S_F64_S; |
| 625 | case WebAssembly::I64_TRUNC_S_SAT_F32: return WebAssembly::I64_TRUNC_S_SAT_F32_S; |
| 626 | case WebAssembly::I64_TRUNC_S_SAT_F64: return WebAssembly::I64_TRUNC_S_SAT_F64_S; |
| 627 | case WebAssembly::I64_TRUNC_U_F32: return WebAssembly::I64_TRUNC_U_F32_S; |
| 628 | case WebAssembly::I64_TRUNC_U_F64: return WebAssembly::I64_TRUNC_U_F64_S; |
| 629 | case WebAssembly::I64_TRUNC_U_SAT_F32: return WebAssembly::I64_TRUNC_U_SAT_F32_S; |
| 630 | case WebAssembly::I64_TRUNC_U_SAT_F64: return WebAssembly::I64_TRUNC_U_SAT_F64_S; |
| 631 | case WebAssembly::LE_F32: return WebAssembly::LE_F32_S; |
| 632 | case WebAssembly::LE_F64: return WebAssembly::LE_F64_S; |
| 633 | case WebAssembly::LE_S_I32: return WebAssembly::LE_S_I32_S; |
| 634 | case WebAssembly::LE_S_I64: return WebAssembly::LE_S_I64_S; |
| 635 | case WebAssembly::LE_U_I32: return WebAssembly::LE_U_I32_S; |
| 636 | case WebAssembly::LE_U_I64: return WebAssembly::LE_U_I64_S; |
| 637 | case WebAssembly::LOAD16_S_I32: return WebAssembly::LOAD16_S_I32_S; |
| 638 | case WebAssembly::LOAD16_S_I64: return WebAssembly::LOAD16_S_I64_S; |
| 639 | case WebAssembly::LOAD16_U_I32: return WebAssembly::LOAD16_U_I32_S; |
| 640 | case WebAssembly::LOAD16_U_I64: return WebAssembly::LOAD16_U_I64_S; |
| 641 | case WebAssembly::LOAD32_S_I64: return WebAssembly::LOAD32_S_I64_S; |
| 642 | case WebAssembly::LOAD32_U_I64: return WebAssembly::LOAD32_U_I64_S; |
| 643 | case WebAssembly::LOAD8_S_I32: return WebAssembly::LOAD8_S_I32_S; |
| 644 | case WebAssembly::LOAD8_S_I64: return WebAssembly::LOAD8_S_I64_S; |
| 645 | case WebAssembly::LOAD8_U_I32: return WebAssembly::LOAD8_U_I32_S; |
| 646 | case WebAssembly::LOAD8_U_I64: return WebAssembly::LOAD8_U_I64_S; |
| 647 | case WebAssembly::LOAD_F32: return WebAssembly::LOAD_F32_S; |
| 648 | case WebAssembly::LOAD_F64: return WebAssembly::LOAD_F64_S; |
| 649 | case WebAssembly::LOAD_I32: return WebAssembly::LOAD_I32_S; |
| 650 | case WebAssembly::LOAD_I64: return WebAssembly::LOAD_I64_S; |
| 651 | case WebAssembly::LOOP: return WebAssembly::LOOP_S; |
| 652 | case WebAssembly::LT_F32: return WebAssembly::LT_F32_S; |
| 653 | case WebAssembly::LT_F64: return WebAssembly::LT_F64_S; |
| 654 | case WebAssembly::LT_S_I32: return WebAssembly::LT_S_I32_S; |
| 655 | case WebAssembly::LT_S_I64: return WebAssembly::LT_S_I64_S; |
| 656 | case WebAssembly::LT_U_I32: return WebAssembly::LT_U_I32_S; |
| 657 | case WebAssembly::LT_U_I64: return WebAssembly::LT_U_I64_S; |
| 658 | case WebAssembly::MAX_F32: return WebAssembly::MAX_F32_S; |
| 659 | case WebAssembly::MAX_F64: return WebAssembly::MAX_F64_S; |
| 660 | case WebAssembly::MEMORY_GROW_I32: return WebAssembly::MEMORY_GROW_I32_S; |
| 661 | case WebAssembly::MEMORY_SIZE_I32: return WebAssembly::MEMORY_SIZE_I32_S; |
| 662 | case WebAssembly::MEM_GROW_I32: return WebAssembly::MEM_GROW_I32_S; |
| 663 | case WebAssembly::MEM_SIZE_I32: return WebAssembly::MEM_SIZE_I32_S; |
| 664 | case WebAssembly::MIN_F32: return WebAssembly::MIN_F32_S; |
| 665 | case WebAssembly::MIN_F64: return WebAssembly::MIN_F64_S; |
| 666 | case WebAssembly::MUL_F32: return WebAssembly::MUL_F32_S; |
| 667 | case WebAssembly::MUL_F32x4: return WebAssembly::MUL_F32x4_S; |
| 668 | case WebAssembly::MUL_F64: return WebAssembly::MUL_F64_S; |
| 669 | case WebAssembly::MUL_I16x8: return WebAssembly::MUL_I16x8_S; |
| 670 | case WebAssembly::MUL_I32: return WebAssembly::MUL_I32_S; |
| 671 | case WebAssembly::MUL_I32x4: return WebAssembly::MUL_I32x4_S; |
| 672 | case WebAssembly::MUL_I64: return WebAssembly::MUL_I64_S; |
| 673 | case WebAssembly::MUL_I8x16: return WebAssembly::MUL_I8x16_S; |
| 674 | case WebAssembly::NEAREST_F32: return WebAssembly::NEAREST_F32_S; |
| 675 | case WebAssembly::NEAREST_F64: return WebAssembly::NEAREST_F64_S; |
| 676 | case WebAssembly::NEG_F32: return WebAssembly::NEG_F32_S; |
| 677 | case WebAssembly::NEG_F64: return WebAssembly::NEG_F64_S; |
| 678 | case WebAssembly::NE_F32: return WebAssembly::NE_F32_S; |
| 679 | case WebAssembly::NE_F64: return WebAssembly::NE_F64_S; |
| 680 | case WebAssembly::NE_I32: return WebAssembly::NE_I32_S; |
| 681 | case WebAssembly::NE_I64: return WebAssembly::NE_I64_S; |
| 682 | case WebAssembly::NOP: return WebAssembly::NOP_S; |
| 683 | case WebAssembly::OR_I32: return WebAssembly::OR_I32_S; |
| 684 | case WebAssembly::OR_I64: return WebAssembly::OR_I64_S; |
| 685 | case WebAssembly::PCALL_INDIRECT_EXCEPT_REF: return WebAssembly::PCALL_INDIRECT_EXCEPT_REF_S; |
| 686 | case WebAssembly::PCALL_INDIRECT_F32: return WebAssembly::PCALL_INDIRECT_F32_S; |
| 687 | case WebAssembly::PCALL_INDIRECT_F64: return WebAssembly::PCALL_INDIRECT_F64_S; |
| 688 | case WebAssembly::PCALL_INDIRECT_I32: return WebAssembly::PCALL_INDIRECT_I32_S; |
| 689 | case WebAssembly::PCALL_INDIRECT_I64: return WebAssembly::PCALL_INDIRECT_I64_S; |
| 690 | case WebAssembly::PCALL_INDIRECT_VOID: return WebAssembly::PCALL_INDIRECT_VOID_S; |
| 691 | case WebAssembly::PCALL_INDIRECT_v16i8: return WebAssembly::PCALL_INDIRECT_v16i8_S; |
| 692 | case WebAssembly::PCALL_INDIRECT_v4f32: return WebAssembly::PCALL_INDIRECT_v4f32_S; |
| 693 | case WebAssembly::PCALL_INDIRECT_v4i32: return WebAssembly::PCALL_INDIRECT_v4i32_S; |
| 694 | case WebAssembly::PCALL_INDIRECT_v8i16: return WebAssembly::PCALL_INDIRECT_v8i16_S; |
| 695 | case WebAssembly::POPCNT_I32: return WebAssembly::POPCNT_I32_S; |
| 696 | case WebAssembly::POPCNT_I64: return WebAssembly::POPCNT_I64_S; |
| 697 | case WebAssembly::REM_S_I32: return WebAssembly::REM_S_I32_S; |
| 698 | case WebAssembly::REM_S_I64: return WebAssembly::REM_S_I64_S; |
| 699 | case WebAssembly::REM_U_I32: return WebAssembly::REM_U_I32_S; |
| 700 | case WebAssembly::REM_U_I64: return WebAssembly::REM_U_I64_S; |
| 701 | case WebAssembly::RETHROW: return WebAssembly::RETHROW_S; |
| 702 | case WebAssembly::RETHROW_TO_CALLER: return WebAssembly::RETHROW_TO_CALLER_S; |
| 703 | case WebAssembly::RETURN_EXCEPT_REF: return WebAssembly::RETURN_EXCEPT_REF_S; |
| 704 | case WebAssembly::RETURN_F32: return WebAssembly::RETURN_F32_S; |
| 705 | case WebAssembly::RETURN_F64: return WebAssembly::RETURN_F64_S; |
| 706 | case WebAssembly::RETURN_I32: return WebAssembly::RETURN_I32_S; |
| 707 | case WebAssembly::RETURN_I64: return WebAssembly::RETURN_I64_S; |
| 708 | case WebAssembly::RETURN_VOID: return WebAssembly::RETURN_VOID_S; |
| 709 | case WebAssembly::RETURN_v16i8: return WebAssembly::RETURN_v16i8_S; |
| 710 | case WebAssembly::RETURN_v4f32: return WebAssembly::RETURN_v4f32_S; |
| 711 | case WebAssembly::RETURN_v4i32: return WebAssembly::RETURN_v4i32_S; |
| 712 | case WebAssembly::RETURN_v8i16: return WebAssembly::RETURN_v8i16_S; |
| 713 | case WebAssembly::ROTL_I32: return WebAssembly::ROTL_I32_S; |
| 714 | case WebAssembly::ROTL_I64: return WebAssembly::ROTL_I64_S; |
| 715 | case WebAssembly::ROTR_I32: return WebAssembly::ROTR_I32_S; |
| 716 | case WebAssembly::ROTR_I64: return WebAssembly::ROTR_I64_S; |
| 717 | case WebAssembly::SELECT_EXCEPT_REF: return WebAssembly::SELECT_EXCEPT_REF_S; |
| 718 | case WebAssembly::SELECT_F32: return WebAssembly::SELECT_F32_S; |
| 719 | case WebAssembly::SELECT_F64: return WebAssembly::SELECT_F64_S; |
| 720 | case WebAssembly::SELECT_I32: return WebAssembly::SELECT_I32_S; |
| 721 | case WebAssembly::SELECT_I64: return WebAssembly::SELECT_I64_S; |
| 722 | case WebAssembly::SET_GLOBAL_EXCEPT_REF: return WebAssembly::SET_GLOBAL_EXCEPT_REF_S; |
| 723 | case WebAssembly::SET_GLOBAL_F32: return WebAssembly::SET_GLOBAL_F32_S; |
| 724 | case WebAssembly::SET_GLOBAL_F64: return WebAssembly::SET_GLOBAL_F64_S; |
| 725 | case WebAssembly::SET_GLOBAL_I32: return WebAssembly::SET_GLOBAL_I32_S; |
| 726 | case WebAssembly::SET_GLOBAL_I64: return WebAssembly::SET_GLOBAL_I64_S; |
| 727 | case WebAssembly::SET_GLOBAL_V128: return WebAssembly::SET_GLOBAL_V128_S; |
| 728 | case WebAssembly::SET_LOCAL_EXCEPT_REF: return WebAssembly::SET_LOCAL_EXCEPT_REF_S; |
| 729 | case WebAssembly::SET_LOCAL_F32: return WebAssembly::SET_LOCAL_F32_S; |
| 730 | case WebAssembly::SET_LOCAL_F64: return WebAssembly::SET_LOCAL_F64_S; |
| 731 | case WebAssembly::SET_LOCAL_I32: return WebAssembly::SET_LOCAL_I32_S; |
| 732 | case WebAssembly::SET_LOCAL_I64: return WebAssembly::SET_LOCAL_I64_S; |
| 733 | case WebAssembly::SET_LOCAL_V128: return WebAssembly::SET_LOCAL_V128_S; |
| 734 | case WebAssembly::SHL_I32: return WebAssembly::SHL_I32_S; |
| 735 | case WebAssembly::SHL_I64: return WebAssembly::SHL_I64_S; |
| 736 | case WebAssembly::SHR_S_I32: return WebAssembly::SHR_S_I32_S; |
| 737 | case WebAssembly::SHR_S_I64: return WebAssembly::SHR_S_I64_S; |
| 738 | case WebAssembly::SHR_U_I32: return WebAssembly::SHR_U_I32_S; |
| 739 | case WebAssembly::SHR_U_I64: return WebAssembly::SHR_U_I64_S; |
| 740 | case WebAssembly::SQRT_F32: return WebAssembly::SQRT_F32_S; |
| 741 | case WebAssembly::SQRT_F64: return WebAssembly::SQRT_F64_S; |
| 742 | case WebAssembly::STORE16_I32: return WebAssembly::STORE16_I32_S; |
| 743 | case WebAssembly::STORE16_I64: return WebAssembly::STORE16_I64_S; |
| 744 | case WebAssembly::STORE32_I64: return WebAssembly::STORE32_I64_S; |
| 745 | case WebAssembly::STORE8_I32: return WebAssembly::STORE8_I32_S; |
| 746 | case WebAssembly::STORE8_I64: return WebAssembly::STORE8_I64_S; |
| 747 | case WebAssembly::STORE_F32: return WebAssembly::STORE_F32_S; |
| 748 | case WebAssembly::STORE_F64: return WebAssembly::STORE_F64_S; |
| 749 | case WebAssembly::STORE_I32: return WebAssembly::STORE_I32_S; |
| 750 | case WebAssembly::STORE_I64: return WebAssembly::STORE_I64_S; |
| 751 | case WebAssembly::SUB_F32: return WebAssembly::SUB_F32_S; |
| 752 | case WebAssembly::SUB_F32x4: return WebAssembly::SUB_F32x4_S; |
| 753 | case WebAssembly::SUB_F64: return WebAssembly::SUB_F64_S; |
| 754 | case WebAssembly::SUB_I16x8: return WebAssembly::SUB_I16x8_S; |
| 755 | case WebAssembly::SUB_I32: return WebAssembly::SUB_I32_S; |
| 756 | case WebAssembly::SUB_I32x4: return WebAssembly::SUB_I32x4_S; |
| 757 | case WebAssembly::SUB_I64: return WebAssembly::SUB_I64_S; |
| 758 | case WebAssembly::SUB_I8x16: return WebAssembly::SUB_I8x16_S; |
| 759 | case WebAssembly::TEE_EXCEPT_REF: return WebAssembly::TEE_EXCEPT_REF_S; |
| 760 | case WebAssembly::TEE_F32: return WebAssembly::TEE_F32_S; |
| 761 | case WebAssembly::TEE_F64: return WebAssembly::TEE_F64_S; |
| 762 | case WebAssembly::TEE_I32: return WebAssembly::TEE_I32_S; |
| 763 | case WebAssembly::TEE_I64: return WebAssembly::TEE_I64_S; |
| 764 | case WebAssembly::TEE_LOCAL_EXCEPT_REF: return WebAssembly::TEE_LOCAL_EXCEPT_REF_S; |
| 765 | case WebAssembly::TEE_LOCAL_F32: return WebAssembly::TEE_LOCAL_F32_S; |
| 766 | case WebAssembly::TEE_LOCAL_F64: return WebAssembly::TEE_LOCAL_F64_S; |
| 767 | case WebAssembly::TEE_LOCAL_I32: return WebAssembly::TEE_LOCAL_I32_S; |
| 768 | case WebAssembly::TEE_LOCAL_I64: return WebAssembly::TEE_LOCAL_I64_S; |
| 769 | case WebAssembly::TEE_LOCAL_V128: return WebAssembly::TEE_LOCAL_V128_S; |
| 770 | case WebAssembly::TEE_V128: return WebAssembly::TEE_V128_S; |
| 771 | case WebAssembly::THROW_I32: return WebAssembly::THROW_I32_S; |
| 772 | case WebAssembly::THROW_I64: return WebAssembly::THROW_I64_S; |
| 773 | case WebAssembly::TRUNC_F32: return WebAssembly::TRUNC_F32_S; |
| 774 | case WebAssembly::TRUNC_F64: return WebAssembly::TRUNC_F64_S; |
| 775 | case WebAssembly::TRY: return WebAssembly::TRY_S; |
| 776 | case WebAssembly::UNREACHABLE: return WebAssembly::UNREACHABLE_S; |
| 777 | case WebAssembly::XOR_I32: return WebAssembly::XOR_I32_S; |
| 778 | case WebAssembly::XOR_I64: return WebAssembly::XOR_I64_S; |
| 779 | } |
| 780 | } |