[LLVMdev] Generating target dependent function calls

Tobias Grosser grosser at fim.uni-passau.de
Sat Dec 25 22:09:21 PST 2010


On 12/22/2010 03:12 PM, Peter Collingbourne wrote:
> On Wed, Dec 22, 2010 at 01:38:06PM -0500, Tobias Grosser wrote:
>> Hi,
>>
>> raghesh and I are working in Polly on automatically generating OpenMP
>> calls. This works nicely on a 64bit architecture,
>> however the functions we need to generate are slightly different on
>> different platforms.
>>
>> The reason for the difference is that e.g "long" in
>>
>>   >  bool GOMP_loop_runtime_next(long, long)
>>
>> has a different size on different architectures.
>>
>> Currently we generate the prototypes and functions ourselves:
>>   >  declare i8 @GOMP_loop_runtime_next(i64*, i64*) nounwind
>>
>> To support a 32bit architecture we would need to generate:
>>   >  declare i8 @GOMP_loop_runtime_next(i32*, i32*) nounwind
>>
>> Has anybody an idea what's a conceptually clean way to generate OpenMP
>> function calls for different architectures and best even for different
>> OpenMP implementations (e.g. mpc.sf.net)
>>
>> Would overloaded intrinsics be a possible approach? How could we
>> model/derive the right signature for our target architecture. TargetData
>> does not seem to be enough for this. Is there a better approach than
>> passing this information using a command line switch?
>>
>> Cheers and thanks for your help
>
> Hi Tobias,
>
> I'm facing a similar problem generating CUDA runtime code for
> different architectures.  One solution I'm currently considering
> is to use the TargetInfo class from Clang's Basic library which can
> be used to obtain target specific parameters (such as sizeof(long))
> given a target triple.

Interesting. Maybe I can get enough information from the target triple 
itself. Module::&getTargetTriple should be enough. I did not think about 
this, but that might work. Thanks for the pointer.

Tobi



More information about the llvm-dev mailing list