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();
37FunctionPass *createWebAssemblyReduceToAnyAllTrue(WebAssemblyTargetMachine &TM);
38
39// GlobalISel
40InstructionSelector *
41createWebAssemblyInstructionSelector(const WebAssemblyTargetMachine &,
42 const WebAssemblySubtarget &,
43 const WebAssemblyRegisterBankInfo &);
44
45FunctionPass *createWebAssemblyPostLegalizerCombiner();
46void initializeWebAssemblyPostLegalizerCombinerPass(PassRegistry &);
47
48FunctionPass *createWebAssemblyPreLegalizerCombiner();
49void initializeWebAssemblyPreLegalizerCombinerPass(PassRegistry &);
50
51// ISel and immediate followup passes.
52FunctionPass *createWebAssemblyISelDag(WebAssemblyTargetMachine &TM,
53 CodeGenOptLevel OptLevel);
54FunctionPass *createWebAssemblyArgumentMove();
55FunctionPass *createWebAssemblySetP2AlignOperands();
56FunctionPass *createWebAssemblyCleanCodeAfterTrap();
57
58// Late passes.
59FunctionPass *createWebAssemblyReplacePhysRegs();
60FunctionPass *createWebAssemblyNullifyDebugValueLists();
61FunctionPass *createWebAssemblyOptimizeLiveIntervals();
62FunctionPass *createWebAssemblyMemIntrinsicResults();
63FunctionPass *createWebAssemblyRegStackify(CodeGenOptLevel OptLevel);
64FunctionPass *createWebAssemblyRegColoring();
65FunctionPass *createWebAssemblyFixBrTableDefaults();
66FunctionPass *createWebAssemblyFixIrreducibleControlFlow();
67FunctionPass *createWebAssemblyLateEHPrepare();
68FunctionPass *createWebAssemblyCFGSort();
69FunctionPass *createWebAssemblyCFGStackify();
70FunctionPass *createWebAssemblyExplicitLocals();
71FunctionPass *createWebAssemblyLowerBrUnless();
72FunctionPass *createWebAssemblyRegNumbering();
73FunctionPass *createWebAssemblyVecReduce();
74FunctionPass *createWebAssemblyDebugFixup();
75FunctionPass *createWebAssemblyPeephole();
76ModulePass *createWebAssemblyMCLowerPrePass();
77
78// PassRegistry initialization declarations.
79void initializeFixFunctionBitcastsPass(PassRegistry &);
80void initializeOptimizeReturnedPass(PassRegistry &);
81void initializeWebAssemblyRefTypeMem2LocalPass(PassRegistry &);
82void initializeWebAssemblyAddMissingPrototypesPass(PassRegistry &);
83void initializeWebAssemblyArgumentMovePass(PassRegistry &);
84void initializeWebAssemblyAsmPrinterPass(PassRegistry &);
85void initializeWebAssemblyCleanCodeAfterTrapPass(PassRegistry &);
86void initializeWebAssemblyCFGSortPass(PassRegistry &);
87void initializeWebAssemblyCFGStackifyPass(PassRegistry &);
88void initializeWebAssemblyDAGToDAGISelLegacyPass(PassRegistry &);
89void initializeWebAssemblyDebugFixupPass(PassRegistry &);
90void initializeWebAssemblyExceptionInfoPass(PassRegistry &);
91void initializeWebAssemblyExplicitLocalsPass(PassRegistry &);
92void initializeWebAssemblyFixBrTableDefaultsPass(PassRegistry &);
93void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &);
94void initializeWebAssemblyLateEHPreparePass(PassRegistry &);
95void initializeWebAssemblyLowerBrUnlessPass(PassRegistry &);
96void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &);
97void initializeWebAssemblyLowerRefTypesIntPtrConvPass(PassRegistry &);
98void initializeWebAssemblyMCLowerPrePassPass(PassRegistry &);
99void initializeWebAssemblyMemIntrinsicResultsPass(PassRegistry &);
100void initializeWebAssemblyNullifyDebugValueListsPass(PassRegistry &);
101void initializeWebAssemblyOptimizeLiveIntervalsPass(PassRegistry &);
102void initializeWebAssemblyPeepholePass(PassRegistry &);
103void initializeWebAssemblyRegColoringPass(PassRegistry &);
104void initializeWebAssemblyRegNumberingPass(PassRegistry &);
105void initializeWebAssemblyRegStackifyPass(PassRegistry &);
106void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &);
107void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &);
108
109namespace WebAssembly {
110enum TargetIndex {
111 // Followed by a local index (ULEB).
112 TI_LOCAL,
113 // Followed by an absolute global index (ULEB). DEPRECATED.
114 TI_GLOBAL_FIXED,
115 // Followed by the index from the bottom of the Wasm stack.
116 TI_OPERAND_STACK,
117 // Followed by a compilation unit relative global index (uint32_t)
118 // that will have an associated relocation.
119 TI_GLOBAL_RELOC,
120 // Like TI_LOCAL, but indicates an indirect value (e.g. byval arg
121 // passed by pointer).
122 TI_LOCAL_INDIRECT
123};
124} // end namespace WebAssembly
125
126} // end namespace llvm
127
128#endif
129