[LLVMdev] Turning on/off sub-target features (e.g. Altivec on PowerPC)

Chris Lattner clattner at apple.com
Thu Mar 18 10:20:34 PDT 2010


On Mar 18, 2010, at 7:30 AM, Sergei Dyshel wrote:

> Hello,
> 
> I'm using Mono with experimental LLVM backend support on PowerPC. I noticed that although LLVM's IR contains SIMD instructions the assembly produced doesn't contain any Altivec instructions and my PowerPC970 machine of course has Altivec support. Isn't there some kind of autodetection? I searched in Target sources but only found out that Altivec is disabled by default.
> 
> Can I turn Altivec support on (and off, I need both cases) from the code? Some info: Mono's utilizes LLVM in this way:
> 
> LLVMInitializePowerPCTarget ();
> LLVMInitializePowerPCTargetInfo ();
> ExecutionEngine *EE = ExecutionEngine::createJIT ( ... );
> fpm = new FunctionPassManager ( ... );
> fpm->add(new TargetData(*EE->getTargetData()));
> 
> and then uses ExecutionEngine object for compiling functions.

The JIT should autodetect that you have altivec.  Check the code here: PPCSubtarget.cpp:75.  It currently looks like it's only implemented for Mac OS/X systems.

You can control individual cpu attributes like this by using EngineBuilder with the setMAttrs(...) function.  It corresponds directly to llc's -mattr=+foo,-bar argument.

-Chris



More information about the llvm-dev mailing list