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