Is there any special reason to lift it into LLVM IR? The method you listed is called during CodeGenPrepare. It is supposed to used for optimizations in the backend.
Not sure if you can hack here if you just want to emit the IR.
Is there any special reason to lift it into LLVM IR?
I’m running analysis on KLEE and it doesn’t support inline asm. It has a special pass called RaiseAsm, that calls expandInlineAsm(), which is why I thought it’d be better to implement this on LLVM side.
Not sure if you can hack here if you just want to emit the IR.
I don’t have a clear thought either. Currently it doesn’t have the ability to turn assembly into LLVM IR. Parsing it in a separate pass looks more concise if we only have a few assemble to handle.
Why not expanding them directly in the pass? How about constraints other than “r”?
I thought expandInlineAsm is more appropriate place for this code, since it already raises bswap to the IR. But I guess I will just do it on the KLEE side.
Yeah. The code was there for more than 10 years Copy ExpandInlineAsm to TargetLowering from TargetAsmInfo. · llvm/llvm-project@5849d22 · GitHub. No new expansion added since then.
From the PoW of codegen, the expansion doesn’t help much. Users are supposed to use builtins for flexibility and inline asm for special purpose, i.e., register constraints, asm optimizations etc. Given that, it is also not a good idea to arbitrarily do such work, especially under -O0.
For example, we can lower builtins according to the targets feature. Compiler Explorer
But lowering an inline bsf into tzcnt under -O0 does seem compiler issue.