From 4fc4e42dea2547f40d3672ccf473fc2fbbdfc903 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 24 Oct 2016 19:49:43 +0000 Subject: [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 --- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index e8fbe9413455..f0f74e7b5e80 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -41,6 +41,11 @@ static cl::opt EnableEmSjLj( cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"), cl::init(false)); +static cl::opt ExplicitLocals( + "wasm-explicit-locals", + cl::desc("WebAssembly with explicit get_local/set_local"), + cl::init(false)); + extern "C" void LLVMInitializeWebAssemblyTarget() { // Register the target. RegisterTargetMachine X( @@ -256,6 +261,10 @@ void WebAssemblyPassConfig::addPreEmitPass() { addPass(createWebAssemblyRegColoring()); } + // Insert explicit get_local and set_local operators. + if (ExplicitLocals) + addPass(createWebAssemblyExplicitLocals()); + // Eliminate multiple-entry loops. addPass(createWebAssemblyFixIrreducibleControlFlow()); -- cgit v1.2.3