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