[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / lib / Target / RISCV / RISCVInstrInfo.h
blobd3ae04aefe04a36293462b5e772be839152ea40d
1 //===-- RISCVInstrInfo.h - RISCV 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 RISCV implementation of the TargetInstrInfo class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_RISCV_RISCVINSTRINFO_H
14 #define LLVM_LIB_TARGET_RISCV_RISCVINSTRINFO_H
16 #include "RISCVRegisterInfo.h"
17 #include "llvm/CodeGen/TargetInstrInfo.h"
19 #define GET_INSTRINFO_HEADER
20 #include "RISCVGenInstrInfo.inc"
22 namespace llvm {
24 class RISCVSubtarget;
26 class RISCVInstrInfo : public RISCVGenInstrInfo {
28 public:
29 explicit RISCVInstrInfo(RISCVSubtarget &STI);
31 unsigned isLoadFromStackSlot(const MachineInstr &MI,
32 int &FrameIndex) const override;
33 unsigned isStoreToStackSlot(const MachineInstr &MI,
34 int &FrameIndex) const override;
36 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
37 const DebugLoc &DL, unsigned DstReg, unsigned SrcReg,
38 bool KillSrc) const override;
40 void storeRegToStackSlot(MachineBasicBlock &MBB,
41 MachineBasicBlock::iterator MBBI, unsigned SrcReg,
42 bool IsKill, int FrameIndex,
43 const TargetRegisterClass *RC,
44 const TargetRegisterInfo *TRI) const override;
46 void loadRegFromStackSlot(MachineBasicBlock &MBB,
47 MachineBasicBlock::iterator MBBI, unsigned DstReg,
48 int FrameIndex, const TargetRegisterClass *RC,
49 const TargetRegisterInfo *TRI) const override;
51 // Materializes the given integer Val into DstReg.
52 void movImm(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
53 const DebugLoc &DL, Register DstReg, uint64_t Val,
54 MachineInstr::MIFlag Flag = MachineInstr::NoFlags) const;
56 unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
58 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
59 MachineBasicBlock *&FBB,
60 SmallVectorImpl<MachineOperand> &Cond,
61 bool AllowModify) const override;
63 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
64 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
65 const DebugLoc &dl,
66 int *BytesAdded = nullptr) const override;
68 unsigned insertIndirectBranch(MachineBasicBlock &MBB,
69 MachineBasicBlock &NewDestBB,
70 const DebugLoc &DL, int64_t BrOffset,
71 RegScavenger *RS = nullptr) const override;
73 unsigned removeBranch(MachineBasicBlock &MBB,
74 int *BytesRemoved = nullptr) const override;
76 bool
77 reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
79 MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;
81 bool isBranchOffsetInRange(unsigned BranchOpc,
82 int64_t BrOffset) const override;
84 bool isAsCheapAsAMove(const MachineInstr &MI) const override;
86 bool verifyInstruction(const MachineInstr &MI,
87 StringRef &ErrInfo) const override;
89 protected:
90 const RISCVSubtarget &STI;
93 #endif