[WebAssembly] Add new target feature in support of 'extended-const' proposal
[llvm-project.git] / llvm / lib / Target / WebAssembly / WebAssemblyTargetMachine.cpp
blob85014b631a0783683c0ece695dd4db13df80d569
1 //===- WebAssemblyTargetMachine.cpp - Define TargetMachine for WebAssembly -==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file defines the WebAssembly-specific subclass of TargetMachine.
11 ///
12 //===----------------------------------------------------------------------===//
14 #include "WebAssemblyTargetMachine.h"
15 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
16 #include "TargetInfo/WebAssemblyTargetInfo.h"
17 #include "Utils/WebAssemblyUtilities.h"
18 #include "WebAssembly.h"
19 #include "WebAssemblyMachineFunctionInfo.h"
20 #include "WebAssemblyTargetObjectFile.h"
21 #include "WebAssemblyTargetTransformInfo.h"
22 #include "llvm/CodeGen/MIRParser/MIParser.h"
23 #include "llvm/CodeGen/MachineFunctionPass.h"
24 #include "llvm/CodeGen/Passes.h"
25 #include "llvm/CodeGen/RegAllocRegistry.h"
26 #include "llvm/CodeGen/TargetPassConfig.h"
27 #include "llvm/IR/Function.h"
28 #include "llvm/MC/MCAsmInfo.h"
29 #include "llvm/MC/TargetRegistry.h"
30 #include "llvm/Target/TargetOptions.h"
31 #include "llvm/Transforms/Scalar.h"
32 #include "llvm/Transforms/Scalar/LowerAtomic.h"
33 #include "llvm/Transforms/Utils.h"
34 using namespace llvm;
36 #define DEBUG_TYPE "wasm"
38 // A command-line option to keep implicit locals
39 // for the purpose of testing with lit/llc ONLY.
40 // This produces output which is not valid WebAssembly, and is not supported
41 // by assemblers/disassemblers and other MC based tools.
42 static cl::opt<bool> WasmDisableExplicitLocals(
43 "wasm-disable-explicit-locals", cl::Hidden,
44 cl::desc("WebAssembly: output implicit locals in"
45 " instruction output for test purposes only."),
46 cl::init(false));
48 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() {
49 // Register the target.
50 RegisterTargetMachine<WebAssemblyTargetMachine> X(
51 getTheWebAssemblyTarget32());
52 RegisterTargetMachine<WebAssemblyTargetMachine> Y(
53 getTheWebAssemblyTarget64());
55 // Register backend passes
56 auto &PR = *PassRegistry::getPassRegistry();
57 initializeWebAssemblyAddMissingPrototypesPass(PR);
58 initializeWebAssemblyLowerEmscriptenEHSjLjPass(PR);
59 initializeLowerGlobalDtorsPass(PR);
60 initializeFixFunctionBitcastsPass(PR);
61 initializeOptimizeReturnedPass(PR);
62 initializeWebAssemblyArgumentMovePass(PR);
63 initializeWebAssemblySetP2AlignOperandsPass(PR);
64 initializeWebAssemblyReplacePhysRegsPass(PR);
65 initializeWebAssemblyPrepareForLiveIntervalsPass(PR);
66 initializeWebAssemblyOptimizeLiveIntervalsPass(PR);
67 initializeWebAssemblyMemIntrinsicResultsPass(PR);
68 initializeWebAssemblyRegStackifyPass(PR);
69 initializeWebAssemblyRegColoringPass(PR);
70 initializeWebAssemblyNullifyDebugValueListsPass(PR);
71 initializeWebAssemblyFixIrreducibleControlFlowPass(PR);
72 initializeWebAssemblyLateEHPreparePass(PR);
73 initializeWebAssemblyExceptionInfoPass(PR);
74 initializeWebAssemblyCFGSortPass(PR);
75 initializeWebAssemblyCFGStackifyPass(PR);
76 initializeWebAssemblyExplicitLocalsPass(PR);
77 initializeWebAssemblyLowerBrUnlessPass(PR);
78 initializeWebAssemblyRegNumberingPass(PR);
79 initializeWebAssemblyDebugFixupPass(PR);
80 initializeWebAssemblyPeepholePass(PR);
81 initializeWebAssemblyMCLowerPrePassPass(PR);
84 //===----------------------------------------------------------------------===//
85 // WebAssembly Lowering public interface.
86 //===----------------------------------------------------------------------===//
88 static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM,
89 const Triple &TT) {
90 if (!RM.hasValue()) {
91 // Default to static relocation model. This should always be more optimial
92 // than PIC since the static linker can determine all global addresses and
93 // assume direct function calls.
94 return Reloc::Static;
97 if (!TT.isOSEmscripten()) {
98 // Relocation modes other than static are currently implemented in a way
99 // that only works for Emscripten, so disable them if we aren't targeting
100 // Emscripten.
101 return Reloc::Static;
104 return *RM;
107 /// Create an WebAssembly architecture model.
109 WebAssemblyTargetMachine::WebAssemblyTargetMachine(
110 const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
111 const TargetOptions &Options, Optional<Reloc::Model> RM,
112 Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT)
113 : LLVMTargetMachine(
115 TT.isArch64Bit()
116 ? (TT.isOSEmscripten() ? "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
117 "f128:64-n32:64-S128-ni:1:10:20"
118 : "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
119 "n32:64-S128-ni:1:10:20")
120 : (TT.isOSEmscripten() ? "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-"
121 "f128:64-n32:64-S128-ni:1:10:20"
122 : "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-"
123 "n32:64-S128-ni:1:10:20"),
124 TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT),
125 getEffectiveCodeModel(CM, CodeModel::Large), OL),
126 TLOF(new WebAssemblyTargetObjectFile()) {
127 // WebAssembly type-checks instructions, but a noreturn function with a return
128 // type that doesn't match the context will cause a check failure. So we lower
129 // LLVM 'unreachable' to ISD::TRAP and then lower that to WebAssembly's
130 // 'unreachable' instructions which is meant for that case.
131 this->Options.TrapUnreachable = true;
133 // WebAssembly treats each function as an independent unit. Force
134 // -ffunction-sections, effectively, so that we can emit them independently.
135 this->Options.FunctionSections = true;
136 this->Options.DataSections = true;
137 this->Options.UniqueSectionNames = true;
139 initAsmInfo();
141 // Note that we don't use setRequiresStructuredCFG(true). It disables
142 // optimizations than we're ok with, and want, such as critical edge
143 // splitting and tail merging.
146 WebAssemblyTargetMachine::~WebAssemblyTargetMachine() = default; // anchor.
148 const WebAssemblySubtarget *WebAssemblyTargetMachine::getSubtargetImpl() const {
149 return getSubtargetImpl(std::string(getTargetCPU()),
150 std::string(getTargetFeatureString()));
153 const WebAssemblySubtarget *
154 WebAssemblyTargetMachine::getSubtargetImpl(std::string CPU,
155 std::string FS) const {
156 auto &I = SubtargetMap[CPU + FS];
157 if (!I) {
158 I = std::make_unique<WebAssemblySubtarget>(TargetTriple, CPU, FS, *this);
160 return I.get();
163 const WebAssemblySubtarget *
164 WebAssemblyTargetMachine::getSubtargetImpl(const Function &F) const {
165 Attribute CPUAttr = F.getFnAttribute("target-cpu");
166 Attribute FSAttr = F.getFnAttribute("target-features");
168 std::string CPU =
169 CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
170 std::string FS =
171 FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
173 // This needs to be done before we create a new subtarget since any
174 // creation will depend on the TM and the code generation flags on the
175 // function that reside in TargetOptions.
176 resetTargetOptions(F);
178 return getSubtargetImpl(CPU, FS);
181 namespace {
183 class CoalesceFeaturesAndStripAtomics final : public ModulePass {
184 // Take the union of all features used in the module and use it for each
185 // function individually, since having multiple feature sets in one module
186 // currently does not make sense for WebAssembly. If atomics are not enabled,
187 // also strip atomic operations and thread local storage.
188 static char ID;
189 WebAssemblyTargetMachine *WasmTM;
191 public:
192 CoalesceFeaturesAndStripAtomics(WebAssemblyTargetMachine *WasmTM)
193 : ModulePass(ID), WasmTM(WasmTM) {}
195 bool runOnModule(Module &M) override {
196 FeatureBitset Features = coalesceFeatures(M);
198 std::string FeatureStr = getFeatureString(Features);
199 WasmTM->setTargetFeatureString(FeatureStr);
200 for (auto &F : M)
201 replaceFeatures(F, FeatureStr);
203 bool StrippedAtomics = false;
204 bool StrippedTLS = false;
206 if (!Features[WebAssembly::FeatureAtomics])
207 StrippedAtomics = stripAtomics(M);
209 if (!Features[WebAssembly::FeatureBulkMemory])
210 StrippedTLS = stripThreadLocals(M);
212 if (StrippedAtomics && !StrippedTLS)
213 stripThreadLocals(M);
214 else if (StrippedTLS && !StrippedAtomics)
215 stripAtomics(M);
217 recordFeatures(M, Features, StrippedAtomics || StrippedTLS);
219 // Conservatively assume we have made some change
220 return true;
223 private:
224 FeatureBitset coalesceFeatures(const Module &M) {
225 FeatureBitset Features =
226 WasmTM
227 ->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
228 std::string(WasmTM->getTargetFeatureString()))
229 ->getFeatureBits();
230 for (auto &F : M)
231 Features |= WasmTM->getSubtargetImpl(F)->getFeatureBits();
232 return Features;
235 std::string getFeatureString(const FeatureBitset &Features) {
236 std::string Ret;
237 for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
238 if (Features[KV.Value])
239 Ret += (StringRef("+") + KV.Key + ",").str();
241 return Ret;
244 void replaceFeatures(Function &F, const std::string &Features) {
245 F.removeFnAttr("target-features");
246 F.removeFnAttr("target-cpu");
247 F.addFnAttr("target-features", Features);
250 bool stripAtomics(Module &M) {
251 // Detect whether any atomics will be lowered, since there is no way to tell
252 // whether the LowerAtomic pass lowers e.g. stores.
253 bool Stripped = false;
254 for (auto &F : M) {
255 for (auto &B : F) {
256 for (auto &I : B) {
257 if (I.isAtomic()) {
258 Stripped = true;
259 goto done;
265 done:
266 if (!Stripped)
267 return false;
269 LowerAtomicPass Lowerer;
270 FunctionAnalysisManager FAM;
271 for (auto &F : M)
272 Lowerer.run(F, FAM);
274 return true;
277 bool stripThreadLocals(Module &M) {
278 bool Stripped = false;
279 for (auto &GV : M.globals()) {
280 if (GV.isThreadLocal()) {
281 Stripped = true;
282 GV.setThreadLocal(false);
285 return Stripped;
288 void recordFeatures(Module &M, const FeatureBitset &Features, bool Stripped) {
289 for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
290 if (Features[KV.Value]) {
291 // Mark features as used
292 std::string MDKey = (StringRef("wasm-feature-") + KV.Key).str();
293 M.addModuleFlag(Module::ModFlagBehavior::Error, MDKey,
294 wasm::WASM_FEATURE_PREFIX_USED);
297 // Code compiled without atomics or bulk-memory may have had its atomics or
298 // thread-local data lowered to nonatomic operations or non-thread-local
299 // data. In that case, we mark the pseudo-feature "shared-mem" as disallowed
300 // to tell the linker that it would be unsafe to allow this code ot be used
301 // in a module with shared memory.
302 if (Stripped) {
303 M.addModuleFlag(Module::ModFlagBehavior::Error, "wasm-feature-shared-mem",
304 wasm::WASM_FEATURE_PREFIX_DISALLOWED);
308 char CoalesceFeaturesAndStripAtomics::ID = 0;
310 /// WebAssembly Code Generator Pass Configuration Options.
311 class WebAssemblyPassConfig final : public TargetPassConfig {
312 public:
313 WebAssemblyPassConfig(WebAssemblyTargetMachine &TM, PassManagerBase &PM)
314 : TargetPassConfig(TM, PM) {}
316 WebAssemblyTargetMachine &getWebAssemblyTargetMachine() const {
317 return getTM<WebAssemblyTargetMachine>();
320 FunctionPass *createTargetRegisterAllocator(bool) override;
322 void addIRPasses() override;
323 void addISelPrepare() override;
324 bool addInstSelector() override;
325 void addPostRegAlloc() override;
326 bool addGCPasses() override { return false; }
327 void addPreEmitPass() override;
328 bool addPreISel() override;
330 // No reg alloc
331 bool addRegAssignAndRewriteFast() override { return false; }
333 // No reg alloc
334 bool addRegAssignAndRewriteOptimized() override { return false; }
336 } // end anonymous namespace
338 TargetTransformInfo
339 WebAssemblyTargetMachine::getTargetTransformInfo(const Function &F) const {
340 return TargetTransformInfo(WebAssemblyTTIImpl(this, F));
343 TargetPassConfig *
344 WebAssemblyTargetMachine::createPassConfig(PassManagerBase &PM) {
345 return new WebAssemblyPassConfig(*this, PM);
348 FunctionPass *WebAssemblyPassConfig::createTargetRegisterAllocator(bool) {
349 return nullptr; // No reg alloc
352 using WebAssembly::WasmEnableEH;
353 using WebAssembly::WasmEnableEmEH;
354 using WebAssembly::WasmEnableEmSjLj;
355 using WebAssembly::WasmEnableSjLj;
357 static void basicCheckForEHAndSjLj(TargetMachine *TM) {
358 // Before checking, we make sure TargetOptions.ExceptionModel is the same as
359 // MCAsmInfo.ExceptionsType. Normally these have to be the same, because clang
360 // stores the exception model info in LangOptions, which is later transferred
361 // to TargetOptions and MCAsmInfo. But when clang compiles bitcode directly,
362 // clang's LangOptions is not used and thus the exception model info is not
363 // correctly transferred to TargetOptions and MCAsmInfo, so we make sure we
364 // have the correct exception model in in WebAssemblyMCAsmInfo constructor.
365 // But in this case TargetOptions is still not updated, so we make sure they
366 // are the same.
367 TM->Options.ExceptionModel = TM->getMCAsmInfo()->getExceptionHandlingType();
369 // Basic Correctness checking related to -exception-model
370 if (TM->Options.ExceptionModel != ExceptionHandling::None &&
371 TM->Options.ExceptionModel != ExceptionHandling::Wasm)
372 report_fatal_error("-exception-model should be either 'none' or 'wasm'");
373 if (WasmEnableEmEH && TM->Options.ExceptionModel == ExceptionHandling::Wasm)
374 report_fatal_error("-exception-model=wasm not allowed with "
375 "-enable-emscripten-cxx-exceptions");
376 if (WasmEnableEH && TM->Options.ExceptionModel != ExceptionHandling::Wasm)
377 report_fatal_error(
378 "-wasm-enable-eh only allowed with -exception-model=wasm");
379 if (WasmEnableSjLj && TM->Options.ExceptionModel != ExceptionHandling::Wasm)
380 report_fatal_error(
381 "-wasm-enable-sjlj only allowed with -exception-model=wasm");
382 if ((!WasmEnableEH && !WasmEnableSjLj) &&
383 TM->Options.ExceptionModel == ExceptionHandling::Wasm)
384 report_fatal_error(
385 "-exception-model=wasm only allowed with at least one of "
386 "-wasm-enable-eh or -wasm-enable-sjj");
388 // You can't enable two modes of EH at the same time
389 if (WasmEnableEmEH && WasmEnableEH)
390 report_fatal_error(
391 "-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-eh");
392 // You can't enable two modes of SjLj at the same time
393 if (WasmEnableEmSjLj && WasmEnableSjLj)
394 report_fatal_error(
395 "-enable-emscripten-sjlj not allowed with -wasm-enable-sjlj");
396 // You can't mix Emscripten EH with Wasm SjLj.
397 if (WasmEnableEmEH && WasmEnableSjLj)
398 report_fatal_error(
399 "-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-sjlj");
400 // Currently it is allowed to mix Wasm EH with Emscripten SjLj as an interim
401 // measure, but some code will error out at compile time in this combination.
402 // See WebAssemblyLowerEmscriptenEHSjLj pass for details.
405 //===----------------------------------------------------------------------===//
406 // The following functions are called from lib/CodeGen/Passes.cpp to modify
407 // the CodeGen pass sequence.
408 //===----------------------------------------------------------------------===//
410 void WebAssemblyPassConfig::addIRPasses() {
411 // Add signatures to prototype-less function declarations
412 addPass(createWebAssemblyAddMissingPrototypes());
414 // Lower .llvm.global_dtors into .llvm_global_ctors with __cxa_atexit calls.
415 addPass(createWebAssemblyLowerGlobalDtors());
417 // Fix function bitcasts, as WebAssembly requires caller and callee signatures
418 // to match.
419 addPass(createWebAssemblyFixFunctionBitcasts());
421 // Optimize "returned" function attributes.
422 if (getOptLevel() != CodeGenOpt::None)
423 addPass(createWebAssemblyOptimizeReturned());
425 basicCheckForEHAndSjLj(TM);
427 // If exception handling is not enabled and setjmp/longjmp handling is
428 // enabled, we lower invokes into calls and delete unreachable landingpad
429 // blocks. Lowering invokes when there is no EH support is done in
430 // TargetPassConfig::addPassesToHandleExceptions, but that runs after these IR
431 // passes and Emscripten SjLj handling expects all invokes to be lowered
432 // before.
433 if (!WasmEnableEmEH && !WasmEnableEH) {
434 addPass(createLowerInvokePass());
435 // The lower invoke pass may create unreachable code. Remove it in order not
436 // to process dead blocks in setjmp/longjmp handling.
437 addPass(createUnreachableBlockEliminationPass());
440 // Handle exceptions and setjmp/longjmp if enabled. Unlike Wasm EH preparation
441 // done in WasmEHPrepare pass, Wasm SjLj preparation shares libraries and
442 // transformation algorithms with Emscripten SjLj, so we run
443 // LowerEmscriptenEHSjLj pass also when Wasm SjLj is enabled.
444 if (WasmEnableEmEH || WasmEnableEmSjLj || WasmEnableSjLj)
445 addPass(createWebAssemblyLowerEmscriptenEHSjLj());
447 // Expand indirectbr instructions to switches.
448 addPass(createIndirectBrExpandPass());
450 TargetPassConfig::addIRPasses();
453 void WebAssemblyPassConfig::addISelPrepare() {
454 // Lower atomics and TLS if necessary
455 addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
457 // This is a no-op if atomics are not used in the module
458 addPass(createAtomicExpandPass());
460 TargetPassConfig::addISelPrepare();
463 bool WebAssemblyPassConfig::addInstSelector() {
464 (void)TargetPassConfig::addInstSelector();
465 addPass(
466 createWebAssemblyISelDag(getWebAssemblyTargetMachine(), getOptLevel()));
467 // Run the argument-move pass immediately after the ScheduleDAG scheduler
468 // so that we can fix up the ARGUMENT instructions before anything else
469 // sees them in the wrong place.
470 addPass(createWebAssemblyArgumentMove());
471 // Set the p2align operands. This information is present during ISel, however
472 // it's inconvenient to collect. Collect it now, and update the immediate
473 // operands.
474 addPass(createWebAssemblySetP2AlignOperands());
476 // Eliminate range checks and add default targets to br_table instructions.
477 addPass(createWebAssemblyFixBrTableDefaults());
479 return false;
482 void WebAssemblyPassConfig::addPostRegAlloc() {
483 // TODO: The following CodeGen passes don't currently support code containing
484 // virtual registers. Consider removing their restrictions and re-enabling
485 // them.
487 // These functions all require the NoVRegs property.
488 disablePass(&MachineCopyPropagationID);
489 disablePass(&PostRAMachineSinkingID);
490 disablePass(&PostRASchedulerID);
491 disablePass(&FuncletLayoutID);
492 disablePass(&StackMapLivenessID);
493 disablePass(&LiveDebugValuesID);
494 disablePass(&PatchableFunctionID);
495 disablePass(&ShrinkWrapID);
497 // This pass hurts code size for wasm because it can generate irreducible
498 // control flow.
499 disablePass(&MachineBlockPlacementID);
501 TargetPassConfig::addPostRegAlloc();
504 void WebAssemblyPassConfig::addPreEmitPass() {
505 TargetPassConfig::addPreEmitPass();
507 // Nullify DBG_VALUE_LISTs that we cannot handle.
508 addPass(createWebAssemblyNullifyDebugValueLists());
510 // Eliminate multiple-entry loops.
511 addPass(createWebAssemblyFixIrreducibleControlFlow());
513 // Do various transformations for exception handling.
514 // Every CFG-changing optimizations should come before this.
515 if (TM->Options.ExceptionModel == ExceptionHandling::Wasm)
516 addPass(createWebAssemblyLateEHPrepare());
518 // Now that we have a prologue and epilogue and all frame indices are
519 // rewritten, eliminate SP and FP. This allows them to be stackified,
520 // colored, and numbered with the rest of the registers.
521 addPass(createWebAssemblyReplacePhysRegs());
523 // Preparations and optimizations related to register stackification.
524 if (getOptLevel() != CodeGenOpt::None) {
525 // LiveIntervals isn't commonly run this late. Re-establish preconditions.
526 addPass(createWebAssemblyPrepareForLiveIntervals());
528 // Depend on LiveIntervals and perform some optimizations on it.
529 addPass(createWebAssemblyOptimizeLiveIntervals());
531 // Prepare memory intrinsic calls for register stackifying.
532 addPass(createWebAssemblyMemIntrinsicResults());
534 // Mark registers as representing wasm's value stack. This is a key
535 // code-compression technique in WebAssembly. We run this pass (and
536 // MemIntrinsicResults above) very late, so that it sees as much code as
537 // possible, including code emitted by PEI and expanded by late tail
538 // duplication.
539 addPass(createWebAssemblyRegStackify());
541 // Run the register coloring pass to reduce the total number of registers.
542 // This runs after stackification so that it doesn't consider registers
543 // that become stackified.
544 addPass(createWebAssemblyRegColoring());
547 // Sort the blocks of the CFG into topological order, a prerequisite for
548 // BLOCK and LOOP markers.
549 addPass(createWebAssemblyCFGSort());
551 // Insert BLOCK and LOOP markers.
552 addPass(createWebAssemblyCFGStackify());
554 // Insert explicit local.get and local.set operators.
555 if (!WasmDisableExplicitLocals)
556 addPass(createWebAssemblyExplicitLocals());
558 // Lower br_unless into br_if.
559 addPass(createWebAssemblyLowerBrUnless());
561 // Perform the very last peephole optimizations on the code.
562 if (getOptLevel() != CodeGenOpt::None)
563 addPass(createWebAssemblyPeephole());
565 // Create a mapping from LLVM CodeGen virtual registers to wasm registers.
566 addPass(createWebAssemblyRegNumbering());
568 // Fix debug_values whose defs have been stackified.
569 if (!WasmDisableExplicitLocals)
570 addPass(createWebAssemblyDebugFixup());
572 // Collect information to prepare for MC lowering / asm printing.
573 addPass(createWebAssemblyMCLowerPrePass());
576 bool WebAssemblyPassConfig::addPreISel() {
577 TargetPassConfig::addPreISel();
578 addPass(createWebAssemblyLowerRefTypesIntPtrConv());
579 return false;
582 yaml::MachineFunctionInfo *
583 WebAssemblyTargetMachine::createDefaultFuncInfoYAML() const {
584 return new yaml::WebAssemblyFunctionInfo();
587 yaml::MachineFunctionInfo *WebAssemblyTargetMachine::convertFuncInfoToYAML(
588 const MachineFunction &MF) const {
589 const auto *MFI = MF.getInfo<WebAssemblyFunctionInfo>();
590 return new yaml::WebAssemblyFunctionInfo(*MFI);
593 bool WebAssemblyTargetMachine::parseMachineFunctionInfo(
594 const yaml::MachineFunctionInfo &MFI, PerFunctionMIParsingState &PFS,
595 SMDiagnostic &Error, SMRange &SourceRange) const {
596 const auto &YamlMFI =
597 reinterpret_cast<const yaml::WebAssemblyFunctionInfo &>(MFI);
598 MachineFunction &MF = PFS.MF;
599 MF.getInfo<WebAssemblyFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
600 return false;