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