Skip to content

cmd/asm: a flag to dump Prog initialization as Go code #16342

Open

Description

@minux

When writing code for compiler backends, we sometimes
need to manual create assembly instructions by initializing
cmd/internal/obj.Prog structs directly. Even though
the revamped Addr types makes the task much easier than
it was, the process is still very error-prone and any mistakes
made there is pretty hard to diagnose.

I propose that we add an internal mode to cmd/asm that
instead of dumping .o object file, it prints the required
Prog initialization code to stdout.

I first discussed this with @cherrymui and we both liked the
idea.

Ideally, the new mode should be able to accept instruction
either from stdin, or better, from command line, so it is easier
to use from within an editor. This mode might also serve as
documentation for mapping instructions to Prog.

/cc @robpike @randall77 @ianlancetaylor

Activity

  1. added this to the Go1.8Early milestone on Jul 13, 2016
  2. robpike commented on Jul 13, 2016

    @robpike
    Contributor

    Sounds like a good idea to me.

  3. josharian commented on Jul 13, 2016

    @josharian
    Contributor

    Yes please. Re: reading from stdin, see also josharian@853cbde. It'd be nice to make sure the command line designs for these play nicely together.

  4. changed the title [-]proposal: cmd/asm: a flag to dump Prog initialization as Go code[/-] [+]cmd/asm: a flag to dump Prog initialization as Go code[/+] on Aug 29, 2016
  5. adg commented on Aug 29, 2016

    @adg
    Contributor

    @josharian assigned to you. happy birthday. 😂

  6. josharian commented on Aug 29, 2016

    @josharian
    Contributor

    Thank you? But you missed by several months... 📅 📅 📅

  7. cherrymui commented on Aug 29, 2016

    @cherrymui
    Member

    FYI a while ago I wrote an incomplete CL https://go-review.googlesource.com/c/25390/. You may take it from there if you like :)

  8. modified the milestones: Unplanned, Go1.8Early on Oct 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions