Index: src/IceCompiler.cpp |
diff --git a/src/IceCompiler.cpp b/src/IceCompiler.cpp |
index 4ad7730dd7ce30332c8b5ba9cb8268ff54bc8193..54ab076a69e8b070ada26c90f05fa5c4df5e5081 100644 |
--- a/src/IceCompiler.cpp |
+++ b/src/IceCompiler.cpp |
@@ -26,6 +26,8 @@ |
#include "IceELFObjectWriter.h" |
#include "PNaClTranslator.h" |
Jim Stichnoth
2016/04/01 01:46:44
remove blank line?
Eric Holk
2016/04/01 19:15:01
Done.
|
+#include "WasmTranslator.h" |
+ |
#ifdef __clang__ |
#pragma clang diagnostic push |
#pragma clang diagnostic ignored "-Wunused-parameter" |
@@ -54,6 +56,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, |
@@ -76,14 +83,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(); |
+ 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() |