Tristate mayLoad, mayStore, and hasSideEffects.

Keep track of the set/unset state of these bits along with their
true/false values, but treat '?' as '0' for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162461 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen
2012-08-23 19:34:46 +00:00
parent f104bf65b9
commit c1f10fd5b9
5 changed files with 37 additions and 7 deletions

View File

@@ -1963,6 +1963,23 @@ bool Record::getValueAsBit(StringRef FieldName) const {
"' does not have a bit initializer!";
}
bool Record::getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const {
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
throw "Record `" + getName() + "' does not have a field named `" +
FieldName.str() + "'!\n";
if (R->getValue() == UnsetInit::get()) {
Unset = true;
return false;
}
Unset = false;
if (BitInit *BI = dynamic_cast<BitInit*>(R->getValue()))
return BI->getValue();
throw "Record `" + getName() + "', field `" + FieldName.str() +
"' does not have a bit initializer!";
}
/// getValueAsDag - This method looks up the specified field and returns its
/// value as an Dag, throwing an exception if the field does not exist or if
/// the value is not the right type.