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]

Code transformation and optimization


Hi,

I would like to make some code transformation and your help would be
greatly appreciated.
To make things clear let's say that I would like to declare a new keyword
called special_else
for instance.
This new keyword has the same syntax as an else statement but the
difference is
expression to be evaluated ie instructions between special_else parenthesis
(...) should be put 
inside a function returning a int instead of being evaluated.
Then the code between special_else blocks {} shouldn't be executed, I mean
I would like to add a goto
just before { and jumping just after } block.
Sorry it it's not very clear but a sample code could help :

Original code
int main(int argc, char* argv[])
{
	if (1)
	{
		puts("INSIDE if block");
	}
	special_else( puts "hello gcc";  1 == 1) 
	{
		puts("INSIDE special_else block");
	}
	puts("AFTER special_else block");
}

Code as it should bd transformed : 
int main(int argc, char* argv[])
{
	if (1)
	{
		puts("INSIDE if block");
	}
	goto AFTER_SPEC_ELSE;
	puts("INSIDE special_else block"); // This instruction is never executed
AFTER_SPEC_ELSE:
	puts("AFTER special_else block");
}

int special_else_filter()
{
	puts "hello gcc";  
	return 1 == 1;
}

For now we manage to do some transformation, the problem is with
optimization because the code
just after goto shouldn't be discarded even if it appears to be stupid
because it cannot be executed.

Thanks

Vincent R.



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