LLVM  15.0.0git
R600RegisterInfo.cpp
Go to the documentation of this file.
1 //===-- R600RegisterInfo.cpp - R600 Register Information ------------------===//
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 /// \file
10 /// R600 implementation of the TargetRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "R600RegisterInfo.h"
16 #include "R600Defines.h"
17 #include "R600Subtarget.h"
18 
19 using namespace llvm;
20 
21 #define GET_REGINFO_TARGET_DESC
22 #include "R600GenRegisterInfo.inc"
23 
24 unsigned R600RegisterInfo::getSubRegFromChannel(unsigned Channel) {
25  static const uint16_t SubRegFromChannelTable[] = {
26  R600::sub0, R600::sub1, R600::sub2, R600::sub3,
27  R600::sub4, R600::sub5, R600::sub6, R600::sub7,
28  R600::sub8, R600::sub9, R600::sub10, R600::sub11,
29  R600::sub12, R600::sub13, R600::sub14, R600::sub15
30  };
31 
32  assert(Channel < array_lengthof(SubRegFromChannelTable));
33  return SubRegFromChannelTable[Channel];
34 }
35 
37  BitVector Reserved(getNumRegs());
38 
40  const R600InstrInfo *TII = ST.getInstrInfo();
41 
42  reserveRegisterTuples(Reserved, R600::ZERO);
44  reserveRegisterTuples(Reserved, R600::ONE);
45  reserveRegisterTuples(Reserved, R600::ONE_INT);
46  reserveRegisterTuples(Reserved, R600::NEG_HALF);
47  reserveRegisterTuples(Reserved, R600::NEG_ONE);
48  reserveRegisterTuples(Reserved, R600::PV_X);
49  reserveRegisterTuples(Reserved, R600::ALU_LITERAL_X);
50  reserveRegisterTuples(Reserved, R600::ALU_CONST);
51  reserveRegisterTuples(Reserved, R600::PREDICATE_BIT);
52  reserveRegisterTuples(Reserved, R600::PRED_SEL_OFF);
53  reserveRegisterTuples(Reserved, R600::PRED_SEL_ZERO);
54  reserveRegisterTuples(Reserved, R600::PRED_SEL_ONE);
55  reserveRegisterTuples(Reserved, R600::INDIRECT_BASE_ADDR);
56 
57  for (MCPhysReg R : R600::R600_AddrRegClass)
58  reserveRegisterTuples(Reserved, R);
59 
60  TII->reserveIndirectRegisters(Reserved, MF, *this);
61 
62  return Reserved;
63 }
64 
65 // Dummy to not crash RegisterClassInfo.
66 static const MCPhysReg CalleeSavedReg = R600::NoRegister;
67 
69  const MachineFunction *) const {
70  return &CalleeSavedReg;
71 }
72 
74  return R600::NoRegister;
75 }
76 
77 unsigned R600RegisterInfo::getHWRegChan(unsigned reg) const {
78  return this->getEncodingValue(reg) >> HW_CHAN_SHIFT;
79 }
80 
81 unsigned R600RegisterInfo::getHWRegIndex(unsigned Reg) const {
82  return GET_REG_INDEX(getEncodingValue(Reg));
83 }
84 
86  MVT VT) const {
87  switch(VT.SimpleTy) {
88  default:
89  case MVT::i32: return &R600::R600_TReg32RegClass;
90  }
91 }
92 
94  assert(!Reg.isVirtual());
95 
96  switch (Reg) {
97  case R600::OQAP:
98  case R600::OQBP:
99  case R600::AR_X:
100  return false;
101  default:
102  return true;
103  }
104 }
105 
107  int SPAdj,
108  unsigned FIOperandNum,
109  RegScavenger *RS) const {
110  llvm_unreachable("Subroutines not supported yet");
111 }
112 
113 void R600RegisterInfo::reserveRegisterTuples(BitVector &Reserved, unsigned Reg) const {
114  MCRegAliasIterator R(Reg, this, true);
115 
116  for (; R.isValid(); ++R)
117  Reserved.set(*R);
118 }
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:104
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
GET_REG_INDEX
#define GET_REG_INDEX(reg)
Definition: R600Defines.h:57
llvm::BitVector::set
BitVector & set()
Definition: BitVector.h:344
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
HW_CHAN_SHIFT
#define HW_CHAN_SHIFT
Definition: R600Defines.h:54
llvm::R600RegisterInfo::getSubRegFromChannel
static unsigned getSubRegFromChannel(unsigned Channel)
Definition: R600RegisterInfo.cpp:24
llvm::R600RegisterInfo::getCalleeSavedRegs
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Definition: R600RegisterInfo.cpp:68
llvm::R600RegisterInfo::eliminateFrameIndex
void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
Definition: R600RegisterInfo.cpp:106
llvm::R600RegisterInfo::getCFGStructurizerRegClass
const TargetRegisterClass * getCFGStructurizerRegClass(MVT VT) const
get the register class of the specified type to use in the CFGStructurizer
Definition: R600RegisterInfo.cpp:85
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:45
llvm::MVT::SimpleTy
SimpleValueType SimpleTy
Definition: MachineValueType.h:321
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:127
llvm::R600RegisterInfo::reserveRegisterTuples
void reserveRegisterTuples(BitVector &Reserved, unsigned Reg) const
Definition: R600RegisterInfo.cpp:113
llvm::BitVector
Definition: BitVector.h:75
llvm::R600RegisterInfo::getFrameRegister
Register getFrameRegister(const MachineFunction &MF) const override
Definition: R600RegisterInfo.cpp:73
llvm::array_lengthof
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLArrayExtras.h:29
R600MCTargetDesc.h
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:640
llvm::R600Subtarget
Definition: R600Subtarget.h:29
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::MCPhysReg
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition: MCRegister.h:21
llvm::RegScavenger
Definition: RegisterScavenging.h:34
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::R600RegisterInfo::getHWRegIndex
unsigned getHWRegIndex(unsigned Reg) const
Definition: R600RegisterInfo.cpp:81
llvm::MVT
Machine Value Type.
Definition: MachineValueType.h:31
R600RegisterInfo.h
llvm::MachineFunction
Definition: MachineFunction.h:241
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
HALF
@ HALF
Definition: DXILOpLowering.cpp:34
CalleeSavedReg
static const MCPhysReg CalleeSavedReg
Definition: R600RegisterInfo.cpp:66
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
uint16_t
R600Subtarget.h
llvm::MVT::i32
@ i32
Definition: MachineValueType.h:46
llvm::R600RegisterInfo::getReservedRegs
BitVector getReservedRegs(const MachineFunction &MF) const override
Definition: R600RegisterInfo.cpp:36
llvm::R600InstrInfo
Definition: R600InstrInfo.h:38
llvm::R600RegisterInfo::isPhysRegLiveAcrossClauses
bool isPhysRegLiveAcrossClauses(Register Reg) const
Definition: R600RegisterInfo.cpp:93
R600Defines.h
llvm::R600RegisterInfo::getHWRegChan
unsigned getHWRegChan(unsigned reg) const
get the HW encoding for a register's channel.
Definition: R600RegisterInfo.cpp:77
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::MCRegAliasIterator
MCRegAliasIterator enumerates all registers aliasing Reg.
Definition: MCRegisterInfo.h:788