1 //===- ARMRegisterInfo.cpp - ARM Register Information -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the "Instituto Nokia de Tecnologia" and
6 // is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // This file contains the ARM implementation of the MRegisterInfo class.
13 //===----------------------------------------------------------------------===//
16 #include "ARMRegisterInfo.h"
17 #include "llvm/CodeGen/MachineInstrBuilder.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/CodeGen/MachineFrameInfo.h"
20 #include "llvm/CodeGen/MachineLocation.h"
21 #include "llvm/Type.h"
22 #include "llvm/ADT/STLExtras.h"
26 ARMRegisterInfo::ARMRegisterInfo()
27 : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP) {
30 void ARMRegisterInfo::
31 storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
32 unsigned SrcReg, int FI,
33 const TargetRegisterClass *RC) const {
34 // On the order of operands here: think "[FI + 0] = SrcReg".
35 assert (RC == ARM::IntRegsRegisterClass);
36 BuildMI(MBB, I, ARM::str, 3).addFrameIndex(FI).addImm(0).addReg(SrcReg);
39 void ARMRegisterInfo::
40 loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
41 unsigned DestReg, int FI,
42 const TargetRegisterClass *RC) const {
43 assert (RC == ARM::IntRegsRegisterClass);
44 BuildMI(MBB, I, ARM::ldr, 2, DestReg).addFrameIndex(FI).addImm(0);
47 void ARMRegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
48 MachineBasicBlock::iterator I,
49 unsigned DestReg, unsigned SrcReg,
50 const TargetRegisterClass *RC) const {
51 assert (RC == ARM::IntRegsRegisterClass);
52 BuildMI(MBB, I, ARM::movrr, 1, DestReg).addReg(SrcReg);
55 MachineInstr *ARMRegisterInfo::foldMemoryOperand(MachineInstr* MI,
61 const unsigned* ARMRegisterInfo::getCalleeSaveRegs() const {
62 static const unsigned CalleeSaveRegs[] = { 0 };
63 return CalleeSaveRegs;
66 const TargetRegisterClass* const *
67 ARMRegisterInfo::getCalleeSaveRegClasses() const {
68 static const TargetRegisterClass * const CalleeSaveRegClasses[] = { 0 };
69 return CalleeSaveRegClasses;
72 void ARMRegisterInfo::
73 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
74 MachineBasicBlock::iterator I) const {
79 ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const {
80 MachineInstr &MI = *II;
81 MachineBasicBlock &MBB = *MI.getParent();
82 MachineFunction &MF = *MBB.getParent();
84 assert (MI.getOpcode() == ARM::movrr);
86 unsigned FrameIdx = 1;
88 int FrameIndex = MI.getOperand(FrameIdx).getFrameIndex();
90 int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex);
92 unsigned StackSize = MF.getFrameInfo()->getStackSize();
96 // Insert a set of r12 with the full address
98 MachineBasicBlock *MBB2 = MI.getParent();
99 BuildMI(*MBB2, II, ARM::addri, 2, ARM::R12).addReg(ARM::R13).addImm(Offset);
101 // Replace the FrameIndex with r12
102 MI.getOperand(FrameIdx).ChangeToRegister(ARM::R12);
105 void ARMRegisterInfo::
106 processFunctionBeforeFrameFinalized(MachineFunction &MF) const {}
108 void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
111 void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
112 MachineBasicBlock &MBB) const {
115 unsigned ARMRegisterInfo::getRARegister() const {
119 unsigned ARMRegisterInfo::getFrameRegister(MachineFunction &MF) const {
123 #include "ARMGenRegisterInfo.inc"