Chromium Code Reviews| Index: src/IceCompiler.cpp |
| diff --git a/src/IceCompiler.cpp b/src/IceCompiler.cpp |
| index bd5e8343a554bf1ada85fd1da831f64ce6007770..26eb5a1a7e8ef518249fb70df3f684d52b9e4339 100644 |
| --- a/src/IceCompiler.cpp |
| +++ b/src/IceCompiler.cpp |
| @@ -27,6 +27,10 @@ |
| #include "IceELFObjectWriter.h" |
| #include "PNaClTranslator.h" |
| +#ifdef SUBZERO_WASM |
| +#include "WasmTranslator.h" |
| +#endif |
|
JF
2016/03/28 18:17:13
Why not put the #if in the other header?
Eric Holk
2016/03/29 19:54:08
Done.
|
| + |
| #ifdef __clang__ |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wunused-parameter" |
| @@ -55,6 +59,11 @@ bool llvmIRInput(const IceString &Filename) { |
| std::regex_match(Filename, std::regex(".*\\.ll")); |
| } |
| +bool wasmInput(const IceString &Filename) { |
| + return BuildDefs::llvmIrAsInput() && |
| + std::regex_match(Filename, std::regex(".*\\.wasm")); |
|
JF
2016/03/28 18:17:13
Eek, I wouldn't use regex for this. It's a huge ha
Eric Holk
2016/03/29 19:54:08
I just cargo-culted from the previous llvmIRInput
|
| +} |
| + |
| } // end of anonymous namespace |
| void Compiler::run(const Ice::ClFlags &Flags, GlobalContext &Ctx, |
| @@ -78,13 +87,28 @@ void Compiler::run(const Ice::ClFlags &Flags, GlobalContext &Ctx, |
| std::unique_ptr<Translator> Translator; |
| const IceString &IRFilename = Flags.getIRFilename(); |
| - const bool BuildOnRead = Flags.getBuildOnRead() && !llvmIRInput(IRFilename); |
| + 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) { |
| +#ifdef SUBZERO_WASM |
|
Jim Stichnoth
2016/03/29 17:49:57
We try to minimize the use of #ifdef code. Where
Eric Holk
2016/03/29 22:58:07
My latest update should have basically no #ifdef c
|
| + 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; |
| +#endif |
|
JF
2016/03/28 18:17:13
Would be nice if this switch were only visible fro
Eric Holk
2016/03/29 19:54:08
Done.
|
| } else if (BuildDefs::llvmIr()) { |
| if (BuildDefs::browser()) { |
| Ctx.getStrError() |