LLVM  12.0.0git
WebAssemblyTargetMachine.cpp
Go to the documentation of this file.
1 //===- WebAssemblyTargetMachine.cpp - Define TargetMachine for WebAssembly -==//
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 defines the WebAssembly-specific subclass of TargetMachine.
11 ///
12 //===----------------------------------------------------------------------===//
13 
17 #include "WebAssembly.h"
23 #include "llvm/CodeGen/Passes.h"
26 #include "llvm/IR/Function.h"
29 #include "llvm/Transforms/Scalar.h"
31 #include "llvm/Transforms/Utils.h"
32 using namespace llvm;
33 
34 #define DEBUG_TYPE "wasm"
35 
36 // Emscripten's asm.js-style exception handling
38  "enable-emscripten-cxx-exceptions",
39  cl::desc("WebAssembly Emscripten-style exception handling"),
40  cl::init(false));
41 
42 // Emscripten's asm.js-style setjmp/longjmp handling
44  "enable-emscripten-sjlj",
45  cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"),
46  cl::init(false));
47 
48 // A command-line option to keep implicit locals
49 // for the purpose of testing with lit/llc ONLY.
50 // This produces output which is not valid WebAssembly, and is not supported
51 // by assemblers/disassemblers and other MC based tools.
53  "wasm-disable-explicit-locals", cl::Hidden,
54  cl::desc("WebAssembly: output implicit locals in"
55  " instruction output for test purposes only."),
56  cl::init(false));
57 
59  // Register the target.
64 
65  // Register backend passes
66  auto &PR = *PassRegistry::getPassRegistry();
90 }
91 
92 //===----------------------------------------------------------------------===//
93 // WebAssembly Lowering public interface.
94 //===----------------------------------------------------------------------===//
95 
97  const Triple &TT) {
98  if (!RM.hasValue()) {
99  // Default to static relocation model. This should always be more optimial
100  // than PIC since the static linker can determine all global addresses and
101  // assume direct function calls.
102  return Reloc::Static;
103  }
104 
105  if (!TT.isOSEmscripten()) {
106  // Relocation modes other than static are currently implemented in a way
107  // that only works for Emscripten, so disable them if we aren't targeting
108  // Emscripten.
109  return Reloc::Static;
110  }
111 
112  return *RM;
113 }
114 
115 /// Create an WebAssembly architecture model.
116 ///
118  const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
119  const TargetOptions &Options, Optional<Reloc::Model> RM,
122  TT.isArch64Bit() ? "e-m:e-p:64:64-i64:64-n32:64-S128"
123  : "e-m:e-p:32:32-i64:64-n32:64-S128",
124  TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT),
125  getEffectiveCodeModel(CM, CodeModel::Large), OL),
126  TLOF(new WebAssemblyTargetObjectFile()) {
127  // WebAssembly type-checks instructions, but a noreturn function with a return
128  // type that doesn't match the context will cause a check failure. So we lower
129  // LLVM 'unreachable' to ISD::TRAP and then lower that to WebAssembly's
130  // 'unreachable' instructions which is meant for that case.
131  this->Options.TrapUnreachable = true;
132 
133  // WebAssembly treats each function as an independent unit. Force
134  // -ffunction-sections, effectively, so that we can emit them independently.
135  this->Options.FunctionSections = true;
136  this->Options.DataSections = true;
137  this->Options.UniqueSectionNames = true;
138 
139  initAsmInfo();
140 
141  // Note that we don't use setRequiresStructuredCFG(true). It disables
142  // optimizations than we're ok with, and want, such as critical edge
143  // splitting and tail merging.
144 }
145 
147 
149  return getSubtargetImpl(std::string(getTargetCPU()),
150  std::string(getTargetFeatureString()));
151 }
152 
153 const WebAssemblySubtarget *
155  std::string FS) const {
156  auto &I = SubtargetMap[CPU + FS];
157  if (!I) {
158  I = std::make_unique<WebAssemblySubtarget>(TargetTriple, CPU, FS, *this);
159  }
160  return I.get();
161 }
162 
163 const WebAssemblySubtarget *
165  Attribute CPUAttr = F.getFnAttribute("target-cpu");
166  Attribute FSAttr = F.getFnAttribute("target-features");
167 
168  std::string CPU =
169  CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
170  std::string FS =
171  FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
172 
173  // This needs to be done before we create a new subtarget since any
174  // creation will depend on the TM and the code generation flags on the
175  // function that reside in TargetOptions.
177 
178  return getSubtargetImpl(CPU, FS);
179 }
180 
181 namespace {
182 
183 class CoalesceFeaturesAndStripAtomics final : public ModulePass {
184  // Take the union of all features used in the module and use it for each
185  // function individually, since having multiple feature sets in one module
186  // currently does not make sense for WebAssembly. If atomics are not enabled,
187  // also strip atomic operations and thread local storage.
188  static char ID;
189  WebAssemblyTargetMachine *WasmTM;
190 
191 public:
192  CoalesceFeaturesAndStripAtomics(WebAssemblyTargetMachine *WasmTM)
193  : ModulePass(ID), WasmTM(WasmTM) {}
194 
195  bool runOnModule(Module &M) override {
196  FeatureBitset Features = coalesceFeatures(M);
197 
198  std::string FeatureStr = getFeatureString(Features);
199  WasmTM->setTargetFeatureString(FeatureStr);
200  for (auto &F : M)
201  replaceFeatures(F, FeatureStr);
202 
203  bool StrippedAtomics = false;
204  bool StrippedTLS = false;
205 
206  if (!Features[WebAssembly::FeatureAtomics])
207  StrippedAtomics = stripAtomics(M);
208 
209  if (!Features[WebAssembly::FeatureBulkMemory])
210  StrippedTLS = stripThreadLocals(M);
211 
212  if (StrippedAtomics && !StrippedTLS)
213  stripThreadLocals(M);
214  else if (StrippedTLS && !StrippedAtomics)
215  stripAtomics(M);
216 
217  recordFeatures(M, Features, StrippedAtomics || StrippedTLS);
218 
219  // Conservatively assume we have made some change
220  return true;
221  }
222 
223 private:
224  FeatureBitset coalesceFeatures(const Module &M) {
225  FeatureBitset Features =
226  WasmTM
227  ->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
228  std::string(WasmTM->getTargetFeatureString()))
229  ->getFeatureBits();
230  for (auto &F : M)
231  Features |= WasmTM->getSubtargetImpl(F)->getFeatureBits();
232  return Features;
233  }
234 
235  std::string getFeatureString(const FeatureBitset &Features) {
236  std::string Ret;
237  for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
238  if (Features[KV.Value])
239  Ret += (StringRef("+") + KV.Key + ",").str();
240  }
241  return Ret;
242  }
243 
244  void replaceFeatures(Function &F, const std::string &Features) {
245  F.removeFnAttr("target-features");
246  F.removeFnAttr("target-cpu");
247  F.addFnAttr("target-features", Features);
248  }
249 
250  bool stripAtomics(Module &M) {
251  // Detect whether any atomics will be lowered, since there is no way to tell
252  // whether the LowerAtomic pass lowers e.g. stores.
253  bool Stripped = false;
254  for (auto &F : M) {
255  for (auto &B : F) {
256  for (auto &I : B) {
257  if (I.isAtomic()) {
258  Stripped = true;
259  goto done;
260  }
261  }
262  }
263  }
264 
265  done:
266  if (!Stripped)
267  return false;
268 
269  LowerAtomicPass Lowerer;
271  for (auto &F : M)
272  Lowerer.run(F, FAM);
273 
274  return true;
275  }
276 
277  bool stripThreadLocals(Module &M) {
278  bool Stripped = false;
279  for (auto &GV : M.globals()) {
280  if (GV.isThreadLocal()) {
281  Stripped = true;
282  GV.setThreadLocal(false);
283  }
284  }
285  return Stripped;
286  }
287 
288  void recordFeatures(Module &M, const FeatureBitset &Features, bool Stripped) {
289  for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
290  if (Features[KV.Value]) {
291  // Mark features as used
292  std::string MDKey = (StringRef("wasm-feature-") + KV.Key).str();
293  M.addModuleFlag(Module::ModFlagBehavior::Error, MDKey,
295  }
296  }
297  // Code compiled without atomics or bulk-memory may have had its atomics or
298  // thread-local data lowered to nonatomic operations or non-thread-local
299  // data. In that case, we mark the pseudo-feature "shared-mem" as disallowed
300  // to tell the linker that it would be unsafe to allow this code ot be used
301  // in a module with shared memory.
302  if (Stripped) {
303  M.addModuleFlag(Module::ModFlagBehavior::Error, "wasm-feature-shared-mem",
305  }
306  }
307 };
309 
310 /// WebAssembly Code Generator Pass Configuration Options.
311 class WebAssemblyPassConfig final : public TargetPassConfig {
312 public:
313  WebAssemblyPassConfig(WebAssemblyTargetMachine &TM, PassManagerBase &PM)
314  : TargetPassConfig(TM, PM) {}
315 
316  WebAssemblyTargetMachine &getWebAssemblyTargetMachine() const {
317  return getTM<WebAssemblyTargetMachine>();
318  }
319 
320  FunctionPass *createTargetRegisterAllocator(bool) override;
321 
322  void addIRPasses() override;
323  bool addInstSelector() override;
324  void addPostRegAlloc() override;
325  bool addGCPasses() override { return false; }
326  void addPreEmitPass() override;
327 
328  // No reg alloc
329  bool addRegAssignAndRewriteFast() override { return false; }
330 
331  // No reg alloc
332  bool addRegAssignAndRewriteOptimized() override { return false; }
333 };
334 } // end anonymous namespace
335 
339 }
340 
343  return new WebAssemblyPassConfig(*this, PM);
344 }
345 
346 FunctionPass *WebAssemblyPassConfig::createTargetRegisterAllocator(bool) {
347  return nullptr; // No reg alloc
348 }
349 
350 //===----------------------------------------------------------------------===//
351 // The following functions are called from lib/CodeGen/Passes.cpp to modify
352 // the CodeGen pass sequence.
353 //===----------------------------------------------------------------------===//
354 
355 void WebAssemblyPassConfig::addIRPasses() {
356  // Lower atomics and TLS if necessary
357  addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
358 
359  // This is a no-op if atomics are not used in the module
360  addPass(createAtomicExpandPass());
361 
362  // Add signatures to prototype-less function declarations
364 
365  // Lower .llvm.global_dtors into .llvm_global_ctors with __cxa_atexit calls.
367 
368  // Fix function bitcasts, as WebAssembly requires caller and callee signatures
369  // to match.
371 
372  // Optimize "returned" function attributes.
373  if (getOptLevel() != CodeGenOpt::None)
375 
376  // If exception handling is not enabled and setjmp/longjmp handling is
377  // enabled, we lower invokes into calls and delete unreachable landingpad
378  // blocks. Lowering invokes when there is no EH support is done in
379  // TargetPassConfig::addPassesToHandleExceptions, but this runs after this
380  // function and SjLj handling expects all invokes to be lowered before.
381  if (!EnableEmException &&
382  TM->Options.ExceptionModel == ExceptionHandling::None) {
383  addPass(createLowerInvokePass());
384  // The lower invoke pass may create unreachable code. Remove it in order not
385  // to process dead blocks in setjmp/longjmp handling.
387  }
388 
389  // Handle exceptions and setjmp/longjmp if enabled.
392  EnableEmSjLj));
393 
394  // Expand indirectbr instructions to switches.
395  addPass(createIndirectBrExpandPass());
396 
398 }
399 
400 bool WebAssemblyPassConfig::addInstSelector() {
402  addPass(
403  createWebAssemblyISelDag(getWebAssemblyTargetMachine(), getOptLevel()));
404  // Run the argument-move pass immediately after the ScheduleDAG scheduler
405  // so that we can fix up the ARGUMENT instructions before anything else
406  // sees them in the wrong place.
408  // Set the p2align operands. This information is present during ISel, however
409  // it's inconvenient to collect. Collect it now, and update the immediate
410  // operands.
412 
413  // Eliminate range checks and add default targets to br_table instructions.
415 
416  return false;
417 }
418 
419 void WebAssemblyPassConfig::addPostRegAlloc() {
420  // TODO: The following CodeGen passes don't currently support code containing
421  // virtual registers. Consider removing their restrictions and re-enabling
422  // them.
423 
424  // These functions all require the NoVRegs property.
425  disablePass(&MachineCopyPropagationID);
426  disablePass(&PostRAMachineSinkingID);
427  disablePass(&PostRASchedulerID);
428  disablePass(&FuncletLayoutID);
429  disablePass(&StackMapLivenessID);
430  disablePass(&LiveDebugValuesID);
431  disablePass(&PatchableFunctionID);
432  disablePass(&ShrinkWrapID);
433 
434  // This pass hurts code size for wasm because it can generate irreducible
435  // control flow.
436  disablePass(&MachineBlockPlacementID);
437 
439 }
440 
441 void WebAssemblyPassConfig::addPreEmitPass() {
443 
444  // Eliminate multiple-entry loops.
446 
447  // Do various transformations for exception handling.
448  // Every CFG-changing optimizations should come before this.
449  if (TM->Options.ExceptionModel == ExceptionHandling::Wasm)
451 
452  // Now that we have a prologue and epilogue and all frame indices are
453  // rewritten, eliminate SP and FP. This allows them to be stackified,
454  // colored, and numbered with the rest of the registers.
456 
457  // Preparations and optimizations related to register stackification.
458  if (getOptLevel() != CodeGenOpt::None) {
459  // LiveIntervals isn't commonly run this late. Re-establish preconditions.
461 
462  // Depend on LiveIntervals and perform some optimizations on it.
464 
465  // Prepare memory intrinsic calls for register stackifying.
467 
468  // Mark registers as representing wasm's value stack. This is a key
469  // code-compression technique in WebAssembly. We run this pass (and
470  // MemIntrinsicResults above) very late, so that it sees as much code as
471  // possible, including code emitted by PEI and expanded by late tail
472  // duplication.
473  addPass(createWebAssemblyRegStackify());
474 
475  // Run the register coloring pass to reduce the total number of registers.
476  // This runs after stackification so that it doesn't consider registers
477  // that become stackified.
478  addPass(createWebAssemblyRegColoring());
479  }
480 
481  // Sort the blocks of the CFG into topological order, a prerequisite for
482  // BLOCK and LOOP markers.
483  addPass(createWebAssemblyCFGSort());
484 
485  // Insert BLOCK and LOOP markers.
486  addPass(createWebAssemblyCFGStackify());
487 
488  // Insert explicit local.get and local.set operators.
491 
492  // Lower br_unless into br_if.
494 
495  // Perform the very last peephole optimizations on the code.
496  if (getOptLevel() != CodeGenOpt::None)
497  addPass(createWebAssemblyPeephole());
498 
499  // Create a mapping from LLVM CodeGen virtual registers to wasm registers.
501 
502  // Fix debug_values whose defs have been stackified.
504  addPass(createWebAssemblyDebugFixup());
505 }
506 
509  return new yaml::WebAssemblyFunctionInfo();
510 }
511 
513  const MachineFunction &MF) const {
514  const auto *MFI = MF.getInfo<WebAssemblyFunctionInfo>();
515  return new yaml::WebAssemblyFunctionInfo(*MFI);
516 }
517 
520  SMDiagnostic &Error, SMRange &SourceRange) const {
521  const auto &YamlMFI =
522  reinterpret_cast<const yaml::WebAssemblyFunctionInfo &>(MFI);
523  MachineFunction &MF = PFS.MF;
524  MF.getInfo<WebAssemblyFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
525  return false;
526 }
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
static cl::opt< bool > WasmDisableExplicitLocals("wasm-disable-explicit-locals", cl::Hidden, cl::desc("WebAssembly: output implicit locals in" " instruction output for test purposes only."), cl::init(false))
Represents a range in source code.
Definition: SMLoc.h:48
StringRef getTargetFeatureString() const
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.
Definition: StringRef.h:248
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.
Definition: AllocatorList.h:23
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.
Definition: Module.h:67
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
Definition: TargetMachine.h:96
This file a TargetTransformInfo::Concept conforming object specific to the WebAssembly target machine...
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 &)
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
F(f)
void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &)
A pass that lowers atomic intrinsic into non-atomic intrinsics.
Definition: LowerAtomic.h:22
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.
This file registers the WebAssembly target.
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
FunctionPass * createWebAssemblyRegNumbering()
FunctionPass * createLowerInvokePass()
Definition: LowerInvoke.cpp:87
void initializeWebAssemblyRegNumberingPass(PassRegistry &)
void initializeWebAssemblyExceptionInfoPass(PassRegistry &)
void initializeOptimizeReturnedPass(PassRegistry &)
FunctionPass * createWebAssemblyRegColoring()
Target-Independent Code Generator Pass Configuration Options.
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
This file declares the WebAssembly-specific subclass of TargetMachine.
RegisterTargetMachine - Helper template for registering a target machine implementation,...
const SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]
unsigned FunctionSections
Emit functions into separate sections.
Used to provide key value pairs for feature and CPU bit flags.
FunctionPass * createUnreachableBlockEliminationPass()
createUnreachableBlockEliminationPass - The LLVM code generator does not work well with unreachable b...
StringRef getTargetCPU() const
unsigned UniqueSectionNames
ModulePass * createWebAssemblyAddMissingPrototypes()
WebAssembly Exception Handling.
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:151
void initializeWebAssemblyDebugFixupPass(PassRegistry &)
void initializeWebAssemblyExplicitLocalsPass(PassRegistry &)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:427
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void initializeWebAssemblyPeepholePass(PassRegistry &)
Container class for subtarget features.
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)
ModulePass * createWebAssemblyLowerGlobalDtors()
char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
This file provides WebAssembly-specific target descriptions.
const WebAssemblySubtarget * getSubtargetImpl() const
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...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setTargetFeatureString(StringRef FS)
void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &)
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
FunctionPass * createWebAssemblySetP2AlignOperands()
void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &)
char & MachineCopyPropagationID
MachineCopyPropagation - This pass performs copy propagation on machine instructions.
cl::opt< bool > EnableEmException("enable-emscripten-cxx-exceptions", cl::desc("WebAssembly Emscripten-style exception handling"), cl::init(false))
void initializeWebAssemblyLateEHPreparePass(PassRegistry &)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
FunctionPass * createIndirectBrExpandPass()
char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
ModulePass * createWebAssemblyFixFunctionBitcasts()
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget()
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
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...
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:131
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 &)
FunctionPass * createWebAssemblyFixBrTableDefaults()
std::string TargetCPU
Definition: TargetMachine.h:97
FunctionPass * createWebAssemblyDebugFixup()
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:275
FunctionPass * createWebAssemblyLateEHPrepare()
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
No exception support.
#define I(x, y, z)
Definition: MD5.cpp:59
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:238
This file declares WebAssembly-specific per-machine-function information.
char & MachineBlockPlacementID
MachineBlockPlacement - This pass places basic blocks based on branch probabilities.
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 initializeWebAssemblyAddMissingPrototypesPass(PassRegistry &)
void initializeFixFunctionBitcastsPass(PassRegistry &)
std::string TargetFS
Definition: TargetMachine.h:98
FunctionPass * createWebAssemblyOptimizeLiveIntervals()
FunctionPass * createWebAssemblyCFGStackify()
void initializeWebAssemblyPrepareForLiveIntervalsPass(PassRegistry &)
void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &)
void initializeLowerGlobalDtorsPass(PassRegistry &)
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
FunctionPass * createWebAssemblyPrepareForLiveIntervals()
char & ShrinkWrapID
ShrinkWrap pass. Look for the best place to insert save and restore.
Definition: ShrinkWrap.cpp:250
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
A container for analyses that lazily runs them and caches their results.
unsigned TrapUnreachable
Emit target-specific trap instruction for 'unreachable' IR instructions.
Target & getTheWebAssemblyTarget32()
FunctionPass * createWebAssemblyReplacePhysRegs()
void initializeWebAssemblyCFGSortPass(PassRegistry &)
FunctionPass * createAtomicExpandPass()
Target & getTheWebAssemblyTarget64()
FunctionPass * createWebAssemblyExplicitLocals()
void initializeWebAssemblyRegColoringPass(PassRegistry &)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:251