2007-01-19 08:51:42 +01:00
|
|
|
//====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
|
2009-08-11 17:33:49 +02:00
|
|
|
//
|
2007-01-19 08:51:42 +01:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2009-08-11 17:33:49 +02:00
|
|
|
//
|
2007-01-19 08:51:42 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares ARM-specific per-machine-function information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ARMMACHINEFUNCTIONINFO_H
|
|
|
|
#define ARMMACHINEFUNCTIONINFO_H
|
|
|
|
|
|
|
|
#include "ARMSubtarget.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2008-02-10 19:45:23 +01:00
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
2007-01-19 08:51:42 +01:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2007-03-01 08:52:44 +01:00
|
|
|
#include "llvm/ADT/BitVector.h"
|
2007-01-19 08:51:42 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2011-01-15 01:09:18 +01:00
|
|
|
/// ARMFunctionInfo - This class is derived from MachineFunctionInfo and
|
|
|
|
/// contains private ARM-specific information for each MachineFunction.
|
2007-01-19 08:51:42 +01:00
|
|
|
class ARMFunctionInfo : public MachineFunctionInfo {
|
|
|
|
|
|
|
|
/// isThumb - True if this function is compiled under Thumb mode.
|
2007-04-23 22:07:25 +02:00
|
|
|
/// Used to initialized Align, so must precede it.
|
2007-01-19 08:51:42 +01:00
|
|
|
bool isThumb;
|
|
|
|
|
2009-06-30 20:04:13 +02:00
|
|
|
/// hasThumb2 - True if the target architecture supports Thumb2. Do not use
|
|
|
|
/// to determine if function is compiled under Thumb mode, for that use
|
|
|
|
/// 'isThumb'.
|
|
|
|
bool hasThumb2;
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
/// VarArgsRegSaveSize - Size of the register save area for vararg functions.
|
|
|
|
///
|
|
|
|
unsigned VarArgsRegSaveSize;
|
|
|
|
|
2007-01-20 03:09:25 +01:00
|
|
|
/// HasStackFrame - True if this function has a stack frame. Set by
|
2007-01-19 08:51:42 +01:00
|
|
|
/// processFunctionBeforeCalleeSavedScan().
|
2007-01-20 03:09:25 +01:00
|
|
|
bool HasStackFrame;
|
2007-01-19 08:51:42 +01:00
|
|
|
|
2010-08-10 21:30:19 +02:00
|
|
|
/// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by
|
|
|
|
/// emitPrologue.
|
|
|
|
bool RestoreSPFromFP;
|
|
|
|
|
2007-03-01 09:26:31 +01:00
|
|
|
/// LRSpilledForFarJump - True if the LR register has been for spilled to
|
|
|
|
/// enable far jump.
|
|
|
|
bool LRSpilledForFarJump;
|
2007-01-29 23:22:24 +01:00
|
|
|
|
2007-01-20 03:09:25 +01:00
|
|
|
/// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
|
2007-01-19 08:51:42 +01:00
|
|
|
/// spill stack offset.
|
|
|
|
unsigned FramePtrSpillOffset;
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
/// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
|
|
|
|
/// register spills areas. For Mac OS X:
|
2007-01-19 08:51:42 +01:00
|
|
|
///
|
2010-11-02 18:35:25 +01:00
|
|
|
/// GPR callee-saved (1) : r4, r5, r6, r7, lr
|
|
|
|
/// --------------------------------------------
|
|
|
|
/// GPR callee-saved (2) : r8, r10, r11
|
2007-01-19 08:51:42 +01:00
|
|
|
/// --------------------------------------------
|
|
|
|
/// DPR callee-saved : d8 - d15
|
2010-11-02 18:35:25 +01:00
|
|
|
unsigned GPRCS1Offset;
|
|
|
|
unsigned GPRCS2Offset;
|
2007-01-19 08:51:42 +01:00
|
|
|
unsigned DPRCSOffset;
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
/// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
|
|
|
|
/// areas.
|
|
|
|
unsigned GPRCS1Size;
|
|
|
|
unsigned GPRCS2Size;
|
2007-01-19 08:51:42 +01:00
|
|
|
unsigned DPRCSSize;
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
/// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
|
|
|
|
/// which belong to these spill areas.
|
|
|
|
BitVector GPRCS1Frames;
|
|
|
|
BitVector GPRCS2Frames;
|
2007-03-01 08:52:44 +01:00
|
|
|
BitVector DPRCSFrames;
|
2007-01-19 08:51:42 +01:00
|
|
|
|
2007-03-01 09:26:31 +01:00
|
|
|
/// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
|
|
|
|
///
|
|
|
|
BitVector SpilledCSRegs;
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
/// JumpTableUId - Unique id for jumptables.
|
|
|
|
///
|
|
|
|
unsigned JumpTableUId;
|
|
|
|
|
2011-01-17 09:03:18 +01:00
|
|
|
unsigned PICLabelUId;
|
2008-11-08 01:51:41 +01:00
|
|
|
|
2010-04-17 16:41:14 +02:00
|
|
|
/// VarArgsFrameIndex - FrameIndex for start of varargs area.
|
|
|
|
int VarArgsFrameIndex;
|
|
|
|
|
2010-06-19 01:09:54 +02:00
|
|
|
/// HasITBlocks - True if IT blocks have been inserted.
|
|
|
|
bool HasITBlocks;
|
|
|
|
|
2011-01-30 23:07:39 +01:00
|
|
|
/// CPEClones - Track constant pool entries clones created by Constant Island
|
|
|
|
/// pass.
|
|
|
|
DenseMap<unsigned, unsigned> CPEClones;
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
public:
|
|
|
|
ARMFunctionInfo() :
|
2009-06-30 20:04:13 +02:00
|
|
|
isThumb(false),
|
|
|
|
hasThumb2(false),
|
2010-08-10 21:30:19 +02:00
|
|
|
VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false),
|
2009-10-08 03:50:26 +02:00
|
|
|
LRSpilledForFarJump(false),
|
2010-11-02 18:35:25 +01:00
|
|
|
FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
|
|
|
|
GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
|
|
|
|
GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0),
|
2011-01-17 09:03:18 +01:00
|
|
|
JumpTableUId(0), PICLabelUId(0),
|
|
|
|
VarArgsFrameIndex(0), HasITBlocks(false) {}
|
2007-01-19 08:51:42 +01:00
|
|
|
|
2009-06-06 01:05:51 +02:00
|
|
|
explicit ARMFunctionInfo(MachineFunction &MF) :
|
2007-01-19 08:51:42 +01:00
|
|
|
isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
|
2009-06-30 20:04:13 +02:00
|
|
|
hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
|
2010-08-10 21:30:19 +02:00
|
|
|
VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false),
|
2009-10-08 03:50:26 +02:00
|
|
|
LRSpilledForFarJump(false),
|
2010-11-02 18:35:25 +01:00
|
|
|
FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
|
|
|
|
GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
|
|
|
|
GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32),
|
2007-03-01 09:26:31 +01:00
|
|
|
SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()),
|
2011-01-17 09:03:18 +01:00
|
|
|
JumpTableUId(0), PICLabelUId(0),
|
|
|
|
VarArgsFrameIndex(0), HasITBlocks(false) {}
|
2007-01-19 08:51:42 +01:00
|
|
|
|
|
|
|
bool isThumbFunction() const { return isThumb; }
|
2009-07-09 01:10:31 +02:00
|
|
|
bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
|
2009-06-30 20:04:13 +02:00
|
|
|
bool isThumb2Function() const { return isThumb && hasThumb2; }
|
2007-01-19 08:51:42 +01:00
|
|
|
|
|
|
|
unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
|
|
|
|
void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
|
|
|
|
|
2007-01-20 03:09:25 +01:00
|
|
|
bool hasStackFrame() const { return HasStackFrame; }
|
|
|
|
void setHasStackFrame(bool s) { HasStackFrame = s; }
|
2007-01-29 23:22:24 +01:00
|
|
|
|
2010-08-10 21:30:19 +02:00
|
|
|
bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; }
|
|
|
|
void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; }
|
|
|
|
|
2007-03-01 09:26:31 +01:00
|
|
|
bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
|
|
|
|
void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
|
2007-01-29 23:22:24 +01:00
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
|
|
|
|
void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
|
2009-08-11 17:33:49 +02:00
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
|
|
|
|
unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
|
2007-01-19 08:51:42 +01:00
|
|
|
unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
|
|
|
|
void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
|
2007-01-19 08:51:42 +01:00
|
|
|
void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
|
|
|
|
unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
|
2007-01-19 08:51:42 +01:00
|
|
|
unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
|
|
|
|
void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
|
2007-01-19 08:51:42 +01:00
|
|
|
void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
bool isGPRCalleeSavedArea1Frame(int fi) const {
|
|
|
|
if (fi < 0 || fi >= (int)GPRCS1Frames.size())
|
|
|
|
return false;
|
|
|
|
return GPRCS1Frames[fi];
|
|
|
|
}
|
|
|
|
bool isGPRCalleeSavedArea2Frame(int fi) const {
|
|
|
|
if (fi < 0 || fi >= (int)GPRCS2Frames.size())
|
2007-01-25 04:07:27 +01:00
|
|
|
return false;
|
2010-11-02 18:35:25 +01:00
|
|
|
return GPRCS2Frames[fi];
|
2007-01-19 08:51:42 +01:00
|
|
|
}
|
2007-01-25 04:07:27 +01:00
|
|
|
bool isDPRCalleeSavedAreaFrame(int fi) const {
|
|
|
|
if (fi < 0 || fi >= (int)DPRCSFrames.size())
|
|
|
|
return false;
|
|
|
|
return DPRCSFrames[fi];
|
2007-01-19 08:51:42 +01:00
|
|
|
}
|
|
|
|
|
2010-11-02 18:35:25 +01:00
|
|
|
void addGPRCalleeSavedArea1Frame(int fi) {
|
|
|
|
if (fi >= 0) {
|
|
|
|
int Size = GPRCS1Frames.size();
|
|
|
|
if (fi >= Size) {
|
|
|
|
Size *= 2;
|
|
|
|
if (fi >= Size)
|
|
|
|
Size = fi+1;
|
|
|
|
GPRCS1Frames.resize(Size);
|
|
|
|
}
|
|
|
|
GPRCS1Frames[fi] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void addGPRCalleeSavedArea2Frame(int fi) {
|
2007-01-25 04:07:27 +01:00
|
|
|
if (fi >= 0) {
|
2010-11-02 18:35:25 +01:00
|
|
|
int Size = GPRCS2Frames.size();
|
2007-03-01 08:52:44 +01:00
|
|
|
if (fi >= Size) {
|
|
|
|
Size *= 2;
|
|
|
|
if (fi >= Size)
|
|
|
|
Size = fi+1;
|
2010-11-02 18:35:25 +01:00
|
|
|
GPRCS2Frames.resize(Size);
|
2007-03-01 08:52:44 +01:00
|
|
|
}
|
2010-11-02 18:35:25 +01:00
|
|
|
GPRCS2Frames[fi] = true;
|
2007-01-25 04:07:27 +01:00
|
|
|
}
|
2007-01-19 08:51:42 +01:00
|
|
|
}
|
2007-01-25 04:07:27 +01:00
|
|
|
void addDPRCalleeSavedAreaFrame(int fi) {
|
|
|
|
if (fi >= 0) {
|
2007-03-01 08:52:44 +01:00
|
|
|
int Size = DPRCSFrames.size();
|
|
|
|
if (fi >= Size) {
|
|
|
|
Size *= 2;
|
|
|
|
if (fi >= Size)
|
|
|
|
Size = fi+1;
|
|
|
|
DPRCSFrames.resize(Size);
|
|
|
|
}
|
2007-01-25 04:07:27 +01:00
|
|
|
DPRCSFrames[fi] = true;
|
|
|
|
}
|
2007-01-19 08:51:42 +01:00
|
|
|
}
|
|
|
|
|
2007-03-01 09:26:31 +01:00
|
|
|
void setCSRegisterIsSpilled(unsigned Reg) {
|
|
|
|
SpilledCSRegs.set(Reg);
|
|
|
|
}
|
|
|
|
|
2008-11-08 01:51:41 +01:00
|
|
|
bool isCSRegisterSpilled(unsigned Reg) const {
|
2007-03-01 09:26:31 +01:00
|
|
|
return SpilledCSRegs[Reg];
|
|
|
|
}
|
|
|
|
|
|
|
|
const BitVector &getSpilledCSRegisters() const {
|
|
|
|
return SpilledCSRegs;
|
|
|
|
}
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
unsigned createJumpTableUId() {
|
|
|
|
return JumpTableUId++;
|
|
|
|
}
|
2008-11-08 01:51:41 +01:00
|
|
|
|
|
|
|
unsigned getNumJumpTables() const {
|
|
|
|
return JumpTableUId;
|
|
|
|
}
|
|
|
|
|
2011-01-17 09:03:18 +01:00
|
|
|
void initPICLabelUId(unsigned UId) {
|
|
|
|
PICLabelUId = UId;
|
2008-11-08 01:51:41 +01:00
|
|
|
}
|
|
|
|
|
2011-01-17 09:03:18 +01:00
|
|
|
unsigned getNumPICLabels() const {
|
|
|
|
return PICLabelUId;
|
2008-11-08 01:51:41 +01:00
|
|
|
}
|
|
|
|
|
2011-01-17 09:03:18 +01:00
|
|
|
unsigned createPICLabelUId() {
|
|
|
|
return PICLabelUId++;
|
2008-11-08 01:51:41 +01:00
|
|
|
}
|
2010-04-17 16:41:14 +02:00
|
|
|
|
|
|
|
int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
|
|
|
|
void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
|
2010-06-19 01:09:54 +02:00
|
|
|
|
|
|
|
bool hasITBlocks() const { return HasITBlocks; }
|
|
|
|
void setHasITBlocks(bool h) { HasITBlocks = h; }
|
2011-01-30 23:07:39 +01:00
|
|
|
|
|
|
|
void recordCPEClone(unsigned CPIdx, unsigned CPCloneIdx) {
|
|
|
|
if (!CPEClones.insert(std::make_pair(CPCloneIdx, CPIdx)).second)
|
|
|
|
assert(0 && "Duplicate entries!");
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getOriginalCPIdx(unsigned CloneIdx) const {
|
|
|
|
DenseMap<unsigned, unsigned>::const_iterator I = CPEClones.find(CloneIdx);
|
|
|
|
if (I != CPEClones.end())
|
|
|
|
return I->second;
|
|
|
|
else
|
|
|
|
return -1U;
|
|
|
|
}
|
2007-01-19 08:51:42 +01:00
|
|
|
};
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif // ARMMACHINEFUNCTIONINFO_H
|