mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Add an ARMConstantPool class for external symbols. This will split out the support for external symbols from the base class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140938 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f4e4592c3
commit
ff4a8023ec
@ -35,6 +35,15 @@ ARMConstantPoolValue::ARMConstantPoolValue(Type *Ty, unsigned id,
|
|||||||
PCAdjust(PCAdj), Modifier(modifier),
|
PCAdjust(PCAdj), Modifier(modifier),
|
||||||
AddCurrentAddress(addCurrentAddress) {}
|
AddCurrentAddress(addCurrentAddress) {}
|
||||||
|
|
||||||
|
ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C, unsigned id,
|
||||||
|
ARMCP::ARMCPKind kind,
|
||||||
|
unsigned char PCAdj,
|
||||||
|
ARMCP::ARMCPModifier modifier,
|
||||||
|
bool addCurrentAddress)
|
||||||
|
: MachineConstantPoolValue((Type*)Type::getInt32Ty(C)),
|
||||||
|
LabelId(id), Kind(kind), PCAdjust(PCAdj), Modifier(modifier),
|
||||||
|
AddCurrentAddress(addCurrentAddress) {}
|
||||||
|
|
||||||
ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
|
ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
|
||||||
const MachineBasicBlock *mbb,
|
const MachineBasicBlock *mbb,
|
||||||
unsigned id,
|
unsigned id,
|
||||||
@ -55,6 +64,10 @@ ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
|
|||||||
S(strdup(s)), LabelId(id), Kind(ARMCP::CPExtSymbol),
|
S(strdup(s)), LabelId(id), Kind(ARMCP::CPExtSymbol),
|
||||||
PCAdjust(PCAdj), Modifier(Modif), AddCurrentAddress(AddCA) {}
|
PCAdjust(PCAdj), Modifier(Modif), AddCurrentAddress(AddCA) {}
|
||||||
|
|
||||||
|
ARMConstantPoolValue::~ARMConstantPoolValue() {
|
||||||
|
free((void*)S);
|
||||||
|
}
|
||||||
|
|
||||||
const MachineBasicBlock *ARMConstantPoolValue::getMBB() const {
|
const MachineBasicBlock *ARMConstantPoolValue::getMBB() const {
|
||||||
return MBB;
|
return MBB;
|
||||||
}
|
}
|
||||||
@ -101,10 +114,6 @@ int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARMConstantPoolValue::~ARMConstantPoolValue() {
|
|
||||||
free((void*)S);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ARMConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
|
ARMConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
|
||||||
ID.AddPointer(S);
|
ID.AddPointer(S);
|
||||||
@ -245,3 +254,68 @@ void ARMConstantPoolConstant::print(raw_ostream &O) const {
|
|||||||
O << CVal->getName();
|
O << CVal->getName();
|
||||||
ARMConstantPoolValue::print(O);
|
ARMConstantPoolValue::print(O);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// ARMConstantPoolSymbol
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
ARMConstantPoolSymbol::ARMConstantPoolSymbol(LLVMContext &C, const char *s,
|
||||||
|
unsigned id,
|
||||||
|
unsigned char PCAdj,
|
||||||
|
ARMCP::ARMCPModifier Modifier,
|
||||||
|
bool AddCurrentAddress)
|
||||||
|
: ARMConstantPoolValue(C, id, ARMCP::CPExtSymbol, PCAdj, Modifier,
|
||||||
|
AddCurrentAddress),
|
||||||
|
S(strdup(s)) {}
|
||||||
|
|
||||||
|
ARMConstantPoolSymbol::~ARMConstantPoolSymbol() {
|
||||||
|
free((void*)S);
|
||||||
|
}
|
||||||
|
|
||||||
|
ARMConstantPoolSymbol *
|
||||||
|
ARMConstantPoolSymbol::Create(LLVMContext &C, const char *s,
|
||||||
|
unsigned ID, unsigned char PCAdj,
|
||||||
|
ARMCP::ARMCPModifier Modifier,
|
||||||
|
bool AddCurrentAddress) {
|
||||||
|
return new ARMConstantPoolSymbol(C, s, ID, PCAdj, Modifier,
|
||||||
|
AddCurrentAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ARMConstantPoolSymbol::getExistingMachineCPValue(MachineConstantPool *CP,
|
||||||
|
unsigned Alignment) {
|
||||||
|
unsigned AlignMask = Alignment - 1;
|
||||||
|
const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants();
|
||||||
|
for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
|
||||||
|
if (Constants[i].isMachineConstantPoolEntry() &&
|
||||||
|
(Constants[i].getAlignment() & AlignMask) == 0) {
|
||||||
|
ARMConstantPoolValue *CPV =
|
||||||
|
(ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
|
||||||
|
ARMConstantPoolSymbol *APS = dyn_cast<ARMConstantPoolSymbol>(CPV);
|
||||||
|
if (!APS) continue;
|
||||||
|
|
||||||
|
if (APS->getLabelId() == this->getLabelId() &&
|
||||||
|
APS->getPCAdjustment() == this->getPCAdjustment() &&
|
||||||
|
CPV_streq(APS->getSymbol(), this->getSymbol()) &&
|
||||||
|
APS->getModifier() == this->getModifier())
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ARMConstantPoolSymbol::hasSameValue(ARMConstantPoolValue *ACPV) {
|
||||||
|
const ARMConstantPoolSymbol *ACPS = dyn_cast<ARMConstantPoolSymbol>(ACPV);
|
||||||
|
return ACPS && CPV_streq(ACPS->S, S) &&
|
||||||
|
ARMConstantPoolValue::hasSameValue(ACPV);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARMConstantPoolSymbol::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
|
||||||
|
ID.AddPointer(S);
|
||||||
|
ARMConstantPoolValue::addSelectionDAGCSEId(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARMConstantPoolSymbol::print(raw_ostream &O) const {
|
||||||
|
O << S;
|
||||||
|
ARMConstantPoolValue::print(O);
|
||||||
|
}
|
||||||
|
@ -63,6 +63,9 @@ protected:
|
|||||||
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
||||||
bool AddCurrentAddress);
|
bool AddCurrentAddress);
|
||||||
|
|
||||||
|
ARMConstantPoolValue(LLVMContext &C, unsigned id, ARMCP::ARMCPKind Kind,
|
||||||
|
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
||||||
|
bool AddCurrentAddress);
|
||||||
public:
|
public:
|
||||||
ARMConstantPoolValue(LLVMContext &C, const MachineBasicBlock *mbb,unsigned id,
|
ARMConstantPoolValue(LLVMContext &C, const MachineBasicBlock *mbb,unsigned id,
|
||||||
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
||||||
@ -73,7 +76,7 @@ public:
|
|||||||
unsigned char PCAdj = 0,
|
unsigned char PCAdj = 0,
|
||||||
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
||||||
bool AddCurrentAddress = false);
|
bool AddCurrentAddress = false);
|
||||||
~ARMConstantPoolValue();
|
virtual ~ARMConstantPoolValue();
|
||||||
|
|
||||||
const char *getSymbol() const { return S; }
|
const char *getSymbol() const { return S; }
|
||||||
const MachineBasicBlock *getMBB() const;
|
const MachineBasicBlock *getMBB() const;
|
||||||
@ -166,6 +169,42 @@ public:
|
|||||||
static bool classof(const ARMConstantPoolConstant *) { return true; }
|
static bool classof(const ARMConstantPoolConstant *) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// ARMConstantPoolSymbol - ARM-specific constantpool values for external
|
||||||
|
/// symbols.
|
||||||
|
class ARMConstantPoolSymbol : public ARMConstantPoolValue {
|
||||||
|
const char *S; // ExtSymbol being loaded.
|
||||||
|
|
||||||
|
ARMConstantPoolSymbol(LLVMContext &C, const char *s, unsigned id,
|
||||||
|
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
||||||
|
bool AddCurrentAddress);
|
||||||
|
|
||||||
|
public:
|
||||||
|
~ARMConstantPoolSymbol();
|
||||||
|
|
||||||
|
static ARMConstantPoolSymbol *Create(LLVMContext &C, const char *s,
|
||||||
|
unsigned ID, unsigned char PCAdj,
|
||||||
|
ARMCP::ARMCPModifier Modifier,
|
||||||
|
bool AddCurrentAddress);
|
||||||
|
|
||||||
|
const char *getSymbol() const { return S; }
|
||||||
|
|
||||||
|
virtual int getExistingMachineCPValue(MachineConstantPool *CP,
|
||||||
|
unsigned Alignment);
|
||||||
|
|
||||||
|
virtual void addSelectionDAGCSEId(FoldingSetNodeID &ID);
|
||||||
|
|
||||||
|
/// hasSameValue - Return true if this ARM constpool value can share the same
|
||||||
|
/// constantpool entry as another ARM constpool value.
|
||||||
|
virtual bool hasSameValue(ARMConstantPoolValue *ACPV);
|
||||||
|
|
||||||
|
virtual void print(raw_ostream &O) const;
|
||||||
|
|
||||||
|
static bool classof(const ARMConstantPoolValue *ACPV) {
|
||||||
|
return ACPV->isExtSymbol();
|
||||||
|
}
|
||||||
|
static bool classof(const ARMConstantPoolSymbol *) { return true; }
|
||||||
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user