brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 7faae8b Raw
105 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIB_TARGET_BPF_BPF_H10#define LLVM_LIB_TARGET_BPF_BPF_H11 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 25#define BPF_TRAP "__bpf_trap"26 27ModulePass *createBPFCheckAndAdjustIR();28 29FunctionPass *createBPFISelDag(BPFTargetMachine &TM);30FunctionPass *createBPFMISimplifyPatchablePass();31FunctionPass *createBPFMIPeepholePass();32FunctionPass *createBPFMIPreEmitPeepholePass();33FunctionPass *createBPFMIPreEmitCheckingPass();34 35InstructionSelector *createBPFInstructionSelector(const BPFTargetMachine &,36                                                  const BPFSubtarget &,37                                                  const BPFRegisterBankInfo &);38 39void initializeBPFAsmPrinterPass(PassRegistry &);40void initializeBPFCheckAndAdjustIRPass(PassRegistry&);41void initializeBPFDAGToDAGISelLegacyPass(PassRegistry &);42void initializeBPFMIPeepholePass(PassRegistry &);43void initializeBPFMIPreEmitCheckingPass(PassRegistry &);44void initializeBPFMIPreEmitPeepholePass(PassRegistry &);45void initializeBPFMISimplifyPatchablePass(PassRegistry &);46 47class BPFAbstractMemberAccessPass48    : public PassInfoMixin<BPFAbstractMemberAccessPass> {49  BPFTargetMachine *TM;50 51public:52  BPFAbstractMemberAccessPass(BPFTargetMachine *TM) : TM(TM) {}53  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);54 55  static bool isRequired() { return true; }56};57 58class BPFPreserveDITypePass : public PassInfoMixin<BPFPreserveDITypePass> {59public:60  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);61 62  static bool isRequired() { return true; }63};64 65class BPFIRPeepholePass : public PassInfoMixin<BPFIRPeepholePass> {66public:67  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);68 69  static bool isRequired() { return true; }70};71 72class BPFASpaceCastSimplifyPass73    : public PassInfoMixin<BPFASpaceCastSimplifyPass> {74public:75  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);76 77  static bool isRequired() { return true; }78};79 80class BPFAdjustOptPass : public PassInfoMixin<BPFAdjustOptPass> {81public:82  PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);83};84 85class BPFPreserveStaticOffsetPass86    : public PassInfoMixin<BPFPreserveStaticOffsetPass> {87  bool AllowPartial;88 89public:90  BPFPreserveStaticOffsetPass(bool AllowPartial) : AllowPartial(AllowPartial) {}91  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);92 93  static bool isRequired() { return true; }94 95  static std::pair<GetElementPtrInst *, LoadInst *>96  reconstructLoad(CallInst *Call);97 98  static std::pair<GetElementPtrInst *, StoreInst *>99  reconstructStore(CallInst *Call);100};101 102} // namespace llvm103 104#endif105