xref: /freebsd/contrib/llvm-project/llvm/lib/Target/BPF/BPF.h (revision 0ad011ececb978e22a9bff2acf76633b094f1ff6)
1 //===-- BPF.h - Top-level interface for BPF representation ------*- 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 #ifndef LLVM_LIB_TARGET_BPF_BPF_H
10 #define LLVM_LIB_TARGET_BPF_BPF_H
11 
12 #include "MCTargetDesc/BPFMCTargetDesc.h"
13 #include "llvm/IR/PassManager.h"
14 #include "llvm/Pass.h"
15 #include "llvm/Target/TargetMachine.h"
16 
17 namespace llvm {
18 class BPFTargetMachine;
19 class PassRegistry;
20 
21 ModulePass *createBPFCheckAndAdjustIR();
22 
23 FunctionPass *createBPFISelDag(BPFTargetMachine &TM);
24 FunctionPass *createBPFMISimplifyPatchablePass();
25 FunctionPass *createBPFMIPeepholePass();
26 FunctionPass *createBPFMIPeepholeTruncElimPass();
27 FunctionPass *createBPFMIPreEmitPeepholePass();
28 FunctionPass *createBPFMIPreEmitCheckingPass();
29 
30 void initializeBPFCheckAndAdjustIRPass(PassRegistry&);
31 void initializeBPFDAGToDAGISelPass(PassRegistry &);
32 void initializeBPFMIPeepholePass(PassRegistry&);
33 void initializeBPFMIPeepholeTruncElimPass(PassRegistry &);
34 void initializeBPFMIPreEmitCheckingPass(PassRegistry&);
35 void initializeBPFMIPreEmitPeepholePass(PassRegistry &);
36 void initializeBPFMISimplifyPatchablePass(PassRegistry &);
37 
38 class BPFAbstractMemberAccessPass
39     : public PassInfoMixin<BPFAbstractMemberAccessPass> {
40   BPFTargetMachine *TM;
41 
42 public:
43   BPFAbstractMemberAccessPass(BPFTargetMachine *TM) : TM(TM) {}
44   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
45 
46   static bool isRequired() { return true; }
47 };
48 
49 class BPFPreserveDITypePass : public PassInfoMixin<BPFPreserveDITypePass> {
50 public:
51   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
52 
53   static bool isRequired() { return true; }
54 };
55 
56 class BPFIRPeepholePass : public PassInfoMixin<BPFIRPeepholePass> {
57 public:
58   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
59 
60   static bool isRequired() { return true; }
61 };
62 
63 class BPFAdjustOptPass : public PassInfoMixin<BPFAdjustOptPass> {
64 public:
65   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
66 };
67 } // namespace llvm
68 
69 #endif
70