This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Useless %esp manipulation; omitting "l" suffix in assembly output; getting the address of a label from another function.


First, a trivial bug. Compile this with gcc cvs:

	struct x { int a, b, c, d; };

	struct x zook(void)
	{
		struct x x = {0, 1, 2, 3};
		return x;
	}

gcc -S -O2 -fomit-frame-pointer -march=athlon-xp test.c

	.file	"test.c"
	.text
	.p2align 4,,15
globl zook
	.type	zook, @function
zook:
	subl	$28, %esp
	movl	32(%esp), %eax
	movl	$0, (%eax)
	movl	$1, 4(%eax)
	movl	$2, 8(%eax)
	movl	$3, 12(%eax)
	addl	$28, %esp
	ret	$4
	.size	zook, .-zook
	.ident	"GCC: (GNU) 3.4 20030410 (experimental)"

and you get code that uselessly moves %esp.

I've got a couple feature requests too, take them or leave them.

1) Output "mov" instead of "movl", etc, since gas doesn't require
the suffix and it's easier to read the code when they are omitted.

2) Given code like

	void process(void *addr)
	{
		goto *addr;
	l1:
	l2:	something goes here
	l3:
	l4:
	}

where you're trying to optimize some code by saving the address of a
label and using it next time the function is called, provide some
way to get the address of the label from another function (useful
for initializing addr the first time). Ie,

	void setup(struct state *s)
	{
		s->addr = process.l1;
	}

or whatever.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]