LLVM  9.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"
20 #include "WebAssembly.h"
21 #include "WebAssemblyMCInstLower.h"
24 #include "llvm/ADT/SmallSet.h"
25 #include "llvm/ADT/StringExtras.h"
26 #include "llvm/CodeGen/Analysis.h"
31 #include "llvm/IR/DataLayout.h"
33 #include "llvm/IR/GlobalVariable.h"
34 #include "llvm/MC/MCContext.h"
35 #include "llvm/MC/MCSectionWasm.h"
36 #include "llvm/MC/MCStreamer.h"
37 #include "llvm/MC/MCSymbol.h"
38 #include "llvm/MC/MCSymbolWasm.h"
39 #include "llvm/Support/Debug.h"
42 using namespace llvm;
43 
44 #define DEBUG_TYPE "asm-printer"
45 
46 //===----------------------------------------------------------------------===//
47 // Helpers.
48 //===----------------------------------------------------------------------===//
49 
50 MVT WebAssemblyAsmPrinter::getRegType(unsigned RegNo) const {
51  const TargetRegisterInfo *TRI = Subtarget->getRegisterInfo();
52  const TargetRegisterClass *TRC = MRI->getRegClass(RegNo);
55  if (TRI->isTypeLegalForClass(*TRC, T))
56  return T;
57  LLVM_DEBUG(errs() << "Unknown type for register number: " << RegNo);
58  llvm_unreachable("Unknown register type");
59  return MVT::Other;
60 }
61 
63  unsigned RegNo = MO.getReg();
65  "Unlowered physical register encountered during assembly printing");
66  assert(!MFI->isVRegStackified(RegNo));
67  unsigned WAReg = MFI->getWAReg(RegNo);
69  return '$' + utostr(WAReg);
70 }
71 
73  MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
74  return static_cast<WebAssemblyTargetStreamer *>(TS);
75 }
76 
77 //===----------------------------------------------------------------------===//
78 // WebAssemblyAsmPrinter Implementation.
79 //===----------------------------------------------------------------------===//
80 
82  for (auto &It : OutContext.getSymbols()) {
83  // Emit a .globaltype and .eventtype declaration.
84  auto Sym = cast<MCSymbolWasm>(It.getValue());
85  if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL)
87  else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_EVENT)
89  }
90 
91  for (const auto &F : M) {
92  // Emit function type info for all undefined functions
93  if (F.isDeclarationForLinker() && !F.isIntrinsic()) {
95  SmallVector<MVT, 4> Params;
96  ComputeSignatureVTs(F.getFunctionType(), F, TM, Params, Results);
97  auto *Sym = cast<MCSymbolWasm>(getSymbol(&F));
98  Sym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
99  if (!Sym->getSignature()) {
100  auto Signature = SignatureFromMVTs(Results, Params);
101  Sym->setSignature(Signature.get());
102  addSignature(std::move(Signature));
103  }
104  // FIXME: this was originally intended for post-linking and was only used
105  // for imports that were only called indirectly (i.e. s2wasm could not
106  // infer the type from a call). With object files it applies to all
107  // imports. so fix the names and the tests, or rethink how import
108  // delcarations work in asm files.
110 
111  if (TM.getTargetTriple().isOSBinFormatWasm() &&
112  F.hasFnAttribute("wasm-import-module")) {
113  StringRef Name =
114  F.getFnAttribute("wasm-import-module").getValueAsString();
115  Sym->setModuleName(Name);
116  getTargetStreamer()->emitImportModule(Sym, Name);
117  }
118  }
119  }
120 
121  for (const auto &G : M.globals()) {
122  if (!G.hasInitializer() && G.hasExternalLinkage()) {
123  if (G.getValueType()->isSized()) {
124  uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
125  OutStreamer->emitELFSize(getSymbol(&G),
127  }
128  }
129  }
130 
131  if (const NamedMDNode *Named = M.getNamedMetadata("wasm.custom_sections")) {
132  for (const Metadata *MD : Named->operands()) {
133  const MDTuple *Tuple = dyn_cast<MDTuple>(MD);
134  if (!Tuple || Tuple->getNumOperands() != 2)
135  continue;
136  const MDString *Name = dyn_cast<MDString>(Tuple->getOperand(0));
137  const MDString *Contents = dyn_cast<MDString>(Tuple->getOperand(1));
138  if (!Name || !Contents)
139  continue;
140 
141  OutStreamer->PushSection();
142  std::string SectionName = (".custom_section." + Name->getString()).str();
143  MCSectionWasm *mySection =
145  OutStreamer->SwitchSection(mySection);
146  OutStreamer->EmitBytes(Contents->getString());
147  OutStreamer->PopSection();
148  }
149  }
150 
151  EmitProducerInfo(M);
152 }
153 
156  if (const NamedMDNode *Debug = M.getNamedMetadata("llvm.dbg.cu")) {
157  llvm::SmallSet<StringRef, 4> SeenLanguages;
158  for (size_t i = 0, e = Debug->getNumOperands(); i < e; ++i) {
159  const auto *CU = cast<DICompileUnit>(Debug->getOperand(i));
160  StringRef Language = dwarf::LanguageString(CU->getSourceLanguage());
161  Language.consume_front("DW_LANG_");
162  if (SeenLanguages.insert(Language).second)
163  Languages.emplace_back(Language.str(), "");
164  }
165  }
166 
168  if (const NamedMDNode *Ident = M.getNamedMetadata("llvm.ident")) {
170  for (size_t i = 0, e = Ident->getNumOperands(); i < e; ++i) {
171  const auto *S = cast<MDString>(Ident->getOperand(i)->getOperand(0));
172  std::pair<StringRef, StringRef> Field = S->getString().split("version");
173  StringRef Name = Field.first.trim();
174  StringRef Version = Field.second.trim();
175  if (SeenTools.insert(Name).second)
176  Tools.emplace_back(Name.str(), Version.str());
177  }
178  }
179 
180  int FieldCount = int(!Languages.empty()) + int(!Tools.empty());
181  if (FieldCount != 0) {
183  ".custom_section.producers", SectionKind::getMetadata());
184  OutStreamer->PushSection();
185  OutStreamer->SwitchSection(Producers);
186  OutStreamer->EmitULEB128IntValue(FieldCount);
187  for (auto &Producers : {std::make_pair("language", &Languages),
188  std::make_pair("processed-by", &Tools)}) {
189  if (Producers.second->empty())
190  continue;
191  OutStreamer->EmitULEB128IntValue(strlen(Producers.first));
192  OutStreamer->EmitBytes(Producers.first);
193  OutStreamer->EmitULEB128IntValue(Producers.second->size());
194  for (auto &Producer : *Producers.second) {
195  OutStreamer->EmitULEB128IntValue(Producer.first.size());
196  OutStreamer->EmitBytes(Producer.first);
197  OutStreamer->EmitULEB128IntValue(Producer.second.size());
198  OutStreamer->EmitBytes(Producer.second);
199  }
200  }
201  OutStreamer->PopSection();
202  }
203 }
204 
206  assert(MF->getConstantPool()->getConstants().empty() &&
207  "WebAssembly disables constant pools");
208 }
209 
211  // Nothing to do; jump tables are incorporated into the instruction stream.
212 }
213 
215  const Function &F = MF->getFunction();
216  SmallVector<MVT, 1> ResultVTs;
217  SmallVector<MVT, 4> ParamVTs;
218  ComputeSignatureVTs(F.getFunctionType(), F, TM, ParamVTs, ResultVTs);
219  auto Signature = SignatureFromMVTs(ResultVTs, ParamVTs);
220  auto *WasmSym = cast<MCSymbolWasm>(CurrentFnSym);
221  WasmSym->setSignature(Signature.get());
222  addSignature(std::move(Signature));
223  WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
224 
225  // FIXME: clean up how params and results are emitted (use signatures)
227 
228  // Emit the function index.
229  if (MDNode *Idx = F.getMetadata("wasm.index")) {
230  assert(Idx->getNumOperands() == 1);
231 
233  cast<ConstantAsMetadata>(Idx->getOperand(0))->getValue()));
234  }
235 
237  ValTypesFromMVTs(MFI->getLocals(), Locals);
238  getTargetStreamer()->emitLocal(Locals);
239 
241 }
242 
244  LLVM_DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
245 
246  switch (MI->getOpcode()) {
247  case WebAssembly::ARGUMENT_i32:
248  case WebAssembly::ARGUMENT_i32_S:
249  case WebAssembly::ARGUMENT_i64:
250  case WebAssembly::ARGUMENT_i64_S:
251  case WebAssembly::ARGUMENT_f32:
252  case WebAssembly::ARGUMENT_f32_S:
253  case WebAssembly::ARGUMENT_f64:
254  case WebAssembly::ARGUMENT_f64_S:
255  case WebAssembly::ARGUMENT_v16i8:
256  case WebAssembly::ARGUMENT_v16i8_S:
257  case WebAssembly::ARGUMENT_v8i16:
258  case WebAssembly::ARGUMENT_v8i16_S:
259  case WebAssembly::ARGUMENT_v4i32:
260  case WebAssembly::ARGUMENT_v4i32_S:
261  case WebAssembly::ARGUMENT_v2i64:
262  case WebAssembly::ARGUMENT_v2i64_S:
263  case WebAssembly::ARGUMENT_v4f32:
264  case WebAssembly::ARGUMENT_v4f32_S:
265  case WebAssembly::ARGUMENT_v2f64:
266  case WebAssembly::ARGUMENT_v2f64_S:
267  // These represent values which are live into the function entry, so there's
268  // no instruction to emit.
269  break;
270  case WebAssembly::FALLTHROUGH_RETURN_I32:
271  case WebAssembly::FALLTHROUGH_RETURN_I32_S:
272  case WebAssembly::FALLTHROUGH_RETURN_I64:
273  case WebAssembly::FALLTHROUGH_RETURN_I64_S:
274  case WebAssembly::FALLTHROUGH_RETURN_F32:
275  case WebAssembly::FALLTHROUGH_RETURN_F32_S:
276  case WebAssembly::FALLTHROUGH_RETURN_F64:
277  case WebAssembly::FALLTHROUGH_RETURN_F64_S:
278  case WebAssembly::FALLTHROUGH_RETURN_v16i8:
279  case WebAssembly::FALLTHROUGH_RETURN_v16i8_S:
280  case WebAssembly::FALLTHROUGH_RETURN_v8i16:
281  case WebAssembly::FALLTHROUGH_RETURN_v8i16_S:
282  case WebAssembly::FALLTHROUGH_RETURN_v4i32:
283  case WebAssembly::FALLTHROUGH_RETURN_v4i32_S:
284  case WebAssembly::FALLTHROUGH_RETURN_v2i64:
285  case WebAssembly::FALLTHROUGH_RETURN_v2i64_S:
286  case WebAssembly::FALLTHROUGH_RETURN_v4f32:
287  case WebAssembly::FALLTHROUGH_RETURN_v4f32_S:
288  case WebAssembly::FALLTHROUGH_RETURN_v2f64:
289  case WebAssembly::FALLTHROUGH_RETURN_v2f64_S: {
290  // These instructions represent the implicit return at the end of a
291  // function body. Always pops one value off the stack.
292  if (isVerbose()) {
293  OutStreamer->AddComment("fallthrough-return-value");
294  OutStreamer->AddBlankLine();
295  }
296  break;
297  }
298  case WebAssembly::FALLTHROUGH_RETURN_VOID:
299  case WebAssembly::FALLTHROUGH_RETURN_VOID_S:
300  // This instruction represents the implicit return at the end of a
301  // function body with no return value.
302  if (isVerbose()) {
303  OutStreamer->AddComment("fallthrough-return-void");
304  OutStreamer->AddBlankLine();
305  }
306  break;
307  default: {
308  WebAssemblyMCInstLower MCInstLowering(OutContext, *this);
309  MCInst TmpInst;
310  MCInstLowering.Lower(MI, TmpInst);
311  EmitToStreamer(*OutStreamer, TmpInst);
312  break;
313  }
314  }
315 }
316 
318  if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
319  if (GV->getValueType()->isFunctionTy()) {
322  }
323  return AsmPrinter::lowerConstant(CV);
324 }
325 
327  unsigned OpNo, unsigned AsmVariant,
328  const char *ExtraCode,
329  raw_ostream &OS) {
330  if (AsmVariant != 0)
331  report_fatal_error("There are no defined alternate asm variants");
332 
333  // First try the generic code, which knows about modifiers like 'c' and 'n'.
334  if (!AsmPrinter::PrintAsmOperand(MI, OpNo, AsmVariant, ExtraCode, OS))
335  return false;
336 
337  if (!ExtraCode) {
338  const MachineOperand &MO = MI->getOperand(OpNo);
339  switch (MO.getType()) {
341  OS << MO.getImm();
342  return false;
344  // FIXME: only opcode that still contains registers, as required by
345  // MachineInstr::getDebugVariable().
347  OS << regToString(MO);
348  return false;
350  getSymbol(MO.getGlobal())->print(OS, MAI);
351  printOffset(MO.getOffset(), OS);
352  return false;
355  printOffset(MO.getOffset(), OS);
356  return false;
358  MO.getMBB()->getSymbol()->print(OS, MAI);
359  return false;
360  default:
361  break;
362  }
363  }
364 
365  return true;
366 }
367 
369  unsigned OpNo,
370  unsigned AsmVariant,
371  const char *ExtraCode,
372  raw_ostream &OS) {
373  if (AsmVariant != 0)
374  report_fatal_error("There are no defined alternate asm variants");
375 
376  // The current approach to inline asm is that "r" constraints are expressed
377  // as local indices, rather than values on the operand stack. This simplifies
378  // using "r" as it eliminates the need to push and pop the values in a
379  // particular order, however it also makes it impossible to have an "m"
380  // constraint. So we don't support it.
381 
382  return AsmPrinter::PrintAsmMemoryOperand(MI, OpNo, AsmVariant, ExtraCode, OS);
383 }
384 
385 // Force static initialization.
389 }
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:218
MachineBasicBlock * getMBB() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:93
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:322
This class is used to lower an MachineInstr into an MCInst.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:139
This class represents lattice values for constants.
Definition: AllocatorList.h:23
const std::vector< MVT > & getLocals() const
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
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.
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
Target specific streamer interface.
Definition: MCStreamer.h:83
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:649
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
Definition: MCContext.h:453
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
MachineBasicBlock reference.
unsigned const TargetRegisterInfo * TRI
Metadata node.
Definition: Metadata.h:863
F(f)
MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:96
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1068
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
Tuple of metadata.
Definition: Metadata.h:1105
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
amdgpu Simplify well known AMD library false Value Value const Twine & Name
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1443
Name of external global symbol.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:408
const char * getSymbolName() const
INLINEASM - Represents an inline asm block.
Definition: ISDOpcodes.h:666
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
std::string regToString(const MachineOperand &MO)
StringRef LanguageString(unsigned Language)
Definition: Dwarf.cpp:299
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
Definition: Module.cpp:251
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
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:360
bool isVerbose() const
Return true if assembly output should contain comments.
Definition: AsmPrinter.h:202
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
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
This is an important base class in LLVM.
Definition: Constant.h:41
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
const GlobalValue * getGlobal() const
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
This file provides WebAssembly-specific target descriptions.
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:81
std::unique_ptr< wasm::WasmSignature > SignatureFromMVTs(const SmallVectorImpl< MVT > &Results, const SmallVectorImpl< MVT > &Params)
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.
const MCExpr * lowerConstant(const Constant *CV) override
Lower the specified LLVM Constant to an MCExpr.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#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
virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ModuleName)=0
.import_module
void Lower(const MachineInstr *MI, MCInst &OutMI) const
This file contains the WebAssembly implementation of the WebAssemblyRegisterInfo class.
void LLVMInitializeWebAssemblyAsmPrinter()
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:435
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:839
const DataFlowGraph & G
Definition: RDFGraph.cpp:210
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:230
static SectionKind getMetadata()
Definition: SectionKind.h:178
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
void ComputeSignatureVTs(const FunctionType *Ty, const Function &F, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
virtual void EmitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition: AsmPrinter.h:394
void EmitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
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
void emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:644
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
void ValTypesFromMVTs(const ArrayRef< MVT > &In, SmallVectorImpl< wasm::ValType > &Out)
int64_t getOffset() const
Return the offset from the symbol in this operand.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
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:123
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:322
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())
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
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()
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1074
#define LLVM_DEBUG(X)
Definition: Debug.h:122
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:413
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:894
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:163
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