if (LHSs && RHSs) {
DefInit *LOp = dynamic_cast<DefInit*>(LHSs->getOperator());
DefInit *ROp = dynamic_cast<DefInit*>(RHSs->getOperator());
- if (LOp->getDef() != ROp->getDef()) {
- bool LIsOps =
- LOp->getDef()->getName() == "outs" ||
- LOp->getDef()->getName() != "ins" ||
- LOp->getDef()->getName() != "defs";
- bool RIsOps =
- ROp->getDef()->getName() == "outs" ||
- ROp->getDef()->getName() != "ins" ||
- ROp->getDef()->getName() != "defs";
- if (!LIsOps || !RIsOps)
- throw "Concated Dag operators do not match!";
- }
+ if (LOp == 0 || ROp == 0 || LOp->getDef() != ROp->getDef())
+ throw "Concated Dag operators do not match!";
std::vector<Init*> Args;
std::vector<std::string> ArgNames;
for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) {
}
break;
}
+ case EQ: {
+ // Make sure we've resolved
+ StringInit *LHSs = dynamic_cast<StringInit*>(LHS);
+ StringInit *RHSs = dynamic_cast<StringInit*>(RHS);
+ if (LHSs && RHSs)
+ return new IntInit(LHSs->getValue() == RHSs->getValue());
+
+ break;
+ }
case SHL:
case SRA:
case SRL: {
case SHL: Result = "!shl"; break;
case SRA: Result = "!sra"; break;
case SRL: Result = "!srl"; break;
+ case EQ: Result = "!eq"; break;
case STRCONCAT: Result = "!strconcat"; break;
case NAMECONCAT:
Result = "!nameconcat<" + getType()->getAsString() + ">"; break;
std::string Val = RHSs->getValue();
std::string::size_type found;
+ std::string::size_type idx = 0;
do {
- found = Val.find(LHSs->getValue());
+ found = Val.find(LHSs->getValue(), idx);
if (found != std::string::npos) {
Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
}
+ idx = found + MHSs->getValue().size();
} while (found != std::string::npos);
return new StringInit(Val);
return 0;
}
-Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const {
+Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
+ const std::string &FieldName) const {
if (dynamic_cast<RecordRecTy*>(getType()))
- if (const RecordVal *RV = R.getValue(VarName)) {
- Init *TheInit = RV->getValue();
+ if (const RecordVal *Val = R.getValue(VarName)) {
+ if (RV != Val && (RV || dynamic_cast<UnsetInit*>(Val->getValue())))
+ return 0;
+ Init *TheInit = Val->getValue();
assert(TheInit != this && "Infinite loop detected!");
- if (Init *I = TheInit->getFieldInit(R, FieldName))
+ if (Init *I = TheInit->getFieldInit(R, RV, FieldName))
return I;
else
return 0;
return 0;
}
-Init *DefInit::getFieldInit(Record &R, const std::string &FieldName) const {
+Init *DefInit::getFieldInit(Record &R, const RecordVal *RV,
+ const std::string &FieldName) const {
return Def->getValue(FieldName)->getValue();
}
Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV,
unsigned Bit) {
- if (Init *BitsVal = Rec->getFieldInit(R, FieldName))
+ if (Init *BitsVal = Rec->getFieldInit(R, RV, FieldName))
if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
assert(Bit < BI->getNumBits() && "Bit reference out of range!");
Init *B = BI->getBit(Bit);
Init *FieldInit::resolveListElementReference(Record &R, const RecordVal *RV,
unsigned Elt) {
- if (Init *ListVal = Rec->getFieldInit(R, FieldName))
+ if (Init *ListVal = Rec->getFieldInit(R, RV, FieldName))
if (ListInit *LI = dynamic_cast<ListInit*>(ListVal)) {
if (Elt >= LI->getSize()) return 0;
Init *E = LI->getElement(Elt);
Init *FieldInit::resolveReferences(Record &R, const RecordVal *RV) {
Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec;
- Init *BitsVal = NewRec->getFieldInit(R, FieldName);
+ Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName);
if (BitsVal) {
Init *BVR = BitsVal->resolveReferences(R, RV);
return BVR->isComplete() ? BVR : this;
}
}
-
void Record::dump() const { errs() << *this; }
raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) {