xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SPIRV/SPIRVInstrInfo.h (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1 //===-- SPIRVInstrInfo.h - SPIR-V 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 SPIR-V implementation of the TargetInstrInfo class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_SPIRV_SPIRVINSTRINFO_H
14 #define LLVM_LIB_TARGET_SPIRV_SPIRVINSTRINFO_H
15 
16 #include "SPIRVRegisterInfo.h"
17 #include "llvm/CodeGen/TargetInstrInfo.h"
18 
19 #define GET_INSTRINFO_HEADER
20 #include "SPIRVGenInstrInfo.inc"
21 
22 namespace llvm {
23 
24 class SPIRVInstrInfo : public SPIRVGenInstrInfo {
25   const SPIRVRegisterInfo RI;
26 
27 public:
28   SPIRVInstrInfo();
29 
30   const SPIRVRegisterInfo &getRegisterInfo() const { return RI; }
31   bool isHeaderInstr(const MachineInstr &MI) const;
32   bool isConstantInstr(const MachineInstr &MI) const;
33   bool isTypeDeclInstr(const MachineInstr &MI) const;
34   bool isDecorationInstr(const MachineInstr &MI) const;
35 
36   bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
37                      MachineBasicBlock *&FBB,
38                      SmallVectorImpl<MachineOperand> &Cond,
39                      bool AllowModify = false) const override;
40 
41   unsigned removeBranch(MachineBasicBlock &MBB,
42                         int *BytesRemoved = nullptr) const override;
43 
44   unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
45                         MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
46                         const DebugLoc &DL,
47                         int *BytesAdded = nullptr) const override;
48   void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
49                    const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,
50                    bool KillSrc) const override;
51   bool expandPostRAPseudo(MachineInstr &MI) const override;
52 };
53 } // namespace llvm
54 
55 #endif // LLVM_LIB_TARGET_SPIRV_SPIRVINSTRINFO_H
56