[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / Target / RISCV / RISCVRegisterInfo.h
blob8b729caa5f713f9214648881f07ef503f0f52f83
1 //===-- RISCVRegisterInfo.h - RISC-V Register Information Impl --*- 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 RISC-V implementation of the TargetRegisterInfo class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_RISCV_RISCVREGISTERINFO_H
14 #define LLVM_LIB_TARGET_RISCV_RISCVREGISTERINFO_H
16 #include "llvm/CodeGen/TargetRegisterInfo.h"
18 #define GET_REGINFO_HEADER
19 #include "RISCVGenRegisterInfo.inc"
21 namespace llvm {
23 struct RISCVRegisterInfo : public RISCVGenRegisterInfo {
25 RISCVRegisterInfo(unsigned HwMode);
27 const uint32_t *getCallPreservedMask(const MachineFunction &MF,
28 CallingConv::ID) const override;
30 const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
32 BitVector getReservedRegs(const MachineFunction &MF) const override;
33 bool isAsmClobberable(const MachineFunction &MF,
34 MCRegister PhysReg) const override;
36 const uint32_t *getNoPreservedMask() const override;
38 bool hasReservedSpillSlot(const MachineFunction &MF, Register Reg,
39 int &FrameIdx) const override;
41 // Update DestReg to have the value SrcReg plus an offset. This is
42 // used during frame layout, and we may need to ensure that if we
43 // split the offset internally that the DestReg is always aligned,
44 // assuming that source reg was.
45 void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator II,
46 const DebugLoc &DL, Register DestReg, Register SrcReg,
47 StackOffset Offset, MachineInstr::MIFlag Flag,
48 MaybeAlign RequiredAlign) const;
50 bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj,
51 unsigned FIOperandNum,
52 RegScavenger *RS = nullptr) const override;
54 bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override;
56 bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override;
58 bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg,
59 int64_t Offset) const override;
61 Register materializeFrameBaseRegister(MachineBasicBlock *MBB, int FrameIdx,
62 int64_t Offset) const override;
64 void resolveFrameIndex(MachineInstr &MI, Register BaseReg,
65 int64_t Offset) const override;
67 int64_t getFrameIndexInstrOffset(const MachineInstr *MI,
68 int Idx) const override;
70 void lowerVSPILL(MachineBasicBlock::iterator II) const;
71 void lowerVRELOAD(MachineBasicBlock::iterator II) const;
73 Register getFrameRegister(const MachineFunction &MF) const override;
75 bool requiresRegisterScavenging(const MachineFunction &MF) const override {
76 return true;
79 bool requiresFrameIndexScavenging(const MachineFunction &MF) const override {
80 return true;
83 const TargetRegisterClass *
84 getPointerRegClass(const MachineFunction &MF,
85 unsigned Kind = 0) const override {
86 return &RISCV::GPRRegClass;
89 const TargetRegisterClass *
90 getLargestLegalSuperClass(const TargetRegisterClass *RC,
91 const MachineFunction &) const override;
93 void getOffsetOpcodes(const StackOffset &Offset,
94 SmallVectorImpl<uint64_t> &Ops) const override;
96 unsigned getRegisterCostTableIndex(const MachineFunction &MF) const override;
98 bool getRegAllocationHints(Register VirtReg, ArrayRef<MCPhysReg> Order,
99 SmallVectorImpl<MCPhysReg> &Hints,
100 const MachineFunction &MF, const VirtRegMap *VRM,
101 const LiveRegMatrix *Matrix) const override;
105 #endif