Re: GCC assmbler for powerpc-eabi

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok I seem to have caused some consternation here, the code is not
intended to do anything meaningful, it is part of the assessment as to
whether GCC/GDB is a valid replacement for our current tool set. It's
role is to get assembler so we cam verify function call overhead as part
of the initial static analysis of each tool used. Unfortunately I picked
sprintf as a test library call and it appears that this causes the
compiler to emit the crxor even when no math is being performed. 

ref. PowerPC Microprocessor 32-bit Family: The Programming Environments
sec. 2.1.3.2 Condition Register CR1 Field Definition
pp.  2-6

ref. PowerPC 405-S Embedded Processor Core
sec. 2.3.4 Condition Register

The 405 ref seems to conflict, or seems to define a usage that is less
specific than the general reference.

The question is still, why do I have the crxor assembler statements
before every "bl sprintf" statement in the function? 

Files are attached and the build was done from inside ecos/test..

So fixing my compile line so it doesn't barf, 
../gnutools/powerpc-eabi/bin/powerpc-eabi-gcc -S -O2 println.c
-I./ecos_install/include/

I get a build result of 

println.c: In function ‘myCall’:
println.c:11: warning: incompatible implicit declaration of built-in
function ‘sprintf’
println.c: In function ‘myCall2’:
println.c:15: warning: incompatible implicit declaration of built-in
function ‘sprintf’
println.c: In function ‘main’:
println.c:23: warning: incompatible implicit declaration of built-in
function ‘printf’

which gives me an assembler function which still has 

myCall2:
	mflr 0
	stwu 1,-8(1)
	lis 9,pstr@ha
	lis 4,.LC0@ha
	la 4,.LC0@l(4)
	stw 0,12(1)
	lwz 5,pstr@l(9)
	crxor 6,6,6	<<<< WHY <<<<<<
	bl sprintf
	lwz 0,12(1)
	addi 1,1,8
	mtlr 0
	blr



On Mon, 2009-04-06 at 10:35 -0700, John (Eljay) Love-Jensen wrote:
> Hi Jeff,
> 
> > o The compiler barfed until I swapped the #define and the #include
> 
> As it should, since that #define is really weird and will break most header
> files and most code.
> 
> (I¹m not sure why you want to replace ³unsigned² with ³int size_t².)
> 
> > o The -finline-functions switch has no effect until one specifies the -O3
> switch.
> 
> The -finline-functions switch is enabled by default with -O3.
> 
> You can enable it manually at -O1 or -O2.
> 
> HTH,
> --Eljay
> 


#include <stdio.h>
#include <string.h>

char *pstr ="42";
char *blowup=NULL;

void myCall(char *cptr)
{
	sprintf(cptr,"Hello baby %f %u", atoi(pstr),atof(pstr));
	memcpy(blowup,pstr,strlen(pstr));
}
void myCall2(char *cptr)
{
	sprintf(cptr,"Hello baby %s", pstr);
}

int main(int argc, char **argv)
{
	char cptr[32];
	myCall(&cptr[0]);
	myCall2(&cptr[0]);
	printf("%s\n",cptr);
	return 0;
}
/* END */
	.file	"println.c"
	.gnu_attribute 4, 1
	.gnu_attribute 8, 1
	.section	".text"
	.align 2
	.globl myCall2
	.type	myCall2, @function
myCall2:
	mflr 0
	stwu 1,-8(1)
	lis 9,pstr@ha
	lis 4,.LC0@ha
	la 4,.LC0@l(4)
	stw 0,12(1)
	lwz 5,pstr@l(9)
	crxor 6,6,6
	bl sprintf
	lwz 0,12(1)
	addi 1,1,8
	mtlr 0
	blr
	.size	myCall2, .-myCall2
	.align 2
	.globl myCall
	.type	myCall, @function
myCall:
	stwu 1,-32(1)
	mflr 0
	stw 29,20(1)
	lis 29,pstr@ha
	stw 27,12(1)
	mr 27,3
	lwz 3,pstr@l(29)
	stw 0,36(1)
	stw 28,16(1)
	crxor 6,6,6
	bl atoi
	mr 28,3
	lwz 3,pstr@l(29)
	crxor 6,6,6
	bl atof
	lis 4,.LC1@ha
	mr 6,3
	mr 5,28
	la 4,.LC1@l(4)
	mr 3,27
	crxor 6,6,6
	bl sprintf
	lwz 28,pstr@l(29)
	mr 3,28
	bl strlen
	lis 9,blowup@ha
	mr 5,3
	lwz 3,blowup@l(9)
	mr 4,28
	bl memcpy
	lwz 0,36(1)
	lwz 27,12(1)
	mtlr 0
	lwz 28,16(1)
	lwz 29,20(1)
	addi 1,1,32
	blr
	.size	myCall, .-myCall
	.globl __eabi
	.align 2
	.globl main
	.type	main, @function
main:
	stwu 1,-56(1)
	mflr 0
	stw 29,44(1)
	addi 29,1,8
	stw 0,60(1)
	bl __eabi
	mr 3,29
	bl myCall
	lis 9,pstr@ha
	lwz 5,pstr@l(9)
	lis 4,.LC0@ha
	la 4,.LC0@l(4)
	mr 3,29
	crxor 6,6,6
	bl sprintf
	mr 3,29
	bl puts
	lwz 0,60(1)
	li 3,0
	lwz 29,44(1)
	mtlr 0
	addi 1,1,56
	blr
	.size	main, .-main
	.globl pstr
	.globl blowup
	.section	.rodata.str1.4,"aMS",@progbits,1
	.align 2
.LC0:
	.string	"Hello baby %s"
	.zero	2
.LC1:
	.string	"Hello baby %f %u"
	.zero	3
.LC2:
	.string	"42"
	.section	.sbss,"aw",@nobits
	.align 2
	.type	blowup, @object
	.size	blowup, 4
blowup:
	.zero	4
	.section	.sdata,"aw",@progbits
	.align 2
	.type	pstr, @object
	.size	pstr, 4
pstr:
	.long	.LC2
	.ident	"GCC: (eCosCentric GNU tools 4.3.2-sw) 4.3.2"

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux