diff options
| author | Owen Anderson <resistor@mac.com> | 2011-06-27 21:06:21 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2011-06-27 21:06:21 +0000 |
| commit | bea6f615eefae279e53bbb63a31d2c3c67274c45 (patch) | |
| tree | 4c5b33c01d807a99de8411304c63cfdb5583b259 /utils/TableGen/Record.cpp | |
| parent | d1f0bbee189ea7cd18d03c4f9f55d0a33b070814 (diff) | |
Add support for alternative register names, useful for instructions whose operands are logically equivalent to existing registers, but happen to be printed specially. For example, an instruciton that prints d0[0] instead of s0.
Patch by Jim Grosbach.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
| -rw-r--r-- | utils/TableGen/Record.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 3c750da55f..730eca1b3c 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -1443,6 +1443,25 @@ Record::getValueAsListOfInts(StringRef FieldName) const { return Ints; } +/// getValueAsListOfStrings - This method looks up the specified field and +/// returns its value as a vector of strings, throwing an exception if the +/// field does not exist or if the value is not the right type. +/// +std::vector<std::string> +Record::getValueAsListOfStrings(StringRef FieldName) const { + ListInit *List = getValueAsListInit(FieldName); + std::vector<std::string> Strings; + for (unsigned i = 0; i < List->getSize(); i++) { + if (StringInit *II = dynamic_cast<StringInit*>(List->getElement(i))) { + Strings.push_back(II->getValue()); + } else { + throw "Record `" + getName() + "', field `" + FieldName.str() + + "' does not have a list of strings initializer!"; + } + } + return Strings; +} + /// getValueAsDef - This method looks up the specified field and returns its /// value as a Record, throwing an exception if the field does not exist or if /// the value is not the right type. |
