3 ms·
> [...] are a bit more knowledgeable of what those Assembly instructions are actually doing. Not only that, they are able to provide proper error messages when
by cesarb 2y ago
> [...] are a bit more knowledgeable of what those Assembly instructions are actually doing. Not only that, they are able to provide proper error messages when the opcodes are badly used.
That's only possible if the compiler knows all assembly instructions being used. But the whole point of GCC-style inline assembly is to be able to use assembly instructions the compiler doesn't know about (for instance, because they're new instructions which didn't exist when the compiler was released), with the same performance as the ones the compiler does know about. In many cases, even the assembler doesn't know about the new instruction, and you have to specify it using .byte directives or similar (though the Unix compiler model, with proper separation between the compiler and the assembler, also allows you to use a newer assembler without having to change your compiler).
- pjmlp 2y agoAgain, this kind of arguments gets tiring, compilers get upgrades.
- leni536 2y agoAnd GCC/clang do get intrinsics that are nicer to use than inline asm, often with more optimization available to them as well. If the compiler does know about a specific instruction, then it's better to just provide the intrinsic than try to infer it from some inline asm string.
- AshamedCaptain 2y agoOne of the benefits of gcc's powerful inline asm support is that it allows you to write new intrinsics. This is almost impossible in most other compilers, as they will do crazy things such as flushing out all registers before each asm block. Very useful for low level work.
- leni536 2y ago> it allows you to write new intrinsics I admit that it gets very close, however I think compiler provided intrinsics can be and are optimized more than ones that are implemented with inline asm, as the compiler knows about the semantics of the instruction for such an intrinsic, and not much about an inline asm one, apart from inputs/outputs/clobbers. Having said that I agree that inline asm is very useful for instructions that the compiler does not know about.
- secondcoming 2y agoThat's great if you're not locked down to a particular compiler version