Page MenuHomePhabricator

[WIP][mlir] Add struct context to parsing.
AbandonedPublic

Authored by ergawy on Sep 22 2020, 5:26 AM.

Details

Reviewers
rriddle
ftynse
Summary

This patch provides a way for dialect parsers to have access to struct
parsing context. This allows, for example, dialects that support
recursive structs (like LLVM, SPIR-V) to properly handle those structs.

Diff Detail

Event Timeline

ergawy created this revision.Sep 22 2020, 5:26 AM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
ergawy requested review of this revision.Sep 22 2020, 5:26 AM
ergawy added a comment.EditedSep 22 2020, 5:29 AM

This is an attempt to address a comment on this review: https://reviews.llvm.org/D87206 to provide a common mechanism for maintaining the struct parsing stack.

I hope this is more or less addresses the issue. Since it touches quite a bit of the infrastructure I am not sure if this is a good direction or not. If not, apologies for the extra noise.

Another approach would be to maintain a stack of Type objects instead of StringRefs. This might provide a more general mechanism and enable other uses in addition to recursive structs (don't have a specific use-case in mind though). However, doing this will need different dialects to construct containing/enclosing types before their sub-types and then mutate the enclosing types after parsing is completed. Not sure that will be a good direction.

mlir/include/mlir/IR/DialectImplementation.h
346

TODO: if this is agreed upon as a good approach, add docs here and elsewhere to describe the new bits.

ergawy added inline comments.Sep 22 2020, 5:35 AM
mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
393

Shouldn't we swap this and the above if conditions? At it is right now, we might not properly clean-up the struct stack if parsing the element type fails.

ergawy updated this revision to Diff 294648.Sep 28 2020, 4:15 AM
  • Rebase.
ergawy abandoned this revision.Mon, Oct 26, 3:07 PM