LLVM  10.0.0svn
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"
21 #include "WebAssembly.h"
22 #include "WebAssemblyMCInstLower.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"
34 #include "llvm/IR/DataLayout.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"
46 
47 using namespace llvm;
48 
49 #define DEBUG_TYPE "asm-printer"
50 
52 
53 //===----------------------------------------------------------------------===//
54 // Helpers.
55 //===----------------------------------------------------------------------===//
56 
57 MVT WebAssemblyAsmPrinter::getRegType(unsigned RegNo) const {
58  const TargetRegisterInfo *TRI = Subtarget->getRegisterInfo();
59  const TargetRegisterClass *TRC = MRI->getRegClass(RegNo);
62  if (TRI->isTypeLegalForClass(*TRC, T))
63  return T;
64  LLVM_DEBUG(errs() << "Unknown type for register number: " << RegNo);
65  llvm_unreachable("Unknown register type");
66  return MVT::Other;
67 }
68 
70  Register RegNo = MO.getReg();
72  "Unlowered physical register encountered during assembly printing");
73  assert(!MFI->isVRegStackified(RegNo));
74  unsigned WAReg = MFI->getWAReg(RegNo);
76  return '$' + utostr(WAReg);
77 }
78 
80  MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
81  return static_cast<WebAssemblyTargetStreamer *>(TS);
82 }
83 
84 //===----------------------------------------------------------------------===//
85 // WebAssemblyAsmPrinter Implementation.
86 //===----------------------------------------------------------------------===//
87 
89  for (auto &It : OutContext.getSymbols()) {
90  // Emit a .globaltype and .eventtype declaration.
91  auto Sym = cast<MCSymbolWasm>(It.getValue());
92  if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL)
94  else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_EVENT)
96  }
97 
98  for (const auto &F : M) {
99  // Emit function type info for all undefined functions
100  if (F.isDeclarationForLinker() && !F.isIntrinsic()) {
102  SmallVector<MVT, 4> Params;
103  computeSignatureVTs(F.getFunctionType(), F, TM, Params, Results);
104  auto *Sym = cast<MCSymbolWasm>(getSymbol(&F));
105  Sym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
106  if (!Sym->getSignature()) {
107  auto Signature = signatureFromMVTs(Results, Params);
108  Sym->setSignature(Signature.get());
109  addSignature(std::move(Signature));
110  }
111  // FIXME: this was originally intended for post-linking and was only used
112  // for imports that were only called indirectly (i.e. s2wasm could not
113  // infer the type from a call). With object files it applies to all
114  // imports. so fix the names and the tests, or rethink how import
115  // delcarations work in asm files.
117 
118  if (TM.getTargetTriple().isOSBinFormatWasm() &&
119  F.hasFnAttribute("wasm-import-module")) {
120  StringRef Name =
121  F.getFnAttribute("wasm-import-module").getValueAsString();
122  Sym->setImportModule(Name);
123  getTargetStreamer()->emitImportModule(Sym, Name);
124  }
125  if (TM.getTargetTriple().isOSBinFormatWasm() &&
126  F.hasFnAttribute("wasm-import-name")) {
127  StringRef Name =
128  F.getFnAttribute("wasm-import-name").getValueAsString();
129  Sym->setImportName(Name);
130  getTargetStreamer()->emitImportName(Sym, Name);
131  }
132  }
133  }
134 
135  for (const auto &G : M.globals()) {
136  if (!G.hasInitializer() && G.hasExternalLinkage()) {
137  if (G.getValueType()->isSized()) {
138  uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
139  OutStreamer->emitELFSize(getSymbol(&G),
141  }
142  }
143  }
144 
145  if (const NamedMDNode *Named = M.getNamedMetadata("wasm.custom_sections")) {
146  for (const Metadata *MD : Named->operands()) {
147  const auto *Tuple = dyn_cast<MDTuple>(MD);
148  if (!Tuple || Tuple->getNumOperands() != 2)
149  continue;
150  const MDString *Name = dyn_cast<MDString>(Tuple->getOperand(0));
151  const MDString *Contents = dyn_cast<MDString>(Tuple->getOperand(1));
152  if (!Name || !Contents)
153  continue;
154 
155  OutStreamer->PushSection();
156  std::string SectionName = (".custom_section." + Name->getString()).str();
157  MCSectionWasm *MySection =
159  OutStreamer->SwitchSection(MySection);
160  OutStreamer->EmitBytes(Contents->getString());
161  OutStreamer->PopSection();
162  }
163  }
164 
165  EmitProducerInfo(M);
167 }
168 
171  if (const NamedMDNode *Debug = M.getNamedMetadata("llvm.dbg.cu")) {
172  llvm::SmallSet<StringRef, 4> SeenLanguages;
173  for (size_t I = 0, E = Debug->getNumOperands(); I < E; ++I) {
174  const auto *CU = cast<DICompileUnit>(Debug->getOperand(I));
175  StringRef Language = dwarf::LanguageString(CU->getSourceLanguage());
176  Language.consume_front("DW_LANG_");
177  if (SeenLanguages.insert(Language).second)
178  Languages.emplace_back(Language.str(), "");
179  }
180  }
181 
183  if (const NamedMDNode *Ident = M.getNamedMetadata("llvm.ident")) {
185  for (size_t I = 0, E = Ident->getNumOperands(); I < E; ++I) {
186  const auto *S = cast<MDString>(Ident->getOperand(I)->getOperand(0));
187  std::pair<StringRef, StringRef> Field = S->getString().split("version");
188  StringRef Name = Field.first.trim();
189  StringRef Version = Field.second.trim();
190  if (SeenTools.insert(Name).second)
191  Tools.emplace_back(Name.str(), Version.str());
192  }
193  }
194 
195  int FieldCount = int(!Languages.empty()) + int(!Tools.empty());
196  if (FieldCount != 0) {
198  ".custom_section.producers", SectionKind::getMetadata());
199  OutStreamer->PushSection();
200  OutStreamer->SwitchSection(Producers);
201  OutStreamer->EmitULEB128IntValue(FieldCount);
202  for (auto &Producers : {std::make_pair("language", &Languages),
203  std::make_pair("processed-by", &Tools)}) {
204  if (Producers.second->empty())
205  continue;
206  OutStreamer->EmitULEB128IntValue(strlen(Producers.first));
207  OutStreamer->EmitBytes(Producers.first);
208  OutStreamer->EmitULEB128IntValue(Producers.second->size());
209  for (auto &Producer : *Producers.second) {
210  OutStreamer->EmitULEB128IntValue(Producer.first.size());
211  OutStreamer->EmitBytes(Producer.first);
212  OutStreamer->EmitULEB128IntValue(Producer.second.size());
213  OutStreamer->EmitBytes(Producer.second);
214  }
215  }
216  OutStreamer->PopSection();
217  }
218 }
219 
221  struct FeatureEntry {
222  uint8_t Prefix;
223  StringRef Name;
224  };
225 
226  // Read target features and linkage policies from module metadata
227  SmallVector<FeatureEntry, 4> EmittedFeatures;
228  for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
229  std::string MDKey = (StringRef("wasm-feature-") + KV.Key).str();
230  Metadata *Policy = M.getModuleFlag(MDKey);
231  if (Policy == nullptr)
232  continue;
233 
234  FeatureEntry Entry;
235  Entry.Prefix = 0;
236  Entry.Name = KV.Key;
237 
238  if (auto *MD = cast<ConstantAsMetadata>(Policy))
239  if (auto *I = cast<ConstantInt>(MD->getValue()))
240  Entry.Prefix = I->getZExtValue();
241 
242  // Silently ignore invalid metadata
243  if (Entry.Prefix != wasm::WASM_FEATURE_PREFIX_USED &&
244  Entry.Prefix != wasm::WASM_FEATURE_PREFIX_REQUIRED &&
245  Entry.Prefix != wasm::WASM_FEATURE_PREFIX_DISALLOWED)
246  continue;
247 
248  EmittedFeatures.push_back(Entry);
249  }
250 
251  if (EmittedFeatures.size() == 0)
252  return;
253 
254  // Emit features and linkage policies into the "target_features" section
255  MCSectionWasm *FeaturesSection = OutContext.getWasmSection(
256  ".custom_section.target_features", SectionKind::getMetadata());
257  OutStreamer->PushSection();
258  OutStreamer->SwitchSection(FeaturesSection);
259 
260  OutStreamer->EmitULEB128IntValue(EmittedFeatures.size());
261  for (auto &F : EmittedFeatures) {
262  OutStreamer->EmitIntValue(F.Prefix, 1);
263  OutStreamer->EmitULEB128IntValue(F.Name.size());
264  OutStreamer->EmitBytes(F.Name);
265  }
266 
267  OutStreamer->PopSection();
268 }
269 
271  assert(MF->getConstantPool()->getConstants().empty() &&
272  "WebAssembly disables constant pools");
273 }
274 
276  // Nothing to do; jump tables are incorporated into the instruction stream.
277 }
278 
280  const Function &F = MF->getFunction();
281  SmallVector<MVT, 1> ResultVTs;
282  SmallVector<MVT, 4> ParamVTs;
283  computeSignatureVTs(F.getFunctionType(), F, TM, ParamVTs, ResultVTs);
284  auto Signature = signatureFromMVTs(ResultVTs, ParamVTs);
285  auto *WasmSym = cast<MCSymbolWasm>(CurrentFnSym);
286  WasmSym->setSignature(Signature.get());
287  addSignature(std::move(Signature));
288  WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
289 
290  // FIXME: clean up how params and results are emitted (use signatures)
292 
293  // Emit the function index.
294  if (MDNode *Idx = F.getMetadata("wasm.index")) {
295  assert(Idx->getNumOperands() == 1);
296 
298  cast<ConstantAsMetadata>(Idx->getOperand(0))->getValue()));
299  }
300 
302  valTypesFromMVTs(MFI->getLocals(), Locals);
303  getTargetStreamer()->emitLocal(Locals);
304 
306 }
307 
309  LLVM_DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
310 
311  switch (MI->getOpcode()) {
312  case WebAssembly::ARGUMENT_i32:
313  case WebAssembly::ARGUMENT_i32_S:
314  case WebAssembly::ARGUMENT_i64:
315  case WebAssembly::ARGUMENT_i64_S:
316  case WebAssembly::ARGUMENT_f32:
317  case WebAssembly::ARGUMENT_f32_S:
318  case WebAssembly::ARGUMENT_f64:
319  case WebAssembly::ARGUMENT_f64_S:
320  case WebAssembly::ARGUMENT_v16i8:
321  case WebAssembly::ARGUMENT_v16i8_S:
322  case WebAssembly::ARGUMENT_v8i16:
323  case WebAssembly::ARGUMENT_v8i16_S:
324  case WebAssembly::ARGUMENT_v4i32:
325  case WebAssembly::ARGUMENT_v4i32_S:
326  case WebAssembly::ARGUMENT_v2i64:
327  case WebAssembly::ARGUMENT_v2i64_S:
328  case WebAssembly::ARGUMENT_v4f32:
329  case WebAssembly::ARGUMENT_v4f32_S:
330  case WebAssembly::ARGUMENT_v2f64:
331  case WebAssembly::ARGUMENT_v2f64_S:
332  // These represent values which are live into the function entry, so there's
333  // no instruction to emit.
334  break;
335  case WebAssembly::FALLTHROUGH_RETURN: {
336  // These instructions represent the implicit return at the end of a
337  // function body.
338  if (isVerbose()) {
339  OutStreamer->AddComment("fallthrough-return");
340  OutStreamer->AddBlankLine();
341  }
342  break;
343  }
344  case WebAssembly::COMPILER_FENCE:
345  // This is a compiler barrier that prevents instruction reordering during
346  // backend compilation, and should not be emitted.
347  break;
348  case WebAssembly::EXTRACT_EXCEPTION_I32:
349  case WebAssembly::EXTRACT_EXCEPTION_I32_S:
350  // These are pseudo instructions that simulates popping values from stack.
351  // We print these only when we have -wasm-keep-registers on for assembly
352  // readability.
353  if (!WasmKeepRegisters)
354  break;
356  default: {
357  WebAssemblyMCInstLower MCInstLowering(OutContext, *this);
358  MCInst TmpInst;
359  MCInstLowering.lower(MI, TmpInst);
360  EmitToStreamer(*OutStreamer, TmpInst);
361  break;
362  }
363  }
364 }
365 
367  unsigned OpNo,
368  const char *ExtraCode,
369  raw_ostream &OS) {
370  // First try the generic code, which knows about modifiers like 'c' and 'n'.
371  if (!AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS))
372  return false;
373 
374  if (!ExtraCode) {
375  const MachineOperand &MO = MI->getOperand(OpNo);
376  switch (MO.getType()) {
378  OS << MO.getImm();
379  return false;
381  // FIXME: only opcode that still contains registers, as required by
382  // MachineInstr::getDebugVariable().
384  OS << regToString(MO);
385  return false;
387  PrintSymbolOperand(MO, OS);
388  return false;
391  printOffset(MO.getOffset(), OS);
392  return false;
394  MO.getMBB()->getSymbol()->print(OS, MAI);
395  return false;
396  default:
397  break;
398  }
399  }
400 
401  return true;
402 }
403 
405  unsigned OpNo,
406  const char *ExtraCode,
407  raw_ostream &OS) {
408  // The current approach to inline asm is that "r" constraints are expressed
409  // as local indices, rather than values on the operand stack. This simplifies
410  // using "r" as it eliminates the need to push and pop the values in a
411  // particular order, however it also makes it impossible to have an "m"
412  // constraint. So we don't support it.
413 
414  return AsmPrinter::PrintAsmMemoryOperand(MI, OpNo, ExtraCode, OS);
415 }
416 
417 // Force static initialization.
421 }
cl::opt< bool > WasmKeepRegisters
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:641
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
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...
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:232
MachineBasicBlock * getMBB() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:93
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
This class is used to lower an MachineInstr into an MCInst.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:88
virtual void emitGlobalType(const MCSymbolWasm *Sym)=0
.globaltype
This class prints an WebAssembly MCInst to wasm file syntax.
Target specific streamer interface.
Definition: MCStreamer.h:91
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:663
This file contains the declarations for metadata subclasses.
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
Definition: MCContext.h:487
This file declares the class to lower WebAssembly MachineInstrs to their corresponding MCInst records...
void EmitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
Function Alias Analysis Results
virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule)=0
.import_module
MachineBasicBlock reference.
unsigned const TargetRegisterInfo * TRI
Metadata node.
Definition: Metadata.h:863
F(f)
MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:96
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
void computeSignatureVTs(const FunctionType *Ty, const Function &F, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
Tuple of metadata.
Definition: Metadata.h:1105
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
constexpr char Language[]
Key for Kernel::Metadata::mLanguage.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
A tuple of MDNodes.
Definition: Metadata.h:1325
MVT getRegType(unsigned RegNo) const
This file registers the WebAssembly target.
std::unique_ptr< wasm::WasmSignature > signatureFromMVTs(const SmallVectorImpl< MVT > &Results, const SmallVectorImpl< MVT > &Params)
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1440
Name of external global symbol.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:410
const char * getSymbolName() const
INLINEASM - Represents an inline asm block.
Definition: ISDOpcodes.h:703
This file declares the WebAssembly-specific subclass of TargetMachine.
const SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]
std::string regToString(const MachineOperand &MO)
StringRef LanguageString(unsigned Language)
Definition: Dwarf.cpp:308
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
Definition: Module.cpp:250
Used to provide key value pairs for feature and CPU bit flags.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example, iterate over all symbols.
Definition: MCContext.h:386
bool isVerbose() const
Return true if assembly output should contain comments.
Definition: AsmPrinter.h:203
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const
Return true if the given TargetRegisterClass has the ValueType T.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
Definition: MCExpr.cpp:169
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
StringRef getString() const
Definition: Metadata.cpp:463
Address of a global value.
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:112
Machine Value Type.
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:84
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition: Module.cpp:310
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void EmitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
This represents a section on wasm.
Definition: MCSectionWasm.h:27
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:134
This file provides WebAssembly-specific target descriptions.
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:81
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn&#39;t already there.
Definition: SmallSet.h:180
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
size_t size() const
Definition: SmallVector.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void addSignature(std::unique_ptr< wasm::WasmSignature > &&Sig)
This file declares WebAssembly-specific target streamer classes.
const std::vector< MachineConstantPoolEntry > & getConstants() const
This file contains the WebAssembly implementation of the WebAssemblyRegisterInfo class.
void LLVMInitializeWebAssemblyAsmPrinter()
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:449
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
MachineOperand class - Representation of each machine instruction operand.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:235
static SectionKind getMetadata()
Definition: SectionKind.h:178
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...
std::string utostr(uint64_t X, bool isNeg=false)
Definition: StringExtras.h:223
int64_t getImm() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:163
virtual void EmitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition: AsmPrinter.h:396
void EmitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
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...
const WebAssemblyRegisterInfo * getRegisterInfo() const override
void EmitJumpTableInfo() override
Print assembly representations of the jump tables used by the current function to the current output ...
Representation of each machine instruction.
Definition: MachineInstr.h:63
virtual void emitFunctionType(const MCSymbolWasm *Sym)=0
.functype
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
virtual void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName)=0
.import_name
int64_t getOffset() const
Return the offset from the symbol in this operand.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
#define I(x, y, z)
Definition: MD5.cpp:58
This file declares WebAssembly-specific per-machine-function information.
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
Definition: Pass.cpp:128
void EmitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:332
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
uint32_t Size
Definition: Profile.cpp:46
virtual void emitEventType(const MCSymbolWasm *Sym)=0
.eventtype
unsigned getWAReg(unsigned VReg) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void valTypesFromMVTs(const ArrayRef< MVT > &In, SmallVectorImpl< wasm::ValType > &Out)
void lower(const MachineInstr *MI, MCInst &OutMI) const
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
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...
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
Definition: Register.h:69
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:273
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
A single uniqued string.
Definition: Metadata.h:603
Target & getTheWebAssemblyTarget32()
Register getReg() const
getReg - Returns the register number.
#define LLVM_DEBUG(X)
Definition: Debug.h:122
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:415
Target & getTheWebAssemblyTarget64()
WebAssemblyTargetStreamer * getTargetStreamer()
Root of the metadata hierarchy.
Definition: Metadata.h:57
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const uint64_t Version
Definition: InstrProf.h:980
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition: MCSymbol.cpp:59