summaryrefslogtreecommitdiff
path: root/utils/TableGen/Record.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2010-01-05 19:11:42 +0000
committerDavid Greene <greened@obbligato.org>2010-01-05 19:11:42 +0000
commit6786d5e18387465d6106eaef0b7923526ef0bc10 (patch)
tree3665a60a078ae910aeff79fc75a4c8eb9f918781 /utils/TableGen/Record.cpp
parent5f7775c85e60aa659ac76c4b18f7a1f6494f23e2 (diff)
downloadllvm-6786d5e18387465d6106eaef0b7923526ef0bc10.tar.gz
llvm-6786d5e18387465d6106eaef0b7923526ef0bc10.tar.bz2
llvm-6786d5e18387465d6106eaef0b7923526ef0bc10.tar.xz
Add an !eq() operator to TableGen. It operates on strings only.
Use !cast<string>() to compare other types of objects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92754 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r--utils/TableGen/Record.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 542735e88b..f9e2fe8a39 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -730,6 +730,15 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
}
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: {
@@ -768,6 +777,7 @@ std::string BinOpInit::getAsString() const {
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;