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(bool DoEH, bool DoSjLj);
29ModulePass *createWebAssemblyLowerGlobalDtors();
30ModulePass *createWebAssemblyAddMissingPrototypes();
31ModulePass *createWebAssemblyFixFunctionBitcasts();
32FunctionPass *createWebAssemblyOptimizeReturned();
33
34// ISel and immediate followup passes.
35FunctionPass *createWebAssemblyISelDag(WebAssemblyTargetMachine &TM,
36                                       CodeGenOpt::Level OptLevel);
37FunctionPass *createWebAssemblyArgumentMove();
38FunctionPass *createWebAssemblySetP2AlignOperands();
39
40// Late passes.
41FunctionPass *createWebAssemblyReplacePhysRegs();
42FunctionPass *createWebAssemblyPrepareForLiveIntervals();
43FunctionPass *createWebAssemblyOptimizeLiveIntervals();
44FunctionPass *createWebAssemblyMemIntrinsicResults();
45FunctionPass *createWebAssemblyRegStackify();
46FunctionPass *createWebAssemblyRegColoring();
47FunctionPass *createWebAssemblyFixBrTableDefaults();
48FunctionPass *createWebAssemblyFixIrreducibleControlFlow();
49FunctionPass *createWebAssemblyLateEHPrepare();
50FunctionPass *createWebAssemblyCFGSort();
51FunctionPass *createWebAssemblyCFGStackify();
52FunctionPass *createWebAssemblyExplicitLocals();
53FunctionPass *createWebAssemblyLowerBrUnless();
54FunctionPass *createWebAssemblyRegNumbering();
55FunctionPass *createWebAssemblyDebugFixup();
56FunctionPass *createWebAssemblyPeephole();
57
58// PassRegistry initialization declarations.
59void initializeWebAssemblyAddMissingPrototypesPass(PassRegistry &);
60void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &);
61void initializeLowerGlobalDtorsPass(PassRegistry &);
62void initializeFixFunctionBitcastsPass(PassRegistry &);
63void initializeOptimizeReturnedPass(PassRegistry &);
64void initializeWebAssemblyArgumentMovePass(PassRegistry &);
65void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &);
66void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &);
67void initializeWebAssemblyPrepareForLiveIntervalsPass(PassRegistry &);
68void initializeWebAssemblyOptimizeLiveIntervalsPass(PassRegistry &);
69void initializeWebAssemblyMemIntrinsicResultsPass(PassRegistry &);
70void initializeWebAssemblyRegStackifyPass(PassRegistry &);
71void initializeWebAssemblyRegColoringPass(PassRegistry &);
72void initializeWebAssemblyFixBrTableDefaultsPass(PassRegistry &);
73void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &);
74void initializeWebAssemblyLateEHPreparePass(PassRegistry &);
75void initializeWebAssemblyExceptionInfoPass(PassRegistry &);
76void initializeWebAssemblyCFGSortPass(PassRegistry &);
77void initializeWebAssemblyCFGStackifyPass(PassRegistry &);
78void initializeWebAssemblyExplicitLocalsPass(PassRegistry &);
79void initializeWebAssemblyLowerBrUnlessPass(PassRegistry &);
80void initializeWebAssemblyRegNumberingPass(PassRegistry &);
81void initializeWebAssemblyDebugFixupPass(PassRegistry &);
82void initializeWebAssemblyPeepholePass(PassRegistry &);
83
84namespace WebAssembly {
85enum TargetIndex {
86  // Followed by a local index (ULEB).
87  TI_LOCAL,
88  // Followed by an absolute global index (ULEB). DEPRECATED.
89  TI_GLOBAL_FIXED,
90  TI_OPERAND_STACK,
91  // Followed by a compilation unit relative global index (uint32_t)
92  // that will have an associated relocation.
93  TI_GLOBAL_RELOC
94};
95} // end namespace WebAssembly
96
97} // end namespace llvm
98
99#endif
100