]> granicus.if.org Git - clang/commitdiff
Add option and macro definition for AES instructions. Now produces real
authorEric Christopher <echristo@apple.com>
Fri, 2 Apr 2010 23:50:19 +0000 (23:50 +0000)
committerEric Christopher <echristo@apple.com>
Fri, 2 Apr 2010 23:50:19 +0000 (23:50 +0000)
assembly for testcases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100253 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
lib/Basic/Targets.cpp

index d088be04c03ee7de608e50246ecc85a5ad7347b6..ed68d68dd62106e892b9e9caa6eb67fc17dd9dc0 100644 (file)
@@ -431,6 +431,7 @@ def mno_sse4_1 : Flag<"-mno-sse4.1">, Group<m_x86_Features_Group>;
 def mno_sse4_2 : Flag<"-mno-sse4.2">, Group<m_x86_Features_Group>;
 def mno_sse : Flag<"-mno-sse">, Group<m_x86_Features_Group>;
 def mno_ssse3 : Flag<"-mno-ssse3">, Group<m_x86_Features_Group>;
+def mno_aes : Flag<"-mno-aes">, Group<m_x86_Features_Group>;
 
 def mno_thumb : Flag<"-mno-thumb">, Group<m_Group>;
 def marm : Flag<"-marm">, Alias<mno_thumb>;
@@ -447,6 +448,7 @@ def msse4_1 : Flag<"-msse4.1">, Group<m_x86_Features_Group>;
 def msse4_2 : Flag<"-msse4.2">, Group<m_x86_Features_Group>;
 def msse : Flag<"-msse">, Group<m_x86_Features_Group>;
 def mssse3 : Flag<"-mssse3">, Group<m_x86_Features_Group>;
+def maes : Flag<"-maes">, Group<m_x86_Features_Group>;
 def mthumb : Flag<"-mthumb">, Group<m_Group>;
 def mtune_EQ : Joined<"-mtune=">, Group<m_Group>;
 def multi__module : Flag<"-multi_module">;
index e3d9ed3335a7e6240def3129daca704f969be43d..1797804a7aab2902b722034221688369ce8d77b1 100644 (file)
@@ -765,9 +765,12 @@ class X86TargetInfo : public TargetInfo {
     NoAMD3DNow, AMD3DNow, AMD3DNowAthlon
   } AMD3DNowLevel;
 
+  bool HasAES;
+  
 public:
   X86TargetInfo(const std::string& triple)
-    : TargetInfo(triple), SSELevel(NoMMXSSE), AMD3DNowLevel(NoAMD3DNow) {
+    : TargetInfo(triple), SSELevel(NoMMXSSE), AMD3DNowLevel(NoAMD3DNow),
+      HasAES(false) {
     LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
   }
   virtual void getTargetBuiltins(const Builtin::Info *&Records,
@@ -813,6 +816,7 @@ void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
   Features["ssse3"] = false;
   Features["sse41"] = false;
   Features["sse42"] = false;
+  Features["aes"] = false;
 
   // LLVM does not currently recognize this.
   // Features["sse4a"] = false;
@@ -841,8 +845,10 @@ void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
     Features["sse42"] = false;
   } else if (CPU == "atom")
     setFeatureEnabled(Features, "sse3", true);
-  else if (CPU == "corei7")
+  else if (CPU == "corei7") {
     setFeatureEnabled(Features, "sse4", true);
+    setFeatureEnabled(Features, "aes", true);
+  }
   else if (CPU == "k6" || CPU == "winchip-c6")
     setFeatureEnabled(Features, "mmx", true);
   else if (CPU == "k6-2" || CPU == "k6-3" || CPU == "athlon" ||
@@ -892,6 +898,8 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
       Features["3dnowa"] = true;
     else if (Name == "3dnowa")
       Features["3dnow"] = Features["3dnowa"] = true;
+    else if (Name == "aes")
+      Features["aes"] = true;
   } else {
     if (Name == "mmx")
       Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
@@ -917,6 +925,8 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
       Features["3dnow"] = Features["3dnowa"] = false;
     else if (Name == "3dnowa")
       Features["3dnowa"] = false;
+    else if (Name == "aes")
+      Features["aes"] = false;
   }
 
   return true;
@@ -931,6 +941,11 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) {
     if (Features[i][0] == '-')
       continue;
 
+    if (Features[i].substr(1) == "aes") {
+      HasAES = true;
+      continue;
+    }
+
     assert(Features[i][0] == '+' && "Invalid target feature!");
     X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Features[i].substr(1))
       .Case("sse42", SSE42)
@@ -969,6 +984,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
     DefineStd(Builder, "i386", Opts);
   }
 
+  if (HasAES)
+    Builder.defineMacro("__AES__");
+
   // Target properties.
   Builder.defineMacro("__LITTLE_ENDIAN__");