1 //===-- R600RegisterInfo.cpp - R600 Register Information ------------------===//
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
7 //===----------------------------------------------------------------------===//
10 /// R600 implementation of the TargetRegisterInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "R600RegisterInfo.h"
15 #include "AMDGPUTargetMachine.h"
16 #include "R600Defines.h"
17 #include "R600InstrInfo.h"
18 #include "R600MachineFunctionInfo.h"
19 #include "MCTargetDesc/AMDGPUMCTargetDesc.h"
23 R600RegisterInfo::R600RegisterInfo() : R600GenRegisterInfo(0) {
28 #define GET_REGINFO_TARGET_DESC
29 #include "R600GenRegisterInfo.inc"
31 BitVector
R600RegisterInfo::getReservedRegs(const MachineFunction
&MF
) const {
32 BitVector
Reserved(getNumRegs());
34 const R600Subtarget
&ST
= MF
.getSubtarget
<R600Subtarget
>();
35 const R600InstrInfo
*TII
= ST
.getInstrInfo();
37 reserveRegisterTuples(Reserved
, R600::ZERO
);
38 reserveRegisterTuples(Reserved
, R600::HALF
);
39 reserveRegisterTuples(Reserved
, R600::ONE
);
40 reserveRegisterTuples(Reserved
, R600::ONE_INT
);
41 reserveRegisterTuples(Reserved
, R600::NEG_HALF
);
42 reserveRegisterTuples(Reserved
, R600::NEG_ONE
);
43 reserveRegisterTuples(Reserved
, R600::PV_X
);
44 reserveRegisterTuples(Reserved
, R600::ALU_LITERAL_X
);
45 reserveRegisterTuples(Reserved
, R600::ALU_CONST
);
46 reserveRegisterTuples(Reserved
, R600::PREDICATE_BIT
);
47 reserveRegisterTuples(Reserved
, R600::PRED_SEL_OFF
);
48 reserveRegisterTuples(Reserved
, R600::PRED_SEL_ZERO
);
49 reserveRegisterTuples(Reserved
, R600::PRED_SEL_ONE
);
50 reserveRegisterTuples(Reserved
, R600::INDIRECT_BASE_ADDR
);
52 for (TargetRegisterClass::iterator I
= R600::R600_AddrRegClass
.begin(),
53 E
= R600::R600_AddrRegClass
.end(); I
!= E
; ++I
) {
54 reserveRegisterTuples(Reserved
, *I
);
57 TII
->reserveIndirectRegisters(Reserved
, MF
, *this);
62 // Dummy to not crash RegisterClassInfo.
63 static const MCPhysReg CalleeSavedReg
= R600::NoRegister
;
65 const MCPhysReg
*R600RegisterInfo::getCalleeSavedRegs(
66 const MachineFunction
*) const {
67 return &CalleeSavedReg
;
70 Register
R600RegisterInfo::getFrameRegister(const MachineFunction
&MF
) const {
71 return R600::NoRegister
;
74 unsigned R600RegisterInfo::getHWRegChan(unsigned reg
) const {
75 return this->getEncodingValue(reg
) >> HW_CHAN_SHIFT
;
78 unsigned R600RegisterInfo::getHWRegIndex(unsigned Reg
) const {
79 return GET_REG_INDEX(getEncodingValue(Reg
));
82 const TargetRegisterClass
* R600RegisterInfo::getCFGStructurizerRegClass(
86 case MVT::i32
: return &R600::R600_TReg32RegClass
;
90 const RegClassWeight
&R600RegisterInfo::getRegClassWeight(
91 const TargetRegisterClass
*RC
) const {
95 bool R600RegisterInfo::isPhysRegLiveAcrossClauses(unsigned Reg
) const {
96 assert(!Register::isVirtualRegister(Reg
));
108 void R600RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI
,
110 unsigned FIOperandNum
,
111 RegScavenger
*RS
) const {
112 llvm_unreachable("Subroutines not supported yet");
115 void R600RegisterInfo::reserveRegisterTuples(BitVector
&Reserved
, unsigned Reg
) const {
116 MCRegAliasIterator
R(Reg
, this, true);
118 for (; R
.isValid(); ++R
)