Skip to content

Commit

Permalink
parse into datastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Oct 21, 2024
1 parent 4e7f24c commit 55e8cdd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/llvm-dialects/TableGen/Operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Operation : public OperationBase {
std::string name;
std::string mnemonic;
std::vector<Trait *> traits;
std::map<llvm::StringRef, std::vector<Trait *>> value_traits;

std::vector<NamedValue> results;

Expand Down
23 changes: 23 additions & 0 deletions lib/TableGen/Operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,29 @@ bool Operation::parse(raw_ostream &errs, GenDialectsContext *context,
for (RecordTy *traitRec : record->getValueAsListOfDefs("traits"))
op->traits.push_back(context->getTrait(traitRec));

ListInit *List = record->getValueAsListInit("value_traits");
for (const Init *I : List->getValues()) {
if (const DagInit *DI = dyn_cast<DagInit>(I)) {
if (DI->getNumArgs() != 1) {
errs << "value_traits " << *DI << " is missing argument name";
return false;
}
StringRef name = DI->getArgNameStr(0);
std::vector<Trait*>& traits = op->value_traits[name];

if (const DefInit *Op = dyn_cast<DefInit>(DI->getOperator()))
traits.push_back(context->getTrait(Op->getDef()));
else {
errs << "value_traits " << *DI << " is not of form (Trait $arg)";
return false;
}
}
else {
errs << "value_traits was not a list of DAG's";
return false;
}
}

EvaluationPlanner evaluation(op->m_system);

for (const auto &arg : op->getFullArguments()) {
Expand Down

0 comments on commit 55e8cdd

Please sign in to comment.