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 ModulePass *createBPFCheckAndAdjustIR(); 26 27 FunctionPass *createBPFISelDag(BPFTargetMachine &TM); 28 FunctionPass *createBPFMISimplifyPatchablePass(); 29 FunctionPass *createBPFMIPeepholePass(); 30 FunctionPass *createBPFMIPreEmitPeepholePass(); 31 FunctionPass *createBPFMIPreEmitCheckingPass(); 32 33 InstructionSelector *createBPFInstructionSelector(const BPFTargetMachine &, 34 const BPFSubtarget &, 35 const BPFRegisterBankInfo &); 36 37 void initializeBPFCheckAndAdjustIRPass(PassRegistry&); 38 void initializeBPFDAGToDAGISelPass(PassRegistry &); 39 void initializeBPFMIPeepholePass(PassRegistry &); 40 void initializeBPFMIPreEmitCheckingPass(PassRegistry&); 41 void initializeBPFMIPreEmitPeepholePass(PassRegistry &); 42 void initializeBPFMISimplifyPatchablePass(PassRegistry &); 43 44 class BPFAbstractMemberAccessPass 45 : public PassInfoMixin<BPFAbstractMemberAccessPass> { 46 BPFTargetMachine *TM; 47 48 public: 49 BPFAbstractMemberAccessPass(BPFTargetMachine *TM) : TM(TM) {} 50 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 51 52 static bool isRequired() { return true; } 53 }; 54 55 class BPFPreserveDITypePass : public PassInfoMixin<BPFPreserveDITypePass> { 56 public: 57 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 58 59 static bool isRequired() { return true; } 60 }; 61 62 class BPFIRPeepholePass : public PassInfoMixin<BPFIRPeepholePass> { 63 public: 64 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 65 66 static bool isRequired() { return true; } 67 }; 68 69 class BPFAdjustOptPass : public PassInfoMixin<BPFAdjustOptPass> { 70 public: 71 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); 72 }; 73 74 class BPFPreserveStaticOffsetPass 75 : public PassInfoMixin<BPFPreserveStaticOffsetPass> { 76 bool AllowPartial; 77 78 public: 79 BPFPreserveStaticOffsetPass(bool AllowPartial) : AllowPartial(AllowPartial) {} 80 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 81 82 static bool isRequired() { return true; } 83 84 static std::pair<GetElementPtrInst *, LoadInst *> 85 reconstructLoad(CallInst *Call); 86 87 static std::pair<GetElementPtrInst *, StoreInst *> 88 reconstructStore(CallInst *Call); 89 }; 90 91 } // namespace llvm 92 93 #endif 94