Skip to content
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

Rework put_string-based codegen #204

Open
aborg-dev opened this issue Feb 2, 2024 · 1 comment
Open

Rework put_string-based codegen #204

aborg-dev opened this issue Feb 2, 2024 · 1 comment
Labels
C-housekeeping Category: Refactoring, cleanups, code quality

Comments

@aborg-dev
Copy link

We currently generate most of zkAsm code using put_string function:

fn put_string(s: &str, sink: &mut MachBuffer<Inst>) {

There are a few things that we can improve here:

@aborg-dev aborg-dev added the C-housekeeping Category: Refactoring, cleanups, code quality label Feb 14, 2024
@MCJOHN974
Copy link

In continue to today discussion, I agree that better way to do this will be iteratively add functions like

fn emit_assign32(sink, reg, val) {
   sink.put_string(...)
}

But once majority of such functions will be implemented I still for introducing ZkasmSink struct, which will be wrapper on top of old sink, and once we will need some new functionality of old sink we will be able to easily do something

impl ZkasmSink {
    fn new_sink_feature(...) {
        self.sink.new_sink_feature()
    }
}

So we wouldn't really deviate codestyle much, we will just enrich a bit functionality of sink.

And this will help to fully avoid direct put_string usage, and made code more consistent, which will be better I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-housekeeping Category: Refactoring, cleanups, code quality
Projects
None yet
Development

No branches or pull requests

2 participants