LLVM  9.0.0svn
AMDGPURegisterInfo.cpp
Go to the documentation of this file.
1 //===-- AMDGPURegisterInfo.cpp - AMDGPU 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 /// Parent TargetRegisterInfo class common to all hw codegen targets.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "AMDGPURegisterInfo.h"
15 #include "AMDGPUTargetMachine.h"
16 #include "SIMachineFunctionInfo.h"
17 #include "SIRegisterInfo.h"
19 
20 using namespace llvm;
21 
23 
24 //===----------------------------------------------------------------------===//
25 // Function handling callbacks - Functions are a seldom used feature of GPUS, so
26 // they are not supported at this time.
27 //===----------------------------------------------------------------------===//
28 
29 unsigned AMDGPURegisterInfo::getSubRegFromChannel(unsigned Channel) {
30  static const unsigned SubRegs[] = {
31  AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, AMDGPU::sub3, AMDGPU::sub4,
32  AMDGPU::sub5, AMDGPU::sub6, AMDGPU::sub7, AMDGPU::sub8, AMDGPU::sub9,
33  AMDGPU::sub10, AMDGPU::sub11, AMDGPU::sub12, AMDGPU::sub13, AMDGPU::sub14,
34  AMDGPU::sub15
35  };
36 
37  assert(Channel < array_lengthof(SubRegs));
38  return SubRegs[Channel];
39 }
40 
41 void AMDGPURegisterInfo::reserveRegisterTuples(BitVector &Reserved, unsigned Reg) const {
42  MCRegAliasIterator R(Reg, this, true);
43 
44  for (; R.isValid(); ++R)
45  Reserved.set(*R);
46 }
47 
48 #define GET_REGINFO_TARGET_DESC
49 #include "AMDGPUGenRegisterInfo.inc"
50 
51 // Forced to be here by one .inc
53  const MachineFunction *MF) const {
55  switch (CC) {
56  case CallingConv::C:
57  case CallingConv::Fast:
58  case CallingConv::Cold:
59  return CSR_AMDGPU_HighRegs_SaveList;
60  default: {
61  // Dummy to not crash RegisterClassInfo.
62  static const MCPhysReg NoCalleeSavedReg = AMDGPU::NoRegister;
63  return &NoCalleeSavedReg;
64  }
65  }
66 }
67 
68 const MCPhysReg *
70  return nullptr;
71 }
72 
74  CallingConv::ID CC) const {
75  switch (CC) {
76  case CallingConv::C:
77  case CallingConv::Fast:
78  case CallingConv::Cold:
79  return CSR_AMDGPU_HighRegs_RegMask;
80  default:
81  return nullptr;
82  }
83 }
84 
86  const SIMachineFunctionInfo *FuncInfo = MF.getInfo<SIMachineFunctionInfo>();
87  return FuncInfo->getFrameOffsetReg();
88 }
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
BitVector & set()
Definition: BitVector.h:397
Interface definition for SIRegisterInfo.
static unsigned getSubRegFromChannel(unsigned Channel)
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This class represents lattice values for constants.
Definition: AllocatorList.h:23
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
unsigned Reg
TargetRegisterInfo interface that is implemented by all hw codegen targets.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:42
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
unsigned getFrameRegister(const MachineFunction &MF) const override
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
MCRegAliasIterator enumerates all registers aliasing Reg.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
The AMDGPU TargetMachine interface definition for hw codgen targets.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:212
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:1043
const Function & getFunction() const
Return the LLVM function that this machine code represents.
Provides AMDGPU specific target descriptions.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
void reserveRegisterTuples(BitVector &, unsigned Reg) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())