mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-22 10:29:35 +00:00
[mips] Define a derived class of PseudoSourceValue that represents a GOT entry
resolved by lazy-binding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191578 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b99f6e14af
commit
479a778590
@ -22,6 +22,53 @@ static cl::opt<bool>
|
||||
FixGlobalBaseReg("mips-fix-global-base-reg", cl::Hidden, cl::init(true),
|
||||
cl::desc("Always use $gp as the global base register."));
|
||||
|
||||
// class MipsCallEntry.
|
||||
MipsCallEntry::MipsCallEntry(const StringRef &N) {
|
||||
#ifndef NDEBUG
|
||||
Name = N;
|
||||
Val = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
MipsCallEntry::MipsCallEntry(const GlobalValue *V) {
|
||||
#ifndef NDEBUG
|
||||
Val = V;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MipsCallEntry::isConstant(const MachineFrameInfo *) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MipsCallEntry::isAliased(const MachineFrameInfo *) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MipsCallEntry::mayAlias(const MachineFrameInfo *) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MipsCallEntry::printCustom(raw_ostream &O) const {
|
||||
O << "MipsCallEntry: ";
|
||||
#ifndef NDEBUG
|
||||
if (Val)
|
||||
O << Val->getName();
|
||||
else
|
||||
O << Name;
|
||||
#endif
|
||||
}
|
||||
|
||||
MipsFunctionInfo::~MipsFunctionInfo() {
|
||||
for (StringMap<const MipsCallEntry *>::iterator
|
||||
I = ExternalCallEntries.begin(), E = ExternalCallEntries.end(); I != E;
|
||||
++I)
|
||||
delete I->getValue();
|
||||
|
||||
for (ValueMap<const GlobalValue *, const MipsCallEntry *>::iterator
|
||||
I = GlobalCallEntries.begin(), E = GlobalCallEntries.end(); I != E; ++I)
|
||||
delete I->second;
|
||||
}
|
||||
|
||||
bool MipsFunctionInfo::globalBaseRegSet() const {
|
||||
return GlobalBaseReg;
|
||||
}
|
||||
@ -72,4 +119,26 @@ bool MipsFunctionInfo::isEhDataRegFI(int FI) const {
|
||||
|| FI == EhDataRegFI[2] || FI == EhDataRegFI[3]);
|
||||
}
|
||||
|
||||
MachinePointerInfo MipsFunctionInfo::callPtrInfo(const StringRef &Name) {
|
||||
StringMap<const MipsCallEntry *>::const_iterator I;
|
||||
I = ExternalCallEntries.find(Name);
|
||||
|
||||
if (I != ExternalCallEntries.end())
|
||||
return MachinePointerInfo(I->getValue());
|
||||
|
||||
const MipsCallEntry *E = ExternalCallEntries[Name] = new MipsCallEntry(Name);
|
||||
return MachinePointerInfo(E);
|
||||
}
|
||||
|
||||
MachinePointerInfo MipsFunctionInfo::callPtrInfo(const GlobalValue *Val) {
|
||||
ValueMap<const GlobalValue *, const MipsCallEntry *>::const_iterator I;
|
||||
I = GlobalCallEntries.find(Val);
|
||||
|
||||
if (I != GlobalCallEntries.end())
|
||||
return MachinePointerInfo(I->second);
|
||||
|
||||
const MipsCallEntry *E = GlobalCallEntries[Val] = new MipsCallEntry(Val);
|
||||
return MachinePointerInfo(E);
|
||||
}
|
||||
|
||||
void MipsFunctionInfo::anchor() { }
|
||||
|
@ -15,14 +15,37 @@
|
||||
#define MIPS_MACHINE_FUNCTION_INFO_H
|
||||
|
||||
#include "MipsSubtarget.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/ValueMap.h"
|
||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineMemOperand.h"
|
||||
#include "llvm/CodeGen/PseudoSourceValue.h"
|
||||
#include "llvm/IR/GlobalValue.h"
|
||||
#include "llvm/Target/TargetFrameLowering.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// \brief A class derived from PseudoSourceValue that represents a GOT entry
|
||||
/// resolved by lazy-binding.
|
||||
class MipsCallEntry : public PseudoSourceValue {
|
||||
public:
|
||||
explicit MipsCallEntry(const StringRef &N);
|
||||
explicit MipsCallEntry(const GlobalValue *V);
|
||||
virtual bool isConstant(const MachineFrameInfo *) const;
|
||||
virtual bool isAliased(const MachineFrameInfo *) const;
|
||||
virtual bool mayAlias(const MachineFrameInfo *) const;
|
||||
|
||||
private:
|
||||
virtual void printCustom(raw_ostream &O) const;
|
||||
#ifndef NDEBUG
|
||||
std::string Name;
|
||||
const GlobalValue *Val;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// MipsFunctionInfo - This class is derived from MachineFunction private
|
||||
/// Mips target-specific information for each MachineFunction.
|
||||
class MipsFunctionInfo : public MachineFunctionInfo {
|
||||
@ -32,6 +55,8 @@ public:
|
||||
VarArgsFrameIndex(0), CallsEhReturn(false)
|
||||
{}
|
||||
|
||||
~MipsFunctionInfo();
|
||||
|
||||
unsigned getSRetReturnReg() const { return SRetReturnReg; }
|
||||
void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
|
||||
|
||||
@ -59,6 +84,14 @@ public:
|
||||
int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
|
||||
bool isEhDataRegFI(int FI) const;
|
||||
|
||||
/// \brief Create a MachinePointerInfo that has a MipsCallEntr object
|
||||
/// representing a GOT entry for an external function.
|
||||
MachinePointerInfo callPtrInfo(const StringRef &Name);
|
||||
|
||||
/// \brief Create a MachinePointerInfo that has a MipsCallEntr object
|
||||
/// representing a GOT entry for a global function.
|
||||
MachinePointerInfo callPtrInfo(const GlobalValue *Val);
|
||||
|
||||
private:
|
||||
virtual void anchor();
|
||||
|
||||
@ -92,6 +125,10 @@ private:
|
||||
|
||||
/// Frame objects for spilling eh data registers.
|
||||
int EhDataRegFI[4];
|
||||
|
||||
/// MipsCallEntry maps.
|
||||
StringMap<const MipsCallEntry *> ExternalCallEntries;
|
||||
ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries;
|
||||
};
|
||||
|
||||
} // end of namespace llvm
|
||||
|
Loading…
Reference in New Issue
Block a user