简体   繁体   中英

gcc inline assembly function that clobbers all the floating-point registers

I'm trying to write an asm statement (inline assembly in GCC ), that just calls some function, that returns one value in floating-point register and has no operands, but potentially clobbers all the floating-point registers.

asm("call *%1"
    : "=t"(result_)
    : "d"(code_.data())
    : "memory", "cc", "ax", "%st(1)", "%st(2)", "%st(3)", "%st(4)", "%st(5)", "%st(6)", "%st(7)"
    );

My problem is that I cannot tell the assembler, that is clobbering the top floating-point register %st(0) too, because I cannot specify "%st(0)" (or "%st" ) in clobber list (it results in an compilation error).

You are returning a result in %st(0) ; that is what the t constraint means. The compiler therefore knows it is modified.

I am not sure why your GCC is not recognizing %st(0) or %st as a name in the clobber list, but this should not cause a problem in this situation.

Apple clang version 4.0 (tags/Apple/clang-418.0.60) accepts %st in the clobber list, even with =t as an output constraint.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM