forked from OSchip/llvm-project
Add an ARMConstantPool class for external symbols. This will split out the support for external symbols from the base class.
llvm-svn: 140938
This commit is contained in:
parent
d115c4d300
commit
d7fa016720
|
@ -35,6 +35,15 @@ ARMConstantPoolValue::ARMConstantPoolValue(Type *Ty, unsigned id,
|
|||
PCAdjust(PCAdj), Modifier(modifier),
|
||||
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,
|
||||
const MachineBasicBlock *mbb,
|
||||
unsigned id,
|
||||
|
@ -55,6 +64,10 @@ ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
|
|||
S(strdup(s)), LabelId(id), Kind(ARMCP::CPExtSymbol),
|
||||
PCAdjust(PCAdj), Modifier(Modif), AddCurrentAddress(AddCA) {}
|
||||
|
||||
ARMConstantPoolValue::~ARMConstantPoolValue() {
|
||||
free((void*)S);
|
||||
}
|
||||
|
||||
const MachineBasicBlock *ARMConstantPoolValue::getMBB() const {
|
||||
return MBB;
|
||||
}
|
||||
|
@ -101,10 +114,6 @@ int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
|
|||
return -1;
|
||||
}
|
||||
|
||||
ARMConstantPoolValue::~ARMConstantPoolValue() {
|
||||
free((void*)S);
|
||||
}
|
||||
|
||||
void
|
||||
ARMConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
|
||||
ID.AddPointer(S);
|
||||
|
@ -245,3 +254,68 @@ void ARMConstantPoolConstant::print(raw_ostream &O) const {
|
|||
O << CVal->getName();
|
||||
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,
|
||||
bool AddCurrentAddress);
|
||||
|
||||
ARMConstantPoolValue(LLVMContext &C, unsigned id, ARMCP::ARMCPKind Kind,
|
||||
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
|
||||
bool AddCurrentAddress);
|
||||
public:
|
||||
ARMConstantPoolValue(LLVMContext &C, const MachineBasicBlock *mbb,unsigned id,
|
||||
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
|
||||
|
@ -73,7 +76,7 @@ public:
|
|||
unsigned char PCAdj = 0,
|
||||
ARMCP::ARMCPModifier Modifier = ARMCP::no_modifier,
|
||||
bool AddCurrentAddress = false);
|
||||
~ARMConstantPoolValue();
|
||||
virtual ~ARMConstantPoolValue();
|
||||
|
||||
const char *getSymbol() const { return S; }
|
||||
const MachineBasicBlock *getMBB() const;
|
||||
|
@ -166,6 +169,42 @@ public:
|
|||
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
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue