Skip to content

feat[venom]: update text format for data section#4414

Merged
charles-cooper merged 8 commits intovyperlang:masterfrom
charles-cooper:feat/venom-db-bytes
Dec 20, 2024
Merged

feat[venom]: update text format for data section#4414
charles-cooper merged 8 commits intovyperlang:masterfrom
charles-cooper:feat/venom-db-bytes

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper commented Dec 19, 2024

What I did

add cases for raw bytes (which are generated by --optimize codesize) in data section. update parser to parse the new text format. refactor internal representation of data section to not use IRInstruction. remove xfail from previously passing test cases. tweak IRFunction repr to add the function name at close (helpful for debugging).

this is a follow on to #4402.

How I did it

How to verify it

Commit message

this commit updates the parser and grammar with new syntax for the data
section. it also adds cases for raw bytes (which are generated by
`--optimize codesize`) in the data section, which are required to
round-trip venom produced in `--optimize codesize` mode.

new format:
```
data readonly {
    dbsection foo {
        db @label1
        db x"abcd"
    }
}
```

the new "readonly" modifier doesn't have disambiguating power yet, but
it will make it easier to add "writable" data sections to the grammar in
the future if we decide to add that.

misc/refactor:
- remove xfail from previously failing test cases.
- refactor internal representation of data section to not use
  `IRInstruction`
- add `_as_asm_symbol` for easier lowering of labels
- tweak `IRFunction.__repr__()` to add the function name at close
  (helpful for debugging).
- tweak `IRBasicBlock.__repr__()` to add basic block and function name
  at close to help with readability

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

use more structured classes in its internal representation

remove dead branch in venom_to_assembly
update DataItem to implement __str__() instead of __repr__()
@charles-cooper charles-cooper changed the title feat[venom]: add roundtrip for bytes in data section feat[venom]: add text format for bytes in data section Dec 19, 2024
@harkal
Copy link
Copy Markdown
Collaborator

harkal commented Dec 20, 2024

I believe that since we took the path of "higher level" syntax with curly brackets etc .rodata looks kinda out of place. It would be more appropriate if we had code marked with .text or something. I would imagine it like this:

data_section readonly foo {
    db @label
    db x"abcd"
    db @label 0xBEEF @label2 "a" ; support multiple data in one line version
}

@charles-cooper charles-cooper changed the title feat[venom]: add text format for bytes in data section feat[venom]: update text format for data section Dec 20, 2024
@charles-cooper charles-cooper enabled auto-merge (squash) December 20, 2024 19:45
@charles-cooper charles-cooper merged commit fadd4de into vyperlang:master Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants