OLD | NEW |
1 //===- subzero/src/WasmTranslator.h - WASM to Subzero Translation ---------===// | 1 //===- subzero/src/WasmTranslator.h - WASM to Subzero Translation ---------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
11 /// \brief Declares a driver for translating Wasm bitcode into PNaCl bitcode. | 11 /// \brief Declares a driver for translating Wasm bitcode into PNaCl bitcode. |
12 /// | 12 /// |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #ifndef SUBZERO_SRC_WASMTRANSLATOR_H | 15 #ifndef SUBZERO_SRC_WASMTRANSLATOR_H |
16 #define SUBZERO_SRC_WASMTRANSLATOR_H | 16 #define SUBZERO_SRC_WASMTRANSLATOR_H |
17 | 17 |
18 #if ALLOW_WASM | 18 #if ALLOW_WASM |
19 | 19 |
20 #include "IceGlobalContext.h" | 20 #include "IceGlobalContext.h" |
21 #include "IceTranslator.h" | 21 #include "IceTranslator.h" |
22 | 22 |
| 23 #ifdef __clang__ |
| 24 #pragma clang diagnostic push |
| 25 #pragma clang diagnostic ignored "-Wunused-parameter" |
| 26 #endif // __clang__ |
| 27 |
| 28 #include "llvm/Support/StreamingMemoryObject.h" |
| 29 |
| 30 #ifdef __clang__ |
| 31 #pragma clang diagnostic pop |
| 32 #endif // __clang__ |
| 33 |
23 namespace v8 { | 34 namespace v8 { |
24 namespace internal { | 35 namespace internal { |
25 class Zone; | 36 class Zone; |
26 namespace wasm { | 37 namespace wasm { |
27 class FunctionEnv; | 38 struct FunctionBody; |
28 } // end of namespace wasm | 39 } // end of namespace wasm |
29 } // end of namespace internal | 40 } // end of namespace internal |
30 } // end of namespace v8 | 41 } // end of namespace v8 |
31 | 42 |
32 namespace Ice { | 43 namespace Ice { |
33 | 44 |
34 class WasmTranslator : public Translator { | 45 class WasmTranslator : public Translator { |
35 WasmTranslator() = delete; | 46 WasmTranslator() = delete; |
36 WasmTranslator(const WasmTranslator &) = delete; | 47 WasmTranslator(const WasmTranslator &) = delete; |
37 WasmTranslator &operator=(const WasmTranslator &) = delete; | 48 WasmTranslator &operator=(const WasmTranslator &) = delete; |
38 | 49 |
39 template <typename F = std::function<void(Ostream &)>> void log(F Fn) { | 50 template <typename F = std::function<void(Ostream &)>> void log(F Fn) { |
40 if (BuildDefs::dump() && (getFlags().getVerbose() & IceV_Wasm)) { | 51 if (BuildDefs::dump() && (getFlags().getVerbose() & IceV_Wasm)) { |
41 Fn(Ctx->getStrDump()); | 52 Fn(Ctx->getStrDump()); |
42 Ctx->getStrDump().flush(); | 53 Ctx->getStrDump().flush(); |
43 } | 54 } |
44 } | 55 } |
45 | 56 |
46 public: | 57 public: |
47 explicit WasmTranslator(GlobalContext *Ctx); | 58 explicit WasmTranslator(GlobalContext *Ctx); |
48 | 59 |
49 void translate(const std::string &IRFilename, | 60 void translate(const std::string &IRFilename, |
50 std::unique_ptr<llvm::DataStreamer> InputStream); | 61 std::unique_ptr<llvm::DataStreamer> InputStream); |
51 | 62 |
52 /// Translates a single Wasm function. | 63 /// Translates a single Wasm function. |
53 /// | 64 /// |
54 /// Parameters: | 65 /// Parameters: |
55 /// Zone - an arena for the V8 code to allocate from. | 66 /// Zone - an arena for the V8 code to allocate from. |
56 /// Env - information about the function (signature, variable count, etc.). | 67 /// Body - information about the function to translate |
57 /// Base - a pointer to the start of the Wasm module. | 68 std::unique_ptr<Cfg> |
58 /// Start - a pointer to the start of the function within the module. | 69 translateFunction(v8::internal::Zone *Zone, |
59 /// End - a pointer to the end of the function. | 70 v8::internal::wasm::FunctionBody &Body); |
60 std::unique_ptr<Cfg> translateFunction(v8::internal::Zone *Zone, | |
61 v8::internal::wasm::FunctionEnv *Env, | |
62 const uint8_t *Base, | |
63 const uint8_t *Start, | |
64 const uint8_t *End); | |
65 | 71 |
66 private: | 72 private: |
67 std::unique_ptr<uint8_t[]> Buffer; | 73 std::unique_ptr<uint8_t[]> Buffer; |
68 SizeT BufferSize; | 74 SizeT BufferSize; |
69 }; | 75 }; |
70 } | 76 } |
71 | 77 |
72 #endif // ALLOW_WASM | 78 #endif // ALLOW_WASM |
73 | 79 |
74 #endif // SUBZERO_SRC_WASMTRANSLATOR_H | 80 #endif // SUBZERO_SRC_WASMTRANSLATOR_H |
OLD | NEW |