41#define DEBUG_TYPE "wasm"
49 cl::desc(
"WebAssembly: output implicit locals in"
50 " instruction output for test purposes only."),
57 "enable-emscripten-sjlj",
58 cl::desc(
"WebAssembly Emscripten-style setjmp/longjmp handling"),
62 "wasm-enable-sjlj",
cl::desc(
"WebAssembly setjmp/longjmp handling"));
70 "wasm-use-legacy-eh",
cl::desc(
"WebAssembly exception handling (legacy)"),
138 "-enable-emscripten-sjlj not allowed with -wasm-enable-sjlj");
142 "-exception-model=emscripten not allowed with -wasm-enable-sjlj");
157 "-exception-model should be either 'none', 'wasm', or 'emscripten'");
160 "-wasm-enable-sjlj only allowed with -exception-model=wasm");
177 UsesMultivalueABI(
Options.MCOptions.getABIName() ==
"experimental-mv") {
208 auto &
I = SubtargetMap[CPU.str() + FS.str()];
210 I = std::make_unique<WebAssemblySubtarget>(
TargetTriple, CPU, FS, *
this);
217 Attribute CPUAttr =
F.getFnAttribute(
"target-cpu");
218 Attribute FSAttr =
F.getFnAttribute(
"target-features");
238 FunctionPass *createTargetRegisterAllocator(
bool)
override;
240 void addIRPasses()
override;
241 void addISelPrepare()
override;
242 bool addInstSelector()
override;
243 void addOptimizedRegAlloc()
override;
244 void addPostRegAlloc()
override;
245 bool addGCPasses()
override {
return false; }
246 void addPreEmitPass()
override;
247 bool addPreISel()
override;
250 bool addRegAssignAndRewriteFast()
override {
return false; }
253 bool addRegAssignAndRewriteOptimized()
override {
return false; }
255 bool addIRTranslator()
override;
256 void addPreLegalizeMachineIR()
override;
257 bool addLegalizeMachineIR()
override;
258 void addPreRegBankSelect()
override;
259 bool addRegBankSelect()
override;
260 bool addGlobalInstructionSelect()
override;
278 return new WebAssemblyPassConfig(*
this, PM);
281FunctionPass *WebAssemblyPassConfig::createTargetRegisterAllocator(
bool) {
290void WebAssemblyPassConfig::addIRPasses() {
313 if (!EnableEmEH && !EnableWasmEH) {
332 getWebAssemblyTargetMachine()));
337void WebAssemblyPassConfig::addISelPrepare() {
343 getWebAssemblyTargetMachine()));
351bool WebAssemblyPassConfig::addInstSelector() {
374void WebAssemblyPassConfig::addOptimizedRegAlloc() {
387void WebAssemblyPassConfig::addPostRegAlloc() {
410void WebAssemblyPassConfig::addPreEmitPass() {
485bool WebAssemblyPassConfig::addPreISel() {
490bool WebAssemblyPassConfig::addIRTranslator() {
495void WebAssemblyPassConfig::addPreLegalizeMachineIR() {
500bool WebAssemblyPassConfig::addLegalizeMachineIR() {
505void WebAssemblyPassConfig::addPreRegBankSelect() {
511bool WebAssemblyPassConfig::addRegBankSelect() {
516bool WebAssemblyPassConfig::addGlobalInstructionSelect() {
520 if (isGlobalISelAbortEnabled()) {
static Reloc::Model getEffectiveRelocModel()
#define LLVM_EXTERNAL_VISIBILITY
This file declares the IRTranslator pass.
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
Target-Independent Code Generator Pass Configuration Options pass.
cl::opt< bool > WasmEnableSjLj
cl::opt< bool > WasmEnableEmSjLj
cl::opt< bool > WasmDisableExplicitLocals
This file defines the interfaces that WebAssembly uses to lower LLVM code into a selection DAG.
This file provides WebAssembly-specific target descriptions.
This file declares WebAssembly-specific per-machine-function information.
This file registers the WebAssembly target.
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget()
static void basicCheckForEHAndSjLj(TargetMachine *TM)
This file declares the WebAssembly-specific subclass of TargetMachine.
This file declares the WebAssembly-specific subclass of TargetLoweringObjectFile.
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.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
CodeGenTargetMachineImpl(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
Lightweight error class with error context and mandatory checking.
FunctionPass class - This class is used to implement most global optimizations.
This pass is responsible for selecting generic machine instructions to target-specific instructions.
static void setUseExtended(bool Enable)
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Represents a range in source code.
Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
std::unique_ptr< const MCSubtargetInfo > STI
unsigned UniqueSectionNames
unsigned FunctionSections
Emit functions into separate sections.
unsigned NoTrapAfterNoreturn
Do not emit a trap instruction for 'unreachable' IR instructions behind noreturn calls,...
unsigned DataSections
Emit data into separate sections.
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
ExceptionHandling ExceptionModel
What exception model to use.
Target-Independent Code Generator Pass Configuration Options.
virtual void addPostRegAlloc()
This method may be implemented by targets that want to run passes after register allocation pass pipe...
virtual bool addInstSelector()
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
virtual bool addPreISel()
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
virtual void addOptimizedRegAlloc()
addOptimizedRegAlloc - Add passes related to register allocation.
virtual void addPreEmitPass()
This pass may be implemented by targets that want to run passes immediately before machine code is em...
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
virtual void addISelPrepare()
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
TargetSubtargetInfo - Generic base class for all target subtargets.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
Create an WebAssembly architecture model.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
const WebAssemblySubtarget * getSubtargetImpl(StringRef CPU, StringRef FS) const
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
~WebAssemblyTargetMachine() override
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
cl::opt< bool > WasmEnableSjLj
cl::opt< bool > WasmEnableEmSjLj
cl::opt< bool > WasmDisableExplicitLocals
cl::opt< bool > WasmUseLegacyEH
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI ModulePass * createLowerGlobalDtorsLegacyPass()
LLVM_ABI FunctionPass * createIndirectBrExpandPass()
FunctionPass * createWebAssemblyExplicitLocalsLegacyPass()
FunctionPass * createWebAssemblyCleanCodeAfterTrapLegacyPass()
ModulePass * createWebAssemblyMCLowerPreLegacyPass()
void initializeWebAssemblySetP2AlignOperandsLegacyPass(PassRegistry &)
void initializeWebAssemblyRegStackifyLegacyPass(PassRegistry &)
LLVM_ABI char & RegisterCoalescerID
RegisterCoalescer - This pass merges live ranges to eliminate copies.
void initializeWebAssemblyPeepholeLegacyPass(PassRegistry &)
LLVM_ABI char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
LLVM_ABI char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
LLVM_ABI char & RemoveLoadsIntoFakeUsesID
RemoveLoadsIntoFakeUses pass.
void initializeWebAssemblyExceptionInfoWrapperPassPass(PassRegistry &)
FunctionPass * createWebAssemblyPreLegalizerCombinerLegacyPass()
FunctionPass * createWebAssemblyRegNumberingLegacyPass()
void initializeWebAssemblyDAGToDAGISelLegacyPass(PassRegistry &)
FunctionPass * createWebAssemblySetP2AlignOperandsLegacyPass()
void initializeWebAssemblyPreLegalizerCombinerLegacyPass(PassRegistry &)
void initializeWebAssemblyMemIntrinsicResultsLegacyPass(PassRegistry &)
void initializeWebAssemblyRegNumberingLegacyPass(PassRegistry &)
void initializeWebAssemblyLateEHPrepareLegacyPass(PassRegistry &)
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
void initializeWebAssemblyNullifyDebugValueListsLegacyPass(PassRegistry &)
FunctionPass * createWebAssemblyArgumentMoveLegacyPass()
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
LLVM_ABI char & ShrinkWrapID
ShrinkWrap pass. Look for the best place to insert save and restore.
LLVM_ABI char & MachineLateInstrsCleanupID
MachineLateInstrsCleanup - This pass removes redundant identical instructions after register allocati...
void initializeWebAssemblyRefTypeMem2LocalLegacyPass(PassRegistry &)
LLVM_ABI char & UnreachableMachineBlockElimID
UnreachableMachineBlockElimination - This pass removes unreachable machine basic blocks.
LLVM_ABI FunctionPass * createLowerInvokePass()
void initializeWebAssemblyFixFunctionBitcastsLegacyPass(PassRegistry &)
ModulePass * createWebAssemblyLowerEmscriptenEHSjLjLegacyPass(bool EnableEmEH)
void initializeWebAssemblyLowerBrUnlessLegacyPass(PassRegistry &)
Target & getTheWebAssemblyTarget32()
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
LLVM_ABI void initializeLowerGlobalDtorsLegacyPassPass(PassRegistry &)
FunctionPass * createWebAssemblyReduceToAnyAllTrueLegacyPass(WebAssemblyTargetMachine &TM)
FunctionPass * createWebAssemblyRegColoringLegacyPass()
LLVM_ABI char & FuncletLayoutID
This pass lays out funclets contiguously.
FunctionPass * createWebAssemblyPostLegalizerCombinerLegacyPass()
FunctionPass * createWebAssemblyFixIrreducibleControlFlowLegacyPass()
LLVM_ABI char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
void initializeWebAssemblyPostLegalizerCombinerLegacyPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
ModulePass * createWebAssemblyCoalesceFeaturesAndStripAtomicsLegacyPass(WebAssemblyTargetMachine &TM)
FunctionPass * createWebAssemblyRefTypeMem2LocalLegacyPass()
void initializeWebAssemblyArgumentMoveLegacyPass(PassRegistry &)
void initializeWebAssemblyOptimizeReturnedLegacyPass(PassRegistry &)
void initializeWebAssemblyExplicitLocalsLegacyPass(PassRegistry &)
ModulePass * createWebAssemblyFixFunctionBitcastsLegacyPass()
FunctionPass * createWebAssemblyPeepholeLegacyPass()
LLVM_ABI void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
FunctionPass * createWebAssemblyMemIntrinsicResultsLegacyPass()
void initializeWebAssemblyLowerEmscriptenEHSjLjLegacyPass(PassRegistry &)
Target & getTheWebAssemblyTarget64()
FunctionPass * createWebAssemblyOptimizeReturnedLegacyPass()
void initializeWebAssemblyFixBrTableDefaultsLegacyPass(PassRegistry &)
void initializeWebAssemblyAddMissingPrototypesLegacyPass(PassRegistry &)
@ Emscripten
Emscripten JavaScript-based exception handling.
@ None
No exception support.
@ Default
Not specified; resolve to the target's default model.
@ Wasm
WebAssembly Exception Handling.
void initializeWebAssemblyCFGSortLegacyPass(PassRegistry &)
FunctionPass * createWebAssemblyDebugFixupLegacyPass()
FunctionPass * createWebAssemblyFixBrTableDefaultsLegacyPass()
FunctionPass * createWebAssemblyISelDagLegacyPass(WebAssemblyTargetMachine &TM, CodeGenOptLevel OptLevel)
FunctionPass * createWebAssemblyNullifyDebugValueListsLegacyPass()
FunctionPass * createWebAssemblyCFGStackifyLegacyPass()
void initializeWebAssemblyRegColoringLegacyPass(PassRegistry &)
FunctionPass * createWebAssemblyRegStackifyLegacyPass(CodeGenOptLevel OptLevel)
FunctionPass * createWebAssemblyOptimizeLiveIntervalsLegacyPass()
void initializeWebAssemblyFixIrreducibleControlFlowLegacyPass(PassRegistry &)
FunctionPass * createWebAssemblyLowerBrUnlessLegacyPass()
LLVM_ABI char & MachineBlockPlacementID
MachineBlockPlacement - This pass places basic blocks based on branch probabilities.
ModulePass * createWebAssemblyAddMissingPrototypesLegacyPass()
LLVM_ABI FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
FunctionPass * createWebAssemblyReplacePhysRegsLegacyPass()
void initializeWebAssemblyCFGStackifyLegacyPass(PassRegistry &)
void initializeWebAssemblyOptimizeLiveIntervalsLegacyPass(PassRegistry &)
FunctionPass * createWebAssemblyCFGSortLegacyPass()
void initializeWebAssemblyMCLowerPreLegacyPass(PassRegistry &)
void initializeWebAssemblyAsmPrinterPass(PassRegistry &)
void initializeWebAssemblyReplacePhysRegsLegacyPass(PassRegistry &)
LLVM_ABI char & MachineCopyPropagationID
MachineCopyPropagation - This pass performs copy propagation on machine instructions.
FunctionPass * createWebAssemblyLateEHPrepareLegacyPass()
void initializeWebAssemblyDebugFixupLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createUnreachableBlockEliminationPass()
createUnreachableBlockEliminationPass - The LLVM code generator does not work well with unreachable b...
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static FuncInfoTy * create(BumpPtrAllocator &Allocator, const Function &F, const SubtargetTy *STI)
Factory function: default behavior is to call new using the supplied allocator.
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.