From 6328cc316d7032517399da9230a197cd29f2664d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 3 Mar 2009 19:56:18 +0000 Subject: implement support for propagating *features* down to the code generator and defining target-specific macros based on them (like __SSE3__ and friends). After extensive discussion with Daniel, this work will need driver support, which will translate things like -msse3 into a -mattr feature. Until this work is done, the code in clang.cpp is disabled and the X86TargetInfo ctor still defaults to SSE2. With these two things changed, this code will work. PR3634 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65966 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/clang.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'Driver') diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 54e93f8031..9ecddd8cd5 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -517,10 +517,10 @@ Trigraphs("trigraphs", llvm::cl::desc("Process trigraph sequences.")); static llvm::cl::opt Ansi("ansi", llvm::cl::desc("Equivalent to specifying -std=c89.")); - static llvm::cl::list -TargetOptions("m", llvm::cl::Prefix, llvm::cl::value_desc("option"), - llvm::cl::desc("Target-specific options, such as -msse3")); +TargetFeatures("mattr", llvm::cl::CommaSeparated, + llvm::cl::desc("Target specific attributes (-mattr=help for details)")); + // FIXME: add: @@ -530,19 +530,25 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, // Allow the target to set the default the langauge options as it sees fit. Target->getDefaultLangOptions(Options); - // If the user specified any -mfoo options, pass them to the target for - // validation and processing. - if (!TargetOptions.empty()) { + // If there are any -mattr options, pass them to the target for validation and + // processing. The driver should have already consolidated all the + // target-feature settings and passed them to us in the -mattr list. The + // -mattr list is treated by the code generator as a diff against the -mcpu + // setting, but the driver should pass all enabled options as "+" settings. + // This means that the target should only look at + settings. + if (!TargetFeatures.empty() + // FIXME: The driver is not quite yet ready for this. + && 0) { std::string ErrorStr; - int Opt = Target->HandleTargetOptions(&TargetOptions[0], - TargetOptions.size(), ErrorStr); + int Opt = Target->HandleTargetFeatures(&TargetFeatures[0], + TargetFeatures.size(), ErrorStr); if (Opt != -1) { if (ErrorStr.empty()) - fprintf(stderr, "invalid command line option '%s'\n", - TargetOptions[Opt].c_str()); + fprintf(stderr, "invalid feature '%s'\n", + TargetFeatures[Opt].c_str()); else - fprintf(stderr, "command line option '%s': %s\n", - TargetOptions[Opt].c_str(), ErrorStr.c_str()); + fprintf(stderr, "feature '%s': %s\n", + TargetFeatures[Opt].c_str(), ErrorStr.c_str()); exit(1); } } @@ -1253,10 +1259,6 @@ static llvm::cl::opt TargetCPU("mcpu", llvm::cl::desc("Target a specific cpu type (-mcpu=help for details)")); -static llvm::cl::list -TargetFeatures("mattr", - llvm::cl::desc("Target specific attributes (-mattr=help for details)")); - static void InitializeCompileOptions(CompileOptions &Opts) { Opts.OptimizeSize = OptSize; if (OptSize) { -- cgit v1.2.1