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();
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 initializeWebAssemblyCleanCodeAfterTrapPass(PassRegistry &);
68void initializeWebAssemblyCFGSortPass(PassRegistry &);
69void initializeWebAssemblyCFGStackifyPass(PassRegistry &);
70void initializeWebAssemblyDAGToDAGISelLegacyPass(PassRegistry &);
71void initializeWebAssemblyDebugFixupPass(PassRegistry &);
72void initializeWebAssemblyExceptionInfoPass(PassRegistry &);
73void initializeWebAssemblyExplicitLocalsPass(PassRegistry &);
74void initializeWebAssemblyFixBrTableDefaultsPass(PassRegistry &);
75void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &);
76void initializeWebAssemblyLateEHPreparePass(PassRegistry &);
77void initializeWebAssemblyLowerBrUnlessPass(PassRegistry &);
78void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &);
79void initializeWebAssemblyLowerRefTypesIntPtrConvPass(PassRegistry &);
80void initializeWebAssemblyMCLowerPrePassPass(PassRegistry &);
81void initializeWebAssemblyMemIntrinsicResultsPass(PassRegistry &);
82void initializeWebAssemblyNullifyDebugValueListsPass(PassRegistry &);
83void initializeWebAssemblyOptimizeLiveIntervalsPass(PassRegistry &);
84void initializeWebAssemblyPeepholePass(PassRegistry &);
85void initializeWebAssemblyRegColoringPass(PassRegistry &);
86void initializeWebAssemblyRegNumberingPass(PassRegistry &);
87void initializeWebAssemblyRegStackifyPass(PassRegistry &);
88void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &);
89void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &);
90
91namespace WebAssembly {
92enum TargetIndex {
93 // Followed by a local index (ULEB).
94 TI_LOCAL,
95 // Followed by an absolute global index (ULEB). DEPRECATED.
96 TI_GLOBAL_FIXED,
97 // Followed by the index from the bottom of the Wasm stack.
98 TI_OPERAND_STACK,
99 // Followed by a compilation unit relative global index (uint32_t)
100 // that will have an associated relocation.
101 TI_GLOBAL_RELOC,
102 // Like TI_LOCAL, but indicates an indirect value (e.g. byval arg
103 // passed by pointer).
104 TI_LOCAL_INDIRECT
105};
106} // end namespace WebAssembly
107
108} // end namespace llvm
109
110#endif
111