MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / compile

Method compile

test/llvm/LLVMcoreTest.cpp:67–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65 VM.registerModule(SpecTestMod);
66 }
67 Expect<std::string> compile(const std::string &FileName) {
68 WasmEdge::Configure CopyConf = Conf;
69 WasmEdge::Loader::Loader Loader(Conf);
70 WasmEdge::Validator::Validator ValidatorEngine(Conf);
71 CopyConf.getCompilerConfigure().setOutputFormat(
72 CompilerConfigure::OutputFormat::Native);
73 CopyConf.getCompilerConfigure().setOptimizationLevel(
74 WasmEdge::CompilerConfigure::OptimizationLevel::O0);
75 CopyConf.getCompilerConfigure().setDumpIR(true);
76 WasmEdge::LLVM::Compiler Compiler(CopyConf);
77 WasmEdge::LLVM::CodeGen CodeGen(CopyConf);
78 auto Path = std::filesystem::u8path(FileName);
79 Path.replace_extension(std::filesystem::u8path(WASMEDGE_LIB_EXTENSION));
80 const auto SOPath = Path.u8string();
81 std::vector<WasmEdge::Byte> Data;
82 std::unique_ptr<WasmEdge::AST::Module> Module;
83 return Loader.loadFile(FileName)
84 .and_then([&](auto Result) noexcept {
85 Data = std::move(Result);
86 return Loader.parseModule(Data);
87 })
88 .and_then([&](auto Result) noexcept {
89 Module = std::move(Result);
90 return ValidatorEngine.validate(*Module);
91 })
92 .and_then([&]() noexcept { return Compiler.compile(*Module); })
93 .and_then([&](auto Result) noexcept {
94 return CodeGen.codegen(Data, std::move(Result), SOPath);
95 })
96 .and_then([&]() noexcept { return Expect<std::string>{SOPath}; });
97 }
98 };
99
100 T.onInit = [&ConfRef](SpecTest::ContextHandle Parent,

Callers 4

TEST_PFunction · 0.45
TESTFunction · 0.45
compileModuleFunction · 0.45
TESTFunction · 0.45

Calls 7

setOutputFormatMethod · 0.80
setOptimizationLevelMethod · 0.80
setDumpIRMethod · 0.80
parseModuleMethod · 0.80
codegenMethod · 0.80
loadFileMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected