• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- WebAssemblyAsmPrinter.cpp - WebAssembly LLVM assembly writer ------===//
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 contains a printer that converts from our internal
11 /// representation of machine-dependent LLVM code to the WebAssembly assembly
12 /// language.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #include "WebAssemblyAsmPrinter.h"
17 #include "MCTargetDesc/WebAssemblyInstPrinter.h"
18 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
19 #include "MCTargetDesc/WebAssemblyTargetStreamer.h"
20 #include "TargetInfo/WebAssemblyTargetInfo.h"
21 #include "WebAssembly.h"
22 #include "WebAssemblyMCInstLower.h"
23 #include "WebAssemblyMachineFunctionInfo.h"
24 #include "WebAssemblyRegisterInfo.h"
25 #include "WebAssemblyTargetMachine.h"
26 #include "llvm/ADT/SmallSet.h"
27 #include "llvm/ADT/StringExtras.h"
28 #include "llvm/BinaryFormat/Wasm.h"
29 #include "llvm/CodeGen/Analysis.h"
30 #include "llvm/CodeGen/AsmPrinter.h"
31 #include "llvm/CodeGen/MachineConstantPool.h"
32 #include "llvm/CodeGen/MachineInstr.h"
33 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
34 #include "llvm/IR/DataLayout.h"
35 #include "llvm/IR/DebugInfoMetadata.h"
36 #include "llvm/IR/GlobalVariable.h"
37 #include "llvm/IR/Metadata.h"
38 #include "llvm/MC/MCContext.h"
39 #include "llvm/MC/MCSectionWasm.h"
40 #include "llvm/MC/MCStreamer.h"
41 #include "llvm/MC/MCSymbol.h"
42 #include "llvm/MC/MCSymbolWasm.h"
43 #include "llvm/Support/Debug.h"
44 #include "llvm/Support/TargetRegistry.h"
45 #include "llvm/Support/raw_ostream.h"
46 
47 using namespace llvm;
48 
49 #define DEBUG_TYPE "asm-printer"
50 
51 extern cl::opt<bool> WasmKeepRegisters;
52 extern cl::opt<bool> EnableEmException;
53 extern cl::opt<bool> EnableEmSjLj;
54 
55 //===----------------------------------------------------------------------===//
56 // Helpers.
57 //===----------------------------------------------------------------------===//
58 
getRegType(unsigned RegNo) const59 MVT WebAssemblyAsmPrinter::getRegType(unsigned RegNo) const {
60   const TargetRegisterInfo *TRI = Subtarget->getRegisterInfo();
61   const TargetRegisterClass *TRC = MRI->getRegClass(RegNo);
62   for (MVT T : {MVT::i32, MVT::i64, MVT::f32, MVT::f64, MVT::v16i8, MVT::v8i16,
63                 MVT::v4i32, MVT::v2i64, MVT::v4f32, MVT::v2f64})
64     if (TRI->isTypeLegalForClass(*TRC, T))
65       return T;
66   LLVM_DEBUG(errs() << "Unknown type for register number: " << RegNo);
67   llvm_unreachable("Unknown register type");
68   return MVT::Other;
69 }
70 
regToString(const MachineOperand & MO)71 std::string WebAssemblyAsmPrinter::regToString(const MachineOperand &MO) {
72   Register RegNo = MO.getReg();
73   assert(Register::isVirtualRegister(RegNo) &&
74          "Unlowered physical register encountered during assembly printing");
75   assert(!MFI->isVRegStackified(RegNo));
76   unsigned WAReg = MFI->getWAReg(RegNo);
77   assert(WAReg != WebAssemblyFunctionInfo::UnusedReg);
78   return '$' + utostr(WAReg);
79 }
80 
getTargetStreamer()81 WebAssemblyTargetStreamer *WebAssemblyAsmPrinter::getTargetStreamer() {
82   MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
83   return static_cast<WebAssemblyTargetStreamer *>(TS);
84 }
85 
86 // Emscripten exception handling helpers
87 //
88 // This converts invoke names generated by LowerEmscriptenEHSjLj to real names
89 // that are expected by JavaScript glue code. The invoke names generated by
90 // Emscripten JS glue code are based on their argument and return types; for
91 // example, for a function that takes an i32 and returns nothing, it is
92 // 'invoke_vi'. But the format of invoke generated by LowerEmscriptenEHSjLj pass
93 // contains a mangled string generated from their IR types, for example,
94 // "__invoke_void_%struct.mystruct*_int", because final wasm types are not
95 // available in the IR pass. So we convert those names to the form that
96 // Emscripten JS code expects.
97 //
98 // Refer to LowerEmscriptenEHSjLj pass for more details.
99 
100 // Returns true if the given function name is an invoke name generated by
101 // LowerEmscriptenEHSjLj pass.
isEmscriptenInvokeName(StringRef Name)102 static bool isEmscriptenInvokeName(StringRef Name) {
103   if (Name.front() == '"' && Name.back() == '"')
104     Name = Name.substr(1, Name.size() - 2);
105   return Name.startswith("__invoke_");
106 }
107 
108 // Returns a character that represents the given wasm value type in invoke
109 // signatures.
getInvokeSig(wasm::ValType VT)110 static char getInvokeSig(wasm::ValType VT) {
111   switch (VT) {
112   case wasm::ValType::I32:
113     return 'i';
114   case wasm::ValType::I64:
115     return 'j';
116   case wasm::ValType::F32:
117     return 'f';
118   case wasm::ValType::F64:
119     return 'd';
120   case wasm::ValType::V128:
121     return 'V';
122   case wasm::ValType::EXNREF:
123     return 'E';
124   case wasm::ValType::FUNCREF:
125     return 'F';
126   case wasm::ValType::EXTERNREF:
127     return 'X';
128   }
129   llvm_unreachable("Unhandled wasm::ValType enum");
130 }
131 
132 // Given the wasm signature, generate the invoke name in the format JS glue code
133 // expects.
getEmscriptenInvokeSymbolName(wasm::WasmSignature * Sig)134 static std::string getEmscriptenInvokeSymbolName(wasm::WasmSignature *Sig) {
135   assert(Sig->Returns.size() <= 1);
136   std::string Ret = "invoke_";
137   if (!Sig->Returns.empty())
138     for (auto VT : Sig->Returns)
139       Ret += getInvokeSig(VT);
140   else
141     Ret += 'v';
142   // Invokes' first argument is a pointer to the original function, so skip it
143   for (unsigned I = 1, E = Sig->Params.size(); I < E; I++)
144     Ret += getInvokeSig(Sig->Params[I]);
145   return Ret;
146 }
147 
148 //===----------------------------------------------------------------------===//
149 // WebAssemblyAsmPrinter Implementation.
150 //===----------------------------------------------------------------------===//
151 
getMCSymbolForFunction(const Function * F,bool EnableEmEH,wasm::WasmSignature * Sig,bool & InvokeDetected)152 MCSymbolWasm *WebAssemblyAsmPrinter::getMCSymbolForFunction(
153     const Function *F, bool EnableEmEH, wasm::WasmSignature *Sig,
154     bool &InvokeDetected) {
155   MCSymbolWasm *WasmSym = nullptr;
156   if (EnableEmEH && isEmscriptenInvokeName(F->getName())) {
157     assert(Sig);
158     InvokeDetected = true;
159     if (Sig->Returns.size() > 1) {
160       std::string Msg =
161           "Emscripten EH/SjLj does not support multivalue returns: " +
162           std::string(F->getName()) + ": " +
163           WebAssembly::signatureToString(Sig);
164       report_fatal_error(Msg);
165     }
166     WasmSym = cast<MCSymbolWasm>(
167         GetExternalSymbolSymbol(getEmscriptenInvokeSymbolName(Sig)));
168   } else {
169     WasmSym = cast<MCSymbolWasm>(getSymbol(F));
170   }
171   return WasmSym;
172 }
173 
emitEndOfAsmFile(Module & M)174 void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
175   for (auto &It : OutContext.getSymbols()) {
176     // Emit a .globaltype and .eventtype declaration.
177     auto Sym = cast<MCSymbolWasm>(It.getValue());
178     if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL)
179       getTargetStreamer()->emitGlobalType(Sym);
180     else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_EVENT)
181       getTargetStreamer()->emitEventType(Sym);
182   }
183 
184   DenseSet<MCSymbol *> InvokeSymbols;
185   for (const auto &F : M) {
186     if (F.isIntrinsic())
187       continue;
188 
189     // Emit function type info for all undefined functions
190     if (F.isDeclarationForLinker()) {
191       SmallVector<MVT, 4> Results;
192       SmallVector<MVT, 4> Params;
193       computeSignatureVTs(F.getFunctionType(), &F, F, TM, Params, Results);
194       // At this point these MCSymbols may or may not have been created already
195       // and thus also contain a signature, but we need to get the signature
196       // anyway here in case it is an invoke that has not yet been created. We
197       // will discard it later if it turns out not to be necessary.
198       auto Signature = signatureFromMVTs(Results, Params);
199       bool InvokeDetected = false;
200       auto *Sym = getMCSymbolForFunction(&F, EnableEmException || EnableEmSjLj,
201                                          Signature.get(), InvokeDetected);
202 
203       // Multiple functions can be mapped to the same invoke symbol. For
204       // example, two IR functions '__invoke_void_i8*' and '__invoke_void_i32'
205       // are both mapped to '__invoke_vi'. We keep them in a set once we emit an
206       // Emscripten EH symbol so we don't emit the same symbol twice.
207       if (InvokeDetected && !InvokeSymbols.insert(Sym).second)
208         continue;
209 
210       Sym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
211       if (!Sym->getSignature()) {
212         Sym->setSignature(Signature.get());
213         addSignature(std::move(Signature));
214       } else {
215         // This symbol has already been created and had a signature. Discard it.
216         Signature.reset();
217       }
218 
219       getTargetStreamer()->emitFunctionType(Sym);
220 
221       if (F.hasFnAttribute("wasm-import-module")) {
222         StringRef Name =
223             F.getFnAttribute("wasm-import-module").getValueAsString();
224         Sym->setImportModule(storeName(Name));
225         getTargetStreamer()->emitImportModule(Sym, Name);
226       }
227       if (F.hasFnAttribute("wasm-import-name")) {
228         // If this is a converted Emscripten EH/SjLj symbol, we shouldn't use
229         // the original function name but the converted symbol name.
230         StringRef Name =
231             InvokeDetected
232                 ? Sym->getName()
233                 : F.getFnAttribute("wasm-import-name").getValueAsString();
234         Sym->setImportName(storeName(Name));
235         getTargetStreamer()->emitImportName(Sym, Name);
236       }
237     }
238 
239     if (F.hasFnAttribute("wasm-export-name")) {
240       auto *Sym = cast<MCSymbolWasm>(getSymbol(&F));
241       StringRef Name = F.getFnAttribute("wasm-export-name").getValueAsString();
242       Sym->setExportName(storeName(Name));
243       getTargetStreamer()->emitExportName(Sym, Name);
244     }
245   }
246 
247   for (const auto &G : M.globals()) {
248     if (!G.hasInitializer() && G.hasExternalLinkage()) {
249       if (G.getValueType()->isSized()) {
250         uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
251         OutStreamer->emitELFSize(getSymbol(&G),
252                                  MCConstantExpr::create(Size, OutContext));
253       }
254     }
255   }
256 
257   if (const NamedMDNode *Named = M.getNamedMetadata("wasm.custom_sections")) {
258     for (const Metadata *MD : Named->operands()) {
259       const auto *Tuple = dyn_cast<MDTuple>(MD);
260       if (!Tuple || Tuple->getNumOperands() != 2)
261         continue;
262       const MDString *Name = dyn_cast<MDString>(Tuple->getOperand(0));
263       const MDString *Contents = dyn_cast<MDString>(Tuple->getOperand(1));
264       if (!Name || !Contents)
265         continue;
266 
267       OutStreamer->PushSection();
268       std::string SectionName = (".custom_section." + Name->getString()).str();
269       MCSectionWasm *MySection =
270           OutContext.getWasmSection(SectionName, SectionKind::getMetadata());
271       OutStreamer->SwitchSection(MySection);
272       OutStreamer->emitBytes(Contents->getString());
273       OutStreamer->PopSection();
274     }
275   }
276 
277   EmitProducerInfo(M);
278   EmitTargetFeatures(M);
279 }
280 
EmitProducerInfo(Module & M)281 void WebAssemblyAsmPrinter::EmitProducerInfo(Module &M) {
282   llvm::SmallVector<std::pair<std::string, std::string>, 4> Languages;
283   if (const NamedMDNode *Debug = M.getNamedMetadata("llvm.dbg.cu")) {
284     llvm::SmallSet<StringRef, 4> SeenLanguages;
285     for (size_t I = 0, E = Debug->getNumOperands(); I < E; ++I) {
286       const auto *CU = cast<DICompileUnit>(Debug->getOperand(I));
287       StringRef Language = dwarf::LanguageString(CU->getSourceLanguage());
288       Language.consume_front("DW_LANG_");
289       if (SeenLanguages.insert(Language).second)
290         Languages.emplace_back(Language.str(), "");
291     }
292   }
293 
294   llvm::SmallVector<std::pair<std::string, std::string>, 4> Tools;
295   if (const NamedMDNode *Ident = M.getNamedMetadata("llvm.ident")) {
296     llvm::SmallSet<StringRef, 4> SeenTools;
297     for (size_t I = 0, E = Ident->getNumOperands(); I < E; ++I) {
298       const auto *S = cast<MDString>(Ident->getOperand(I)->getOperand(0));
299       std::pair<StringRef, StringRef> Field = S->getString().split("version");
300       StringRef Name = Field.first.trim();
301       StringRef Version = Field.second.trim();
302       if (SeenTools.insert(Name).second)
303         Tools.emplace_back(Name.str(), Version.str());
304     }
305   }
306 
307   int FieldCount = int(!Languages.empty()) + int(!Tools.empty());
308   if (FieldCount != 0) {
309     MCSectionWasm *Producers = OutContext.getWasmSection(
310         ".custom_section.producers", SectionKind::getMetadata());
311     OutStreamer->PushSection();
312     OutStreamer->SwitchSection(Producers);
313     OutStreamer->emitULEB128IntValue(FieldCount);
314     for (auto &Producers : {std::make_pair("language", &Languages),
315             std::make_pair("processed-by", &Tools)}) {
316       if (Producers.second->empty())
317         continue;
318       OutStreamer->emitULEB128IntValue(strlen(Producers.first));
319       OutStreamer->emitBytes(Producers.first);
320       OutStreamer->emitULEB128IntValue(Producers.second->size());
321       for (auto &Producer : *Producers.second) {
322         OutStreamer->emitULEB128IntValue(Producer.first.size());
323         OutStreamer->emitBytes(Producer.first);
324         OutStreamer->emitULEB128IntValue(Producer.second.size());
325         OutStreamer->emitBytes(Producer.second);
326       }
327     }
328     OutStreamer->PopSection();
329   }
330 }
331 
EmitTargetFeatures(Module & M)332 void WebAssemblyAsmPrinter::EmitTargetFeatures(Module &M) {
333   struct FeatureEntry {
334     uint8_t Prefix;
335     std::string Name;
336   };
337 
338   // Read target features and linkage policies from module metadata
339   SmallVector<FeatureEntry, 4> EmittedFeatures;
340   auto EmitFeature = [&](std::string Feature) {
341     std::string MDKey = (StringRef("wasm-feature-") + Feature).str();
342     Metadata *Policy = M.getModuleFlag(MDKey);
343     if (Policy == nullptr)
344       return;
345 
346     FeatureEntry Entry;
347     Entry.Prefix = 0;
348     Entry.Name = Feature;
349 
350     if (auto *MD = cast<ConstantAsMetadata>(Policy))
351       if (auto *I = cast<ConstantInt>(MD->getValue()))
352         Entry.Prefix = I->getZExtValue();
353 
354     // Silently ignore invalid metadata
355     if (Entry.Prefix != wasm::WASM_FEATURE_PREFIX_USED &&
356         Entry.Prefix != wasm::WASM_FEATURE_PREFIX_REQUIRED &&
357         Entry.Prefix != wasm::WASM_FEATURE_PREFIX_DISALLOWED)
358       return;
359 
360     EmittedFeatures.push_back(Entry);
361   };
362 
363   for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
364     EmitFeature(KV.Key);
365   }
366   // This pseudo-feature tells the linker whether shared memory would be safe
367   EmitFeature("shared-mem");
368 
369   if (EmittedFeatures.size() == 0)
370     return;
371 
372   // Emit features and linkage policies into the "target_features" section
373   MCSectionWasm *FeaturesSection = OutContext.getWasmSection(
374       ".custom_section.target_features", SectionKind::getMetadata());
375   OutStreamer->PushSection();
376   OutStreamer->SwitchSection(FeaturesSection);
377 
378   OutStreamer->emitULEB128IntValue(EmittedFeatures.size());
379   for (auto &F : EmittedFeatures) {
380     OutStreamer->emitIntValue(F.Prefix, 1);
381     OutStreamer->emitULEB128IntValue(F.Name.size());
382     OutStreamer->emitBytes(F.Name);
383   }
384 
385   OutStreamer->PopSection();
386 }
387 
emitConstantPool()388 void WebAssemblyAsmPrinter::emitConstantPool() {
389   assert(MF->getConstantPool()->getConstants().empty() &&
390          "WebAssembly disables constant pools");
391 }
392 
emitJumpTableInfo()393 void WebAssemblyAsmPrinter::emitJumpTableInfo() {
394   // Nothing to do; jump tables are incorporated into the instruction stream.
395 }
396 
emitFunctionBodyStart()397 void WebAssemblyAsmPrinter::emitFunctionBodyStart() {
398   const Function &F = MF->getFunction();
399   SmallVector<MVT, 1> ResultVTs;
400   SmallVector<MVT, 4> ParamVTs;
401   computeSignatureVTs(F.getFunctionType(), &F, F, TM, ParamVTs, ResultVTs);
402 
403   auto Signature = signatureFromMVTs(ResultVTs, ParamVTs);
404   auto *WasmSym = cast<MCSymbolWasm>(CurrentFnSym);
405   WasmSym->setSignature(Signature.get());
406   addSignature(std::move(Signature));
407   WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
408 
409   getTargetStreamer()->emitFunctionType(WasmSym);
410 
411   // Emit the function index.
412   if (MDNode *Idx = F.getMetadata("wasm.index")) {
413     assert(Idx->getNumOperands() == 1);
414 
415     getTargetStreamer()->emitIndIdx(AsmPrinter::lowerConstant(
416         cast<ConstantAsMetadata>(Idx->getOperand(0))->getValue()));
417   }
418 
419   SmallVector<wasm::ValType, 16> Locals;
420   valTypesFromMVTs(MFI->getLocals(), Locals);
421   getTargetStreamer()->emitLocal(Locals);
422 
423   AsmPrinter::emitFunctionBodyStart();
424 }
425 
emitInstruction(const MachineInstr * MI)426 void WebAssemblyAsmPrinter::emitInstruction(const MachineInstr *MI) {
427   LLVM_DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
428 
429   switch (MI->getOpcode()) {
430   case WebAssembly::ARGUMENT_i32:
431   case WebAssembly::ARGUMENT_i32_S:
432   case WebAssembly::ARGUMENT_i64:
433   case WebAssembly::ARGUMENT_i64_S:
434   case WebAssembly::ARGUMENT_f32:
435   case WebAssembly::ARGUMENT_f32_S:
436   case WebAssembly::ARGUMENT_f64:
437   case WebAssembly::ARGUMENT_f64_S:
438   case WebAssembly::ARGUMENT_v16i8:
439   case WebAssembly::ARGUMENT_v16i8_S:
440   case WebAssembly::ARGUMENT_v8i16:
441   case WebAssembly::ARGUMENT_v8i16_S:
442   case WebAssembly::ARGUMENT_v4i32:
443   case WebAssembly::ARGUMENT_v4i32_S:
444   case WebAssembly::ARGUMENT_v2i64:
445   case WebAssembly::ARGUMENT_v2i64_S:
446   case WebAssembly::ARGUMENT_v4f32:
447   case WebAssembly::ARGUMENT_v4f32_S:
448   case WebAssembly::ARGUMENT_v2f64:
449   case WebAssembly::ARGUMENT_v2f64_S:
450     // These represent values which are live into the function entry, so there's
451     // no instruction to emit.
452     break;
453   case WebAssembly::FALLTHROUGH_RETURN: {
454     // These instructions represent the implicit return at the end of a
455     // function body.
456     if (isVerbose()) {
457       OutStreamer->AddComment("fallthrough-return");
458       OutStreamer->AddBlankLine();
459     }
460     break;
461   }
462   case WebAssembly::COMPILER_FENCE:
463     // This is a compiler barrier that prevents instruction reordering during
464     // backend compilation, and should not be emitted.
465     break;
466   case WebAssembly::EXTRACT_EXCEPTION_I32:
467   case WebAssembly::EXTRACT_EXCEPTION_I32_S:
468     // These are pseudo instructions that simulates popping values from stack.
469     // We print these only when we have -wasm-keep-registers on for assembly
470     // readability.
471     if (!WasmKeepRegisters)
472       break;
473     LLVM_FALLTHROUGH;
474   default: {
475     WebAssemblyMCInstLower MCInstLowering(OutContext, *this);
476     MCInst TmpInst;
477     MCInstLowering.lower(MI, TmpInst);
478     EmitToStreamer(*OutStreamer, TmpInst);
479     break;
480   }
481   }
482 }
483 
PrintAsmOperand(const MachineInstr * MI,unsigned OpNo,const char * ExtraCode,raw_ostream & OS)484 bool WebAssemblyAsmPrinter::PrintAsmOperand(const MachineInstr *MI,
485                                             unsigned OpNo,
486                                             const char *ExtraCode,
487                                             raw_ostream &OS) {
488   // First try the generic code, which knows about modifiers like 'c' and 'n'.
489   if (!AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS))
490     return false;
491 
492   if (!ExtraCode) {
493     const MachineOperand &MO = MI->getOperand(OpNo);
494     switch (MO.getType()) {
495     case MachineOperand::MO_Immediate:
496       OS << MO.getImm();
497       return false;
498     case MachineOperand::MO_Register:
499       // FIXME: only opcode that still contains registers, as required by
500       // MachineInstr::getDebugVariable().
501       assert(MI->getOpcode() == WebAssembly::INLINEASM);
502       OS << regToString(MO);
503       return false;
504     case MachineOperand::MO_GlobalAddress:
505       PrintSymbolOperand(MO, OS);
506       return false;
507     case MachineOperand::MO_ExternalSymbol:
508       GetExternalSymbolSymbol(MO.getSymbolName())->print(OS, MAI);
509       printOffset(MO.getOffset(), OS);
510       return false;
511     case MachineOperand::MO_MachineBasicBlock:
512       MO.getMBB()->getSymbol()->print(OS, MAI);
513       return false;
514     default:
515       break;
516     }
517   }
518 
519   return true;
520 }
521 
PrintAsmMemoryOperand(const MachineInstr * MI,unsigned OpNo,const char * ExtraCode,raw_ostream & OS)522 bool WebAssemblyAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
523                                                   unsigned OpNo,
524                                                   const char *ExtraCode,
525                                                   raw_ostream &OS) {
526   // The current approach to inline asm is that "r" constraints are expressed
527   // as local indices, rather than values on the operand stack. This simplifies
528   // using "r" as it eliminates the need to push and pop the values in a
529   // particular order, however it also makes it impossible to have an "m"
530   // constraint. So we don't support it.
531 
532   return AsmPrinter::PrintAsmMemoryOperand(MI, OpNo, ExtraCode, OS);
533 }
534 
535 // Force static initialization.
LLVMInitializeWebAssemblyAsmPrinter()536 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmPrinter() {
537   RegisterAsmPrinter<WebAssemblyAsmPrinter> X(getTheWebAssemblyTarget32());
538   RegisterAsmPrinter<WebAssemblyAsmPrinter> Y(getTheWebAssemblyTarget64());
539 }
540