]> granicus.if.org Git - clang/commitdiff
ccc: Basic translation of gcc subtarget feature options to LLVM
authorDaniel Dunbar <daniel@zuster.org>
Fri, 20 Feb 2009 07:35:04 +0000 (07:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 20 Feb 2009 07:35:04 +0000 (07:35 +0000)
options (i.e., -mno-red-zone, -msoft-float, -mno-sse, etc.)
 - Also, make sure unwind tables default to on Darwin/x86_64.
 - PR3604.

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

tools/ccc/ccclib/Arguments.py
tools/ccc/ccclib/ToolChain.py
tools/ccc/ccclib/Tools.py
tools/ccc/test/ccc/x86-target-features.c [new file with mode: 0644]

index 4a1c7ebbbb438f124a6647a67d0734a217fc5bf6..78d558b3f1964edacd24b9e233262447dbc38f85 100644 (file)
@@ -846,6 +846,7 @@ class OptionParser:
         self.f_timeReportOption = self.addOption(FlagOption('-ftime-report', self.Clang_fGroup))
         self.f_traditionalOption = self.addOption(FlagOption('-ftraditional', self.fGroup))
         self.f_unwindTablesOption = self.addOption(FlagOption('-funwind-tables', self.fGroup))
+        self.f_noUnwindTablesOption = self.addOption(FlagOption('-fno-unwind-tables', self.fGroup))
         self.f_writableStringsOption = self.addOption(FlagOption('-fwritable-strings', self.Clang_fGroup))
         self.f_zeroInitializedInBssOption = self.addOption(FlagOption('-fzero-initialized-in-bss', self.fGroup))
         self.fOption = self.addOption(JoinedOption('-f', self.fGroup))
@@ -867,6 +868,31 @@ class OptionParser:
         self.m_noPascalStringsOption = self.addOption(FlagOption('-mno-pascal-strings', self.mGroup))
         self.m_tuneOption = self.addOption(JoinedOption('-mtune=', self.mGroup))
 
+        self.m_mmxOption = self.addOption(FlagOption('-mmmx', self.mGroup))
+        self.m_noMmxOption = self.addOption(FlagOption('-mno-mmx', self.mGroup))
+        self.m_sseOption = self.addOption(FlagOption('-msse', self.mGroup))
+        self.m_noSseOption = self.addOption(FlagOption('-mno-sse', self.mGroup))
+        self.m_sse2Option = self.addOption(FlagOption('-msse2', self.mGroup))
+        self.m_noSse2Option = self.addOption(FlagOption('-mno-sse2', self.mGroup))
+        self.m_sse3Option = self.addOption(FlagOption('-msse3', self.mGroup))
+        self.m_noSse3Option = self.addOption(FlagOption('-mno-sse3', self.mGroup))
+        self.m_ssse3Option = self.addOption(FlagOption('-mssse3', self.mGroup))
+        self.m_noSsse3Option = self.addOption(FlagOption('-mno-ssse3', self.mGroup))
+        self.m_sse41Option = self.addOption(FlagOption('-msse41', self.mGroup))
+        self.m_noSse41Option = self.addOption(FlagOption('-mno-sse41', self.mGroup))
+        self.m_sse42Option = self.addOption(FlagOption('-msse42', self.mGroup))
+        self.m_noSse42Option = self.addOption(FlagOption('-mno-sse42', self.mGroup))
+        self.m_sse4aOption = self.addOption(FlagOption('-msse4a', self.mGroup))
+        self.m_noSse4aOption = self.addOption(FlagOption('-mno-sse4a', self.mGroup))
+        self.m_3dnowOption = self.addOption(FlagOption('-m3dnow', self.mGroup))
+        self.m_no3dnowOption = self.addOption(FlagOption('-mno-3dnow', self.mGroup))
+        self.m_3dnowaOption = self.addOption(FlagOption('-m3dnowa', self.mGroup))
+        self.m_no3dnowaOption = self.addOption(FlagOption('-mno-3dnowa', self.mGroup))
+        self.m_redZoneOption = self.addOption(FlagOption('-mred-zone', self.mGroup))
+        self.m_noRedZoneOption = self.addOption(FlagOption('-mno-red-zone', self.mGroup))
+        self.m_softFloatOption = self.addOption(FlagOption('-msoft-float', self.mGroup))
+        self.m_noSoftFloatOption = self.addOption(FlagOption('-mno-soft-float', self.mGroup))
+
         # Ugh. Need to disambiguate our naming convetion. -m x goes to
         # the linker sometimes, wheres -mxxxx is used for a variety of
         # other things.        
index cda94083795cb00ece15ce3d842001afd59d210f..ea35de9502c0944549bbdbdaaf6c1b356bb78ef3 100644 (file)
@@ -86,6 +86,12 @@ class ToolChain(object):
     def isMathErrnoDefault(self):
         return True
 
+    def isUnwindTablesDefault(self):
+        # FIXME: Target hook.
+        if self.archName == 'x86_64':
+            return True
+        return False
+
     def getRelocationModel(self, picEnabled, picDisabled):
         if picEnabled:
             return 'pic'
index 3c80861b11816200c720598b8ec5273b4cc4df07..040cfac8519a314d96b99cb9881029c790bcccfc 100644 (file)
@@ -272,8 +272,67 @@ class Clang_CompileTool(Tool):
             if arglist.getLastArg(arglist.parser.f_debugPassArgumentsOption):
                 cmd_args.append('--debug-pass=Arguments')
             # FIXME: set --inline-threshhold=50 if (optimize_size || optimize < 3)
-            if arglist.getLastArg(arglist.parser.f_unwindTablesOption):
-                cmd_args.append('--unwind-tables')
+            cmd_args.append('--unwind-tables=%d' %
+                            arglist.hasFFlag(arglist.parser.f_unwindTablesOption,
+                                             arglist.parser.f_noUnwindTablesOption,
+                                             self.toolChain.isUnwindTablesDefault()))
+            if not arglist.hasFFlag(arglist.parser.m_redZoneOption,
+                                      arglist.parser.m_noRedZoneOption,
+                                      True):
+                cmd_args.append('--disable-red-zone')
+            if arglist.hasFFlag(arglist.parser.m_softFloatOption,
+                                arglist.parser.m_noSoftFloatOption,
+                                False):
+                cmd_args.append('--soft-float')
+                
+            # FIXME: Need target hooks.
+            if self.toolChain.driver.getHostSystemName() == 'darwin':
+                if self.toolChain.archName == 'x86_64':
+                    cmd_args.append('--mcpu=core2')
+                elif self.toolChain.archName == 'i386':
+                    cmd_args.append('--mcpu=yonah')
+            else:
+                pass
+            
+            # FIXME: Ignores ordering
+            attrs = []
+            for pos,neg,flag in [(arglist.parser.m_mmxOption,
+                                  arglist.parser.m_noMmxOption,
+                                  'mmx'),
+                                 (arglist.parser.m_sseOption,
+                                  arglist.parser.m_noSseOption,
+                                  'sse'),
+                                 (arglist.parser.m_sse2Option,
+                                  arglist.parser.m_noSse2Option,
+                                  'sse2'),
+                                 (arglist.parser.m_sse3Option,
+                                  arglist.parser.m_noSse3Option,
+                                  'sse3'),
+                                 (arglist.parser.m_ssse3Option,
+                                  arglist.parser.m_noSsse3Option,
+                                  'ssse3'),
+                                 (arglist.parser.m_sse41Option,
+                                  arglist.parser.m_noSse41Option,
+                                  'sse41'),
+                                 (arglist.parser.m_sse42Option,
+                                  arglist.parser.m_noSse42Option,
+                                  'sse42'),
+                                 (arglist.parser.m_sse4aOption,
+                                  arglist.parser.m_noSse4aOption,
+                                  'sse4a'),
+                                 (arglist.parser.m_3dnowOption,
+                                  arglist.parser.m_no3dnowOption,
+                                  '3dnow'),
+                                 (arglist.parser.m_3dnowaOption,
+                                  arglist.parser.m_no3dnowaOption,
+                                  '3dnowa'),
+                                 ]:
+                if arglist.getLastArg(pos):
+                    attrs.append('+' + flag)
+                elif arglist.getLastArg(neg):
+                    attrs.append('-' + flag)
+            if attrs:
+                cmd_args.append('--mattrs=%s' % ','.join(attrs))
 
             if arglist.hasFFlag(arglist.parser.f_mathErrnoOption,
                                 arglist.parser.f_noMathErrnoOption,
diff --git a/tools/ccc/test/ccc/x86-target-features.c b/tools/ccc/test/ccc/x86-target-features.c
new file mode 100644 (file)
index 0000000..3414922
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: xcc -ccc-host-machine i386 -### -S %s -mno-red-zone -mno-sse -msse4a -msoft-float &> %t &&
+// RUN: grep '"--mattrs=-sse,+sse4a"' %t &&
+// RUN: grep '"--disable-red-zone"' %t &&
+// RUN: grep '"--soft-float"' %t