Proper values for LLVMCreateTargetMachine

I can’t seem to get LLVMCreateTargetMachine to work on my box (MBP i7 OS X 10.8). What should the values of triple, cpu and features be? I’m just looking for a way to get this up and going for now, I don’t need specific optimizations.

No matter what I send the function, I always get nil back. I’m giving it LLVMGetFirstTarget as the target value.

Thanks for the help,

Timothy

Hi Timothy,

https://hpcforge.org/scm/viewvc.php/trunk/src/runtime/Platform.cpp?root=kernelgen&view=markup

In this example either Host or NVPTX target machine is created and then used for code generation:

https://hpcforge.org/scm/viewvc.php/trunk/src/runtime/CodeGen.cpp?root=kernelgen&view=markup

This example in turn was long ago studied from llc.cpp, I think.

So the basic idea is first to select triple, then create target for this triple, then create target machine from target, triple and extra target-specific options.

If you are compiling for native host, default triple would suffice:

Triple triple;
triple.setTriple(sys::getDefaultTargetTriple());

Hope it helps.

  • D.

2012/12/26 Timothy Baldridge <tbaldridge@gmail.com>