xref: /freebsd/contrib/llvm-project/llvm/lib/Target/BPF/BPF.h (revision cab6a39d7b343596a5823e65c0f7b426551ec22d)
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/Target/TargetMachine.h"
15 
16 namespace llvm {
17 class BPFTargetMachine;
18 
19 ModulePass *createBPFAdjustOpt();
20 ModulePass *createBPFCheckAndAdjustIR();
21 
22 FunctionPass *createBPFAbstractMemberAccess(BPFTargetMachine *TM);
23 FunctionPass *createBPFPreserveDIType();
24 FunctionPass *createBPFISelDag(BPFTargetMachine &TM);
25 FunctionPass *createBPFMISimplifyPatchablePass();
26 FunctionPass *createBPFMIPeepholePass();
27 FunctionPass *createBPFMIPeepholeTruncElimPass();
28 FunctionPass *createBPFMIPreEmitPeepholePass();
29 FunctionPass *createBPFMIPreEmitCheckingPass();
30 
31 void initializeBPFAdjustOptPass(PassRegistry&);
32 void initializeBPFCheckAndAdjustIRPass(PassRegistry&);
33 
34 void initializeBPFAbstractMemberAccessLegacyPassPass(PassRegistry &);
35 void initializeBPFPreserveDITypePass(PassRegistry&);
36 void initializeBPFMISimplifyPatchablePass(PassRegistry&);
37 void initializeBPFMIPeepholePass(PassRegistry&);
38 void initializeBPFMIPeepholeTruncElimPass(PassRegistry&);
39 void initializeBPFMIPreEmitPeepholePass(PassRegistry&);
40 void initializeBPFMIPreEmitCheckingPass(PassRegistry&);
41 
42 class BPFAbstractMemberAccessPass
43     : public PassInfoMixin<BPFAbstractMemberAccessPass> {
44   BPFTargetMachine *TM;
45 
46 public:
47   BPFAbstractMemberAccessPass(BPFTargetMachine *TM) : TM(TM) {}
48   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
49 
50   static bool isRequired() { return true; }
51 };
52 
53 class BPFPreserveDITypePass : public PassInfoMixin<BPFPreserveDITypePass> {
54 public:
55   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
56 
57   static bool isRequired() { return true; }
58 };
59 
60 class BPFAdjustOptPass : public PassInfoMixin<BPFAdjustOptPass> {
61 public:
62   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
63 };
64 } // namespace llvm
65 
66 #endif
67