diff options
| author | David Greene <greened@obbligato.org> | 2010-01-05 19:11:42 +0000 |
|---|---|---|
| committer | David Greene <greened@obbligato.org> | 2010-01-05 19:11:42 +0000 |
| commit | 297bfe6d711285bc9d80a3bacb3bb363c0e444c4 (patch) | |
| tree | e4d284df05e6dd9390954f2d96e6f17e191592cb /llvm/utils/TableGen/Record.cpp | |
| parent | a318efd1f21a21358f45a201f7b6cb2b8b118ec0 (diff) | |
| download | bcm5719-llvm-297bfe6d711285bc9d80a3bacb3bb363c0e444c4.tar.gz bcm5719-llvm-297bfe6d711285bc9d80a3bacb3bb363c0e444c4.zip | |
Add an !eq() operator to TableGen. It operates on strings only.
Use !cast<string>() to compare other types of objects.
llvm-svn: 92754
Diffstat (limited to 'llvm/utils/TableGen/Record.cpp')
| -rw-r--r-- | llvm/utils/TableGen/Record.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp index 542735e88b4..f9e2fe8a397 100644 --- a/llvm/utils/TableGen/Record.cpp +++ b/llvm/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; |

