LLVM API Documentation

R600RegisterInfo.cpp
Go to the documentation of this file.
00001 //===-- R600RegisterInfo.cpp - R600 Register Information ------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 /// \file
00011 /// \brief R600 implementation of the TargetRegisterInfo class.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #include "R600RegisterInfo.h"
00016 #include "AMDGPUTargetMachine.h"
00017 #include "R600Defines.h"
00018 #include "R600InstrInfo.h"
00019 #include "R600MachineFunctionInfo.h"
00020 
00021 using namespace llvm;
00022 
00023 R600RegisterInfo::R600RegisterInfo(const AMDGPUSubtarget &st)
00024 : AMDGPURegisterInfo(st)
00025   { RCW.RegWeight = 0; RCW.WeightLimit = 0;}
00026 
00027 BitVector R600RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
00028   BitVector Reserved(getNumRegs());
00029 
00030   const R600InstrInfo *TII = static_cast<const R600InstrInfo*>(ST.getInstrInfo());
00031 
00032   Reserved.set(AMDGPU::ZERO);
00033   Reserved.set(AMDGPU::HALF);
00034   Reserved.set(AMDGPU::ONE);
00035   Reserved.set(AMDGPU::ONE_INT);
00036   Reserved.set(AMDGPU::NEG_HALF);
00037   Reserved.set(AMDGPU::NEG_ONE);
00038   Reserved.set(AMDGPU::PV_X);
00039   Reserved.set(AMDGPU::ALU_LITERAL_X);
00040   Reserved.set(AMDGPU::ALU_CONST);
00041   Reserved.set(AMDGPU::PREDICATE_BIT);
00042   Reserved.set(AMDGPU::PRED_SEL_OFF);
00043   Reserved.set(AMDGPU::PRED_SEL_ZERO);
00044   Reserved.set(AMDGPU::PRED_SEL_ONE);
00045   Reserved.set(AMDGPU::INDIRECT_BASE_ADDR);
00046 
00047   for (TargetRegisterClass::iterator I = AMDGPU::R600_AddrRegClass.begin(),
00048                         E = AMDGPU::R600_AddrRegClass.end(); I != E; ++I) {
00049     Reserved.set(*I);
00050   }
00051 
00052   TII->reserveIndirectRegisters(Reserved, MF);
00053 
00054   return Reserved;
00055 }
00056 
00057 unsigned R600RegisterInfo::getHWRegChan(unsigned reg) const {
00058   return this->getEncodingValue(reg) >> HW_CHAN_SHIFT;
00059 }
00060 
00061 unsigned R600RegisterInfo::getHWRegIndex(unsigned Reg) const {
00062   return GET_REG_INDEX(getEncodingValue(Reg));
00063 }
00064 
00065 const TargetRegisterClass * R600RegisterInfo::getCFGStructurizerRegClass(
00066                                                                    MVT VT) const {
00067   switch(VT.SimpleTy) {
00068   default:
00069   case MVT::i32: return &AMDGPU::R600_TReg32RegClass;
00070   }
00071 }
00072 
00073 const RegClassWeight &R600RegisterInfo::getRegClassWeight(
00074   const TargetRegisterClass *RC) const {
00075   return RCW;
00076 }
00077 
00078 bool R600RegisterInfo::isPhysRegLiveAcrossClauses(unsigned Reg) const {
00079   assert(!TargetRegisterInfo::isVirtualRegister(Reg));
00080 
00081   switch (Reg) {
00082   case AMDGPU::OQAP:
00083   case AMDGPU::OQBP:
00084   case AMDGPU::AR_X:
00085     return false;
00086   default:
00087     return true;
00088   }
00089 }