xref: /freebsd/contrib/llvm-project/llvm/lib/Target/BPF/BPFInstrInfo.h (revision 9286d46a794f25482880d29864a8901ef6666fae)
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 
22 namespace llvm {
23 
24 class BPFInstrInfo : public BPFGenInstrInfo {
25   const BPFRegisterInfo RI;
26 
27 public:
28   BPFInstrInfo();
29 
30   const BPFRegisterInfo &getRegisterInfo() const { return RI; }
31 
32   void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
33                    const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,
34                    bool KillSrc) const override;
35 
36   bool expandPostRAPseudo(MachineInstr &MI) const override;
37 
38   void storeRegToStackSlot(MachineBasicBlock &MBB,
39                            MachineBasicBlock::iterator MBBI, Register SrcReg,
40                            bool isKill, int FrameIndex,
41                            const TargetRegisterClass *RC,
42                            const TargetRegisterInfo *TRI,
43                            Register VReg) const override;
44 
45   void loadRegFromStackSlot(MachineBasicBlock &MBB,
46                             MachineBasicBlock::iterator MBBI, Register DestReg,
47                             int FrameIndex, const TargetRegisterClass *RC,
48                             const TargetRegisterInfo *TRI,
49                             Register VReg) 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 private:
62   void expandMEMCPY(MachineBasicBlock::iterator) const;
63 
64 };
65 }
66 
67 #endif
68