LLVM  14.0.0git
WebAssemblyAsmPrinter.cpp
Go to the documentation of this file.
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"
22 #include "WebAssembly.h"
23 #include "WebAssemblyMCInstLower.h"
28 #include "llvm/ADT/SmallSet.h"
29 #include "llvm/ADT/StringExtras.h"
30 #include "llvm/BinaryFormat/Wasm.h"
31 #include "llvm/CodeGen/Analysis.h"
36 #include "llvm/IR/DataLayout.h"
38 #include "llvm/IR/GlobalVariable.h"
39 #include "llvm/IR/Metadata.h"
40 #include "llvm/MC/MCContext.h"
41 #include "llvm/MC/MCSectionWasm.h"
42 #include "llvm/MC/MCStreamer.h"
43 #include "llvm/MC/MCSymbol.h"
44 #include "llvm/MC/MCSymbolWasm.h"
45 #include "llvm/MC/TargetRegistry.h"
46 #include "llvm/Support/Debug.h"
48 
49 using namespace llvm;
50 
51 #define DEBUG_TYPE "asm-printer"
52 
56 
57 //===----------------------------------------------------------------------===//
58 // Helpers.
59 //===----------------------------------------------------------------------===//
60 
61 MVT WebAssemblyAsmPrinter::getRegType(unsigned RegNo) const {
62  const TargetRegisterInfo *TRI = Subtarget->getRegisterInfo();
63  const TargetRegisterClass *TRC = MRI->getRegClass(RegNo);
66  if (TRI->isTypeLegalForClass(*TRC, T))
67  return T;
68  LLVM_DEBUG(errs() << "Unknown type for register number: " << RegNo);
69  llvm_unreachable("Unknown register type");
70  return MVT::Other;
71 }
72 
74  Register RegNo = MO.getReg();
76  "Unlowered physical register encountered during assembly printing");
77  assert(!MFI->isVRegStackified(RegNo));
78  unsigned WAReg = MFI->getWAReg(RegNo);
80  return '$' + utostr(WAReg);
81 }
82 
84  MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
85  return static_cast<WebAssemblyTargetStreamer *>(TS);
86 }
87 
88 // Emscripten exception handling helpers
89 //
90 // This converts invoke names generated by LowerEmscriptenEHSjLj to real names
91 // that are expected by JavaScript glue code. The invoke names generated by
92 // Emscripten JS glue code are based on their argument and return types; for
93 // example, for a function that takes an i32 and returns nothing, it is
94 // 'invoke_vi'. But the format of invoke generated by LowerEmscriptenEHSjLj pass
95 // contains a mangled string generated from their IR types, for example,
96 // "__invoke_void_%struct.mystruct*_int", because final wasm types are not
97 // available in the IR pass. So we convert those names to the form that
98 // Emscripten JS code expects.
99 //
100 // Refer to LowerEmscriptenEHSjLj pass for more details.
101 
102 // Returns true if the given function name is an invoke name generated by
103 // LowerEmscriptenEHSjLj pass.
105  if (Name.front() == '"' && Name.back() == '"')
106  Name = Name.substr(1, Name.size() - 2);
107  return Name.startswith("__invoke_");
108 }
109 
110 // Returns a character that represents the given wasm value type in invoke
111 // signatures.
112 static char getInvokeSig(wasm::ValType VT) {
113  switch (VT) {
114  case wasm::ValType::I32:
115  return 'i';
116  case wasm::ValType::I64:
117  return 'j';
118  case wasm::ValType::F32:
119  return 'f';
120  case wasm::ValType::F64:
121  return 'd';
122  case wasm::ValType::V128:
123  return 'V';
125  return 'F';
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.
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 
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()) + ": " +
165  }
166  WasmSym = cast<MCSymbolWasm>(
168  } else {
169  WasmSym = cast<MCSymbolWasm>(getSymbol(F));
170  }
171  return WasmSym;
172 }
173 
177  return;
178  }
179 
180  assert(!GV->isThreadLocal());
181 
182  MCSymbolWasm *Sym = cast<MCSymbolWasm>(getSymbol(GV));
183 
184  if (!Sym->getType()) {
185  const WebAssemblyTargetLowering &TLI = *Subtarget->getTargetLowering();
188  VTs);
189  if (VTs.size() != 1 ||
190  TLI.getNumRegisters(GV->getParent()->getContext(), VTs[0]) != 1)
191  report_fatal_error("Aggregate globals not yet implemented");
192  MVT VT = TLI.getRegisterType(GV->getParent()->getContext(), VTs[0]);
193  bool Mutable = true;
196  Sym->setGlobalType(wasm::WasmGlobalType{uint8_t(Type), Mutable});
197  }
198 
199  emitVisibility(Sym, GV->getVisibility(), !GV->isDeclaration());
200  if (GV->hasInitializer()) {
201  assert(getSymbolPreferLocal(*GV) == Sym);
202  emitLinkage(GV, Sym);
204  OutStreamer->emitLabel(Sym);
205  // TODO: Actually emit the initializer value. Otherwise the global has the
206  // default value for its type (0, ref.null, etc).
207  OutStreamer->AddBlankLine();
208  }
209 }
210 
212  auto *WasmSym = cast<MCSymbolWasm>(GetExternalSymbolSymbol(Name));
213 
214  // May be called multiple times, so early out.
215  if (WasmSym->getType().hasValue())
216  return WasmSym;
217 
218  const WebAssemblySubtarget &Subtarget = getSubtarget();
219 
220  // Except for certain known symbols, all symbols used by CodeGen are
221  // functions. It's OK to hardcode knowledge of specific symbols here; this
222  // method is precisely there for fetching the signatures of known
223  // Clang-provided symbols.
224  if (Name == "__stack_pointer" || Name == "__tls_base" ||
225  Name == "__memory_base" || Name == "__table_base" ||
226  Name == "__tls_size" || Name == "__tls_align") {
227  bool Mutable =
228  Name == "__stack_pointer" || Name == "__tls_base";
229  WasmSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL);
230  WasmSym->setGlobalType(wasm::WasmGlobalType{
231  uint8_t(Subtarget.hasAddr64() ? wasm::WASM_TYPE_I64
233  Mutable});
234  return WasmSym;
235  }
236 
237  if (Name.startswith("GCC_except_table")) {
238  WasmSym->setType(wasm::WASM_SYMBOL_TYPE_DATA);
239  return WasmSym;
240  }
241 
244  if (Name == "__cpp_exception" || Name == "__c_longjmp") {
245  WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG);
246  // In static linking we define tag symbols in WasmException::endModule().
247  // But we may have multiple objects to be linked together, each of which
248  // defines the tag symbols. To resolve them, we declare them as weak. In
249  // dynamic linking we make tag symbols undefined in the backend, define it
250  // in JS, and feed them to each importing module.
251  if (!isPositionIndependent())
252  WasmSym->setWeak(true);
253  WasmSym->setExternal(true);
254 
255  // Currently both C++ exceptions and C longjmps have a single pointer type
256  // param. For C++ exceptions it is a pointer to an exception object, and for
257  // C longjmps it is pointer to a struct that contains a setjmp buffer and a
258  // longjmp return value. We may consider using multiple value parameters for
259  // longjmps later when multivalue support is ready.
260  wasm::ValType AddrType =
262  Params.push_back(AddrType);
263  } else { // Function symbols
264  WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
265  getLibcallSignature(Subtarget, Name, Returns, Params);
266  }
267  auto Signature = std::make_unique<wasm::WasmSignature>(std::move(Returns),
268  std::move(Params));
269  WasmSym->setSignature(Signature.get());
270  addSignature(std::move(Signature));
271 
272  return WasmSym;
273 }
274 
276  if (signaturesEmitted)
277  return;
278  signaturesEmitted = true;
279 
280  // Normally symbols for globals get discovered as the MI gets lowered,
281  // but we need to know about them ahead of time.
283  for (const auto &Name : MMIW.MachineSymbolsUsed) {
284  getOrCreateWasmSymbol(Name.getKey());
285  }
286 
287  for (auto &It : OutContext.getSymbols()) {
288  // Emit .globaltype, .tagtype, or .tabletype declarations.
289  auto Sym = cast<MCSymbolWasm>(It.getValue());
290  if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
291  // .globaltype already handled by emitGlobalVariable for defined
292  // variables; here we make sure the types of external wasm globals get
293  // written to the file.
294  if (Sym->isUndefined())
296  } else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TAG)
298  else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TABLE)
300  }
301 
302  DenseSet<MCSymbol *> InvokeSymbols;
303  for (const auto &F : M) {
304  if (F.isIntrinsic())
305  continue;
306 
307  // Emit function type info for all undefined functions
308  if (F.isDeclarationForLinker()) {
310  SmallVector<MVT, 4> Params;
311  computeSignatureVTs(F.getFunctionType(), &F, F, TM, Params, Results);
312  // At this point these MCSymbols may or may not have been created already
313  // and thus also contain a signature, but we need to get the signature
314  // anyway here in case it is an invoke that has not yet been created. We
315  // will discard it later if it turns out not to be necessary.
316  auto Signature = signatureFromMVTs(Results, Params);
317  bool InvokeDetected = false;
319  Signature.get(), InvokeDetected);
320 
321  // Multiple functions can be mapped to the same invoke symbol. For
322  // example, two IR functions '__invoke_void_i8*' and '__invoke_void_i32'
323  // are both mapped to '__invoke_vi'. We keep them in a set once we emit an
324  // Emscripten EH symbol so we don't emit the same symbol twice.
325  if (InvokeDetected && !InvokeSymbols.insert(Sym).second)
326  continue;
327 
328  Sym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
329  if (!Sym->getSignature()) {
330  Sym->setSignature(Signature.get());
331  addSignature(std::move(Signature));
332  } else {
333  // This symbol has already been created and had a signature. Discard it.
334  Signature.reset();
335  }
336 
338 
339  if (F.hasFnAttribute("wasm-import-module")) {
340  StringRef Name =
341  F.getFnAttribute("wasm-import-module").getValueAsString();
342  Sym->setImportModule(storeName(Name));
344  }
345  if (F.hasFnAttribute("wasm-import-name")) {
346  // If this is a converted Emscripten EH/SjLj symbol, we shouldn't use
347  // the original function name but the converted symbol name.
348  StringRef Name =
349  InvokeDetected
350  ? Sym->getName()
351  : F.getFnAttribute("wasm-import-name").getValueAsString();
352  Sym->setImportName(storeName(Name));
354  }
355  }
356 
357  if (F.hasFnAttribute("wasm-export-name")) {
358  auto *Sym = cast<MCSymbolWasm>(getSymbol(&F));
359  StringRef Name = F.getFnAttribute("wasm-export-name").getValueAsString();
360  Sym->setExportName(storeName(Name));
362  }
363  }
364 }
365 
368 
369  // When a function's address is taken, a TABLE_INDEX relocation is emitted
370  // against the function symbol at the use site. However the relocation
371  // doesn't explicitly refer to the table. In the future we may want to
372  // define a new kind of reloc against both the function and the table, so
373  // that the linker can see that the function symbol keeps the table alive,
374  // but for now manually mark the table as live.
375  for (const auto &F : M) {
376  if (!F.isIntrinsic() && F.hasAddressTaken()) {
377  MCSymbolWasm *FunctionTable =
379  OutStreamer->emitSymbolAttribute(FunctionTable, MCSA_NoDeadStrip);
380  break;
381  }
382  }
383 
384  for (const auto &G : M.globals()) {
385  if (!G.hasInitializer() && G.hasExternalLinkage() &&
386  !WebAssembly::isWasmVarAddressSpace(G.getAddressSpace()) &&
387  G.getValueType()->isSized()) {
388  uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
389  OutStreamer->emitELFSize(getSymbol(&G),
391  }
392  }
393 
394  if (const NamedMDNode *Named = M.getNamedMetadata("wasm.custom_sections")) {
395  for (const Metadata *MD : Named->operands()) {
396  const auto *Tuple = dyn_cast<MDTuple>(MD);
397  if (!Tuple || Tuple->getNumOperands() != 2)
398  continue;
399  const MDString *Name = dyn_cast<MDString>(Tuple->getOperand(0));
400  const MDString *Contents = dyn_cast<MDString>(Tuple->getOperand(1));
401  if (!Name || !Contents)
402  continue;
403 
404  OutStreamer->PushSection();
405  std::string SectionName = (".custom_section." + Name->getString()).str();
406  MCSectionWasm *MySection =
408  OutStreamer->SwitchSection(MySection);
409  OutStreamer->emitBytes(Contents->getString());
410  OutStreamer->PopSection();
411  }
412  }
413 
416 }
417 
420  if (const NamedMDNode *Debug = M.getNamedMetadata("llvm.dbg.cu")) {
421  llvm::SmallSet<StringRef, 4> SeenLanguages;
422  for (size_t I = 0, E = Debug->getNumOperands(); I < E; ++I) {
423  const auto *CU = cast<DICompileUnit>(Debug->getOperand(I));
424  StringRef Language = dwarf::LanguageString(CU->getSourceLanguage());
425  Language.consume_front("DW_LANG_");
426  if (SeenLanguages.insert(Language).second)
427  Languages.emplace_back(Language.str(), "");
428  }
429  }
430 
432  if (const NamedMDNode *Ident = M.getNamedMetadata("llvm.ident")) {
434  for (size_t I = 0, E = Ident->getNumOperands(); I < E; ++I) {
435  const auto *S = cast<MDString>(Ident->getOperand(I)->getOperand(0));
436  std::pair<StringRef, StringRef> Field = S->getString().split("version");
437  StringRef Name = Field.first.trim();
438  StringRef Version = Field.second.trim();
439  if (SeenTools.insert(Name).second)
440  Tools.emplace_back(Name.str(), Version.str());
441  }
442  }
443 
444  int FieldCount = int(!Languages.empty()) + int(!Tools.empty());
445  if (FieldCount != 0) {
447  ".custom_section.producers", SectionKind::getMetadata());
448  OutStreamer->PushSection();
449  OutStreamer->SwitchSection(Producers);
450  OutStreamer->emitULEB128IntValue(FieldCount);
451  for (auto &Producers : {std::make_pair("language", &Languages),
452  std::make_pair("processed-by", &Tools)}) {
453  if (Producers.second->empty())
454  continue;
455  OutStreamer->emitULEB128IntValue(strlen(Producers.first));
456  OutStreamer->emitBytes(Producers.first);
457  OutStreamer->emitULEB128IntValue(Producers.second->size());
458  for (auto &Producer : *Producers.second) {
459  OutStreamer->emitULEB128IntValue(Producer.first.size());
460  OutStreamer->emitBytes(Producer.first);
461  OutStreamer->emitULEB128IntValue(Producer.second.size());
462  OutStreamer->emitBytes(Producer.second);
463  }
464  }
465  OutStreamer->PopSection();
466  }
467 }
468 
470  struct FeatureEntry {
471  uint8_t Prefix;
472  std::string Name;
473  };
474 
475  // Read target features and linkage policies from module metadata
476  SmallVector<FeatureEntry, 4> EmittedFeatures;
477  auto EmitFeature = [&](std::string Feature) {
478  std::string MDKey = (StringRef("wasm-feature-") + Feature).str();
479  Metadata *Policy = M.getModuleFlag(MDKey);
480  if (Policy == nullptr)
481  return;
482 
483  FeatureEntry Entry;
484  Entry.Prefix = 0;
485  Entry.Name = Feature;
486 
487  if (auto *MD = cast<ConstantAsMetadata>(Policy))
488  if (auto *I = cast<ConstantInt>(MD->getValue()))
489  Entry.Prefix = I->getZExtValue();
490 
491  // Silently ignore invalid metadata
492  if (Entry.Prefix != wasm::WASM_FEATURE_PREFIX_USED &&
493  Entry.Prefix != wasm::WASM_FEATURE_PREFIX_REQUIRED &&
494  Entry.Prefix != wasm::WASM_FEATURE_PREFIX_DISALLOWED)
495  return;
496 
497  EmittedFeatures.push_back(Entry);
498  };
499 
500  for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
501  EmitFeature(KV.Key);
502  }
503  // This pseudo-feature tells the linker whether shared memory would be safe
504  EmitFeature("shared-mem");
505 
506  // This is an "architecture", not a "feature", but we emit it as such for
507  // the benefit of tools like Binaryen and consistency with other producers.
508  // FIXME: Subtarget is null here, so can't Subtarget->hasAddr64() ?
509  if (M.getDataLayout().getPointerSize() == 8) {
510  // Can't use EmitFeature since "wasm-feature-memory64" is not a module
511  // flag.
512  EmittedFeatures.push_back({wasm::WASM_FEATURE_PREFIX_USED, "memory64"});
513  }
514 
515  if (EmittedFeatures.size() == 0)
516  return;
517 
518  // Emit features and linkage policies into the "target_features" section
519  MCSectionWasm *FeaturesSection = OutContext.getWasmSection(
520  ".custom_section.target_features", SectionKind::getMetadata());
521  OutStreamer->PushSection();
522  OutStreamer->SwitchSection(FeaturesSection);
523 
524  OutStreamer->emitULEB128IntValue(EmittedFeatures.size());
525  for (auto &F : EmittedFeatures) {
526  OutStreamer->emitIntValue(F.Prefix, 1);
527  OutStreamer->emitULEB128IntValue(F.Name.size());
528  OutStreamer->emitBytes(F.Name);
529  }
530 
531  OutStreamer->PopSection();
532 }
533 
535  assert(MF->getConstantPool()->getConstants().empty() &&
536  "WebAssembly disables constant pools");
537 }
538 
540  // Nothing to do; jump tables are incorporated into the instruction stream.
541 }
542 
544  const {
545  AsmPrinter::emitLinkage(GV, Sym);
546  // This gets called before the function label and type are emitted.
547  // We use it to emit signatures of external functions.
548  // FIXME casts!
549  const_cast<WebAssemblyAsmPrinter *>(this)
551 }
552 
553 
555  const Function &F = MF->getFunction();
556  SmallVector<MVT, 1> ResultVTs;
557  SmallVector<MVT, 4> ParamVTs;
558  computeSignatureVTs(F.getFunctionType(), &F, F, TM, ParamVTs, ResultVTs);
559 
560  auto Signature = signatureFromMVTs(ResultVTs, ParamVTs);
561  auto *WasmSym = cast<MCSymbolWasm>(CurrentFnSym);
562  WasmSym->setSignature(Signature.get());
563  addSignature(std::move(Signature));
564  WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
565 
567 
568  // Emit the function index.
569  if (MDNode *Idx = F.getMetadata("wasm.index")) {
570  assert(Idx->getNumOperands() == 1);
571 
573  cast<ConstantAsMetadata>(Idx->getOperand(0))->getValue()));
574  }
575 
577  valTypesFromMVTs(MFI->getLocals(), Locals);
578  getTargetStreamer()->emitLocal(Locals);
579 
581 }
582 
584  LLVM_DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
585 
586  switch (MI->getOpcode()) {
587  case WebAssembly::ARGUMENT_i32:
588  case WebAssembly::ARGUMENT_i32_S:
589  case WebAssembly::ARGUMENT_i64:
590  case WebAssembly::ARGUMENT_i64_S:
591  case WebAssembly::ARGUMENT_f32:
592  case WebAssembly::ARGUMENT_f32_S:
593  case WebAssembly::ARGUMENT_f64:
594  case WebAssembly::ARGUMENT_f64_S:
595  case WebAssembly::ARGUMENT_v16i8:
596  case WebAssembly::ARGUMENT_v16i8_S:
597  case WebAssembly::ARGUMENT_v8i16:
598  case WebAssembly::ARGUMENT_v8i16_S:
599  case WebAssembly::ARGUMENT_v4i32:
600  case WebAssembly::ARGUMENT_v4i32_S:
601  case WebAssembly::ARGUMENT_v2i64:
602  case WebAssembly::ARGUMENT_v2i64_S:
603  case WebAssembly::ARGUMENT_v4f32:
604  case WebAssembly::ARGUMENT_v4f32_S:
605  case WebAssembly::ARGUMENT_v2f64:
606  case WebAssembly::ARGUMENT_v2f64_S:
607  // These represent values which are live into the function entry, so there's
608  // no instruction to emit.
609  break;
610  case WebAssembly::FALLTHROUGH_RETURN: {
611  // These instructions represent the implicit return at the end of a
612  // function body.
613  if (isVerbose()) {
614  OutStreamer->AddComment("fallthrough-return");
615  OutStreamer->AddBlankLine();
616  }
617  break;
618  }
619  case WebAssembly::COMPILER_FENCE:
620  // This is a compiler barrier that prevents instruction reordering during
621  // backend compilation, and should not be emitted.
622  break;
623  default: {
624  WebAssemblyMCInstLower MCInstLowering(OutContext, *this);
625  MCInst TmpInst;
626  MCInstLowering.lower(MI, TmpInst);
627  EmitToStreamer(*OutStreamer, TmpInst);
628  break;
629  }
630  }
631 }
632 
634  unsigned OpNo,
635  const char *ExtraCode,
636  raw_ostream &OS) {
637  // First try the generic code, which knows about modifiers like 'c' and 'n'.
638  if (!AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS))
639  return false;
640 
641  if (!ExtraCode) {
642  const MachineOperand &MO = MI->getOperand(OpNo);
643  switch (MO.getType()) {
645  OS << MO.getImm();
646  return false;
648  // FIXME: only opcode that still contains registers, as required by
649  // MachineInstr::getDebugVariable().
650  assert(MI->getOpcode() == WebAssembly::INLINEASM);
651  OS << regToString(MO);
652  return false;
654  PrintSymbolOperand(MO, OS);
655  return false;
658  printOffset(MO.getOffset(), OS);
659  return false;
661  MO.getMBB()->getSymbol()->print(OS, MAI);
662  return false;
663  default:
664  break;
665  }
666  }
667 
668  return true;
669 }
670 
672  unsigned OpNo,
673  const char *ExtraCode,
674  raw_ostream &OS) {
675  // The current approach to inline asm is that "r" constraints are expressed
676  // as local indices, rather than values on the operand stack. This simplifies
677  // using "r" as it eliminates the need to push and pop the values in a
678  // particular order, however it also makes it impossible to have an "m"
679  // constraint. So we don't support it.
680 
681  return AsmPrinter::PrintAsmMemoryOperand(MI, OpNo, ExtraCode, OS);
682 }
683 
684 // Force static initialization.
688 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::WebAssemblyTargetStreamer::emitLocal
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
AsmPrinter.h
llvm::WebAssemblySubtarget::getRegisterInfo
const WebAssemblyRegisterInfo * getRegisterInfo() const override
Definition: WebAssemblySubtarget.h:81
llvm::WebAssemblyFeatureKV
const SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]
llvm::AsmPrinter::isPositionIndependent
bool isPositionIndependent() const
Definition: AsmPrinter.cpp:214
WasmKeepRegisters
cl::opt< bool > WasmKeepRegisters
MachineModuleInfoImpls.h
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:105
MachineInstr.h
llvm::MachineOperand::MO_Immediate
@ MO_Immediate
Immediate operand.
Definition: MachineOperand.h:53
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::WebAssemblyTargetStreamer
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
Definition: WebAssemblyTargetStreamer.h:29
llvm::wasm::ValType::I32
@ I32
WasmEnableEmEH
cl::opt< bool > WasmEnableEmEH
llvm::AsmPrinter::printOffset
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
Definition: AsmPrinter.cpp:3110
WebAssembly.h
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::WebAssemblyFunctionInfo::getLocals
const std::vector< MVT > & getLocals() const
Definition: WebAssemblyMachineFunctionInfo.h:95
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1421
llvm::SectionKind::getMetadata
static SectionKind getMetadata()
Definition: SectionKind.h:182
Metadata.h
llvm::AsmPrinter::lowerConstant
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
Definition: AsmPrinter.cpp:2487
llvm::getTheWebAssemblyTarget32
Target & getTheWebAssemblyTarget32()
Definition: WebAssemblyTargetInfo.cpp:20
llvm::MCSymbolWasm::getType
Optional< wasm::WasmSymbolType > getType() const
Definition: MCSymbolWasm.h:51
DebugInfoMetadata.h
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
llvm::MachineModuleInfoWasm::MachineSymbolsUsed
StringSet MachineSymbolsUsed
Definition: MachineModuleInfoImpls.h:113
T
llvm::Function
Definition: Function.h:62
llvm::MCContext::getSymbols
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example,...
Definition: MCContext.h:502
llvm::WebAssemblyTargetStreamer::emitIndIdx
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx
llvm::WebAssemblySubtarget::getTargetLowering
const WebAssemblyTargetLowering * getTargetLowering() const override
Definition: WebAssemblySubtarget.h:75
llvm::AsmPrinter::MAI
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:87
llvm::MCConstantExpr::create
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
llvm::WebAssembly::getOrCreateFunctionTableSymbol
MCSymbolWasm * getOrCreateFunctionTableSymbol(MCContext &Ctx, const WebAssemblySubtarget *Subtarget)
Returns the __indirect_function_table, for use in call_indirect and in function bitcasts.
Definition: WebAssemblyUtilities.cpp:100
llvm::signatureFromMVTs
std::unique_ptr< wasm::WasmSignature > signatureFromMVTs(const SmallVectorImpl< MVT > &Results, const SmallVectorImpl< MVT > &Params)
Definition: WebAssemblyMachineFunctionInfo.cpp:100
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
WebAssemblyMCInstLower.h
llvm::WebAssemblyAsmPrinter::PrintAsmMemoryOperand
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
Definition: WebAssemblyAsmPrinter.cpp:671
isEmscriptenInvokeName
static bool isEmscriptenInvokeName(StringRef Name)
Definition: WebAssemblyAsmPrinter.cpp:104
llvm::WebAssemblyAsmPrinter::getSubtarget
const WebAssemblySubtarget & getSubtarget() const
Definition: WebAssemblyAsmPrinter.h:46
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::wasm::WASM_SYMBOL_TYPE_TABLE
@ WASM_SYMBOL_TYPE_TABLE
Definition: Wasm.h:375
llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:372
llvm::WebAssembly::signatureToString
std::string signatureToString(const wasm::WasmSignature *Sig)
Definition: WebAssemblyTypeUtilities.cpp:122
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:233
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::AsmPrinter::PrintSymbolOperand
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
Definition: AsmPrinterInlineAsm.cpp:456
llvm::WebAssemblySubtarget::hasAddr64
bool hasAddr64() const
Definition: WebAssemblySubtarget.h:91
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:134
llvm::WebAssemblyAsmPrinter::regToString
std::string regToString(const MachineOperand &MO)
Definition: WebAssemblyAsmPrinter.cpp:73
Results
Function Alias Analysis Results
Definition: AliasAnalysis.cpp:847
llvm::WebAssemblyAsmPrinter::emitLinkage
void emitLinkage(const GlobalValue *, MCSymbol *) const override
This emits linkage information about GVSym based on GV, if this is supported by the target.
Definition: WebAssemblyAsmPrinter.cpp:543
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:893
WebAssemblyTargetMachine.h
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::MVT::v2f64
@ v2f64
Definition: MachineValueType.h:172
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
llvm::WebAssemblyAsmPrinter::getOrCreateWasmSymbol
MCSymbol * getOrCreateWasmSymbol(StringRef Name)
Definition: WebAssemblyAsmPrinter.cpp:211
llvm::MachineOperand::getOffset
int64_t getOffset() const
Return the offset from the symbol in this operand.
Definition: MachineOperand.h:600
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1559
llvm::WebAssemblyTargetStreamer::emitImportModule
virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule)=0
.import_module
llvm::WebAssemblyMCInstLower
This class is used to lower an MachineInstr into an MCInst.
Definition: WebAssemblyMCInstLower.h:30
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::AsmPrinter::emitGlobalVariable
virtual void emitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
Definition: AsmPrinter.cpp:507
llvm::MachineOperand::MO_Register
@ MO_Register
Register operand.
Definition: MachineOperand.h:52
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::GlobalVariable::hasInitializer
bool hasInitializer() const
Definitions have initializers, declarations don't.
Definition: GlobalVariable.h:92
llvm::AsmPrinter::EmitToStreamer
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:242
llvm::wasm::WASM_FEATURE_PREFIX_REQUIRED
@ WASM_FEATURE_PREFIX_REQUIRED
Definition: Wasm.h:332
llvm::ComputeValueVTs
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
Definition: Analysis.cpp:124
llvm::ISD::INLINEASM
@ INLINEASM
INLINEASM - Represents an inline asm block.
Definition: ISDOpcodes.h:980
llvm::WebAssemblyTargetLowering
Definition: WebAssemblyISelLowering.h:43
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::MCSA_NoDeadStrip
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
Definition: MCDirectives.h:38
llvm::WebAssemblyTargetStreamer::emitFunctionType
virtual void emitFunctionType(const MCSymbolWasm *Sym)=0
.functype
llvm::MachineBasicBlock::getSymbol
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Definition: MachineBasicBlock.cpp:60
llvm::WebAssemblyTargetStreamer::emitExportName
virtual void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName)=0
.export_name
llvm::WebAssemblyMCInstLower::lower
void lower(const MachineInstr *MI, MCInst &OutMI) const
Definition: WebAssemblyMCInstLower.cpp:213
llvm::GlobalValue::isDeclaration
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:228
llvm::dwarf::LanguageString
StringRef LanguageString(unsigned Language)
Definition: Dwarf.cpp:327
llvm::AsmPrinter::emitLinkage
virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target.
Definition: AsmPrinter.cpp:440
llvm::wasm::ValType::F64
@ F64
llvm::WebAssemblyTargetStreamer::emitTableType
virtual void emitTableType(const MCSymbolWasm *Sym)=0
.tabletype
llvm::WebAssemblyTargetStreamer::emitImportName
virtual void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName)=0
.import_name
llvm::MachineOperand::MO_GlobalAddress
@ MO_GlobalAddress
Address of a global value.
Definition: MachineOperand.h:62
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MachineOperand::getImm
int64_t getImm() const
Definition: MachineOperand.h:537
llvm::AMDGPU::HSAMD::Kernel::Key::Language
constexpr char Language[]
Key for Kernel::Metadata::mLanguage.
Definition: AMDGPUMetadata.h:383
llvm::MCSectionWasm
This represents a section on wasm.
Definition: MCSectionWasm.h:26
llvm::AsmPrinter::OutStreamer
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:96
llvm::AsmPrinter::PrintAsmMemoryOperand
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
Definition: AsmPrinterInlineAsm.cpp:508
MCSymbolWasm.h
llvm::MVT::f64
@ f64
Definition: MachineValueType.h:56
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::WebAssemblyAsmPrinter::addSignature
void addSignature(std::unique_ptr< wasm::WasmSignature > &&Sig)
Definition: WebAssemblyAsmPrinter.h:47
llvm::wasm::WASM_FEATURE_PREFIX_DISALLOWED
@ WASM_FEATURE_PREFIX_DISALLOWED
Definition: Wasm.h:333
MCContext.h
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::WebAssemblyAsmPrinter::getRegType
MVT getRegType(unsigned RegNo) const
Definition: WebAssemblyAsmPrinter.cpp:61
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:46
MCSymbol.h
llvm::wasm::ValType::F32
@ F32
llvm::WebAssembly::toValType
wasm::ValType toValType(MVT Type)
Definition: WebAssemblyTypeUtilities.cpp:131
WebAssemblyRuntimeLibcallSignatures.h
llvm::wasm::WasmGlobalType
Definition: Wasm.h:105
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::WebAssemblyAsmPrinter::emitJumpTableInfo
void emitJumpTableInfo() override
Print assembly representations of the jump tables used by the current function to the current output ...
Definition: WebAssemblyAsmPrinter.cpp:539
llvm::MCSymbolWasm::setType
void setType(wasm::WasmSymbolType type)
Definition: MCSymbolWasm.h:53
WebAssemblyTypeUtilities.h
llvm::AsmPrinter::CurrentFnSym
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:118
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:143
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION
@ WASM_SYMBOL_TYPE_FUNCTION
Definition: Wasm.h:370
llvm::wasm::ValType
ValType
Definition: Wasm.h:411
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:91
llvm::AsmPrinter::emitFunctionBodyStart
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition: AsmPrinter.h:482
llvm::SubtargetFeatureKV
Used to provide key value pairs for feature and CPU bit flags.
Definition: MCSubtargetInfo.h:34
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::MCSymbol::print
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition: MCSymbol.cpp:59
llvm::MCContext::getWasmSection
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
Definition: MCContext.h:621
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
WebAssemblyUtilities.h
WebAssemblyMCTargetDesc.h
llvm::MachineRegisterInfo::getRegClass
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Definition: MachineRegisterInfo.h:634
llvm::WebAssemblyAsmPrinter::EmitTargetFeatures
void EmitTargetFeatures(Module &M)
Definition: WebAssemblyAsmPrinter.cpp:469
llvm::wasm::WASM_TYPE_I32
@ WASM_TYPE_I32
Definition: Wasm.h:253
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
WebAssemblyTargetStreamer.h
llvm::WebAssemblyFunctionInfo::UnusedReg
static const unsigned UnusedReg
Definition: WebAssemblyMachineFunctionInfo.h:122
llvm::cl::opt< bool >
llvm::WebAssemblyAsmPrinter::emitFunctionBodyStart
void emitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
Definition: WebAssemblyAsmPrinter.cpp:554
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::MVT::v16i8
@ v16i8
Definition: MachineValueType.h:80
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::MVT::v2i64
@ v2i64
Definition: MachineValueType.h:118
llvm::GlobalValue::getVisibility
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:229
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:578
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
llvm::wasm::ValType::EXTERNREF
@ EXTERNREF
llvm::wasm::ValType::I64
@ I64
llvm::MCSymbolWasm
Definition: MCSymbolWasm.h:16
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::wasm::ValType::FUNCREF
@ FUNCREF
llvm::AsmPrinter::getSymbolPreferLocal
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
Definition: AsmPrinter.cpp:489
llvm::valTypesFromMVTs
void valTypesFromMVTs(const ArrayRef< MVT > &In, SmallVectorImpl< wasm::ValType > &Out)
Definition: WebAssemblyMachineFunctionInfo.cpp:93
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::getLibcallSignature
void getLibcallSignature(const WebAssemblySubtarget &Subtarget, RTLIB::Libcall LC, SmallVectorImpl< wasm::ValType > &Rets, SmallVectorImpl< wasm::ValType > &Params)
Definition: WebAssemblyRuntimeLibcallSignatures.cpp:516
WebAssemblyTargetInfo.h
llvm::wasm::WasmSignature::Returns
SmallVector< ValType, 1 > Returns
Definition: Wasm.h:422
Analysis.h
StringExtras.h
MachineConstantPool.h
llvm::WebAssemblyAsmPrinter::EmitProducerInfo
void EmitProducerInfo(Module &M)
Definition: WebAssemblyAsmPrinter.cpp:418
llvm::MachineOperand::getType
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Definition: MachineOperand.h:219
llvm::wasm::WASM_SYMBOL_TYPE_TAG
@ WASM_SYMBOL_TYPE_TAG
Definition: Wasm.h:374
llvm::WebAssemblyFunctionInfo::getWAReg
unsigned getWAReg(unsigned VReg) const
Definition: WebAssemblyMachineFunctionInfo.h:150
llvm::Register::isVirtualRegister
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
Definition: Register.h:71
llvm::MVT::v4f32
@ v4f32
Definition: MachineValueType.h:157
llvm::WebAssemblyFunctionInfo::isVRegStackified
bool isVRegStackified(unsigned VReg) const
Definition: WebAssemblyMachineFunctionInfo.h:136
llvm::MachineFunction::getConstantPool
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
Definition: MachineFunction.h:666
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::AsmPrinter::getSymbol
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:485
llvm::MVT::Other
@ Other
Definition: MachineValueType.h:42
llvm::WebAssemblyAsmPrinter::emitExternalDecls
void emitExternalDecls(const Module &M)
Definition: WebAssemblyAsmPrinter.cpp:275
llvm::GlobalValue::isThreadLocal
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
Definition: GlobalValue.h:244
llvm::AsmPrinter::MF
MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:99
llvm::AsmPrinter::OutContext
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:91
llvm::MVT
Machine Value Type.
Definition: MachineValueType.h:31
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition: MachineOperand.h:360
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::WebAssemblyAsmPrinter
Definition: WebAssemblyAsmPrinter.h:21
WebAssemblyMachineFunctionInfo.h
getInvokeSig
static char getInvokeSig(wasm::ValType VT)
Definition: WebAssemblyAsmPrinter.cpp:112
llvm::wasm::WASM_FEATURE_PREFIX_USED
@ WASM_FEATURE_PREFIX_USED
Definition: Wasm.h:331
llvm::AsmPrinter::GetExternalSymbolSymbol
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
Definition: AsmPrinter.cpp:3187
llvm::MachineOperand::getMBB
MachineBasicBlock * getMBB() const
Definition: MachineOperand.h:552
WebAssemblyAsmPrinter.h
DataLayout.h
llvm::MVT::i64
@ i64
Definition: MachineValueType.h:47
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::WebAssemblyAsmPrinter::PrintAsmOperand
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
Definition: WebAssemblyAsmPrinter.cpp:633
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
llvm::MachineModuleInfoWasm
MachineModuleInfoWasm - This is a MachineModuleInfoImpl implementation for Wasm targets.
Definition: MachineModuleInfoImpls.h:107
llvm::TargetRegisterInfo::isTypeLegalForClass
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const
Return true if the given TargetRegisterClass has the ValueType T.
Definition: TargetRegisterInfo.h:293
llvm::MachineOperand::MO_MachineBasicBlock
@ MO_MachineBasicBlock
MachineBasicBlock reference.
Definition: MachineOperand.h:56
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::WebAssemblySubtarget
Definition: WebAssemblySubtarget.h:35
llvm::MVT::v4i32
@ v4i32
Definition: MachineValueType.h:103
llvm::SmallSet::insert
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Definition: SmallSet.h:180
LLVMInitializeWebAssemblyAsmPrinter
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmPrinter()
Definition: WebAssemblyAsmPrinter.cpp:685
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::AsmPrinter::MMI
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition: AsmPrinter.h:102
llvm::getTheWebAssemblyTarget64
Target & getTheWebAssemblyTarget64()
Definition: WebAssemblyTargetInfo.cpp:24
llvm::WebAssemblyAsmPrinter::getTargetStreamer
WebAssemblyTargetStreamer * getTargetStreamer()
Definition: WebAssemblyAsmPrinter.cpp:83
llvm::WebAssemblyAsmPrinter::emitConstantPool
void emitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Definition: WebAssemblyAsmPrinter.cpp:534
llvm::WebAssemblyAsmPrinter::emitInstruction
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
Definition: WebAssemblyAsmPrinter.cpp:583
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::computeSignatureVTs
void computeSignatureVTs(const FunctionType *Ty, const Function *TargetFunc, const Function &ContextFunc, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
Definition: WebAssemblyMachineFunctionInfo.cpp:49
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:600
uint16_t
llvm::MachineConstantPool::getConstants
const std::vector< MachineConstantPoolEntry > & getConstants() const
Definition: MachineConstantPool.h:145
llvm::SectionName
Definition: DWARFSection.h:21
llvm::MachineOperand::MO_ExternalSymbol
@ MO_ExternalSymbol
Name of external global symbol.
Definition: MachineOperand.h:61
GlobalVariable.h
llvm::MVT::v8i16
@ v8i16
Definition: MachineValueType.h:92
llvm::Module::getContext
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:261
WebAssemblyRegisterInfo.h
llvm::WebAssemblyAsmPrinter::emitGlobalVariable
void emitGlobalVariable(const GlobalVariable *GV) override
Emit the specified global variable to the .s file.
Definition: WebAssemblyAsmPrinter.cpp:174
llvm::MVT::i32
@ i32
Definition: MachineValueType.h:46
llvm::WebAssemblyAsmPrinter::getMCSymbolForFunction
MCSymbolWasm * getMCSymbolForFunction(const Function *F, bool EnableEmEH, wasm::WasmSignature *Sig, bool &InvokeDetected)
Definition: WebAssemblyAsmPrinter.cpp:152
llvm::AsmPrinter::emitVisibility
void emitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
Definition: AsmPrinter.cpp:3347
Wasm.h
llvm::GlobalValue::getAddressSpace
unsigned getAddressSpace() const
Definition: Globals.cpp:112
llvm::wasm::ValType::V128
@ V128
llvm::AsmPrinter::TM
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:84
Version
uint64_t Version
Definition: RawMemProfReader.cpp:24
llvm::MCSymbolWasm::setGlobalType
void setGlobalType(wasm::WasmGlobalType GT)
Definition: MCSymbolWasm.h:135
llvm::MachineOperand::getSymbolName
const char * getSymbolName() const
Definition: MachineOperand.h:608
llvm::WebAssembly::isWasmVarAddressSpace
bool isWasmVarAddressSpace(unsigned AS)
Definition: WebAssemblyUtilities.h:50
MCStreamer.h
WasmEnableEmSjLj
cl::opt< bool > WasmEnableEmSjLj
llvm::TargetLoweringBase::getRegisterType
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
Definition: TargetLowering.h:1477
llvm::TargetLoweringBase::getNumRegisters
virtual unsigned getNumRegisters(LLVMContext &Context, EVT VT, Optional< MVT > RegisterVT=None) const
Return the number of registers that this ValueType will eventually require.
Definition: TargetLowering.h:1515
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:401
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:273
llvm::WebAssemblyTargetStreamer::emitTagType
virtual void emitTagType(const MCSymbolWasm *Sym)=0
.tagtype
llvm::wasm::WASM_TYPE_I64
@ WASM_TYPE_I64
Definition: Wasm.h:254
llvm::OptimizedStructLayoutField
A field in a structure.
Definition: OptimizedStructLayout.h:45
llvm::RegisterAsmPrinter
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Definition: TargetRegistry.h:1338
llvm::MDString::getString
StringRef getString() const
Definition: Metadata.cpp:483
llvm::AsmPrinter::isVerbose
bool isVerbose() const
Return true if assembly output should contain comments.
Definition: AsmPrinter.h:237
raw_ostream.h
llvm::MDString
A single uniqued string.
Definition: Metadata.h:611
TargetRegistry.h
CU
Definition: AArch64AsmBackend.cpp:504
llvm::MachineModuleInfo::getModule
const Module * getModule() const
Definition: MachineModuleInfo.h:174
llvm::MVT::f32
@ f32
Definition: MachineValueType.h:55
llvm::WebAssemblyTargetStreamer::emitGlobalType
virtual void emitGlobalType(const MCSymbolWasm *Sym)=0
.globaltype
llvm::wasm::WasmSignature::Params
SmallVector< ValType, 4 > Params
Definition: Wasm.h:423
Debug.h
getEmscriptenInvokeSymbolName
static std::string getEmscriptenInvokeSymbolName(wasm::WasmSignature *Sig)
Definition: WebAssemblyAsmPrinter.cpp:134
llvm::wasm::WASM_SYMBOL_TYPE_DATA
@ WASM_SYMBOL_TYPE_DATA
Definition: Wasm.h:371
llvm::AsmPrinter::PrintAsmOperand
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
Definition: AsmPrinterInlineAsm.cpp:466
llvm::MachineModuleInfo::getObjFileInfo
Ty & getObjFileInfo()
Keep track of various per-module pieces of information for backends that would like to do so.
Definition: MachineModuleInfo.h:191
llvm::wasm::WasmSignature
Definition: Wasm.h:421
llvm::WebAssemblyAsmPrinter::emitEndOfAsmFile
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
Definition: WebAssemblyAsmPrinter.cpp:366
MCSectionWasm.h
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:908
SmallSet.h