tags:

views:

44

answers:

1

Hello newcomer here (be gentle),

I am attempting to write a program which has floating point code in it. However this program needs to run on 2 different processors. Which have roughly identical ISAs except for their floating point model. They use completely different instructions and registers to do floating point calculations. What would be an elegant way to get gcc to compile one section of code for 1 processor's model, and another section for the other processor's model? I already have in place a method for determining which processor the code is currently running on, so I can have it link to the corresponding code in memory.

Everything is done in C only. For the curious, I'm using powerpc e500v2 and e300 cores.

This is not a homework question, no teachers will be upset at the internet over this.

+2  A: 

Build two different .o files using the different GCC options.

I am assuming that you are talking about code that is compatible enough to share an ELF file, such as x87 vs SSE2 floating point, and not x86 and x86_64 or odd stuff like ClearSpeed.

Zan Lynx