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 *createWebAssemblyPrepareForLiveIntervals(); 44 FunctionPass *createWebAssemblyOptimizeLiveIntervals(); 45 FunctionPass *createWebAssemblyMemIntrinsicResults(); 46 FunctionPass *createWebAssemblyRegStackify(); 47 FunctionPass *createWebAssemblyRegColoring(); 48 FunctionPass *createWebAssemblyFixBrTableDefaults(); 49 FunctionPass *createWebAssemblyFixIrreducibleControlFlow(); 50 FunctionPass *createWebAssemblyLateEHPrepare(); 51 FunctionPass *createWebAssemblyCFGSort(); 52 FunctionPass *createWebAssemblyCFGStackify(); 53 FunctionPass *createWebAssemblyExplicitLocals(); 54 FunctionPass *createWebAssemblyLowerBrUnless(); 55 FunctionPass *createWebAssemblyRegNumbering(); 56 FunctionPass *createWebAssemblyDebugFixup(); 57 FunctionPass *createWebAssemblyPeephole(); 58 ModulePass *createWebAssemblyMCLowerPrePass(); 59 60 // PassRegistry initialization declarations. 61 void initializeWebAssemblyAddMissingPrototypesPass(PassRegistry &); 62 void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &); 63 void initializeFixFunctionBitcastsPass(PassRegistry &); 64 void initializeOptimizeReturnedPass(PassRegistry &); 65 void initializeWebAssemblyArgumentMovePass(PassRegistry &); 66 void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &); 67 void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &); 68 void initializeWebAssemblyNullifyDebugValueListsPass(PassRegistry &); 69 void initializeWebAssemblyPrepareForLiveIntervalsPass(PassRegistry &); 70 void initializeWebAssemblyOptimizeLiveIntervalsPass(PassRegistry &); 71 void initializeWebAssemblyMemIntrinsicResultsPass(PassRegistry &); 72 void initializeWebAssemblyRegStackifyPass(PassRegistry &); 73 void initializeWebAssemblyRegColoringPass(PassRegistry &); 74 void initializeWebAssemblyFixBrTableDefaultsPass(PassRegistry &); 75 void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &); 76 void initializeWebAssemblyLateEHPreparePass(PassRegistry &); 77 void initializeWebAssemblyExceptionInfoPass(PassRegistry &); 78 void initializeWebAssemblyCFGSortPass(PassRegistry &); 79 void initializeWebAssemblyCFGStackifyPass(PassRegistry &); 80 void initializeWebAssemblyExplicitLocalsPass(PassRegistry &); 81 void initializeWebAssemblyLowerBrUnlessPass(PassRegistry &); 82 void initializeWebAssemblyRegNumberingPass(PassRegistry &); 83 void initializeWebAssemblyDebugFixupPass(PassRegistry &); 84 void initializeWebAssemblyPeepholePass(PassRegistry &); 85 void initializeWebAssemblyMCLowerPrePassPass(PassRegistry &); 86 void initializeWebAssemblyLowerRefTypesIntPtrConvPass(PassRegistry &); 87 88 namespace WebAssembly { 89 enum TargetIndex { 90 // Followed by a local index (ULEB). 91 TI_LOCAL, 92 // Followed by an absolute global index (ULEB). DEPRECATED. 93 TI_GLOBAL_FIXED, 94 // Followed by the index from the bottom of the Wasm stack. 95 TI_OPERAND_STACK, 96 // Followed by a compilation unit relative global index (uint32_t) 97 // that will have an associated relocation. 98 TI_GLOBAL_RELOC, 99 // Like TI_LOCAL, but indicates an indirect value (e.g. byval arg 100 // passed by pointer). 101 TI_LOCAL_INDIRECT 102 }; 103 } // end namespace WebAssembly 104 105 } // end namespace llvm 106 107 #endif 108