1//===-- BPFInstrInfo.h - BPF Instruction Information ------------*- 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// This file contains the BPF implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_BPF_BPFINSTRINFO_H
14#define LLVM_LIB_TARGET_BPF_BPFINSTRINFO_H
15
16#include "BPFRegisterInfo.h"
17#include "llvm/CodeGen/TargetInstrInfo.h"
18
19#define GET_INSTRINFO_HEADER
20#include "BPFGenInstrInfo.inc"
21
22namespace llvm {
23class BPFSubtarget;
24
25class BPFInstrInfo : public BPFGenInstrInfo {
26 const BPFRegisterInfo RI;
27
28public:
29 explicit BPFInstrInfo(const BPFSubtarget &STI);
30
31 const BPFRegisterInfo &getRegisterInfo() const { return RI; }
32
33 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
34 const DebugLoc &DL, Register DestReg, Register SrcReg,
35 bool KillSrc, bool RenamableDest = false,
36 bool RenamableSrc = false) const override;
37
38 bool expandPostRAPseudo(MachineInstr &MI) const override;
39
40 void storeRegToStackSlot(
41 MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg,
42 bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg,
43 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
44
45 void loadRegFromStackSlot(
46 MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
47 Register DestReg, int FrameIndex, const TargetRegisterClass *RC,
48 Register VReg, unsigned SubReg = 0,
49 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
50 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
51 MachineBasicBlock *&FBB,
52 SmallVectorImpl<MachineOperand> &Cond,
53 bool AllowModify) const override;
54
55 unsigned removeBranch(MachineBasicBlock &MBB,
56 int *BytesRemoved = nullptr) const override;
57 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
58 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
59 const DebugLoc &DL,
60 int *BytesAdded = nullptr) const override;
61
62 int getJumpTableIndex(const MachineInstr &MI) const override;
63
64private:
65 void expandMEMCPY(MachineBasicBlock::iterator) const;
66
67};
68}
69
70#endif
71