10b57cec5SDimitry Andric //===-- HexagonRegisterInfo.cpp - Hexagon Register Information ------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file contains the Hexagon implementation of the TargetRegisterInfo 100b57cec5SDimitry Andric // class. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #include "HexagonRegisterInfo.h" 150b57cec5SDimitry Andric #include "Hexagon.h" 160b57cec5SDimitry Andric #include "HexagonMachineFunctionInfo.h" 170b57cec5SDimitry Andric #include "HexagonSubtarget.h" 180b57cec5SDimitry Andric #include "HexagonTargetMachine.h" 190b57cec5SDimitry Andric #include "llvm/ADT/BitVector.h" 200b57cec5SDimitry Andric #include "llvm/ADT/STLExtras.h" 210b57cec5SDimitry Andric #include "llvm/CodeGen/LiveIntervals.h" 220b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFrameInfo.h" 230b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h" 240b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunctionPass.h" 250b57cec5SDimitry Andric #include "llvm/CodeGen/MachineInstrBuilder.h" 260b57cec5SDimitry Andric #include "llvm/CodeGen/MachineRegisterInfo.h" 270b57cec5SDimitry Andric #include "llvm/CodeGen/PseudoSourceValue.h" 280b57cec5SDimitry Andric #include "llvm/CodeGen/RegisterScavenging.h" 290b57cec5SDimitry Andric #include "llvm/CodeGen/TargetInstrInfo.h" 300b57cec5SDimitry Andric #include "llvm/IR/Function.h" 310b57cec5SDimitry Andric #include "llvm/IR/Type.h" 320b57cec5SDimitry Andric #include "llvm/MC/MachineLocation.h" 330b57cec5SDimitry Andric #include "llvm/Support/Debug.h" 340b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h" 350b57cec5SDimitry Andric #include "llvm/Support/raw_ostream.h" 360b57cec5SDimitry Andric #include "llvm/Target/TargetMachine.h" 370b57cec5SDimitry Andric #include "llvm/Target/TargetOptions.h" 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric #define GET_REGINFO_TARGET_DESC 400b57cec5SDimitry Andric #include "HexagonGenRegisterInfo.inc" 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric using namespace llvm; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric HexagonRegisterInfo::HexagonRegisterInfo(unsigned HwMode) 450b57cec5SDimitry Andric : HexagonGenRegisterInfo(Hexagon::R31, 0/*DwarfFlavor*/, 0/*EHFlavor*/, 460b57cec5SDimitry Andric 0/*PC*/, HwMode) {} 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric bool HexagonRegisterInfo::isEHReturnCalleeSaveReg(unsigned R) const { 500b57cec5SDimitry Andric return R == Hexagon::R0 || R == Hexagon::R1 || R == Hexagon::R2 || 510b57cec5SDimitry Andric R == Hexagon::R3 || R == Hexagon::D0 || R == Hexagon::D1; 520b57cec5SDimitry Andric } 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric const MCPhysReg * 550b57cec5SDimitry Andric HexagonRegisterInfo::getCallerSavedRegs(const MachineFunction *MF, 560b57cec5SDimitry Andric const TargetRegisterClass *RC) const { 570b57cec5SDimitry Andric using namespace Hexagon; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric static const MCPhysReg Int32[] = { 600b57cec5SDimitry Andric R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, 0 610b57cec5SDimitry Andric }; 620b57cec5SDimitry Andric static const MCPhysReg Int64[] = { 630b57cec5SDimitry Andric D0, D1, D2, D3, D4, D5, D6, D7, 0 640b57cec5SDimitry Andric }; 650b57cec5SDimitry Andric static const MCPhysReg Pred[] = { 660b57cec5SDimitry Andric P0, P1, P2, P3, 0 670b57cec5SDimitry Andric }; 680b57cec5SDimitry Andric static const MCPhysReg VecSgl[] = { 690b57cec5SDimitry Andric V0, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, 700b57cec5SDimitry Andric V14, V15, V16, V17, V18, V19, V20, V21, V22, V23, V24, V25, V26, V27, 710b57cec5SDimitry Andric V28, V29, V30, V31, 0 720b57cec5SDimitry Andric }; 730b57cec5SDimitry Andric static const MCPhysReg VecDbl[] = { 740b57cec5SDimitry Andric W0, W1, W2, W3, W4, W5, W6, W7, W8, W9, W10, W11, W12, W13, W14, W15, 0 750b57cec5SDimitry Andric }; 76480093f4SDimitry Andric static const MCPhysReg VecPred[] = { 77480093f4SDimitry Andric Q0, Q1, Q2, Q3, 0 78480093f4SDimitry Andric }; 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric switch (RC->getID()) { 810b57cec5SDimitry Andric case IntRegsRegClassID: 820b57cec5SDimitry Andric return Int32; 830b57cec5SDimitry Andric case DoubleRegsRegClassID: 840b57cec5SDimitry Andric return Int64; 850b57cec5SDimitry Andric case PredRegsRegClassID: 860b57cec5SDimitry Andric return Pred; 870b57cec5SDimitry Andric case HvxVRRegClassID: 880b57cec5SDimitry Andric return VecSgl; 890b57cec5SDimitry Andric case HvxWRRegClassID: 900b57cec5SDimitry Andric return VecDbl; 91480093f4SDimitry Andric case HvxQRRegClassID: 92480093f4SDimitry Andric return VecPred; 930b57cec5SDimitry Andric default: 940b57cec5SDimitry Andric break; 950b57cec5SDimitry Andric } 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric static const MCPhysReg Empty[] = { 0 }; 980b57cec5SDimitry Andric #ifndef NDEBUG 990b57cec5SDimitry Andric dbgs() << "Register class: " << getRegClassName(RC) << "\n"; 1000b57cec5SDimitry Andric #endif 1010b57cec5SDimitry Andric llvm_unreachable("Unexpected register class"); 1020b57cec5SDimitry Andric return Empty; 1030b57cec5SDimitry Andric } 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric const MCPhysReg * 1070b57cec5SDimitry Andric HexagonRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { 1080b57cec5SDimitry Andric static const MCPhysReg CalleeSavedRegsV3[] = { 1090b57cec5SDimitry Andric Hexagon::R16, Hexagon::R17, Hexagon::R18, Hexagon::R19, 1100b57cec5SDimitry Andric Hexagon::R20, Hexagon::R21, Hexagon::R22, Hexagon::R23, 1110b57cec5SDimitry Andric Hexagon::R24, Hexagon::R25, Hexagon::R26, Hexagon::R27, 0 1120b57cec5SDimitry Andric }; 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andric // Functions that contain a call to __builtin_eh_return also save the first 4 1150b57cec5SDimitry Andric // parameter registers. 1160b57cec5SDimitry Andric static const MCPhysReg CalleeSavedRegsV3EHReturn[] = { 1170b57cec5SDimitry Andric Hexagon::R0, Hexagon::R1, Hexagon::R2, Hexagon::R3, 1180b57cec5SDimitry Andric Hexagon::R16, Hexagon::R17, Hexagon::R18, Hexagon::R19, 1190b57cec5SDimitry Andric Hexagon::R20, Hexagon::R21, Hexagon::R22, Hexagon::R23, 1200b57cec5SDimitry Andric Hexagon::R24, Hexagon::R25, Hexagon::R26, Hexagon::R27, 0 1210b57cec5SDimitry Andric }; 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andric bool HasEHReturn = MF->getInfo<HexagonMachineFunctionInfo>()->hasEHReturn(); 1240b57cec5SDimitry Andric 1250b57cec5SDimitry Andric return HasEHReturn ? CalleeSavedRegsV3EHReturn : CalleeSavedRegsV3; 1260b57cec5SDimitry Andric } 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andric 1290b57cec5SDimitry Andric const uint32_t *HexagonRegisterInfo::getCallPreservedMask( 1300b57cec5SDimitry Andric const MachineFunction &MF, CallingConv::ID) const { 1310b57cec5SDimitry Andric return HexagonCSR_RegMask; 1320b57cec5SDimitry Andric } 1330b57cec5SDimitry Andric 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric BitVector HexagonRegisterInfo::getReservedRegs(const MachineFunction &MF) 1360b57cec5SDimitry Andric const { 1370b57cec5SDimitry Andric BitVector Reserved(getNumRegs()); 1380b57cec5SDimitry Andric Reserved.set(Hexagon::R29); 1390b57cec5SDimitry Andric Reserved.set(Hexagon::R30); 1400b57cec5SDimitry Andric Reserved.set(Hexagon::R31); 1410b57cec5SDimitry Andric Reserved.set(Hexagon::VTMP); 1420b57cec5SDimitry Andric 1430b57cec5SDimitry Andric // Guest registers. 1440b57cec5SDimitry Andric Reserved.set(Hexagon::GELR); // G0 1450b57cec5SDimitry Andric Reserved.set(Hexagon::GSR); // G1 1460b57cec5SDimitry Andric Reserved.set(Hexagon::GOSP); // G2 1470b57cec5SDimitry Andric Reserved.set(Hexagon::G3); // G3 1480b57cec5SDimitry Andric 1490b57cec5SDimitry Andric // Control registers. 1500b57cec5SDimitry Andric Reserved.set(Hexagon::SA0); // C0 1510b57cec5SDimitry Andric Reserved.set(Hexagon::LC0); // C1 1520b57cec5SDimitry Andric Reserved.set(Hexagon::SA1); // C2 1530b57cec5SDimitry Andric Reserved.set(Hexagon::LC1); // C3 1540b57cec5SDimitry Andric Reserved.set(Hexagon::P3_0); // C4 1550b57cec5SDimitry Andric Reserved.set(Hexagon::USR); // C8 1560b57cec5SDimitry Andric Reserved.set(Hexagon::PC); // C9 1570b57cec5SDimitry Andric Reserved.set(Hexagon::UGP); // C10 1580b57cec5SDimitry Andric Reserved.set(Hexagon::GP); // C11 1590b57cec5SDimitry Andric Reserved.set(Hexagon::CS0); // C12 1600b57cec5SDimitry Andric Reserved.set(Hexagon::CS1); // C13 1610b57cec5SDimitry Andric Reserved.set(Hexagon::UPCYCLELO); // C14 1620b57cec5SDimitry Andric Reserved.set(Hexagon::UPCYCLEHI); // C15 1630b57cec5SDimitry Andric Reserved.set(Hexagon::FRAMELIMIT); // C16 1640b57cec5SDimitry Andric Reserved.set(Hexagon::FRAMEKEY); // C17 1650b57cec5SDimitry Andric Reserved.set(Hexagon::PKTCOUNTLO); // C18 1660b57cec5SDimitry Andric Reserved.set(Hexagon::PKTCOUNTHI); // C19 1670b57cec5SDimitry Andric Reserved.set(Hexagon::UTIMERLO); // C30 1680b57cec5SDimitry Andric Reserved.set(Hexagon::UTIMERHI); // C31 1690b57cec5SDimitry Andric // Out of the control registers, only C8 is explicitly defined in 1700b57cec5SDimitry Andric // HexagonRegisterInfo.td. If others are defined, make sure to add 1710b57cec5SDimitry Andric // them here as well. 1720b57cec5SDimitry Andric Reserved.set(Hexagon::C8); 1730b57cec5SDimitry Andric Reserved.set(Hexagon::USR_OVF); 1740b57cec5SDimitry Andric 1755ffd83dbSDimitry Andric // Leveraging these registers will require more work to recognize 1765ffd83dbSDimitry Andric // the new semantics posed, Hi/LoVec patterns, etc. 1775ffd83dbSDimitry Andric // Note well: if enabled, they should be restricted to only 1785ffd83dbSDimitry Andric // where `HST.useHVXOps() && HST.hasV67Ops()` is true. 1795ffd83dbSDimitry Andric for (auto Reg : Hexagon_MC::GetVectRegRev()) 1805ffd83dbSDimitry Andric Reserved.set(Reg); 1815ffd83dbSDimitry Andric 1820b57cec5SDimitry Andric if (MF.getSubtarget<HexagonSubtarget>().hasReservedR19()) 1830b57cec5SDimitry Andric Reserved.set(Hexagon::R19); 1840b57cec5SDimitry Andric 1850b57cec5SDimitry Andric for (int x = Reserved.find_first(); x >= 0; x = Reserved.find_next(x)) 1860b57cec5SDimitry Andric markSuperRegs(Reserved, x); 1870b57cec5SDimitry Andric 1880b57cec5SDimitry Andric return Reserved; 1890b57cec5SDimitry Andric } 1900b57cec5SDimitry Andric 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric void HexagonRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, 1930b57cec5SDimitry Andric int SPAdj, unsigned FIOp, 1940b57cec5SDimitry Andric RegScavenger *RS) const { 1950b57cec5SDimitry Andric // 1960b57cec5SDimitry Andric // Hexagon_TODO: Do we need to enforce this for Hexagon? 1970b57cec5SDimitry Andric assert(SPAdj == 0 && "Unexpected"); 1980b57cec5SDimitry Andric 1990b57cec5SDimitry Andric MachineInstr &MI = *II; 2000b57cec5SDimitry Andric MachineBasicBlock &MB = *MI.getParent(); 2010b57cec5SDimitry Andric MachineFunction &MF = *MB.getParent(); 2020b57cec5SDimitry Andric auto &HST = MF.getSubtarget<HexagonSubtarget>(); 2030b57cec5SDimitry Andric auto &HII = *HST.getInstrInfo(); 2040b57cec5SDimitry Andric auto &HFI = *HST.getFrameLowering(); 2050b57cec5SDimitry Andric 2065ffd83dbSDimitry Andric Register BP; 2070b57cec5SDimitry Andric int FI = MI.getOperand(FIOp).getIndex(); 2080b57cec5SDimitry Andric // Select the base pointer (BP) and calculate the actual offset from BP 2090b57cec5SDimitry Andric // to the beginning of the object at index FI. 210*e8d8bef9SDimitry Andric int Offset = HFI.getFrameIndexReference(MF, FI, BP).getFixed(); 2110b57cec5SDimitry Andric // Add the offset from the instruction. 2120b57cec5SDimitry Andric int RealOffset = Offset + MI.getOperand(FIOp+1).getImm(); 2130b57cec5SDimitry Andric bool IsKill = false; 2140b57cec5SDimitry Andric 2150b57cec5SDimitry Andric unsigned Opc = MI.getOpcode(); 2160b57cec5SDimitry Andric switch (Opc) { 2170b57cec5SDimitry Andric case Hexagon::PS_fia: 2180b57cec5SDimitry Andric MI.setDesc(HII.get(Hexagon::A2_addi)); 2190b57cec5SDimitry Andric MI.getOperand(FIOp).ChangeToImmediate(RealOffset); 2200b57cec5SDimitry Andric MI.RemoveOperand(FIOp+1); 2210b57cec5SDimitry Andric return; 2220b57cec5SDimitry Andric case Hexagon::PS_fi: 2230b57cec5SDimitry Andric // Set up the instruction for updating below. 2240b57cec5SDimitry Andric MI.setDesc(HII.get(Hexagon::A2_addi)); 2250b57cec5SDimitry Andric break; 2260b57cec5SDimitry Andric } 2270b57cec5SDimitry Andric 2280b57cec5SDimitry Andric if (!HII.isValidOffset(Opc, RealOffset, this)) { 2290b57cec5SDimitry Andric // If the offset is not valid, calculate the address in a temporary 2300b57cec5SDimitry Andric // register and use it with offset 0. 2310b57cec5SDimitry Andric auto &MRI = MF.getRegInfo(); 2328bcb0991SDimitry Andric Register TmpR = MRI.createVirtualRegister(&Hexagon::IntRegsRegClass); 2330b57cec5SDimitry Andric const DebugLoc &DL = MI.getDebugLoc(); 2340b57cec5SDimitry Andric BuildMI(MB, II, DL, HII.get(Hexagon::A2_addi), TmpR) 2350b57cec5SDimitry Andric .addReg(BP) 2360b57cec5SDimitry Andric .addImm(RealOffset); 2370b57cec5SDimitry Andric BP = TmpR; 2380b57cec5SDimitry Andric RealOffset = 0; 2390b57cec5SDimitry Andric IsKill = true; 2400b57cec5SDimitry Andric } 2410b57cec5SDimitry Andric 2420b57cec5SDimitry Andric MI.getOperand(FIOp).ChangeToRegister(BP, false, false, IsKill); 2430b57cec5SDimitry Andric MI.getOperand(FIOp+1).ChangeToImmediate(RealOffset); 2440b57cec5SDimitry Andric } 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andric 2470b57cec5SDimitry Andric bool HexagonRegisterInfo::shouldCoalesce(MachineInstr *MI, 2480b57cec5SDimitry Andric const TargetRegisterClass *SrcRC, unsigned SubReg, 2490b57cec5SDimitry Andric const TargetRegisterClass *DstRC, unsigned DstSubReg, 2500b57cec5SDimitry Andric const TargetRegisterClass *NewRC, LiveIntervals &LIS) const { 2510b57cec5SDimitry Andric // Coalescing will extend the live interval of the destination register. 2520b57cec5SDimitry Andric // If the destination register is a vector pair, avoid introducing function 2530b57cec5SDimitry Andric // calls into the interval, since it could result in a spilling of a pair 2540b57cec5SDimitry Andric // instead of a single vector. 2550b57cec5SDimitry Andric MachineFunction &MF = *MI->getParent()->getParent(); 2560b57cec5SDimitry Andric const HexagonSubtarget &HST = MF.getSubtarget<HexagonSubtarget>(); 2570b57cec5SDimitry Andric if (!HST.useHVXOps() || NewRC->getID() != Hexagon::HvxWRRegClass.getID()) 2580b57cec5SDimitry Andric return true; 2590b57cec5SDimitry Andric bool SmallSrc = SrcRC->getID() == Hexagon::HvxVRRegClass.getID(); 2600b57cec5SDimitry Andric bool SmallDst = DstRC->getID() == Hexagon::HvxVRRegClass.getID(); 2610b57cec5SDimitry Andric if (!SmallSrc && !SmallDst) 2620b57cec5SDimitry Andric return true; 2630b57cec5SDimitry Andric 2648bcb0991SDimitry Andric Register DstReg = MI->getOperand(0).getReg(); 2658bcb0991SDimitry Andric Register SrcReg = MI->getOperand(1).getReg(); 2660b57cec5SDimitry Andric const SlotIndexes &Indexes = *LIS.getSlotIndexes(); 2670b57cec5SDimitry Andric auto HasCall = [&Indexes] (const LiveInterval::Segment &S) { 2680b57cec5SDimitry Andric for (SlotIndex I = S.start.getBaseIndex(), E = S.end.getBaseIndex(); 2690b57cec5SDimitry Andric I != E; I = I.getNextIndex()) { 2700b57cec5SDimitry Andric if (const MachineInstr *MI = Indexes.getInstructionFromIndex(I)) 2710b57cec5SDimitry Andric if (MI->isCall()) 2720b57cec5SDimitry Andric return true; 2730b57cec5SDimitry Andric } 2740b57cec5SDimitry Andric return false; 2750b57cec5SDimitry Andric }; 2760b57cec5SDimitry Andric 2770b57cec5SDimitry Andric if (SmallSrc == SmallDst) { 2780b57cec5SDimitry Andric // Both must be true, because the case for both being false was 2790b57cec5SDimitry Andric // checked earlier. Both registers will be coalesced into a register 2800b57cec5SDimitry Andric // of a wider class (HvxWR), and we don't want its live range to 2810b57cec5SDimitry Andric // span over calls. 2820b57cec5SDimitry Andric return !any_of(LIS.getInterval(DstReg), HasCall) && 2830b57cec5SDimitry Andric !any_of(LIS.getInterval(SrcReg), HasCall); 2840b57cec5SDimitry Andric } 2850b57cec5SDimitry Andric 2860b57cec5SDimitry Andric // If one register is large (HvxWR) and the other is small (HvxVR), then 2870b57cec5SDimitry Andric // coalescing is ok if the large is already live across a function call, 2880b57cec5SDimitry Andric // or if the small one is not. 2890b57cec5SDimitry Andric unsigned SmallReg = SmallSrc ? SrcReg : DstReg; 2900b57cec5SDimitry Andric unsigned LargeReg = SmallSrc ? DstReg : SrcReg; 2910b57cec5SDimitry Andric return any_of(LIS.getInterval(LargeReg), HasCall) || 2920b57cec5SDimitry Andric !any_of(LIS.getInterval(SmallReg), HasCall); 2930b57cec5SDimitry Andric } 2940b57cec5SDimitry Andric 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric unsigned HexagonRegisterInfo::getRARegister() const { 2970b57cec5SDimitry Andric return Hexagon::R31; 2980b57cec5SDimitry Andric } 2990b57cec5SDimitry Andric 3000b57cec5SDimitry Andric 3010b57cec5SDimitry Andric Register HexagonRegisterInfo::getFrameRegister(const MachineFunction 3020b57cec5SDimitry Andric &MF) const { 3030b57cec5SDimitry Andric const HexagonFrameLowering *TFI = getFrameLowering(MF); 3040b57cec5SDimitry Andric if (TFI->hasFP(MF)) 3050b57cec5SDimitry Andric return getFrameRegister(); 3060b57cec5SDimitry Andric return getStackRegister(); 3070b57cec5SDimitry Andric } 3080b57cec5SDimitry Andric 3090b57cec5SDimitry Andric 3100b57cec5SDimitry Andric unsigned HexagonRegisterInfo::getFrameRegister() const { 3110b57cec5SDimitry Andric return Hexagon::R30; 3120b57cec5SDimitry Andric } 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andric 3150b57cec5SDimitry Andric unsigned HexagonRegisterInfo::getStackRegister() const { 3160b57cec5SDimitry Andric return Hexagon::R29; 3170b57cec5SDimitry Andric } 3180b57cec5SDimitry Andric 3190b57cec5SDimitry Andric 3200b57cec5SDimitry Andric unsigned HexagonRegisterInfo::getHexagonSubRegIndex( 3210b57cec5SDimitry Andric const TargetRegisterClass &RC, unsigned GenIdx) const { 3220b57cec5SDimitry Andric assert(GenIdx == Hexagon::ps_sub_lo || GenIdx == Hexagon::ps_sub_hi); 3230b57cec5SDimitry Andric 3240b57cec5SDimitry Andric static const unsigned ISub[] = { Hexagon::isub_lo, Hexagon::isub_hi }; 3250b57cec5SDimitry Andric static const unsigned VSub[] = { Hexagon::vsub_lo, Hexagon::vsub_hi }; 3260b57cec5SDimitry Andric static const unsigned WSub[] = { Hexagon::wsub_lo, Hexagon::wsub_hi }; 3270b57cec5SDimitry Andric 3280b57cec5SDimitry Andric switch (RC.getID()) { 3290b57cec5SDimitry Andric case Hexagon::CtrRegs64RegClassID: 3300b57cec5SDimitry Andric case Hexagon::DoubleRegsRegClassID: 3310b57cec5SDimitry Andric return ISub[GenIdx]; 3320b57cec5SDimitry Andric case Hexagon::HvxWRRegClassID: 3330b57cec5SDimitry Andric return VSub[GenIdx]; 3340b57cec5SDimitry Andric case Hexagon::HvxVQRRegClassID: 3350b57cec5SDimitry Andric return WSub[GenIdx]; 3360b57cec5SDimitry Andric } 3370b57cec5SDimitry Andric 3380b57cec5SDimitry Andric if (const TargetRegisterClass *SuperRC = *RC.getSuperClasses()) 3390b57cec5SDimitry Andric return getHexagonSubRegIndex(*SuperRC, GenIdx); 3400b57cec5SDimitry Andric 3410b57cec5SDimitry Andric llvm_unreachable("Invalid register class"); 3420b57cec5SDimitry Andric } 3430b57cec5SDimitry Andric 3440b57cec5SDimitry Andric bool HexagonRegisterInfo::useFPForScavengingIndex(const MachineFunction &MF) 3450b57cec5SDimitry Andric const { 3460b57cec5SDimitry Andric return MF.getSubtarget<HexagonSubtarget>().getFrameLowering()->hasFP(MF); 3470b57cec5SDimitry Andric } 3480b57cec5SDimitry Andric 3490b57cec5SDimitry Andric const TargetRegisterClass * 3500b57cec5SDimitry Andric HexagonRegisterInfo::getPointerRegClass(const MachineFunction &MF, 3510b57cec5SDimitry Andric unsigned Kind) const { 3520b57cec5SDimitry Andric return &Hexagon::IntRegsRegClass; 3530b57cec5SDimitry Andric } 3540b57cec5SDimitry Andric 3550b57cec5SDimitry Andric unsigned HexagonRegisterInfo::getFirstCallerSavedNonParamReg() const { 3560b57cec5SDimitry Andric return Hexagon::R6; 3570b57cec5SDimitry Andric } 3580b57cec5SDimitry Andric 359