diff options
| author | Mikhail Glushenkov <foldr@codedgers.com> | 2011-05-05 04:24:58 +0000 |
|---|---|---|
| committer | Mikhail Glushenkov <foldr@codedgers.com> | 2011-05-05 04:24:58 +0000 |
| commit | 67ebd94a5d9326c2e1f714fa7a9ca479c2d50a13 (patch) | |
| tree | 9ef9e0072a7a686c7307c58821c30cfeb44b2d17 /llvm | |
| parent | e69ab05f6e229ee037e7917df9988de06142e714 (diff) | |
| download | bcm5719-llvm-67ebd94a5d9326c2e1f714fa7a9ca479c2d50a13.tar.gz bcm5719-llvm-67ebd94a5d9326c2e1f714fa7a9ca479c2d50a13.zip | |
llvmc: Make it possible to provide an argument to (join).
llvm-svn: 130914
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp b/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp index 6572595862b..090faf50855 100644 --- a/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp +++ b/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp @@ -74,6 +74,25 @@ int InitPtrToInt(const Init* ptr) { return val.getValue(); } +bool InitPtrToBool(const Init* ptr) { + bool ret = false; + const DefInit& val = dynamic_cast<const DefInit&>(*ptr); + const std::string& str = val.getAsString(); + + if (str == "true") { + ret = true; + } + else if (str == "false") { + ret = false; + } + else { + throw "Incorrect boolean value: '" + str + + "': must be either 'true' or 'false'"; + } + + return ret; +} + const std::string& InitPtrToString(const Init* ptr) { const StringInit& val = dynamic_cast<const StringInit&>(*ptr); return val.getValue(); @@ -95,13 +114,7 @@ const std::string GetOperatorName(const DagInit& D) { /// CheckBooleanConstant - Check that the provided value is a boolean constant. void CheckBooleanConstant(const Init* I) { - const DefInit& val = dynamic_cast<const DefInit&>(*I); - const std::string& str = val.getAsString(); - - if (str != "true" && str != "false") { - throw "Incorrect boolean value: '" + str + - "': must be either 'true' or 'false'"; - } + InitPtrToBool(I); } // CheckNumberOfArguments - Ensure that the number of args in d is @@ -935,8 +948,22 @@ private: } void onJoin (const DagInit& d) { - CheckNumberOfArguments(d, 0); - toolDesc_.setJoin(); + bool isReallyJoin = false; + + if (d.getNumArgs() == 0) { + isReallyJoin = true; + } + else { + Init* I = d.getArg(0); + isReallyJoin = InitPtrToBool(I); + } + + // Is this *really* a join tool? We allow (join false) for generating two + // tool descriptions from a single generic one. + // TOFIX: come up with a cleaner solution. + if (isReallyJoin) { + toolDesc_.setJoin(); + } } void onOutLanguage (const DagInit& d) { |

