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