llc: Add support for -mcpu=native.

When -mcpu=native is passed, autodetect the host CPU and pass that
as the CPU name to the TargetMachine factory method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206095 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach 2014-04-12 01:34:31 +00:00
parent 6bb00df864
commit d023e14a5e

View File

@ -213,6 +213,12 @@ static int compileModule(char **argv, LLVMContext &Context) {
bool SkipModule = MCPU == "help" || bool SkipModule = MCPU == "help" ||
(!MAttrs.empty() && MAttrs.front() == "help"); (!MAttrs.empty() && MAttrs.front() == "help");
// If user asked for the 'native' CPU, autodetect here. If autodection fails,
// this will set the CPU to an empty string which tells the target to
// pick a basic default.
if (MCPU == "native")
MCPU = sys::getHostCPUName();
// If user just wants to list available options, skip module loading // If user just wants to list available options, skip module loading
if (!SkipModule) { if (!SkipModule) {
M.reset(ParseIRFile(InputFilename, Err, Context)); M.reset(ParseIRFile(InputFilename, Err, Context));