Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Mar 2012 08:10:24 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r233166 - in stable/9: contrib/llvm/tools/clang/lib/Basic sys/conf
Message-ID:  <201203190810.q2J8AON4058317@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Mon Mar 19 08:10:23 2012
New Revision: 233166
URL: http://svn.freebsd.org/changeset/base/233166

Log:
  MFC r232894:
    Pull in r145194 from upstream clang trunk:
  
      Make our handling of MMX x SSE closer to what gcc does:
  
      * Enabling sse enables mmx.
      * Disabling (-mno-mmx) mmx, doesn't disable sse (we got this right already).
      * The order in not important. -msse -mno-mmx is the same as -mno-mmx -msse.
  
    Some configure scripts depend on this.
  
    PR:		i386/165968
  
  MFC r232933:
    Update comments and CFLAGS in sys/conf/kern.mk, introduced in r221879,
    to match reality: clang does _not_ disable SSE automatically when
    -mno-mmx is used, you have to specify -mno-sse explicitly.
  
    Note this was the case even before r232894, which only makes a change in
    the 'positive' flag case; e.g. when you specify -msse, MMX gets enabled
    too.

Modified:
  stable/9/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
  stable/9/sys/conf/kern.mk
Directory Properties:
  stable/9/contrib/llvm/   (props changed)
  stable/9/contrib/llvm/tools/clang/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/conf/   (props changed)

Modified: stable/9/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
==============================================================================
--- stable/9/contrib/llvm/tools/clang/lib/Basic/Targets.cpp	Mon Mar 19 07:34:09 2012	(r233165)
+++ stable/9/contrib/llvm/tools/clang/lib/Basic/Targets.cpp	Mon Mar 19 08:10:23 2012	(r233166)
@@ -1583,23 +1583,26 @@ bool X86TargetInfo::setFeatureEnabled(ll
       (Name != "sse4" && Name != "sse4.2" && Name != "sse4.1"))
     return false;
 
+  // FIXME: this should probably use a switch with fall through.
+
   if (Enabled) {
     if (Name == "mmx")
       Features["mmx"] = true;
     else if (Name == "sse")
-      Features["sse"] = true;
+      Features["mmx"] = Features["sse"] = true;
     else if (Name == "sse2")
-      Features["sse"] = Features["sse2"] = true;
+      Features["mmx"] = Features["sse"] = Features["sse2"] = true;
     else if (Name == "sse3")
-      Features["sse"] = Features["sse2"] = Features["sse3"] = true;
+      Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+        true;
     else if (Name == "ssse3")
-      Features["sse"] = Features["sse2"] = Features["sse3"] =
+      Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
         Features["ssse3"] = true;
     else if (Name == "sse4" || Name == "sse4.2")
-      Features["sse"] = Features["sse2"] = Features["sse3"] =
+      Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
         Features["ssse3"] = Features["sse41"] = Features["sse42"] = true;
     else if (Name == "sse4.1")
-      Features["sse"] = Features["sse2"] = Features["sse3"] =
+      Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
         Features["ssse3"] = Features["sse41"] = true;
     else if (Name == "3dnow")
       Features["mmx"] = Features["3dnow"] = true;
@@ -1608,10 +1611,11 @@ bool X86TargetInfo::setFeatureEnabled(ll
     else if (Name == "aes")
       Features["aes"] = true;
     else if (Name == "avx")
-      Features["avx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
-        Features["ssse3"] = Features["sse41"] = Features["sse42"] = true;
+      Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+        Features["ssse3"] = Features["sse41"] = Features["sse42"] =
+        Features["avx"] = true;
     else if (Name == "sse4a")
-      Features["sse4a"] = true;
+      Features["mmx"] = Features["sse4a"] = true;
   } else {
     if (Name == "mmx")
       Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = false;
@@ -3779,13 +3783,32 @@ TargetInfo *TargetInfo::CreateTargetInfo
   Target->getDefaultFeatures(Features);
 
   // Apply the user specified deltas.
+  // First the enables.
   for (std::vector<std::string>::const_iterator it = Opts.Features.begin(),
          ie = Opts.Features.end(); it != ie; ++it) {
     const char *Name = it->c_str();
 
+    if (Name[0] != '+')
+      continue;
+
+    // Apply the feature via the target.
+    if (!Target->setFeatureEnabled(Features, Name + 1, true)) {
+      Diags.Report(diag::err_target_invalid_feature) << Name;
+      return 0;
+    }
+  }
+
+  // Then the disables.
+  for (std::vector<std::string>::const_iterator it = Opts.Features.begin(),
+         ie = Opts.Features.end(); it != ie; ++it) {
+    const char *Name = it->c_str();
+
+    if (Name[0] == '+')
+      continue;
+
     // Apply the feature via the target.
-    if ((Name[0] != '-' && Name[0] != '+') ||
-        !Target->setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) {
+    if (Name[0] != '-' ||
+        !Target->setFeatureEnabled(Features, Name + 1, false)) {
       Diags.Report(diag::err_target_invalid_feature) << Name;
       return 0;
     }

Modified: stable/9/sys/conf/kern.mk
==============================================================================
--- stable/9/sys/conf/kern.mk	Mon Mar 19 07:34:09 2012	(r233165)
+++ stable/9/sys/conf/kern.mk	Mon Mar 19 08:10:23 2012	(r233166)
@@ -46,16 +46,16 @@ CWARNEXTRA?=	-Wno-error-tautological-com
 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
 #
 # clang:
-# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2,
-#                          -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
+# Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
+# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
 #
 .if ${MACHINE_CPUARCH} == "i386"
 .if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
-CFLAGS+=	-mno-align-long-strings -mpreferred-stack-boundary=2 -mno-sse
+CFLAGS+=	-mno-align-long-strings -mpreferred-stack-boundary=2
 .else
 CFLAGS+=	-mno-aes -mno-avx
 .endif
-CFLAGS+=	-mno-mmx -msoft-float
+CFLAGS+=	-mno-mmx -mno-sse -msoft-float
 INLINE_LIMIT?=	8000
 .endif
 
@@ -93,17 +93,15 @@ INLINE_LIMIT?=	15000
 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
 #
 # clang:
-# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2,
-#                          -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
+# Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
+# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
 # (-mfpmath= is not supported)
 #
 .if ${MACHINE_CPUARCH} == "amd64"
-.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
-CFLAGS+=	-mno-sse
-.else
+.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
 CFLAGS+=	-mno-aes -mno-avx
 .endif
-CFLAGS+=	-mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float \
+CFLAGS+=	-mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
 		-fno-asynchronous-unwind-tables
 INLINE_LIMIT?=	8000
 .endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203190810.q2J8AON4058317>