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