Coder Social home page Coder Social logo

Comments (11)

phase avatar phase commented on August 27, 2024 2

I don't think this is something than an IR should add. This adds needless complexity that compiler writers don't need when working with IR. It seems odd that we would want to obfuscate the registers when that's exactly what a compiler writer would want to see.

from wasmtime.

Hyperion101010 avatar Hyperion101010 commented on August 27, 2024

Hi there sunfishcode can i work on this issue, i am new to contributing for open source.
I found compiler design interesting in our class and decided to contribute for same.
I have contributed for mozilla ,some patches in past few months, so i know the procedure of adding patches :)

from wasmtime.

Hyperion101010 avatar Hyperion101010 commented on August 27, 2024

If i am not wrong, web assembly will be used by high level language programmers(web developers) that use js in their day-to-day work. So the code must be easy to read. Moreover if we are thinking about games,etc developers they code in C++ which is again not assembly.

from wasmtime.

sunfishcode avatar sunfishcode commented on August 27, 2024

Hello! This is a good issue to work on, though to be clear, this is about the text format for Cranelift IR, not for WebAssembly itself, so it won't be visible to most developers unless they use compiler-explorer-type tools to look at the compiler IR as its compiling their code.

One of the big tasks here will be to implement infix expression parsing. My high-level idea here is that we can use an operator precedence parser. Do you think that sounds like a good approach?

from wasmtime.

Hyperion101010 avatar Hyperion101010 commented on August 27, 2024

Let's discuss on irc !
I am very excited to start working on this issue

from wasmtime.

Hyperion101010 avatar Hyperion101010 commented on August 27, 2024

hi sunfish what tool are we going to use here ? I can practice them to get working on this issue !

from wasmtime.

sunfishcode avatar sunfishcode commented on August 27, 2024

My rough idea here is that a hand-written operator precedence parser would work well, since the rest of the parser is also hand-written. However, I'm open to other suggestions here.

from wasmtime.

Hyperion101010 avatar Hyperion101010 commented on August 27, 2024

As far as i know it is just a debug feature for programmer .Using this he can understand wasm code more clearly like high level code .

from wasmtime.

sunfishcode avatar sunfishcode commented on August 27, 2024

@phase When I see something like "add v3, v4" in an IR dump before register allocation, most often my next question is "what defined r3 and/or r4?" and next most often my next question is "what else is using v3 or v4?" The infix notation proposed here would make it easier to answer both those questions in many common cases.

If we make this optional so that people don't have to see it when they don't want to, and if we disable it during and after register allocation, it seems like it could make the IR much more readable in many common cases.

Ultimately, I can't say for sure if this will be great, but it has potential :-).

from wasmtime.

bnjbvr avatar bnjbvr commented on August 27, 2024

@phase When I see something like "add v3, v4" in an IR dump before register allocation, most often my next question is "what defined r3 and/or r4?" and next most often my next question is "what else is using v3 or v4?" The infix notation proposed here would make it easier to answer both those questions in many common cases.

This made me think that an alternative / a nice addition to solve this particular problem would be to implement the language server protocol for CLIF. Then, we get "jump to definition" and "see all uses" for free in all the IDEs that have LSP addons (Visual Code, Sublime Text, Vim, etc.). Totally over-engineering to solve such a use case, but a fun small, self-contained project to write, and this could reuse a lot of code from the CLIF parsing infrastructure.

from wasmtime.

cfallin avatar cfallin commented on August 27, 2024

I'm doing some issue gardening and came across this. I think that I agree with the above arguments that this is not very "IR-like": in a sense it privileges certain operations (add, multiply, ...) and allows them to be written in a special syntax that looks like something other than a linear sequence of instructions. Since the underlying abstraction is that linear sequence of instructions, IMHO it would be better for the notation to remain closer to that.

There are also issues about round-tripping: do we represent how the expression was written in the parsed input and try to reproduce that when printing the CLIF back out? Or do we try to maximally use an expression syntax? It's simpler if we always, unconditionally, print one instruction per line, in instruction order.

So I'll go ahead and close this, given the discussion has quiesced, but if someone wants to make a renewed push for it, please feel free to do so.

from wasmtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.