Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 1 | //===- PPC32RegisterInfo.cpp - PowerPC32 Register Information ---*- C++ -*-===// |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 2 | // |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 7 | // |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains the PowerPC32 implementation of the MRegisterInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #define DEBUG_TYPE "reginfo" |
| 15 | #include "PowerPC.h" |
| 16 | #include "PowerPCInstrBuilder.h" |
| 17 | #include "PPC32RegisterInfo.h" |
| 18 | #include "llvm/Constants.h" |
| 19 | #include "llvm/Type.h" |
| 20 | #include "llvm/CodeGen/ValueTypes.h" |
| 21 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 22 | #include "llvm/CodeGen/MachineFunction.h" |
| 23 | #include "llvm/CodeGen/MachineFrameInfo.h" |
| 24 | #include "llvm/Target/TargetFrameInfo.h" |
| 25 | #include "llvm/Target/TargetMachine.h" |
| 26 | #include "llvm/Target/TargetOptions.h" |
Reid Spencer | 551ccae | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 27 | #include "llvm/Support/CommandLine.h" |
| 28 | #include "llvm/Support/Debug.h" |
| 29 | #include "llvm/ADT/STLExtras.h" |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 30 | #include <cstdlib> |
| 31 | #include <iostream> |
| 32 | using namespace llvm; |
| 33 | |
| 34 | namespace llvm { |
| 35 | // Switch toggling compilation for AIX |
| 36 | extern cl::opt<bool> AIX; |
| 37 | } |
| 38 | |
| 39 | PPC32RegisterInfo::PPC32RegisterInfo() |
| 40 | : PPC32GenRegisterInfo(PPC::ADJCALLSTACKDOWN, PPC::ADJCALLSTACKUP) { |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 41 | ImmToIdxMap[PPC::LD] = PPC::LDX; ImmToIdxMap[PPC::STD] = PPC::STDX; |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 42 | ImmToIdxMap[PPC::LBZ] = PPC::LBZX; ImmToIdxMap[PPC::STB] = PPC::STBX; |
| 43 | ImmToIdxMap[PPC::LHZ] = PPC::LHZX; ImmToIdxMap[PPC::LHA] = PPC::LHAX; |
| 44 | ImmToIdxMap[PPC::LWZ] = PPC::LWZX; ImmToIdxMap[PPC::LWA] = PPC::LWAX; |
| 45 | ImmToIdxMap[PPC::LFS] = PPC::LFSX; ImmToIdxMap[PPC::LFD] = PPC::LFDX; |
| 46 | ImmToIdxMap[PPC::STH] = PPC::STHX; ImmToIdxMap[PPC::STW] = PPC::STWX; |
| 47 | ImmToIdxMap[PPC::STFS] = PPC::STFSX; ImmToIdxMap[PPC::STFD] = PPC::STFDX; |
| 48 | ImmToIdxMap[PPC::ADDI] = PPC::ADD; |
| 49 | } |
| 50 | |
Nate Begeman | dfd0e7b | 2004-10-26 05:40:45 +0000 | [diff] [blame] | 51 | static const TargetRegisterClass *getClass(unsigned SrcReg) { |
| 52 | if (PPC32::FPRCRegisterClass->contains(SrcReg)) |
Misha Brukman | 7847fca | 2005-04-22 17:54:37 +0000 | [diff] [blame] | 53 | return PPC32::FPRCRegisterClass; |
Nate Begeman | dfd0e7b | 2004-10-26 05:40:45 +0000 | [diff] [blame] | 54 | assert(PPC32::GPRCRegisterClass->contains(SrcReg) && "Reg not FPR or GPR"); |
| 55 | return PPC32::GPRCRegisterClass; |
| 56 | } |
| 57 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 58 | static unsigned getIdx(const TargetRegisterClass *RC) { |
| 59 | if (RC == PPC32::GPRCRegisterClass) { |
| 60 | switch (RC->getSize()) { |
| 61 | default: assert(0 && "Invalid data size!"); |
| 62 | case 1: return 0; |
| 63 | case 2: return 1; |
| 64 | case 4: return 2; |
| 65 | } |
| 66 | } else if (RC == PPC32::FPRCRegisterClass) { |
| 67 | switch (RC->getSize()) { |
| 68 | default: assert(0 && "Invalid data size!"); |
| 69 | case 4: return 3; |
| 70 | case 8: return 4; |
| 71 | } |
Nate Begeman | 7af0248 | 2005-04-12 07:04:16 +0000 | [diff] [blame] | 72 | } else if (RC == PPC32::CRRCRegisterClass) { |
| 73 | switch (RC->getSize()) { |
| 74 | default: assert(0 && "Invalid data size!"); |
| 75 | case 4: return 2; |
| 76 | } |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 77 | } |
| 78 | std::cerr << "Invalid register class to getIdx()!\n"; |
| 79 | abort(); |
| 80 | } |
| 81 | |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 82 | void |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 83 | PPC32RegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, |
| 84 | MachineBasicBlock::iterator MI, |
| 85 | unsigned SrcReg, int FrameIdx) const { |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 86 | static const unsigned Opcode[] = { |
| 87 | PPC::STB, PPC::STH, PPC::STW, PPC::STFS, PPC::STFD |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 88 | }; |
Nate Begeman | dfd0e7b | 2004-10-26 05:40:45 +0000 | [diff] [blame] | 89 | unsigned OC = Opcode[getIdx(getClass(SrcReg))]; |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 90 | if (SrcReg == PPC::LR) { |
Nate Begeman | da721e7 | 2004-09-27 05:08:17 +0000 | [diff] [blame] | 91 | BuildMI(MBB, MI, PPC::MFLR, 1, PPC::R11).addReg(PPC::LR); |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 92 | addFrameReference(BuildMI(MBB, MI, OC, 3).addReg(PPC::R11),FrameIdx); |
Nate Begeman | 7af0248 | 2005-04-12 07:04:16 +0000 | [diff] [blame] | 93 | } else if (PPC32::CRRCRegisterClass == getClass(SrcReg)) { |
| 94 | BuildMI(MBB, MI, PPC::MFCR, 0, PPC::R11); |
| 95 | addFrameReference(BuildMI(MBB, MI, OC, 3).addReg(PPC::R11),FrameIdx); |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 96 | } else { |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 97 | addFrameReference(BuildMI(MBB, MI, OC, 3).addReg(SrcReg),FrameIdx); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void |
| 102 | PPC32RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 103 | MachineBasicBlock::iterator MI, |
| 104 | unsigned DestReg, int FrameIdx) const{ |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 105 | static const unsigned Opcode[] = { |
| 106 | PPC::LBZ, PPC::LHZ, PPC::LWZ, PPC::LFS, PPC::LFD |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 107 | }; |
Nate Begeman | dfd0e7b | 2004-10-26 05:40:45 +0000 | [diff] [blame] | 108 | unsigned OC = Opcode[getIdx(getClass(DestReg))]; |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 109 | if (DestReg == PPC::LR) { |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 110 | addFrameReference(BuildMI(MBB, MI, OC, 2, PPC::R11), FrameIdx); |
| 111 | BuildMI(MBB, MI, PPC::MTLR, 1).addReg(PPC::R11); |
Nate Begeman | 7af0248 | 2005-04-12 07:04:16 +0000 | [diff] [blame] | 112 | } else if (PPC32::CRRCRegisterClass == getClass(DestReg)) { |
| 113 | addFrameReference(BuildMI(MBB, MI, OC, 2, PPC::R11), FrameIdx); |
| 114 | BuildMI(MBB, MI, PPC::MTCRF, 1, DestReg).addReg(PPC::R11); |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 115 | } else { |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 116 | addFrameReference(BuildMI(MBB, MI, OC, 2, DestReg), FrameIdx); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | void PPC32RegisterInfo::copyRegToReg(MachineBasicBlock &MBB, |
| 121 | MachineBasicBlock::iterator MI, |
| 122 | unsigned DestReg, unsigned SrcReg, |
| 123 | const TargetRegisterClass *RC) const { |
| 124 | MachineInstr *I; |
| 125 | |
| 126 | if (RC == PPC32::GPRCRegisterClass) { |
| 127 | BuildMI(MBB, MI, PPC::OR, 2, DestReg).addReg(SrcReg).addReg(SrcReg); |
| 128 | } else if (RC == PPC32::FPRCRegisterClass) { |
| 129 | BuildMI(MBB, MI, PPC::FMR, 1, DestReg).addReg(SrcReg); |
Nate Begeman | 7af0248 | 2005-04-12 07:04:16 +0000 | [diff] [blame] | 130 | } else if (RC == PPC32::CRRCRegisterClass) { |
| 131 | BuildMI(MBB, MI, PPC::MCRF, 1, DestReg).addReg(SrcReg); |
| 132 | } else { |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 133 | std::cerr << "Attempt to copy register that is not GPR or FPR"; |
| 134 | abort(); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | //===----------------------------------------------------------------------===// |
| 139 | // Stack Frame Processing methods |
| 140 | //===----------------------------------------------------------------------===// |
| 141 | |
| 142 | // hasFP - Return true if the specified function should have a dedicated frame |
| 143 | // pointer register. This is true if the function has variable sized allocas or |
| 144 | // if frame pointer elimination is disabled. |
| 145 | // |
| 146 | static bool hasFP(MachineFunction &MF) { |
| 147 | MachineFrameInfo *MFI = MF.getFrameInfo(); |
| 148 | return MFI->hasVarSizedObjects(); |
| 149 | } |
| 150 | |
| 151 | void PPC32RegisterInfo:: |
| 152 | eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, |
| 153 | MachineBasicBlock::iterator I) const { |
| 154 | if (hasFP(MF)) { |
| 155 | // If we have a frame pointer, convert as follows: |
| 156 | // ADJCALLSTACKDOWN -> addi, r1, r1, -amount |
| 157 | // ADJCALLSTACKUP -> addi, r1, r1, amount |
| 158 | MachineInstr *Old = I; |
| 159 | unsigned Amount = Old->getOperand(0).getImmedValue(); |
| 160 | if (Amount != 0) { |
| 161 | // We need to keep the stack aligned properly. To do this, we round the |
| 162 | // amount of space needed for the outgoing arguments up to the next |
| 163 | // alignment boundary. |
| 164 | unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); |
| 165 | Amount = (Amount+Align-1)/Align*Align; |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 166 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 167 | // Replace the pseudo instruction with a new instruction... |
| 168 | if (Old->getOpcode() == PPC::ADJCALLSTACKDOWN) { |
| 169 | MBB.insert(I, BuildMI(PPC::ADDI, 2, PPC::R1).addReg(PPC::R1) |
| 170 | .addSImm(-Amount)); |
| 171 | } else { |
| 172 | assert(Old->getOpcode() == PPC::ADJCALLSTACKUP); |
| 173 | MBB.insert(I, BuildMI(PPC::ADDI, 2, PPC::R1).addReg(PPC::R1) |
| 174 | .addSImm(Amount)); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | MBB.erase(I); |
| 179 | } |
| 180 | |
| 181 | void |
| 182 | PPC32RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const { |
| 183 | unsigned i = 0; |
| 184 | MachineInstr &MI = *II; |
| 185 | MachineBasicBlock &MBB = *MI.getParent(); |
| 186 | MachineFunction &MF = *MBB.getParent(); |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 187 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 188 | while (!MI.getOperand(i).isFrameIndex()) { |
| 189 | ++i; |
| 190 | assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); |
| 191 | } |
| 192 | |
| 193 | int FrameIndex = MI.getOperand(i).getFrameIndex(); |
| 194 | |
| 195 | // Replace the FrameIndex with base register with GPR1 (SP) or GPR31 (FP). |
| 196 | MI.SetMachineOperandReg(i, hasFP(MF) ? PPC::R31 : PPC::R1); |
| 197 | |
| 198 | // Take into account whether it's an add or mem instruction |
| 199 | unsigned OffIdx = (i == 2) ? 1 : 2; |
| 200 | |
| 201 | // Now add the frame object offset to the offset from r1. |
| 202 | int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) + |
| 203 | MI.getOperand(OffIdx).getImmedValue(); |
| 204 | |
| 205 | // If we're not using a Frame Pointer that has been set to the value of the |
| 206 | // SP before having the stack size subtracted from it, then add the stack size |
| 207 | // to Offset to get the correct offset. |
| 208 | Offset += MF.getFrameInfo()->getStackSize(); |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 209 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 210 | if (Offset > 32767 || Offset < -32768) { |
| 211 | // Insert a set of r0 with the full offset value before the ld, st, or add |
| 212 | MachineBasicBlock *MBB = MI.getParent(); |
| 213 | MBB->insert(II, BuildMI(PPC::LIS, 1, PPC::R0).addSImm(Offset >> 16)); |
| 214 | MBB->insert(II, BuildMI(PPC::ORI, 2, PPC::R0).addReg(PPC::R0) |
| 215 | .addImm(Offset)); |
| 216 | // convert into indexed form of the instruction |
| 217 | // sth 0:rA, 1:imm 2:(rB) ==> sthx 0:rA, 2:rB, 1:r0 |
| 218 | // addi 0:rA 1:rB, 2, imm ==> add 0:rA, 1:rB, 2:r0 |
| 219 | unsigned NewOpcode = const_cast<std::map<unsigned, unsigned>& >(ImmToIdxMap)[MI.getOpcode()]; |
| 220 | assert(NewOpcode && "No indexed form of load or store available!"); |
| 221 | MI.setOpcode(NewOpcode); |
| 222 | MI.SetMachineOperandReg(1, MI.getOperand(i).getReg()); |
| 223 | MI.SetMachineOperandReg(2, PPC::R0); |
| 224 | } else { |
| 225 | MI.SetMachineOperandConst(OffIdx,MachineOperand::MO_SignExtendedImmed,Offset); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | |
| 230 | void PPC32RegisterInfo::emitPrologue(MachineFunction &MF) const { |
| 231 | MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB |
| 232 | MachineBasicBlock::iterator MBBI = MBB.begin(); |
| 233 | MachineFrameInfo *MFI = MF.getFrameInfo(); |
| 234 | MachineInstr *MI; |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 235 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 236 | // Get the number of bytes to allocate from the FrameInfo |
| 237 | unsigned NumBytes = MFI->getStackSize(); |
| 238 | |
| 239 | // If we have calls, we cannot use the red zone to store callee save registers |
| 240 | // and we must set up a stack frame, so calculate the necessary size here. |
| 241 | if (MFI->hasCalls()) { |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 242 | // We reserve argument space for call sites in the function immediately on |
| 243 | // entry to the current function. This eliminates the need for add/sub |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 244 | // brackets around call sites. |
| 245 | NumBytes += MFI->getMaxCallFrameSize(); |
| 246 | } |
| 247 | |
Nate Begeman | 54eed36 | 2005-07-27 06:06:29 +0000 | [diff] [blame^] | 248 | // If we are a leaf function, and use up to 224 bytes of stack space, |
| 249 | // and don't have a frame pointer, then we do not need to adjust the stack |
| 250 | // pointer (we fit in the Red Zone). |
| 251 | if ((NumBytes == 0) || (NumBytes <= 224 && !hasFP(MF) && !MFI->hasCalls())) { |
| 252 | MFI->setStackSize(0); |
| 253 | return; |
| 254 | } |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 255 | |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 256 | // Add the size of R1 to NumBytes size for the store of R1 to the bottom |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 257 | // of the stack and round the size to a multiple of the alignment. |
| 258 | unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); |
Nate Begeman | 5709998 | 2004-08-27 04:28:10 +0000 | [diff] [blame] | 259 | unsigned GPRSize = getSpillSize(PPC::R1)/8; |
Chris Lattner | 8edcd84 | 2004-08-21 19:51:17 +0000 | [diff] [blame] | 260 | unsigned Size = hasFP(MF) ? GPRSize + GPRSize : GPRSize; |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 261 | NumBytes = (NumBytes+Size+Align-1)/Align*Align; |
| 262 | |
| 263 | // Update frame info to pretend that this is part of the stack... |
| 264 | MFI->setStackSize(NumBytes); |
| 265 | |
Nate Begeman | 54eed36 | 2005-07-27 06:06:29 +0000 | [diff] [blame^] | 266 | // If , adjust stack pointer: r1 -= numbytes. |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 267 | if (NumBytes <= 32768) { |
| 268 | MI=BuildMI(PPC::STWU,3).addReg(PPC::R1).addSImm(-NumBytes).addReg(PPC::R1); |
| 269 | MBB.insert(MBBI, MI); |
| 270 | } else { |
| 271 | int NegNumbytes = -NumBytes; |
| 272 | MI = BuildMI(PPC::LIS, 1, PPC::R0).addSImm(NegNumbytes >> 16); |
| 273 | MBB.insert(MBBI, MI); |
| 274 | MI = BuildMI(PPC::ORI, 2, PPC::R0).addReg(PPC::R0) |
| 275 | .addImm(NegNumbytes & 0xFFFF); |
| 276 | MBB.insert(MBBI, MI); |
| 277 | MI = BuildMI(PPC::STWUX, 3).addReg(PPC::R1).addReg(PPC::R1).addReg(PPC::R0); |
| 278 | MBB.insert(MBBI, MI); |
| 279 | } |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 280 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 281 | if (hasFP(MF)) { |
Chris Lattner | 8edcd84 | 2004-08-21 19:51:17 +0000 | [diff] [blame] | 282 | MI = BuildMI(PPC::STW, 3).addReg(PPC::R31).addSImm(GPRSize).addReg(PPC::R1); |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 283 | MBB.insert(MBBI, MI); |
| 284 | MI = BuildMI(PPC::OR, 2, PPC::R31).addReg(PPC::R1).addReg(PPC::R1); |
| 285 | MBB.insert(MBBI, MI); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | void PPC32RegisterInfo::emitEpilogue(MachineFunction &MF, |
| 290 | MachineBasicBlock &MBB) const { |
| 291 | const MachineFrameInfo *MFI = MF.getFrameInfo(); |
| 292 | MachineBasicBlock::iterator MBBI = prior(MBB.end()); |
| 293 | MachineInstr *MI; |
| 294 | assert(MBBI->getOpcode() == PPC::BLR && |
| 295 | "Can only insert epilog into returning blocks"); |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 296 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 297 | // Get the number of bytes allocated from the FrameInfo... |
| 298 | unsigned NumBytes = MFI->getStackSize(); |
Nate Begeman | 5709998 | 2004-08-27 04:28:10 +0000 | [diff] [blame] | 299 | unsigned GPRSize = getSpillSize(PPC::R31)/8; |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 300 | |
| 301 | if (NumBytes != 0) { |
| 302 | if (hasFP(MF)) { |
Nate Begeman | 1f4a132 | 2004-08-22 08:09:17 +0000 | [diff] [blame] | 303 | MI = BuildMI(PPC::LWZ, 2, PPC::R31).addSImm(GPRSize).addReg(PPC::R31); |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 304 | MBB.insert(MBBI, MI); |
| 305 | } |
| 306 | MI = BuildMI(PPC::LWZ, 2, PPC::R1).addSImm(0).addReg(PPC::R1); |
| 307 | MBB.insert(MBBI, MI); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | #include "PPC32GenRegisterInfo.inc" |
| 312 | |
| 313 | const TargetRegisterClass* |
| 314 | PPC32RegisterInfo::getRegClassForType(const Type* Ty) const { |
| 315 | switch (Ty->getTypeID()) { |
| 316 | default: assert(0 && "Invalid type to getClass!"); |
| 317 | case Type::LongTyID: |
| 318 | case Type::ULongTyID: assert(0 && "Long values can't fit in registers!"); |
| 319 | case Type::BoolTyID: |
| 320 | case Type::SByteTyID: |
| 321 | case Type::UByteTyID: |
| 322 | case Type::ShortTyID: |
| 323 | case Type::UShortTyID: |
| 324 | case Type::IntTyID: |
| 325 | case Type::UIntTyID: |
| 326 | case Type::PointerTyID: return &GPRCInstance; |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 327 | |
Misha Brukman | f2ccb77 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 328 | case Type::FloatTyID: |
| 329 | case Type::DoubleTyID: return &FPRCInstance; |
| 330 | } |
| 331 | } |
| 332 | |