diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2006-08-16 14:43:33 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2006-08-16 14:43:33 +0000 |
commit | ec46ea34dcc615558294e9e0dbd0dd0f2894f574 (patch) | |
tree | 0965e178da0dccf23657b2f8734d118b730d6dfd | |
parent | 23329f5e0366af7cd9a96572ed8d6322696e5846 (diff) |
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
-rw-r--r-- | lib/Target/ARM/ARMFrameInfo.h | 43 | ||||
-rw-r--r-- | lib/Target/ARM/ARMISelDAGToDAG.cpp | 5 | ||||
-rw-r--r-- | lib/Target/ARM/ARMInstrInfo.td | 2 | ||||
-rw-r--r-- | lib/Target/ARM/ARMRegisterInfo.cpp | 18 | ||||
-rw-r--r-- | lib/Target/ARM/ARMTargetMachine.cpp | 3 | ||||
-rw-r--r-- | lib/Target/ARM/ARMTargetMachine.h | 3 |
6 files changed, 60 insertions, 14 deletions
diff --git a/lib/Target/ARM/ARMFrameInfo.h b/lib/Target/ARM/ARMFrameInfo.h new file mode 100644 index 0000000000..d25ec9c3f1 --- /dev/null +++ b/lib/Target/ARM/ARMFrameInfo.h @@ -0,0 +1,43 @@ +//===-- ARMTargetFrameInfo.h - Define TargetFrameInfo for ARM ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the "Instituto Nokia de Tecnologia" and +// is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// +// +//===----------------------------------------------------------------------===// + +#ifndef ARM_FRAMEINFO_H +#define ARM_FRAMEINFO_H + +#include "ARM.h" +#include "llvm/Target/TargetFrameInfo.h" +#include "llvm/Target/TargetMachine.h" + +namespace llvm { + +class ARMFrameInfo: public TargetFrameInfo { + std::pair<unsigned, int> LR[1]; + +public: + ARMFrameInfo() + : TargetFrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) { + LR[0].first = ARM::R14; + LR[0].second = -4; + } + + const std::pair<unsigned, int> * + getCalleeSaveSpillSlots(unsigned &NumEntries) const { + NumEntries = 1; + return &LR[0]; + } +}; + +} // End llvm namespace + +#endif diff --git a/lib/Target/ARM/ARMISelDAGToDAG.cpp b/lib/Target/ARM/ARMISelDAGToDAG.cpp index dd6800a13c..80aaae54da 100644 --- a/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -84,9 +84,8 @@ static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG) { SDOperand Callee = Op.getOperand(4); unsigned NumOps = (Op.getNumOperands() - 5) / 2; - // Count how many bytes are to be pushed on the stack. Initially - // only the link register. - unsigned NumBytes = 4; + // Count how many bytes are to be pushed on the stack. + unsigned NumBytes = 0; // Add up all the space actually used. for (unsigned i = 4; i < NumOps; ++i) diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index 7384f2e5f6..cc6377eabd 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -61,7 +61,7 @@ let isReturn = 1 in { def bx: InstARM<(ops), "bx r14", [(retflag)]>; } -let Defs = [R0, R1, R2, R3] in { +let Defs = [R0, R1, R2, R3, R14] in { def bl: InstARM<(ops i32imm:$func, variable_ops), "bl $func", [(ARMcall tglobaladdr:$func)]>; } diff --git a/lib/Target/ARM/ARMRegisterInfo.cpp b/lib/Target/ARM/ARMRegisterInfo.cpp index 5471ccda09..a9c30c40c7 100644 --- a/lib/Target/ARM/ARMRegisterInfo.cpp +++ b/lib/Target/ARM/ARMRegisterInfo.cpp @@ -58,13 +58,21 @@ MachineInstr *ARMRegisterInfo::foldMemoryOperand(MachineInstr* MI, } const unsigned* ARMRegisterInfo::getCalleeSaveRegs() const { - static const unsigned CalleeSaveRegs[] = { 0 }; + static const unsigned CalleeSaveRegs[] = { + ARM::R4, ARM::R5, ARM::R6, ARM::R7, + ARM::R8, ARM::R9, ARM::R10, ARM::R11, + ARM::R14, 0 + }; return CalleeSaveRegs; } const TargetRegisterClass* const * ARMRegisterInfo::getCalleeSaveRegClasses() const { - static const TargetRegisterClass * const CalleeSaveRegClasses[] = { 0 }; + static const TargetRegisterClass * const CalleeSaveRegClasses[] = { + &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, + &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, &ARM::IntRegsRegClass, + &ARM::IntRegsRegClass, 0 + }; return CalleeSaveRegClasses; } @@ -126,16 +134,12 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const { // entry to the current function. This eliminates the need for add/sub // brackets around call sites. NumBytes += MFI->getMaxCallFrameSize(); - } else { - NumBytes += 4; } MFI->setStackSize(NumBytes); //sub sp, sp, #NumBytes BuildMI(MBB, MBBI, ARM::subri, 2, ARM::R13).addReg(ARM::R13).addImm(NumBytes); - //str lr, [sp, #NumBytes - 4] - BuildMI(MBB, MBBI, ARM::str, 2, ARM::R14).addImm(NumBytes - 4).addReg(ARM::R13); } void ARMRegisterInfo::emitEpilogue(MachineFunction &MF, @@ -147,8 +151,6 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF, MachineFrameInfo *MFI = MF.getFrameInfo(); int NumBytes = (int) MFI->getStackSize(); - //ldr lr, [sp] - BuildMI(MBB, MBBI, ARM::ldr, 2, ARM::R14).addImm(NumBytes - 4).addReg(ARM::R13); //add sp, sp, #NumBytes BuildMI(MBB, MBBI, ARM::addri, 2, ARM::R13).addReg(ARM::R13).addImm(NumBytes); } diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index 8c1e954bc2..1ed9292ccb 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "ARMTargetMachine.h" +#include "ARMFrameInfo.h" #include "ARM.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Module.h" @@ -33,7 +34,7 @@ namespace { /// ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS) : TargetMachine("ARM"), DataLayout("E-p:32:32"), - FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4) { + FrameInfo() { } unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) { diff --git a/lib/Target/ARM/ARMTargetMachine.h b/lib/Target/ARM/ARMTargetMachine.h index 97d1f22d0c..400ea0c7be 100644 --- a/lib/Target/ARM/ARMTargetMachine.h +++ b/lib/Target/ARM/ARMTargetMachine.h @@ -20,6 +20,7 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/PassManager.h" #include "ARMInstrInfo.h" +#include "ARMFrameInfo.h" namespace llvm { @@ -28,7 +29,7 @@ class Module; class ARMTargetMachine : public TargetMachine { const TargetData DataLayout; // Calculates type size & alignment ARMInstrInfo InstrInfo; - TargetFrameInfo FrameInfo; + ARMFrameInfo FrameInfo; public: ARMTargetMachine(const Module &M, const std::string &FS); |