summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2016-10-24 19:49:43 +0000
committerDan Gohman <dan433584@gmail.com>2016-10-24 19:49:43 +0000
commit4fc4e42dea2547f40d3672ccf473fc2fbbdfc903 (patch)
treeebcc8d0e10c97409e41a89e296db5aca2f0ce7fc /llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp
parentc3e0ce8f8527d340c168d7361c1c59d8df544ecb (diff)
downloadbcm5719-llvm-4fc4e42dea2547f40d3672ccf473fc2fbbdfc903.tar.gz
bcm5719-llvm-4fc4e42dea2547f40d3672ccf473fc2fbbdfc903.zip
[WebAssembly] Add an option to make get_local/set_local explicit.
This patch adds a pass, controlled by an option and off by default for now, for making implicit get_local/set_local explicit. This simplifies emitting wasm with MC. Differential Revision: https://reviews.llvm.org/D25836 llvm-svn: 285009
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp28
1 files changed, 6 insertions, 22 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp
index 52fdaf0417a..473dcb7a33f 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp
@@ -23,6 +23,7 @@
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySubtarget.h"
+#include "WebAssemblyUtilities.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
@@ -58,27 +59,10 @@ FunctionPass *llvm::createWebAssemblyPrepareForLiveIntervals() {
return new WebAssemblyPrepareForLiveIntervals();
}
-/// Test whether the given instruction is an ARGUMENT.
-static bool IsArgument(const MachineInstr *MI) {
- switch (MI->getOpcode()) {
- case WebAssembly::ARGUMENT_I32:
- case WebAssembly::ARGUMENT_I64:
- case WebAssembly::ARGUMENT_F32:
- case WebAssembly::ARGUMENT_F64:
- case WebAssembly::ARGUMENT_v16i8:
- case WebAssembly::ARGUMENT_v8i16:
- case WebAssembly::ARGUMENT_v4i32:
- case WebAssembly::ARGUMENT_v4f32:
- return true;
- default:
- return false;
- }
-}
-
// Test whether the given register has an ARGUMENT def.
static bool HasArgumentDef(unsigned Reg, const MachineRegisterInfo &MRI) {
for (const auto &Def : MRI.def_instructions(Reg))
- if (IsArgument(&Def))
+ if (WebAssembly::isArgument(Def))
return true;
return false;
}
@@ -126,10 +110,10 @@ bool WebAssemblyPrepareForLiveIntervals::runOnMachineFunction(MachineFunction &M
// Move ARGUMENT_* instructions to the top of the entry block, so that their
// liveness reflects the fact that these really are live-in values.
for (auto MII = Entry.begin(), MIE = Entry.end(); MII != MIE; ) {
- MachineInstr *MI = &*MII++;
- if (IsArgument(MI)) {
- MI->removeFromParent();
- Entry.insert(Entry.begin(), MI);
+ MachineInstr &MI = *MII++;
+ if (WebAssembly::isArgument(MI)) {
+ MI.removeFromParent();
+ Entry.insert(Entry.begin(), &MI);
}
}
OpenPOWER on IntegriCloud