Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 1 | //===-- RISCVInstrInfo.h - RISCV Instruction Information --------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains the RISCV implementation of the TargetInstrInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_RISCV_RISCVINSTRINFO_H |
| 15 | #define LLVM_LIB_TARGET_RISCV_RISCVINSTRINFO_H |
| 16 | |
| 17 | #include "RISCVRegisterInfo.h" |
David Blaikie | 3f833ed | 2017-11-08 01:01:31 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/TargetInstrInfo.h" |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 19 | |
| 20 | #define GET_INSTRINFO_HEADER |
| 21 | #include "RISCVGenInstrInfo.inc" |
| 22 | |
| 23 | namespace llvm { |
| 24 | |
| 25 | class RISCVInstrInfo : public RISCVGenInstrInfo { |
| 26 | |
| 27 | public: |
| 28 | RISCVInstrInfo(); |
Alex Bradbury | cfa6291 | 2017-11-08 12:20:01 +0000 | [diff] [blame] | 29 | |
| 30 | void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, |
| 31 | const DebugLoc &DL, unsigned DstReg, unsigned SrcReg, |
| 32 | bool KillSrc) const override; |
Alex Bradbury | 74913e1 | 2017-11-08 13:31:40 +0000 | [diff] [blame] | 33 | |
| 34 | void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 35 | MachineBasicBlock::iterator MBBI, unsigned SrcReg, |
| 36 | bool IsKill, int FrameIndex, |
| 37 | const TargetRegisterClass *RC, |
| 38 | const TargetRegisterInfo *TRI) const override; |
| 39 | |
| 40 | void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 41 | MachineBasicBlock::iterator MBBI, unsigned DstReg, |
| 42 | int FrameIndex, const TargetRegisterClass *RC, |
| 43 | const TargetRegisterInfo *TRI) const override; |
Alex Bradbury | 9fea488 | 2018-01-10 19:53:46 +0000 | [diff] [blame] | 44 | |
| 45 | // Materializes the given int32 Val into DstReg. |
| 46 | void movImm32(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, |
| 47 | const DebugLoc &DL, unsigned DstReg, uint64_t Val, |
| 48 | MachineInstr::MIFlag Flag = MachineInstr::NoFlags) const; |
Alex Bradbury | e027c93 | 2018-01-10 20:47:00 +0000 | [diff] [blame] | 49 | |
Alex Bradbury | 315cd3a | 2018-01-10 21:05:07 +0000 | [diff] [blame] | 50 | unsigned getInstSizeInBytes(const MachineInstr &MI) const override; |
| 51 | |
Alex Bradbury | e027c93 | 2018-01-10 20:47:00 +0000 | [diff] [blame] | 52 | bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, |
| 53 | MachineBasicBlock *&FBB, |
| 54 | SmallVectorImpl<MachineOperand> &Cond, |
| 55 | bool AllowModify) const override; |
| 56 | |
| 57 | unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
| 58 | MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, |
| 59 | const DebugLoc &dl, |
| 60 | int *BytesAdded = nullptr) const override; |
| 61 | |
Alex Bradbury | 315cd3a | 2018-01-10 21:05:07 +0000 | [diff] [blame] | 62 | unsigned insertIndirectBranch(MachineBasicBlock &MBB, |
| 63 | MachineBasicBlock &NewDestBB, |
| 64 | const DebugLoc &DL, int64_t BrOffset, |
| 65 | RegScavenger *RS = nullptr) const override; |
| 66 | |
Alex Bradbury | e027c93 | 2018-01-10 20:47:00 +0000 | [diff] [blame] | 67 | unsigned removeBranch(MachineBasicBlock &MBB, |
| 68 | int *BytesRemoved = nullptr) const override; |
| 69 | |
| 70 | bool |
| 71 | reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; |
Alex Bradbury | 315cd3a | 2018-01-10 21:05:07 +0000 | [diff] [blame] | 72 | |
| 73 | MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override; |
| 74 | |
| 75 | bool isBranchOffsetInRange(unsigned BranchOpc, |
| 76 | int64_t BrOffset) const override; |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 77 | }; |
| 78 | } |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 79 | #endif |