llvm.org GIT mirror llvm / ec46ea3
Declare the callee saved regs Remove the hard coded store and load of the link register Implement ARMFrameInfo git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29727 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 14 years ago
6 changed file(s) with 60 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
0 //===-- ARMTargetFrameInfo.h - Define TargetFrameInfo for ARM ---*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the "Instituto Nokia de Tecnologia" and
5 // is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARM_FRAMEINFO_H
15 #define ARM_FRAMEINFO_H
16
17 #include "ARM.h"
18 #include "llvm/Target/TargetFrameInfo.h"
19 #include "llvm/Target/TargetMachine.h"
20
21 namespace llvm {
22
23 class ARMFrameInfo: public TargetFrameInfo {
24 std::pair LR[1];
25
26 public:
27 ARMFrameInfo()
28 : TargetFrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
29 LR[0].first = ARM::R14;
30 LR[0].second = -4;
31 }
32
33 const std::pair *
34 getCalleeSaveSpillSlots(unsigned &NumEntries) const {
35 NumEntries = 1;
36 return &LR[0];
37 }
38 };
39
40 } // End llvm namespace
41
42 #endif
8383 SDOperand Callee = Op.getOperand(4);
8484 unsigned NumOps = (Op.getNumOperands() - 5) / 2;
8585
86 // Count how many bytes are to be pushed on the stack. Initially
87 // only the link register.
88 unsigned NumBytes = 4;
86 // Count how many bytes are to be pushed on the stack.
87 unsigned NumBytes = 0;
8988
9089 // Add up all the space actually used.
9190 for (unsigned i = 4; i < NumOps; ++i)
6060 def bx: InstARM<(ops), "bx r14", [(retflag)]>;
6161 }
6262
63 let Defs = [R0, R1, R2, R3] in {
63 let Defs = [R0, R1, R2, R3, R14] in {
6464 def bl: InstARM<(ops i32imm:$func, variable_ops), "bl $func", [(ARMcall tglobaladdr:$func)]>;
6565 }
6666
5757 }
5858
5959 const unsigned* ARMRegisterInfo::getCalleeSaveRegs() const {
60 static const unsigned CalleeSaveRegs[] = { 0 };
60 static const unsigned CalleeSaveRegs[] = {
61 ARM::R4, ARM::R5, ARM::R6, ARM::R7,
62 ARM::R8, ARM::R9, ARM::R10, ARM::R11,
63 ARM::R14, 0
64 };
6165 return CalleeSaveRegs;
6266 }
6367
6468 const TargetRegisterClass* const *
6569 ARMRegisterInfo::getCalleeSaveRegClasses() const {
66 static const TargetRegisterClass * const CalleeSaveRegClasses[] = { 0 };
70 static const TargetRegisterClass * const CalleeSaveRegClasses[] = {
71 &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass,
72 &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass,
73 &ARM::IntRegsRegClass, 0
74 };
6775 return CalleeSaveRegClasses;
6876 }
6977
125133 // entry to the current function. This eliminates the need for add/sub
126134 // brackets around call sites.
127135 NumBytes += MFI->getMaxCallFrameSize();
128 } else {
129 NumBytes += 4;
130136 }
131137
132138 MFI->setStackSize(NumBytes);
133139
134140 //sub sp, sp, #NumBytes
135141 BuildMI(MBB, MBBI, ARM::subri, 2, ARM::R13).addReg(ARM::R13).addImm(NumBytes);
136 //str lr, [sp, #NumBytes - 4]
137 BuildMI(MBB, MBBI, ARM::str, 2, ARM::R14).addImm(NumBytes - 4).addReg(ARM::R13);
138142 }
139143
140144 void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
146150 MachineFrameInfo *MFI = MF.getFrameInfo();
147151 int NumBytes = (int) MFI->getStackSize();
148152
149 //ldr lr, [sp]
150 BuildMI(MBB, MBBI, ARM::ldr, 2, ARM::R14).addImm(NumBytes - 4).addReg(ARM::R13);
151153 //add sp, sp, #NumBytes
152154 BuildMI(MBB, MBBI, ARM::addri, 2, ARM::R13).addReg(ARM::R13).addImm(NumBytes);
153155 }
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "ARMTargetMachine.h"
14 #include "ARMFrameInfo.h"
1415 #include "ARM.h"
1516 #include "llvm/Assembly/PrintModulePass.h"
1617 #include "llvm/Module.h"
3233 ///
3334 ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
3435 : TargetMachine("ARM"), DataLayout("E-p:32:32"),
35 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4) {
36 FrameInfo() {
3637 }
3738
3839 unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
1919 #include "llvm/Target/TargetFrameInfo.h"
2020 #include "llvm/PassManager.h"
2121 #include "ARMInstrInfo.h"
22 #include "ARMFrameInfo.h"
2223
2324 namespace llvm {
2425
2728 class ARMTargetMachine : public TargetMachine {
2829 const TargetData DataLayout; // Calculates type size & alignment
2930 ARMInstrInfo InstrInfo;
30 TargetFrameInfo FrameInfo;
31 ARMFrameInfo FrameInfo;
3132 public:
3233 ARMTargetMachine(const Module &M, const std::string &FS);
3334