[cfe-commits] r65881 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/TargetInfo.h
Chris Lattner
sabre at nondot.org
Mon Mar 2 14:11:07 PST 2009
Author: lattner
Date: Mon Mar 2 16:11:07 2009
New Revision: 65881
URL: http://llvm.org/viewvc/llvm-project?rev=65881&view=rev
Log:
start wiring up support for target-specific -mfoo options like -msse
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Basic/TargetInfo.h
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=65881&r1=65880&r2=65881&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Mar 2 16:11:07 2009
@@ -517,6 +517,12 @@
static llvm::cl::opt<bool>
Ansi("ansi", llvm::cl::desc("Equivalent to specifying -std=c89."));
+
+static llvm::cl::list<std::string>
+TargetOptions("m", llvm::cl::Prefix, llvm::cl::value_desc("option"),
+ llvm::cl::desc("Target-specific options, such as -msse3"));
+
+
// FIXME: add:
// -fdollars-in-identifiers
static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
@@ -524,6 +530,23 @@
// 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()) {
+ std::string ErrorStr;
+ int Opt = Target->HandleTargetOptions(&TargetOptions[0],
+ TargetOptions.size(), ErrorStr);
+ if (Opt != -1) {
+ if (ErrorStr.empty())
+ fprintf(stderr, "invalid command line option '%s'\n",
+ TargetOptions[Opt].c_str());
+ else
+ fprintf(stderr, "command line option '%s': %s\n",
+ TargetOptions[Opt].c_str(), ErrorStr.c_str());
+ exit(1);
+ }
+ }
+
if (Ansi) // "The -ansi option is equivalent to -std=c89."
LangStd = lang_c89;
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=65881&r1=65880&r2=65881&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon Mar 2 16:11:07 2009
@@ -249,6 +249,16 @@
/// options.
virtual void getDefaultLangOptions(LangOptions &Opts) {}
+ /// HandleTargetOptions - Handle target-specific options like -msse2 and
+ /// friends. An array of arguments is passed in: if they are all valid, this
+ /// should handle them and return -1. If there is an error, the index of the
+ /// invalid argument should be returned along with an optional error string.
+ virtual int HandleTargetOptions(std::string *StrArray, unsigned NumStrs,
+ std::string &ErrorReason) {
+ if (NumStrs == 0)
+ return -1;
+ return 0;
+ }
protected:
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
return PointerWidth;
More information about the cfe-commits
mailing list