forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
FXML.2007: PDLL support for creating new ops with empty regions #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
martin-luecke
merged 12 commits into
feature/fused-ops
from
martin.FXML-2007.PDLL_new_ops_with_empty_regions
May 5, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8a203d8
Add optional numRegions attribute to pdl.operation
martin-luecke e9acd20
fix PDL parsing of attr-dict
martin-luecke 0e0e73f
Add optional numRegions attribute to pdl_interp.create_operation
martin-luecke 589ac83
add PDLInterp parsing and printing support for numRegions Attr
martin-luecke 4272436
add PDL parsing and printing support for numRegions Attr
martin-luecke ade21cd
add Bytecode interpreter support for generating ops with empty regions
martin-luecke c9dc70a
add PDLL support for ops with empty regions
martin-luecke a9740f2
reflow code for better readability
martin-luecke 63ef598
Use attribute specific accessor
martin-luecke ad9d75e
address PR comment
martin-luecke 3eee87d
add PDLL parser test
martin-luecke 1aaf8bd
add comments
martin-luecke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,34 +141,51 @@ LogicalResult OperandsOp::verify() { return verifyHasBindingUse(*this); } | |
// pdl::OperationOp | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// Handles parsing of OperationOpAttributes, e.g. {"attr" = %attribute}. | ||
/// Also allows empty `{}` | ||
static ParseResult parseOperationOpAttributes( | ||
OpAsmParser &p, | ||
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &attrOperands, | ||
ArrayAttr &attrNamesAttr) { | ||
Builder &builder = p.getBuilder(); | ||
SmallVector<Attribute, 4> attrNames; | ||
if (succeeded(p.parseOptionalLBrace())) { | ||
auto parseOperands = [&]() { | ||
StringAttr nameAttr; | ||
OpAsmParser::UnresolvedOperand operand; | ||
if (p.parseAttribute(nameAttr) || p.parseEqual() || | ||
p.parseOperand(operand)) | ||
if (failed(p.parseOptionalRBrace())) { | ||
auto parseOperands = [&]() { | ||
StringAttr nameAttr; | ||
OpAsmParser::UnresolvedOperand operand; | ||
if (p.parseAttribute(nameAttr) || p.parseEqual() || | ||
p.parseOperand(operand)) | ||
return failure(); | ||
attrNames.push_back(nameAttr); | ||
attrOperands.push_back(operand); | ||
return success(); | ||
}; | ||
if (p.parseCommaSeparatedList(parseOperands) || p.parseRBrace()) | ||
return failure(); | ||
attrNames.push_back(nameAttr); | ||
attrOperands.push_back(operand); | ||
return success(); | ||
}; | ||
if (p.parseCommaSeparatedList(parseOperands) || p.parseRBrace()) | ||
return failure(); | ||
} | ||
} | ||
Comment on lines
+153
to
167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The github diff is not very informative here.
to enable parsing |
||
attrNamesAttr = builder.getArrayAttr(attrNames); | ||
return success(); | ||
} | ||
|
||
/// Handles printing of OperationOpAttributes, e.g. {"attr" = %attribute}. | ||
/// Prints empty `{}` when it would not be possible to discern the attr-dict | ||
/// otherwise. | ||
static void printOperationOpAttributes(OpAsmPrinter &p, OperationOp op, | ||
OperandRange attrArgs, | ||
ArrayAttr attrNames) { | ||
if (attrNames.empty()) | ||
/// Only omit printing empty `{}` if there are no other attributes that have | ||
/// to be printed later because otherwise we could not discern the attr dict. | ||
static const SmallVector<StringRef, 3> specialAttrs = { | ||
"operand_segment_sizes", "attributeValueNames", "opName"}; | ||
bool onlySpecialAttrs = | ||
llvm::all_of(op->getAttrs(), [&](const NamedAttribute &attr) { | ||
return llvm::any_of(specialAttrs, [&](const StringRef &predefinedAttr) { | ||
return attr.getName() == predefinedAttr; | ||
}); | ||
}); | ||
if (attrNames.empty() && onlySpecialAttrs) | ||
return; | ||
p << " {"; | ||
interleaveComma(llvm::seq<int>(0, attrNames.size()), p, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.