1//===-- WebAssemblyAsmPrinter.cpp - WebAssembly LLVM assembly writer ------===//
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
7//===----------------------------------------------------------------------===//
10/// This file contains a printer that converts from our internal
11/// representation of machine-dependent LLVM code to the WebAssembly assembly
14//===----------------------------------------------------------------------===//
56 #define DEBUG_TYPE "asm-printer"
60//===----------------------------------------------------------------------===//
62//===----------------------------------------------------------------------===//
67 for (
MVT T : {MVT::i32, MVT::i64, MVT::f32, MVT::f64, MVT::v16i8, MVT::v8i16,
68 MVT::v4i32, MVT::v2i64, MVT::v4f32, MVT::v2f64, MVT::v8f16})
69 if (
TRI->isTypeLegalForClass(*TRC,
T))
71 LLVM_DEBUG(
errs() <<
"Unknown type for register number: " << RegNo);
79 "Unlowered physical register encountered during assembly printing");
80 assert(!MFI->isVRegStackified(RegNo));
81 unsigned WAReg = MFI->getWAReg(RegNo);
83 return '$' +
utostr(WAReg);
91// Emscripten exception handling helpers
93// This converts invoke names generated by LowerEmscriptenEHSjLj to real names
94// that are expected by JavaScript glue code. The invoke names generated by
95// Emscripten JS glue code are based on their argument and return types; for
96// example, for a function that takes an i32 and returns nothing, it is
97// 'invoke_vi'. But the format of invoke generated by LowerEmscriptenEHSjLj pass
98// contains a mangled string generated from their IR types, for example,
99// "__invoke_void_%struct.mystruct*_int", because final wasm types are not
100// available in the IR pass. So we convert those names to the form that
101// Emscripten JS code expects.
103// Refer to LowerEmscriptenEHSjLj pass for more details.
105// Returns true if the given function name is an invoke name generated by
106// LowerEmscriptenEHSjLj pass.
108 if (Name.front() ==
'"' && Name.back() ==
'"')
109 Name = Name.substr(1, Name.size() - 2);
110 return Name.starts_with(
"__invoke_");
113// Returns a character that represents the given wasm value type in invoke
138// Given the wasm signature, generate the invoke name in the format JS glue code
142 std::string Ret =
"invoke_";
148 // Invokes' first argument is a pointer to the original function, so skip it
154//===----------------------------------------------------------------------===//
155// WebAssemblyAsmPrinter Implementation.
156//===----------------------------------------------------------------------===//
162 const bool EnableEmEH =
166 InvokeDetected =
true;
169 "Emscripten EH/SjLj does not support multivalue returns: " +
170 std::string(
F->getName()) +
": " +
190 if (!Sym->getType()) {
194 // Subtarget is only set when a function is defined, because
195 // each function can declare a different subtarget. For example,
196 // on ARM a compilation unit might have a function on ARM and
197 // another on Thumb. Therefore only if Subtarget is non-null we
198 // can actually calculate the legal VTs.
212 // TODO: Actually emit the initializer value. Otherwise the global has the
213 // default value for its type (0, ref.null, etc).
220 // May be called multiple times, so early out.
221 if (WasmSym->getType())
226 // Except for certain known symbols, all symbols used by CodeGen are
227 // functions. It's OK to hardcode knowledge of specific symbols here; this
228 // method is precisely there for fetching the signatures of known
229 // Clang-provided symbols.
230 if (Name ==
"__stack_pointer" || Name ==
"__tls_base" ||
231 Name ==
"__memory_base" || Name ==
"__table_base" ||
232 Name ==
"__tls_size" || Name ==
"__tls_align") {
234 Name ==
"__stack_pointer" || Name ==
"__tls_base";
243 if (Name.starts_with(
"GCC_except_table")) {
250 if (Name ==
"__cpp_exception" || Name ==
"__c_longjmp") {
252 WasmSym->setExternal(
true);
254 // Currently both C++ exceptions and C longjmps have a single pointer type
255 // param. For C++ exceptions it is a pointer to an exception object, and for
256 // C longjmps it is pointer to a struct that contains a setjmp buffer and a
257 // longjmp return value. We may consider using multiple value parameters for
258 // longjmps later when multivalue support is ready.
262 }
else {
// Function symbols
266 auto Signature =
OutContext.createWasmSignature();
267 Signature->Returns = std::move(Returns);
268 Signature->Params = std::move(Params);
269 WasmSym->setSignature(Signature);
275 std::optional<wasm::WasmSymbolType> WasmTy = Sym->
getType();
290 break;
// We only handle globals, tags and tables here
295 if (signaturesEmitted)
297 signaturesEmitted =
true;
299 // Normally symbols for globals get discovered as the MI gets lowered,
300 // but we need to know about them ahead of time. This will however,
301 // only find symbols that have been used. Unused symbols from globals will
302 // not be found here.
306 if (WasmSym->isFunction()) {
307 // TODO(wvo): is there any case where this overlaps with the call to
308 // emitFunctionType in the loop below?
314 // Emit .globaltype, .tagtype, or .tabletype declarations for extern
315 // declarations, i.e. those that have only been declared (but not defined)
316 // in the current module
317 auto Sym =
static_cast<MCSymbolWasm *
>(It.getValue().Symbol);
318 if (Sym && !Sym->isDefined())
323 for (
const auto &
F : M) {
327 // Emit function type info for all functions. This will emit duplicate
328 // information for defined functions (which already have function type
329 // info emitted alongside their definition), but this is necessary in
330 // order to enable the single-pass WebAssemblyAsmTypeCheck to succeed.
334 // At this point these MCSymbols may or may not have been created already
335 // and thus also contain a signature, but we need to get the signature
336 // anyway here in case it is an invoke that has not yet been created. We
337 // will discard it later if it turns out not to be necessary.
339 bool InvokeDetected =
false;
342 // Multiple functions can be mapped to the same invoke symbol. For
343 // example, two IR functions '__invoke_void_i8*' and '__invoke_void_i32'
344 // are both mapped to '__invoke_vi'. We keep them in a set once we emit an
345 // Emscripten EH symbol so we don't emit the same symbol twice.
346 if (InvokeDetected && !InvokeSymbols.
insert(Sym).second)
350 if (!Sym->getSignature()) {
351 Sym->setSignature(Signature);
356 if (
F.hasFnAttribute(
"wasm-import-module")) {
358 F.getFnAttribute(
"wasm-import-module").getValueAsString();
359 Sym->setImportModule(
OutContext.allocateString(Name));
362 if (
F.hasFnAttribute(
"wasm-import-name")) {
363 // If this is a converted Emscripten EH/SjLj symbol, we shouldn't use
364 // the original function name but the converted symbol name.
368 :
F.getFnAttribute(
"wasm-import-name").getValueAsString();
369 Sym->setImportName(
OutContext.allocateString(Name));
373 if (
F.hasFnAttribute(
"wasm-export-name")) {
375 StringRef Name =
F.getFnAttribute(
"wasm-export-name").getValueAsString();
376 Sym->setExportName(
OutContext.allocateString(Name));
383 // This is required to emit external declarations (like .functypes) when
384 // no functions are defined in the compilation unit and therefore,
385 // emitDecls() is not called until now.
388 // When a function's address is taken, a TABLE_INDEX relocation is emitted
389 // against the function symbol at the use site. However the relocation
390 // doesn't explicitly refer to the table. In the future we may want to
391 // define a new kind of reloc against both the function and the table, so
392 // that the linker can see that the function symbol keeps the table alive,
393 // but for now manually mark the table as live.
394 for (
const auto &
F : M) {
395 if (!
F.isIntrinsic() &&
F.hasAddressTaken()) {
403 for (
const auto &
G : M.globals()) {
404 if (!
G.hasInitializer() &&
G.hasExternalLinkage() &&
406 G.getValueType()->isSized()) {
407 uint16_t Size = M.getDataLayout().getTypeAllocSize(
G.getValueType());
413 if (
const NamedMDNode *Named = M.getNamedMetadata(
"wasm.custom_sections")) {
414 for (
const Metadata *MD : Named->operands()) {
416 if (!Tuple || Tuple->getNumOperands() != 2)
420 if (!Name || !Contents)
424 std::string
SectionName = (
".custom_section." + Name->getString()).str();
442 for (
size_t I = 0, E =
Debug->getNumOperands();
I < E; ++
I) {
447 Language.consume_front(
"DW_LANG_");
448 if (SeenLanguages.
insert(Language).second)
454 if (
const NamedMDNode *Ident = M.getNamedMetadata(
"llvm.ident")) {
456 for (
size_t I = 0, E = Ident->getNumOperands();
I < E; ++
I) {
458 std::pair<StringRef, StringRef>
Field = S->getString().split(
"version");
461 if (SeenTools.
insert(Name).second)
466 int FieldCount = int(!Languages.
empty()) + int(!Tools.
empty());
467 if (FieldCount != 0) {
473 for (
auto &Producers : {std::make_pair(
"language", &Languages),
474 std::make_pair(
"processed-by", &Tools)}) {
475 if (Producers.second->empty())
477 OutStreamer->emitULEB128IntValue(strlen(Producers.first));
479 OutStreamer->emitULEB128IntValue(Producers.second->size());
480 for (
auto &Producer : *Producers.second) {
481 OutStreamer->emitULEB128IntValue(Producer.first.size());
483 OutStreamer->emitULEB128IntValue(Producer.second.size());
492 struct FeatureEntry {
497 // Read target features and linkage policies from module metadata
499 auto EmitFeature = [&](std::string Feature) {
500 std::string MDKey = (
StringRef(
"wasm-feature-") + Feature).str();
501 Metadata *Policy = M.getModuleFlag(MDKey);
502 if (Policy ==
nullptr)
507 Entry.Name = Feature;
511 Entry.Prefix =
I->getZExtValue();
513 // Silently ignore invalid metadata
524 // This pseudo-feature tells the linker whether shared memory would be safe
525 EmitFeature(
"shared-mem");
527 // This is an "architecture", not a "feature", but we emit it as such for
528 // the benefit of tools like Binaryen and consistency with other producers.
529 // FIXME: Subtarget is null here, so can't Subtarget->hasAddr64() ?
530 if (M.getDataLayout().getPointerSize() == 8) {
531 // Can't use EmitFeature since "wasm-feature-memory64" is not a module
536 if (EmittedFeatures.
size() == 0)
539 // Emit features and linkage policies into the "target_features" section
546 for (
auto &
F : EmittedFeatures) {
556 auto V = M.getNamedGlobal(
"llvm.global.annotations");
560 // Group all the custom attributes by name.
565 // The first field is a pointer to the annotated variable.
567 // Only annotated functions are supported for now.
572 // The second field is a pointer to a global annotation string.
577 CustomSections[AnnotationString].push_back(Sym);
580 // Emit a custom section for each unique attribute.
581 for (
const auto &[Name, Symbols] : CustomSections) {
587 for (
auto &Sym : Symbols) {
598 assert(
MF->getConstantPool()->getConstants().empty() &&
599 "WebAssembly disables constant pools");
603 // Nothing to do; jump tables are incorporated into the instruction stream.
619 // Emit the function index.
620 if (
MDNode *Idx =
F.getMetadata(
"wasm.index")) {
621 assert(Idx->getNumOperands() == 1);
636 WebAssembly_MC::verifyInstructionPredicates(
MI->getOpcode(),
637 Subtarget->getFeatureBits());
639 switch (
MI->getOpcode()) {
640 case WebAssembly::ARGUMENT_i32:
641 case WebAssembly::ARGUMENT_i32_S:
642 case WebAssembly::ARGUMENT_i64:
643 case WebAssembly::ARGUMENT_i64_S:
644 case WebAssembly::ARGUMENT_f32:
645 case WebAssembly::ARGUMENT_f32_S:
646 case WebAssembly::ARGUMENT_f64:
647 case WebAssembly::ARGUMENT_f64_S:
648 case WebAssembly::ARGUMENT_v16i8:
649 case WebAssembly::ARGUMENT_v16i8_S:
650 case WebAssembly::ARGUMENT_v8i16:
651 case WebAssembly::ARGUMENT_v8i16_S:
652 case WebAssembly::ARGUMENT_v4i32:
653 case WebAssembly::ARGUMENT_v4i32_S:
654 case WebAssembly::ARGUMENT_v2i64:
655 case WebAssembly::ARGUMENT_v2i64_S:
656 case WebAssembly::ARGUMENT_v4f32:
657 case WebAssembly::ARGUMENT_v4f32_S:
658 case WebAssembly::ARGUMENT_v2f64:
659 case WebAssembly::ARGUMENT_v2f64_S:
660 case WebAssembly::ARGUMENT_v8f16:
661 case WebAssembly::ARGUMENT_v8f16_S:
662 // These represent values which are live into the function entry, so there's
663 // no instruction to emit.
665 case WebAssembly::FALLTHROUGH_RETURN: {
666 // These instructions represent the implicit return at the end of a
674 case WebAssembly::COMPILER_FENCE:
675 // This is a compiler barrier that prevents instruction reordering during
676 // backend compilation, and should not be emitted.
678 case WebAssembly::CATCH:
679 case WebAssembly::CATCH_S:
680 case WebAssembly::CATCH_REF:
681 case WebAssembly::CATCH_REF_S:
682 case WebAssembly::CATCH_ALL:
683 case WebAssembly::CATCH_ALL_S:
684 case WebAssembly::CATCH_ALL_REF:
685 case WebAssembly::CATCH_ALL_REF_S:
686 // These are pseudo instructions to represent catch clauses in try_table
687 // instruction to simulate block return values.
692 MCInstLowering.
lower(
MI, TmpInst);
701 const char *ExtraCode,
703 // First try the generic code, which knows about modifiers like 'c' and 'n'.
714 // FIXME: only opcode that still contains registers, as required by
715 // MachineInstr::getDebugVariable().
716 assert(
MI->getOpcode() == WebAssembly::INLINEASM);
739 const char *ExtraCode,
741 // The current approach to inline asm is that "r" constraints are expressed
742 // as local indices, rather than values on the operand stack. This simplifies
743 // using "r" as it eliminates the need to push and pop the values in a
744 // particular order, however it also makes it impossible to have an "m"
745 // constraint. So we don't support it.
753 "WebAssembly Assmebly Printer",
false,
false)
755// Force static initialization.
757LLVMInitializeWebAssemblyAsmPrinter() {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Function Alias Analysis Results
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
Module.h This file contains the declarations for the Module class.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Register const TargetRegisterInfo * TRI
This file implements a map that provides insertion order iteration.
OptimizedStructLayoutField Field
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallSet class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
static std::string getEmscriptenInvokeSymbolName(wasm::WasmSignature *Sig)
static bool isEmscriptenInvokeName(StringRef Name)
static char getInvokeSig(wasm::ValType VT)
cl::opt< bool > WasmKeepRegisters
This file contains the declaration of the WebAssemblyMCAsmInfo class.
This file declares the class to lower WebAssembly MachineInstrs to their corresponding MCInst records...
This file provides WebAssembly-specific target descriptions.
This file declares WebAssembly-specific per-machine-function information.
This file contains the WebAssembly implementation of the WebAssemblyRegisterInfo class.
This file provides signature information for runtime libcalls.
This file registers the WebAssembly target.
This file declares the WebAssembly-specific subclass of TargetMachine.
This file declares WebAssembly-specific target streamer classes.
This file contains the declaration of the WebAssembly-specific type parsing utility functions.
This file contains the declaration of the WebAssembly-specific utility functions.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
MCSymbol * getSymbol(const GlobalValue *GV) const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
virtual void emitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
TargetMachine & TM
Target machine description.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
const MCAsmInfo * MAI
Target Asm Printer information.
MachineFunction * MF
The current machine function.
virtual const MCExpr * lowerConstant(const Constant *CV, const Constant *BaseCV=nullptr, uint64_t Offset=0)
Lower the specified LLVM Constant to an MCExpr.
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
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.
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
MCSymbol * CurrentFnSym
The symbol for the current function.
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
MCContext & OutContext
This is the context for the output file that we are streaming.
void emitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
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...
bool isVerbose() const
Return true if assembly output should contain comments.
MCSymbol * GetExternalSymbolSymbol(const Twine &Sym) const
Return the MCSymbol for the specified ExternalSymbol.
@ Debug
Emit .debug_frame.
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.
ConstantArray - Constant Array Declarations.
Implements a dense probed hash-table based set.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
VisibilityTypes getVisibility() const
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
unsigned getAddressSpace() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
Type * getValueType() const
bool hasInitializer() const
Definitions have initializers, declarations don't.
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Instances of this class represent a single low-level machine instruction.
This represents a section on wasm.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
void setSignature(wasm::WasmSignature *Sig)
std::optional< wasm::WasmSymbolType > getType() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Target specific streamer interface.
LLVM_ABI StringRef getString() const
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Representation of each machine instruction.
MachineModuleInfoWasm - This is a MachineModuleInfoImpl implementation for Wasm targets.
SetVector< StringRef > MachineSymbolsUsed
MachineOperand class - Representation of each machine instruction operand.
MachineBasicBlock * getMBB() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_GlobalAddress
Address of a global value.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
int64_t getOffset() const
Return the offset from the symbol in this operand.
This class implements a map that also provides access to all stored values in a deterministic order.
A Module instance is used to store all the information related to an LLVM module.
LLVMContext & getContext() const
Get the global data context.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static SectionKind getMetadata()
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
void emitJumpTableInfo() override
Print assembly representations of the jump tables used by the current function to the current output ...
void EmitProducerInfo(Module &M)
void emitGlobalVariable(const GlobalVariable *GV) override
Emit the specified global variable to the .s file.
void EmitTargetFeatures(Module &M)
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...
const WebAssemblySubtarget & getSubtarget() const
WebAssemblyTargetStreamer * getTargetStreamer()
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
std::string regToString(const MachineOperand &MO)
void emitSymbolType(const MCSymbolWasm *Sym)
MCSymbol * getOrCreateWasmSymbol(StringRef Name)
void emitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
MVT getRegType(unsigned RegNo) const
void emitDecls(const Module &M)
void emitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
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.
void EmitFunctionAttributes(Module &M)
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
MCSymbolWasm * getMCSymbolForFunction(const Function *F, wasm::WasmSignature *Sig, bool &InvokeDetected)
This class is used to lower an MachineInstr into an MCInst.
void lower(const MachineInstr *MI, MCInst &OutMI) const
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
virtual void emitFunctionType(const MCSymbolWasm *Sym)=0
.functype
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
virtual void emitTagType(const MCSymbolWasm *Sym)=0
.tagtype
virtual void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName)=0
.export_name
virtual void emitGlobalType(const MCSymbolWasm *Sym)=0
.globaltype
virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule)=0
.import_module
virtual void emitTableType(const MCSymbolWasm *Sym)=0
.tabletype
virtual void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName)=0
.import_name
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx
std::pair< iterator, bool > insert(const ValueT &V)
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI StringRef LanguageString(unsigned Language)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MCSymbolWasm * getOrCreateFunctionTableSymbol(MCContext &Ctx, const WebAssemblySubtarget *Subtarget)
Returns the __indirect_function_table, for use in call_indirect and in function bitcasts.
void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT, ArrayRef< MVT > VTs)
Sets a Wasm Symbol Type.
static const unsigned UnusedReg
cl::opt< bool > WasmEnableEmEH
cl::opt< bool > WasmEnableEmSjLj
std::string signatureToString(const wasm::WasmSignature *Sig)
void getLibcallSignature(const WebAssemblySubtarget &Subtarget, RTLIB::Libcall LC, SmallVectorImpl< wasm::ValType > &Rets, SmallVectorImpl< wasm::ValType > &Params)
bool isWasmVarAddressSpace(unsigned AS)
@ WASM_FEATURE_PREFIX_USED
@ WASM_FEATURE_PREFIX_DISALLOWED
@ WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_FUNCTION
This is an optimization pass for GlobalISel generic memory operations.
void computeSignatureVTs(const FunctionType *Ty, const Function *TargetFunc, const Function &ContextFunc, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
const SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool getConstantStringInfo(const Value *V, StringRef &Str, bool TrimAtNul=true)
This function computes the length of a null-terminated C string pointed to by V.
std::string utostr(uint64_t X, bool isNeg=false)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target & getTheWebAssemblyTarget32()
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Target & getTheWebAssemblyTarget64()
DWARFExpression::Operation Op
void valTypesFromMVTs(ArrayRef< MVT > In, SmallVectorImpl< wasm::ValType > &Out)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
wasm::WasmSignature * signatureFromMVTs(MCContext &Ctx, const SmallVectorImpl< MVT > &Results, const SmallVectorImpl< MVT > &Params)
void computeLegalValueVTs(const WebAssemblyTargetLowering &TLI, LLVMContext &Ctx, const DataLayout &DL, Type *Ty, SmallVectorImpl< MVT > &ValueVTs)
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Used to provide key value pairs for feature and CPU bit flags.
SmallVector< ValType, 1 > Returns
SmallVector< ValType, 4 > Params