summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.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/WebAssemblyArgumentMove.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/WebAssemblyArgumentMove.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp
index 04951485a71..5fadca38b82 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp
@@ -30,6 +30,7 @@
#include "WebAssembly.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySubtarget.h"
+#include "WebAssemblyUtilities.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
@@ -63,23 +64,6 @@ FunctionPass *llvm::createWebAssemblyArgumentMove() {
return new WebAssemblyArgumentMove();
}
-/// 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;
- }
-}
-
bool WebAssemblyArgumentMove::runOnMachineFunction(MachineFunction &MF) {
DEBUG({
dbgs() << "********** Argument Move **********\n"
@@ -92,7 +76,7 @@ bool WebAssemblyArgumentMove::runOnMachineFunction(MachineFunction &MF) {
// Look for the first NonArg instruction.
for (MachineInstr &MI : EntryMBB) {
- if (!IsArgument(MI)) {
+ if (!WebAssembly::isArgument(MI)) {
InsertPt = MI;
break;
}
@@ -101,7 +85,7 @@ bool WebAssemblyArgumentMove::runOnMachineFunction(MachineFunction &MF) {
// Now move any argument instructions later in the block
// to before our first NonArg instruction.
for (MachineInstr &MI : llvm::make_range(InsertPt, EntryMBB.end())) {
- if (IsArgument(MI)) {
+ if (WebAssembly::isArgument(MI)) {
EntryMBB.insert(InsertPt, MI.removeFromParent());
Changed = true;
}
OpenPOWER on IntegriCloud