31 #define DEBUG_TYPE "wasm" 35 "enable-emscripten-cxx-exceptions",
36 cl::desc(
"WebAssembly Emscripten-style exception handling"),
41 "enable-emscripten-sjlj",
42 cl::desc(
"WebAssembly Emscripten-style setjmp/longjmp handling"),
101 TT.isArch64Bit() ?
"e-m:e-p:64:64-i64:64-n32:64-S128" 102 :
"e-m:e-p:32:32-i64:64-n32:64-S128",
139 auto &
I = SubtargetMap[CPU + FS];
145 I = llvm::make_unique<WebAssemblySubtarget>(
TargetTriple, CPU, FS, *
this);
151 class StripThreadLocal final :
public ModulePass {
159 bool runOnModule(
Module &M)
override {
161 GV.setThreadLocalMode(GlobalValue::ThreadLocalMode::NotThreadLocal);
174 return getTM<WebAssemblyTargetMachine>();
177 FunctionPass *createTargetRegisterAllocator(
bool)
override;
179 void addIRPasses()
override;
180 bool addInstSelector()
override;
181 void addPostRegAlloc()
override;
182 bool addGCPasses()
override {
return false; }
183 void addPreEmitPass()
override;
194 return new WebAssemblyPassConfig(*
this, PM);
197 FunctionPass *WebAssemblyPassConfig::createTargetRegisterAllocator(
bool) {
206 void WebAssemblyPassConfig::addIRPasses() {
210 addPass(
new StripThreadLocal());
252 bool WebAssemblyPassConfig::addInstSelector() {
267 void WebAssemblyPassConfig::addPostRegAlloc() {
285 void WebAssemblyPassConfig::addPreEmitPass() {
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
FunctionPass * createWebAssemblyLowerBrUnless()
CodeModel::Model getEffectiveCodeModel(Optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value...
ModulePass * createWebAssemblyLowerEmscriptenEHSjLj(bool DoEH, bool DoSjLj)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
static cl::opt< bool > EnableEmSjLj("enable-emscripten-sjlj", cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"), cl::init(false))
This class represents lattice values for constants.
FunctionPass * createWebAssemblyCFGSort()
void initializeWebAssemblyOptimizeLiveIntervalsPass(PassRegistry &)
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
FunctionPass * createWebAssemblyArgumentMove()
A Module instance is used to store all the information related to an LLVM module. ...
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with...
unsigned DataSections
Emit data into separate sections.
void initializeWebAssemblyMemIntrinsicResultsPass(PassRegistry &)
char & FuncletLayoutID
This pass lays out funclets contiguously.
FunctionPass * createWebAssemblyPeephole()
void initializeWebAssemblyRegStackifyPass(PassRegistry &)
void initializeWebAssemblyArgumentMovePass(PassRegistry &)
void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &)
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
virtual void addPreEmitPass()
This pass may be implemented by targets that want to run passes immediately before machine code is em...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
FunctionPass * createWebAssemblyRegStackify()
FunctionPass * createWebAssemblyOptimizeReturned()
This file declares the WebAssembly-specific subclass of TargetLoweringObjectFile. ...
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
FunctionPass * createWebAssemblyRegNumbering()
FunctionPass * createWebAssemblyEHRestoreStackPointer()
FunctionPass * createLowerInvokePass()
void initializeWebAssemblyRegNumberingPass(PassRegistry &)
No attributes have been set.
void initializeWebAssemblyExceptionInfoPass(PassRegistry &)
void initializeOptimizeReturnedPass(PassRegistry &)
FunctionPass * createWebAssemblyRegColoring()
Target-Independent Code Generator Pass Configuration Options.
This file declares the WebAssembly-specific subclass of TargetMachine.
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
unsigned FunctionSections
Emit functions into separate sections.
FunctionPass * createUnreachableBlockEliminationPass()
createUnreachableBlockEliminationPass - The LLVM code generator does not work well with unreachable b...
unsigned UniqueSectionNames
ModulePass * createWebAssemblyAddMissingPrototypes()
void initializeWebAssemblyExplicitLocalsPass(PassRegistry &)
initializer< Ty > init(const Ty &Val)
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
void initializeWebAssemblyPeepholePass(PassRegistry &)
FunctionPass * createWebAssemblyISelDag(WebAssemblyTargetMachine &TM, CodeGenOpt::Level OptLevel)
This pass converts a legalized DAG into a WebAssembly-specific DAG, ready for instruction scheduling...
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
FunctionPass * createWebAssemblyCallIndirectFixup()
ModulePass * createWebAssemblyLowerGlobalDtors()
char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
This file provides WebAssembly-specific target descriptions.
void initializeWebAssemblyCallIndirectFixupPass(PassRegistry &)
virtual bool addInstSelector()
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
char & LiveDebugValuesID
LiveDebugValues pass.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &)
FunctionPass class - This class is used to implement most global optimizations.
FunctionPass * createWebAssemblySetP2AlignOperands()
void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &)
char & MachineCopyPropagationID
MachineCopyPropagation - This pass performs copy propagation on machine instructions.
static cl::opt< bool > EnableEmException("enable-emscripten-cxx-exceptions", cl::desc("WebAssembly Emscripten-style exception handling"), cl::init(false))
void initializeWebAssemblyLateEHPreparePass(PassRegistry &)
~WebAssemblyTargetMachine() override
Triple - Helper class for working with autoconf configuration names.
char & PostRASchedulerID
createPostRAScheduler - This pass performs post register allocation scheduling.
ModulePass * createWebAssemblyFixFunctionBitcasts()
void initializeWebAssemblyEHRestoreStackPointerPass(PassRegistry &)
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Pass * createLowerAtomicPass()
void initializeWebAssemblyLowerBrUnlessPass(PassRegistry &)
FunctionPass * createWebAssemblyMemIntrinsicResults()
FunctionPass * createWebAssemblyFixIrreducibleControlFlow()
Target - Wrapper for Target specific information.
virtual void addPostRegAlloc()
This method may be implemented by targets that want to run passes after register allocation pass pipe...
void initializeWebAssemblyCFGStackifyPass(PassRegistry &)
char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
StringRef getValueAsString() const
Return the attribute's value as a string.
FunctionPass * createWebAssemblyLateEHPrepare()
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Create an WebAssembly architecture model.
void LLVMInitializeWebAssemblyTarget()
void initializeWebAssemblyAddMissingPrototypesPass(PassRegistry &)
void initializeFixFunctionBitcastsPass(PassRegistry &)
FunctionPass * createWebAssemblyOptimizeLiveIntervals()
FunctionPass * createWebAssemblyCFGStackify()
void initializeWebAssemblyPrepareForLiveIntervalsPass(PassRegistry &)
void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &)
void initializeLowerGlobalDtorsPass(PassRegistry &)
FunctionPass * createWebAssemblyPrepareForLiveIntervals()
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
iterator_range< global_iterator > globals()
char & ShrinkWrapID
ShrinkWrap pass. Look for the best place to insert save and restore.
StringRef - Represent a constant reference to a string, i.e.
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
Target & getTheWebAssemblyTarget32()
const WebAssemblySubtarget * getSubtargetImpl(const Function &F) const override
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
FunctionPass * createWebAssemblyReplacePhysRegs()
void initializeWebAssemblyCFGSortPass(PassRegistry &)
FunctionPass * createAtomicExpandPass()
Target & getTheWebAssemblyTarget64()
FunctionPass * createWebAssemblyExplicitLocals()
void initializeWebAssemblyRegColoringPass(PassRegistry &)