diff options
author | Dan Gohman <dan433584@gmail.com> | 2016-10-24 23:27:49 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2016-10-24 23:27:49 +0000 |
commit | 3acb187d95a8cbe1941459a9c6fb62cc5d44b1e5 (patch) | |
tree | 450f11c44d1568ef9e344e5163d34bc4d305250b /llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | |
parent | 8b38ffaa986a06a6bdbd243b26eacc46ce9e5889 (diff) | |
download | bcm5719-llvm-3acb187d95a8cbe1941459a9c6fb62cc5d44b1e5.tar.gz bcm5719-llvm-3acb187d95a8cbe1941459a9c6fb62cc5d44b1e5.zip |
[WebAssembly] Implement more WebAssembly binary encoding.
This changes locals from being declared by the emitLocal hook in
WebAssemblyTargetStreamer, rather than with an instruction. After exploring
the infastructure in LLVM more, this seems to make more sense since
declaring locals doesn't use an encoded opcode.
This also adds more 0xd opcodes, type encodings, and miscellaneous
binary encoding bits.
llvm-svn: 285040
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp index 3b527922419..56b0f4fb684 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -109,15 +109,15 @@ static unsigned getTeeLocalOpcode(const TargetRegisterClass *RC) { } /// Get the type associated with the given register class. -static WebAssembly::ValType typeForRegClass(const TargetRegisterClass *RC) { +static MVT typeForRegClass(const TargetRegisterClass *RC) { if (RC == &WebAssembly::I32RegClass) - return WebAssembly::ValType::I32; + return MVT::i32; if (RC == &WebAssembly::I64RegClass) - return WebAssembly::ValType::I64; + return MVT::i64; if (RC == &WebAssembly::F32RegClass) - return WebAssembly::ValType::F32; + return MVT::f32; if (RC == &WebAssembly::F64RegClass) - return WebAssembly::ValType::F64; + return MVT::f64; llvm_unreachable("unrecognized register class"); } @@ -272,21 +272,15 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { } } - // Insert a .locals directive to declare the locals. - MachineInstrBuilder DeclareLocals; + // Define the locals. for (size_t i = 0, e = MRI.getNumVirtRegs(); i < e; ++i) { unsigned Reg = TargetRegisterInfo::index2VirtReg(i); auto I = Reg2Local.find(Reg); if (I == Reg2Local.end() || I->second < MFI.getParams().size()) continue; - if (!DeclareLocals) { - DeclareLocals = BuildMI(*MF.begin(), MF.begin()->begin(), DebugLoc(), - TII->get(WebAssembly::DECLARE_LOCALS)); - Changed = true; - } - - DeclareLocals.addImm(int64_t(typeForRegClass(MRI.getRegClass(Reg)))); + MFI.addLocal(typeForRegClass(MRI.getRegClass(Reg))); + Changed = true; } #ifndef NDEBUG |