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

Rearrange parameters of asm functions in order described in asm(param1, param2) #1584

Open
i582 opened this issue Jan 27, 2025 · 6 comments
Open
Labels
kind: gas! Gas consumption and fee-related things scope: codegen Code generation, a.k.a. compiler backend (src/generator)

Comments

@i582
Copy link
Contributor

i582 commented Jan 27, 2025

asm(value self) extends fun storeBool(self: Builder, value: Bool): Builder { 1 STI }

We want to generate it to:

builder storeBool(int v, builder b) 

This will allow some runtime SWAP to be illuminated at compile time like #1571.

@i582 i582 added kind: gas! Gas consumption and fee-related things scope: codegen Code generation, a.k.a. compiler backend (src/generator) labels Jan 27, 2025
@i582 i582 changed the title rearrange parameters of asm functions in order described in asm(param1, param2) Rearrange parameters of asm functions in order described in asm(param1, param2) Jan 27, 2025
@verytactical
Copy link
Contributor

We have something in the grammar called AsmShuffle. This might be something we already have.

@i582
Copy link
Contributor Author

i582 commented Jan 27, 2025

We have something in the grammar called AsmShuffle. This might be something we already have.

Yep, but for now it translates to FunC asm shuffle syntax only

@novusnota
Copy link
Member

novusnota commented Jan 27, 2025

Oh, so your idea is to make AsmShuffle apply at comptime, in which case the FunC code would be generated with already re-arranged parameters and we'll have less SWAPs. Right, @i582?

@i582
Copy link
Contributor Author

i582 commented Jan 27, 2025

FunC code would be generated with already re-arranged parameters and we'll have less SWAPs.

Exactly!

@verytactical
Copy link
Contributor

That said, AsmShuffle syntax is really not that great. Handling it as a readable list of argument names is more than worth it.

@verytactical
Copy link
Contributor

I think this is a Language feature though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: gas! Gas consumption and fee-related things scope: codegen Code generation, a.k.a. compiler backend (src/generator)
Projects
None yet
Development

No branches or pull requests

3 participants