I am generating some assembly code via llvm and using x86.
in all the instructions source appears before destination like;
subl $8, %esp
movl 16(%esp), %eax
vmovdqu32 c(%rip), %zmm0
addl b+132(%rip), %eax
movl %eax, a+132(%rip)
but when i refered the intel x86 manual, it says instruction has 1st destination and then source;
is it due to llvm follows gas syntax instead of intel? but my machine and normally machines are intel based then how does this gas syntax assembly of llvm execute on our machines?
please correct me if i am wrong.
There are (at least) two styles of x86 assembly: “Intel” and “AT&T” (aka “att”). You can tell clang/llvm which you want to use - e.g in llc you can use -x86-asm-syntax=intel to get intel syntax. When using clang, you can use -mllvm -x86-asm-syntax=intel to achieve the same thing.
The gnu assembler (by default at least) does indeed use the AT&T syntax, but it’s the way most assemblers on any Unix-related toolchains work. I think the reason behind this is to have the same syntax, whether you are using a motorola 68k, a digital pdp-11 or an x86 processor, although I wasn’t there when this was decided some 40-50 years back when Unix was first invented at AT&T (hence the name of the syntax).
The syntax only affects the textual representation of the
instructions. The assemblers know which style they're looking at and
produce the same sequence of bytes in each case, which the CPU
obviously executes the same.