Replies: 6 comments 8 replies
-
Adding a new 'empty' instruction (one new |
Beta Was this translation helpful? Give feedback.
-
For reference, I ended up going through with late label binding, and here is what I've got https://github.com/paraexec/ParaOS/blob/master/parawasm/src/x86_64/mod.rs#L365-L379 Seems to have worked well enough so far. I suspect some of the mechanics of this can be extracted for re-usability and contributed to iced. Happy to help where I can. Is this of any interest? |
Beta Was this translation helpful? Give feedback.
-
What API do you propose should be added? Some method that initializes labels after all instructions have been added? I.e., no calls to |
Beta Was this translation helpful? Give feedback.
-
Great question. While the explicit late binding is what I've done (and it seems to work), I don't think it is very intuitive. What if we developed an instruction insertion/removal API and allowed On the latter note, how [un]reasonable is it to apply the |
Beta Was this translation helpful? Give feedback.
-
Seems like adding a new zero-byte instruction would be the easiest solution. Then just use it as a label and I think your code will work too. If so, I can add one later this week. |
Beta Was this translation helpful? Give feedback.
-
I've added a I've also added |
Beta Was this translation helpful? Give feedback.
-
I admit this may be (a bit) controversial, but here's a problem I am working on. I am using
CodeAssembler
(in my case, using the Rust version of the library) to generate code. Then I take another optimization pass over it to detect known redundancies and other optimizations to make generated code more efficient.The problem, however, comes with relative addressing and labels. If I remove some instructions, eventually, my code would stop working as labels are pointing to an instruction index, and this changes the number of instructions. If I
nop
the optimized-away instructions instead of removing, everything still works fine, but the final code gets polluted with NOPs, which is not ideal.So I was thinking, how can this be addressed. So far, I have some ideas, and I am not sure if any of them are good yet, but I wanted to entertain this problem with you guys.
Instruction
that denotes an "empty" or "void" instruction so that it encodes to nothing during assembly time. This would work for most of the cases where I am reducing the size of the code. But it'll break if my optimization will actually add more instructions (not that I have any optimizations like this at the moment)set_label
until after optimizations) is the approach I am exploring right now (and will perhaps continue down that road if my use case is a non-goal for you guys).Any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions