1//===-- WebAssembly.h - Top-level interface for WebAssembly ----*- C++ -*-===//
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 the entry points for global functions defined in
11/// the LLVM WebAssembly back-end.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLY_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLY_H
17
18#include "GISel/WebAssemblyRegisterBankInfo.h"
19#include "WebAssemblySubtarget.h"
20#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
21#include "llvm/PassRegistry.h"
22#include "llvm/Support/CodeGen.h"
23
24namespace llvm {
25
26class WebAssemblyTargetMachine;
27class ModulePass;
28class FunctionPass;
29
30// LLVM IR passes.
31ModulePass *createWebAssemblyLowerEmscriptenEHSjLj();
32ModulePass *createWebAssemblyAddMissingPrototypes();
33ModulePass *createWebAssemblyFixFunctionBitcasts();
34FunctionPass *createWebAssemblyOptimizeReturned();
35FunctionPass *createWebAssemblyLowerRefTypesIntPtrConv();
36FunctionPass *createWebAssemblyRefTypeMem2Local();
37
38// GlobalISel
39InstructionSelector *
40createWebAssemblyInstructionSelector(const WebAssemblyTargetMachine &,
41 const WebAssemblySubtarget &,
42 const WebAssemblyRegisterBankInfo &);
43
44FunctionPass *createWebAssemblyPostLegalizerCombiner();
45void initializeWebAssemblyPostLegalizerCombinerPass(PassRegistry &);
46
47FunctionPass *createWebAssemblyPreLegalizerCombiner();
48void initializeWebAssemblyPreLegalizerCombinerPass(PassRegistry &);
49
50// ISel and immediate followup passes.
51FunctionPass *createWebAssemblyISelDag(WebAssemblyTargetMachine &TM,
52 CodeGenOptLevel OptLevel);
53FunctionPass *createWebAssemblyArgumentMove();
54FunctionPass *createWebAssemblySetP2AlignOperands();
55FunctionPass *createWebAssemblyCleanCodeAfterTrap();
56
57// Late passes.
58FunctionPass *createWebAssemblyReplacePhysRegs();
59FunctionPass *createWebAssemblyNullifyDebugValueLists();
60FunctionPass *createWebAssemblyOptimizeLiveIntervals();
61FunctionPass *createWebAssemblyMemIntrinsicResults();
62FunctionPass *createWebAssemblyRegStackify(CodeGenOptLevel OptLevel);
63FunctionPass *createWebAssemblyRegColoring();
64FunctionPass *createWebAssemblyFixBrTableDefaults();
65FunctionPass *createWebAssemblyFixIrreducibleControlFlow();
66FunctionPass *createWebAssemblyLateEHPrepare();
67FunctionPass *createWebAssemblyCFGSort();
68FunctionPass *createWebAssemblyCFGStackify();
69FunctionPass *createWebAssemblyExplicitLocals();
70FunctionPass *createWebAssemblyLowerBrUnless();
71FunctionPass *createWebAssemblyRegNumbering();
72FunctionPass *createWebAssemblyDebugFixup();
73FunctionPass *createWebAssemblyPeephole();
74ModulePass *createWebAssemblyMCLowerPrePass();
75
76// PassRegistry initialization declarations.
77void initializeFixFunctionBitcastsPass(PassRegistry &);
78void initializeOptimizeReturnedPass(PassRegistry &);
79void initializeWebAssemblyRefTypeMem2LocalPass(PassRegistry &);
80void initializeWebAssemblyAddMissingPrototypesPass(PassRegistry &);
81void initializeWebAssemblyArgumentMovePass(PassRegistry &);
82void initializeWebAssemblyAsmPrinterPass(PassRegistry &);
83void initializeWebAssemblyCleanCodeAfterTrapPass(PassRegistry &);
84void initializeWebAssemblyCFGSortPass(PassRegistry &);
85void initializeWebAssemblyCFGStackifyPass(PassRegistry &);
86void initializeWebAssemblyDAGToDAGISelLegacyPass(PassRegistry &);
87void initializeWebAssemblyDebugFixupPass(PassRegistry &);
88void initializeWebAssemblyExceptionInfoPass(PassRegistry &);
89void initializeWebAssemblyExplicitLocalsPass(PassRegistry &);
90void initializeWebAssemblyFixBrTableDefaultsPass(PassRegistry &);
91void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &);
92void initializeWebAssemblyLateEHPreparePass(PassRegistry &);
93void initializeWebAssemblyLowerBrUnlessPass(PassRegistry &);
94void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &);
95void initializeWebAssemblyLowerRefTypesIntPtrConvPass(PassRegistry &);
96void initializeWebAssemblyMCLowerPrePassPass(PassRegistry &);
97void initializeWebAssemblyMemIntrinsicResultsPass(PassRegistry &);
98void initializeWebAssemblyNullifyDebugValueListsPass(PassRegistry &);
99void initializeWebAssemblyOptimizeLiveIntervalsPass(PassRegistry &);
100void initializeWebAssemblyPeepholePass(PassRegistry &);
101void initializeWebAssemblyRegColoringPass(PassRegistry &);
102void initializeWebAssemblyRegNumberingPass(PassRegistry &);
103void initializeWebAssemblyRegStackifyPass(PassRegistry &);
104void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &);
105void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &);
106
107namespace WebAssembly {
108enum TargetIndex {
109 // Followed by a local index (ULEB).
110 TI_LOCAL,
111 // Followed by an absolute global index (ULEB). DEPRECATED.
112 TI_GLOBAL_FIXED,
113 // Followed by the index from the bottom of the Wasm stack.
114 TI_OPERAND_STACK,
115 // Followed by a compilation unit relative global index (uint32_t)
116 // that will have an associated relocation.
117 TI_GLOBAL_RELOC,
118 // Like TI_LOCAL, but indicates an indirect value (e.g. byval arg
119 // passed by pointer).
120 TI_LOCAL_INDIRECT
121};
122} // end namespace WebAssembly
123
124} // end namespace llvm
125
126#endif
127