asm! feature is great! One missing feature relative to GCC's inline assembly is supporting flags (condition codes) as output operands. This can often be useful when the inline asm does a
cmp instruction and wants the surrounding Rust code to jump based on that. As to backends, it seems like both LLVM and GCC support this.
Looking through the pre-RFC thread I see discussion of
asm goto (which mostly subsumes this feature, but is much more complex and didn't get shipped in Rust), but not of condition code outputs.
What would it take to get condition code output operands in inline asm?
Does LLVM support this? I couldn't find anything about it in the LLVM LangRef.
Indeed, it seems not to be in the LangRef, but it also seems to be supported by LLVM since clang 9.0.0: Compiler Explorer.
We do want to implement a structured form of
asm goto, with integrated branches rather than a goto. See https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto for one possible syntax for that.
That doesn't preclude having direct output of condition codes, though. Presumably, this would look like a
bool output operand with a special register name, and then optimized compiles could hopefully turn a subsequent branch on that
bool into a conditional jump; less optimized compiles or code patterns would end up with something like x86's
setcc or similar to materialize that
Thank you Josh! I see in that document that condition code outputs are also listed as a possible future feature.
Is there a tracking bug or forum for further developments on inline asm?
Generally we try not to have issues for potential future extensions, since it's an infinite set, and there's no feasible way to close them (since they are possible future extensions).
Discussions will be threads here on IRLO, or on Zulip.
I see, got it. I guess I'm looking for a place to say "+1, this is a feature that would be helpful to me". Normally I'd file a feature request on GitHub, but the Rust GitHub template for feature requests forwarded me here.
Maybe this thread is that already? Trying to figure out the protocol...
Any interest in helping to write the RFC for asm branches?
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.