Closed kito-cheng closed 3 years ago
@clairexen @aswaterman
Seems reasonable to me, to simplify some assembly programming. However, compilers should avoid avoid sext.[b|h] and zext.[h|w] when Zbb isn't present (though actually Zba can implement zext.w, too), since it can be more efficient to schedule the two shifts apart from each other.
However, compilers should avoid avoid sext.[b|h] and zext.[h|w] when Zbb isn't present (though actually Zba can implement zext.w, too), since it can be more efficient to schedule the two shifts apart from each other.
Agree with that, generally compiler should avoid emit pseudo instruction, which will expand to more than one instructions...unless necessary like call
or tail
.
Zba has zext.h also, so all of them are a single instruction with the B extension.
This creates work for binutils and llvm developers, and maybe FreeBSD also. We can handle the binutils work. Who does the llvm work? It would be nice to get an OK from the LLVM folks at least before committing this.
@lenary @ebahapo
We can handle the binutils work. Who does the llvm work?
We have few LLVM developer now, and it should not too much effort I guess, maybe @topperc could help on that?
Note: I didn't mention how pseudo expand with B-extension on purpose, since it still might change.
I agree it shouldn't be much effort in LLVM. I can help.
@topperc thanks you take this :)
I guess just wait some another LLVM folks (maybe non-SiFive guys?) to ack this.
I don't have a fundamental problem with this, and would be happy to help review a patch :)
I do wonder if we want to say "at most two 32-bit instructions" or the like, in these docs? It's unclear to me what guarantees people coding with pseudo-instructions want - turning off relaxation and compressed instructions is needed even if you stick to non-pseduo-instructions and want predictable instruction sizes - presumably if you require predictable instruction sizes, it's also best to stay away from pseudo-instructions too.
From my perspective as an assembly programmer who uses pseudoinstructions, all I really want are clear descriptions of
ld
source tree").In terms of "guarantees", what I'm looking for is a guarantee that "(only) the following things may happen" to my assembly program. What isn't clear to me is whether these things should be considered implementation details --- thus belonging in assembler/linker documentation --- or part of the assembly language specification --- thus belonging here.
I completely understand that we are woefully understaffed w.r.t. documentation, I'm not asking anyone to do anything.
@kito-cheng fyi, I revise my offer to "review" a patch that implements this, I've got an LLVM patch mostly ready which I'll upload to phabricator and tag you as a reviewer for.
Changes:
@lenary I saw the patch, thanks!
@lenary Changes applied, thanks!
I just landed the LLVM implementation in https://github.com/llvm/llvm-project/commit/12406ade0625
Add
sext.b
,sext.h
,zext.b
,zext.h
andzext.w
, and mentionsext.b
andsext.h
could be non pseudo instruction, the motivation is we already hassext.w
now, and B ext also want to define more pseudo forsext
orzext
, so why not add to the baseline pseudo instruction, and let assembler pick best way to expand.