Add a convenience method to tell if two things are equal.

llvm-svn: 140946
This commit is contained in:
Bill Wendling 2011-10-01 12:44:28 +00:00
parent 248512a573
commit f977ff5fb5
2 changed files with 10 additions and 16 deletions

View File

@ -69,9 +69,7 @@ int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
(Constants[i].getAlignment() & AlignMask) == 0) { (Constants[i].getAlignment() & AlignMask) == 0) {
ARMConstantPoolValue *CPV = ARMConstantPoolValue *CPV =
(ARMConstantPoolValue *)Constants[i].Val.MachineCPVal; (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
if (CPV->LabelId == LabelId && if (this->equals(CPV))
CPV->PCAdjust == PCAdjust &&
CPV->Modifier == Modifier)
return i; return i;
} }
} }
@ -186,11 +184,7 @@ int ARMConstantPoolConstant::getExistingMachineCPValue(MachineConstantPool *CP,
(ARMConstantPoolValue *)Constants[i].Val.MachineCPVal; (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
ARMConstantPoolConstant *APC = dyn_cast<ARMConstantPoolConstant>(CPV); ARMConstantPoolConstant *APC = dyn_cast<ARMConstantPoolConstant>(CPV);
if (!APC) continue; if (!APC) continue;
if (APC->CVal == CVal && equals(APC))
if (APC->getGV() == this->CVal &&
APC->getLabelId() == this->getLabelId() &&
APC->getPCAdjustment() == this->getPCAdjustment() &&
APC->getModifier() == this->getModifier())
return i; return i;
} }
} }
@ -256,10 +250,7 @@ int ARMConstantPoolSymbol::getExistingMachineCPValue(MachineConstantPool *CP,
ARMConstantPoolSymbol *APS = dyn_cast<ARMConstantPoolSymbol>(CPV); ARMConstantPoolSymbol *APS = dyn_cast<ARMConstantPoolSymbol>(CPV);
if (!APS) continue; if (!APS) continue;
if (APS->getLabelId() == this->getLabelId() && if (CPV_streq(APS->S, S) && equals(APS))
APS->getPCAdjustment() == this->getPCAdjustment() &&
CPV_streq(APS->getSymbol(), this->getSymbol()) &&
APS->getModifier() == this->getModifier())
return i; return i;
} }
} }
@ -315,10 +306,7 @@ int ARMConstantPoolMBB::getExistingMachineCPValue(MachineConstantPool *CP,
ARMConstantPoolMBB *APMBB = dyn_cast<ARMConstantPoolMBB>(CPV); ARMConstantPoolMBB *APMBB = dyn_cast<ARMConstantPoolMBB>(CPV);
if (!APMBB) continue; if (!APMBB) continue;
if (APMBB->getLabelId() == this->getLabelId() && if (APMBB->MBB == MBB && equals(APMBB))
APMBB->getPCAdjustment() == this->getPCAdjustment() &&
APMBB->getMBB() == this->getMBB() &&
APMBB->getModifier() == this->getModifier())
return i; return i;
} }
} }

View File

@ -93,6 +93,12 @@ public:
/// constantpool entry as another ARM constpool value. /// constantpool entry as another ARM constpool value.
virtual bool hasSameValue(ARMConstantPoolValue *ACPV); virtual bool hasSameValue(ARMConstantPoolValue *ACPV);
bool equals(const ARMConstantPoolValue *A) const {
return this->LabelId == A->LabelId &&
this->PCAdjust == A->PCAdjust &&
this->Modifier == A->Modifier;
}
virtual void print(raw_ostream &O) const; virtual void print(raw_ostream &O) const;
void print(raw_ostream *O) const { if (O) print(*O); } void print(raw_ostream *O) const { if (O) print(*O); }
void dump() const; void dump() const;