[LLVMdev] how to annotate assembler
Konstantin Vladimirov
konstantin.vladimirov at gmail.com
Fri Mar 2 00:20:11 PST 2012
Hi,
In GCC there is one useful option -dp (or -dP for more verbose output)
to annotate assembler with instruction patterns, that was used when
assembler was generated. For example:
double
test(long long s)
{
return s;
}
gcc -S -dp -O0 test.c
test:
.LFB0:
.cfi_startproc
pushq %rbp # 18 *pushdi2_rex64/1 [length = 1]
.cfi_def_cfa_offset 16
movq %rsp, %rbp # 19 *movdi_1_rex64/2 [length = 3]
.cfi_offset 6, -16
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp) # 2 *movdi_1_rex64/4 [length = 4]
cvtsi2sdq -8(%rbp), %xmm0 # 6 *floatdidf2_sse_interunit/2 [length = 6]
leave # 24 leave_rex64 [length = 1]
.cfi_def_cfa 7, 8
ret # 25 return_internal [length = 1]
.cfi_endproc
Now I may look into config/i386/i386.md, and look for mentioned
*pushdi2_rex64, movdi_1_rex64, floatdidf2_sse_interunit and other
patterns and study how they work.
How to make the same annotation for clang output assembler code?
test:
.Leh_func_begin1:
pushq %rbp # ??? what insn in X86InstrInfo.td?
.Llabel1:
movq %rsp, %rbp # ??? what insn in X86InstrInfo.td?
.Llabel2:
movq %rdi, -16(%rbp) # ??? what insn in X86InstrInfo.td?
movq -16(%rbp), %rax # ??? what insn in X86InstrInfo.td?
cvtsi2sdq %rax, %xmm0 # ??? what insn in X86InstrInfo.td?
movsd %xmm0, -8(%rbp) # ??? what insn in X86InstrInfo.td?
movsd -8(%rbp), %xmm0 # ??? what insn in X86InstrInfo.td?
popq %rbp # ??? what insn in X86InstrInfo.td?
ret
---
With best regards, Konstantin
More information about the llvm-dev
mailing list