Skip to content

Commit 67ebd94

Browse files
author
Mikhail Glushenkov
committed
llvmc: Make it possible to provide an argument to (join).
llvm-svn: 130914
1 parent e69ab05 commit 67ebd94

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ int InitPtrToInt(const Init* ptr) {
7474
return val.getValue();
7575
}
7676

77+
bool InitPtrToBool(const Init* ptr) {
78+
bool ret = false;
79+
const DefInit& val = dynamic_cast<const DefInit&>(*ptr);
80+
const std::string& str = val.getAsString();
81+
82+
if (str == "true") {
83+
ret = true;
84+
}
85+
else if (str == "false") {
86+
ret = false;
87+
}
88+
else {
89+
throw "Incorrect boolean value: '" + str +
90+
"': must be either 'true' or 'false'";
91+
}
92+
93+
return ret;
94+
}
95+
7796
const std::string& InitPtrToString(const Init* ptr) {
7897
const StringInit& val = dynamic_cast<const StringInit&>(*ptr);
7998
return val.getValue();
@@ -95,13 +114,7 @@ const std::string GetOperatorName(const DagInit& D) {
95114

96115
/// CheckBooleanConstant - Check that the provided value is a boolean constant.
97116
void CheckBooleanConstant(const Init* I) {
98-
const DefInit& val = dynamic_cast<const DefInit&>(*I);
99-
const std::string& str = val.getAsString();
100-
101-
if (str != "true" && str != "false") {
102-
throw "Incorrect boolean value: '" + str +
103-
"': must be either 'true' or 'false'";
104-
}
117+
InitPtrToBool(I);
105118
}
106119

107120
// CheckNumberOfArguments - Ensure that the number of args in d is
@@ -935,8 +948,22 @@ class CollectToolProperties : public HandlerTable<CollectToolPropertiesHandler>
935948
}
936949

937950
void onJoin (const DagInit& d) {
938-
CheckNumberOfArguments(d, 0);
939-
toolDesc_.setJoin();
951+
bool isReallyJoin = false;
952+
953+
if (d.getNumArgs() == 0) {
954+
isReallyJoin = true;
955+
}
956+
else {
957+
Init* I = d.getArg(0);
958+
isReallyJoin = InitPtrToBool(I);
959+
}
960+
961+
// Is this *really* a join tool? We allow (join false) for generating two
962+
// tool descriptions from a single generic one.
963+
// TOFIX: come up with a cleaner solution.
964+
if (isReallyJoin) {
965+
toolDesc_.setJoin();
966+
}
940967
}
941968

942969
void onOutLanguage (const DagInit& d) {

0 commit comments

Comments
 (0)