Add ARMConstantPoolMBB to hold an MBB value in the constant pool.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140942 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2011-10-01 09:19:10 +00:00
parent 14a1a6b018
commit 9c18f51daa
2 changed files with 90 additions and 1 deletions

View File

@ -299,3 +299,60 @@ void ARMConstantPoolSymbol::print(raw_ostream &O) const {
O << S;
ARMConstantPoolValue::print(O);
}
//===----------------------------------------------------------------------===//
// ARMConstantPoolMBB
//===----------------------------------------------------------------------===//
ARMConstantPoolMBB::ARMConstantPoolMBB(LLVMContext &C, MachineBasicBlock *mbb,
unsigned id, unsigned char PCAdj,
ARMCP::ARMCPModifier Modifier,
bool AddCurrentAddress)
: ARMConstantPoolValue(C, mbb, id, ARMCP::CPMachineBasicBlock, PCAdj,
Modifier, AddCurrentAddress),
MBB(mbb) {}
ARMConstantPoolMBB *ARMConstantPoolMBB::Create(LLVMContext &C,
MachineBasicBlock *mbb,
unsigned ID,
unsigned char PCAdj) {
return new ARMConstantPoolMBB(C, mbb, ID, PCAdj, ARMCP::no_modifier, false);
}
int ARMConstantPoolMBB::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;
ARMConstantPoolMBB *APMBB = dyn_cast<ARMConstantPoolMBB>(CPV);
if (!APMBB) continue;
if (APMBB->getLabelId() == this->getLabelId() &&
APMBB->getPCAdjustment() == this->getPCAdjustment() &&
APMBB->getMBB() == this->getMBB() &&
APMBB->getModifier() == this->getModifier())
return i;
}
}
return -1;
}
bool ARMConstantPoolMBB::hasSameValue(ARMConstantPoolValue *ACPV) {
const ARMConstantPoolMBB *ACPMBB = dyn_cast<ARMConstantPoolMBB>(ACPV);
return ACPMBB && ACPMBB->MBB == MBB &&
ARMConstantPoolValue::hasSameValue(ACPV);
}
void ARMConstantPoolMBB::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
ID.AddPointer(MBB);
ARMConstantPoolValue::addSelectionDAGCSEId(ID);
}
void ARMConstantPoolMBB::print(raw_ostream &O) const {
ARMConstantPoolValue::print(O);
}

View File

@ -88,7 +88,7 @@ public:
bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; }
bool isBlockAddress() const { return Kind == ARMCP::CPBlockAddress; }
bool isLSDA() const { return Kind == ARMCP::CPLSDA; }
bool isMachineBasicBlock() { return Kind == ARMCP::CPMachineBasicBlock; }
bool isMachineBasicBlock() const{ return Kind == ARMCP::CPMachineBasicBlock; }
virtual unsigned getRelocationInfo() const { return 2; }
@ -197,6 +197,38 @@ public:
static bool classof(const ARMConstantPoolSymbol *) { return true; }
};
/// ARMConstantPoolMBB - ARM-specific constantpool value of a machine basic
/// block.
class ARMConstantPoolMBB : public ARMConstantPoolValue {
MachineBasicBlock *MBB; // Machine basic block.
ARMConstantPoolMBB(LLVMContext &C, MachineBasicBlock *mbb, unsigned id,
unsigned char PCAdj, ARMCP::ARMCPModifier Modifier,
bool AddCurrentAddress);
public:
static ARMConstantPoolMBB *Create(LLVMContext &C, MachineBasicBlock *mbb,
unsigned ID, unsigned char PCAdj);
const MachineBasicBlock *getMBB() const { return MBB; }
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->isMachineBasicBlock();
}
static bool classof(const ARMConstantPoolMBB *) { return true; }
};
} // End llvm namespace
#endif