Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: src/IceCompiler.cpp

Issue 1837663002: Initial Subzero WASM prototype. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Make presubmit great again Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceCompiler.cpp
diff --git a/src/IceCompiler.cpp b/src/IceCompiler.cpp
index 7a426fc28de566adac7e312d331106da5175663f..87582a171b47836ce6241399c80a05052b07eace 100644
--- a/src/IceCompiler.cpp
+++ b/src/IceCompiler.cpp
@@ -25,6 +25,7 @@
#include "IceConverter.h"
#include "IceELFObjectWriter.h"
#include "PNaClTranslator.h"
+#include "WasmTranslator.h"
#ifdef __clang__
#pragma clang diagnostic push
@@ -54,6 +55,11 @@ bool llvmIRInput(const std::string &Filename) {
std::regex_match(Filename, std::regex(".*\\.ll"));
}
+bool wasmInput(const std::string &Filename) {
+ return BuildDefs::llvmIrAsInput() &&
+ std::regex_match(Filename, std::regex(".*\\.wasm"));
+}
+
} // end of anonymous namespace
void Compiler::run(const Ice::ClFlags &Flags, GlobalContext &Ctx,
@@ -74,14 +80,28 @@ void Compiler::run(const Ice::ClFlags &Flags, GlobalContext &Ctx,
Ctx.startWorkerThreads();
std::unique_ptr<Translator> Translator;
- const std::string IRFilename = Flags.getIRFilename();
- const bool BuildOnRead = Flags.getBuildOnRead() && !llvmIRInput(IRFilename);
+ const std::string &IRFilename = Flags.getIRFilename();
Jim Stichnoth 2016/04/04 21:26:51 Safer long-term to use plain std::string instead o
Eric Holk 2016/04/04 22:23:22 Done.
+ const bool BuildOnRead = Flags.getBuildOnRead() && !llvmIRInput(IRFilename) &&
+ !wasmInput(IRFilename);
+ const bool WasmBuildOnRead = Flags.getBuildOnRead() && wasmInput(IRFilename);
if (BuildOnRead) {
std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx));
std::unique_ptr<llvm::StreamingMemoryObject> MemObj(
new llvm::StreamingMemoryObjectImpl(InputStream.release()));
PTranslator->translate(IRFilename, std::move(MemObj));
Translator.reset(PTranslator.release());
+ } else if (WasmBuildOnRead) {
+ if (BuildDefs::wasm()) {
+ std::unique_ptr<WasmTranslator> WTranslator(new WasmTranslator(&Ctx));
+
+ WTranslator->translate(IRFilename, std::move(InputStream));
+
+ Translator.reset(WTranslator.release());
+ } else {
+ Ctx.getStrError() << "WASM support not enabled\n";
+ Ctx.getErrorStatus()->assign(EC_Args);
+ return;
+ }
} else if (BuildDefs::llvmIr()) {
if (BuildDefs::browser()) {
Ctx.getStrError()

Powered by Google App Engine
This is Rietveld 408576698