Extend ASR with metadata
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 271
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 173
Description
Original issue: https://gitlab.com/lfortran/lfortran/-/issues/674
Initially every symbol and every stmt will have a metadata member, something along these lines:
--- a/grammar/ASR.asdl
+++ b/grammar/ASR.asdl
@@ -81,7 +81,7 @@ unit
symbol
= Program(symbol_table symtab, identifier name, identifier* dependencies,
- stmt* body)
+ stmt* body, metadata? metadata)
| Module(symbol_table symtab, identifier name, identifier* dependencies,
bool loaded_from_mod, bool intrinsic)
| Subroutine(symbol_table symtab, identifier name, expr* args, stmt* body,
@@ -152,7 +152,7 @@ abi -- External ABI
stmt
- = Allocate(alloc_arg* args, expr? stat, expr? errmsg)
+ = Allocate(alloc_arg* args, expr? stat, expr? errmsg, metadata? metadata)
| Assign(int label, identifier variable)
| Assignment(expr target, expr value, stmt? overloaded)
| Associate(expr target, expr value)
@@ -291,4 +291,10 @@ do_loop_head = (expr? v, expr? start, expr? end, expr? increment)
case_stmt = CaseStmt(expr* test, stmt* body) | CaseStmt_Range(expr? start, expr? end, stmt* body)
+metadata
+ = MetadataGeneralPragma(string text)
+ | MetadataOpenMPPragma(...)
+ | MetadataComment(string comment)
+ | MetadataOptimization(...)
+ | MetadataDeclaration(bool device) # does the array live on a device or host
+
}
So that the frontend can parse things like OpenMP pragmas as well as general (LFortran/LPython) pragmas and any other extensions, such as optimization directives to choose which ASR passes to apply for the given function or loop.
Effectively this would allow a simple way to extend the ASR without having to modify any code, so that we can experiment with some feature first, and later decide whether to keep it as metadata, or put it into ASR proper.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading grammar/ASR.asdl, especially the symbol and stmt definitions and the proposed metadata variants. Determine how metadata should represent OpenMP, general pragmas, optimization directives, comments, and device declarations; done means the ASR can carry metadata on symbols and statements without modifying ASR for each extension.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100