| 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/Instructions.h" |
| 14 | #include "llvm/IR/PassManager.h" |
| 15 | #include "llvm/Pass.h" |
| 16 | #include "llvm/Target/TargetMachine.h" |
| 17 | |
| 18 | namespace llvm { |
| 19 | class BPFRegisterBankInfo; |
| 20 | class BPFSubtarget; |
| 21 | class BPFTargetMachine; |
| 22 | class InstructionSelector; |
| 23 | class PassRegistry; |
| 24 | |
| 25 | #define BPF_TRAP "__bpf_trap" |
| 26 | |
| 27 | ModulePass *createBPFCheckAndAdjustIR(); |
| 28 | |
| 29 | FunctionPass *createBPFISelDag(BPFTargetMachine &TM); |
| 30 | FunctionPass *createBPFMISimplifyPatchablePass(); |
| 31 | FunctionPass *createBPFMIPeepholePass(); |
| 32 | FunctionPass *createBPFMIPreEmitPeepholePass(); |
| 33 | FunctionPass *createBPFMIPreEmitCheckingPass(); |
| 34 | |
| 35 | InstructionSelector *createBPFInstructionSelector(const BPFTargetMachine &, |
| 36 | const BPFSubtarget &, |
| 37 | const BPFRegisterBankInfo &); |
| 38 | |
| 39 | void initializeBPFAsmPrinterPass(PassRegistry &); |
| 40 | void initializeBPFCheckAndAdjustIRPass(PassRegistry&); |
| 41 | void initializeBPFDAGToDAGISelLegacyPass(PassRegistry &); |
| 42 | void initializeBPFMIPeepholePass(PassRegistry &); |
| 43 | void initializeBPFMIPreEmitCheckingPass(PassRegistry &); |
| 44 | void initializeBPFMIPreEmitPeepholePass(PassRegistry &); |
| 45 | void initializeBPFMISimplifyPatchablePass(PassRegistry &); |
| 46 | |
| 47 | class BPFAbstractMemberAccessPass |
| 48 | : public RequiredPassInfoMixin<BPFAbstractMemberAccessPass> { |
| 49 | BPFTargetMachine *TM; |
| 50 | |
| 51 | public: |
| 52 | BPFAbstractMemberAccessPass(BPFTargetMachine *TM) : TM(TM) {} |
| 53 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
| 54 | }; |
| 55 | |
| 56 | class BPFPreserveDITypePass |
| 57 | : public RequiredPassInfoMixin<BPFPreserveDITypePass> { |
| 58 | public: |
| 59 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
| 60 | }; |
| 61 | |
| 62 | class BPFIRPeepholePass : public RequiredPassInfoMixin<BPFIRPeepholePass> { |
| 63 | public: |
| 64 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
| 65 | }; |
| 66 | |
| 67 | class BPFASpaceCastSimplifyPass |
| 68 | : public RequiredPassInfoMixin<BPFASpaceCastSimplifyPass> { |
| 69 | public: |
| 70 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
| 71 | }; |
| 72 | |
| 73 | class BPFAdjustOptPass : public OptionalPassInfoMixin<BPFAdjustOptPass> { |
| 74 | public: |
| 75 | PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); |
| 76 | }; |
| 77 | |
| 78 | class BPFPreserveStaticOffsetPass |
| 79 | : public RequiredPassInfoMixin<BPFPreserveStaticOffsetPass> { |
| 80 | bool AllowPartial; |
| 81 | |
| 82 | public: |
| 83 | BPFPreserveStaticOffsetPass(bool AllowPartial) : AllowPartial(AllowPartial) {} |
| 84 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
| 85 | |
| 86 | static std::pair<GetElementPtrInst *, LoadInst *> |
| 87 | reconstructLoad(CallInst *Call); |
| 88 | |
| 89 | static std::pair<GetElementPtrInst *, StoreInst *> |
| 90 | reconstructStore(CallInst *Call); |
| 91 | }; |
| 92 | |
| 93 | } // namespace llvm |
| 94 | |
| 95 | #endif |
| 96 | |