[LLVMdev] A question of Sparc assembly generated by llc

ckathy clcheng at stanford.edu
Thu Jan 12 10:48:45 PST 2012


Hi,


There are some generated Sparc assembly code like this:

main:                                   ! @main
! BB#0:
	save %sp, -112, %sp
	sethi 0, %l0
	or %g0, 5, %l1
	st %l0, [%fp+-4]
	st %l1, [%fp+-8]
	st %l1, [%fp+-12]
	sethi %hi(.L.str), %l1
	ld [%fp+-8], %o1
	add %l1, %lo(.L.str), %l1
	or %g0, %l1, %o0
	call printf
	nop
	ld [%fp+-12], %o2
	ld [%fp+-8], %l2
	sethi %hi(.L.strQ521), %l3
	add %l3, %lo(.L.strQ521), %o0
	or %g0, %l2, %o1
        call MY_FUNCTION
        nop
        or %g0, 1, %i0
       (subcc %l1, 0, %l1  ! This line is added by me. It was not there)
        bne .LBB0_2
        nop
! BB#1:
	subcc %l2, 0, %l2
	or %g0, %l0, %i0
.LBB0_2:
       .......


I am not an expert on Sparc assembly, but I read from somewhere that
branching instructions are set by the statues flags. The first 'bne'
statement appeared before any subcc or any other cc opcodes. The code is
problematic so I added the line in the brackets based on what I think it
should be doing and it appeared to be working correctly.

Is the standalone 'bne' instruction intentional?  There are some integer
condition code in MY_FUNCTION but I thought the iCC flags will be saved
before the 'call' statement and restored after the 'call' statement. Is it
correct?

By the way, there are 'save %sp, -96, %sp', 'restore %g0, %g0, %g0' and
'retl' statements in MY_FUNCTION.

Thanks,

Chris


-- 
View this message in context: http://old.nabble.com/A-question-of-Sparc-assembly-generated-by-llc-tp33129811p33129811.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list