diff --git a/tools/ccc/ccclib/Arguments.py b/tools/ccc/ccclib/Arguments.py index 4a1c7ebbbb..78d558b3f1 100644 --- a/tools/ccc/ccclib/Arguments.py +++ b/tools/ccc/ccclib/Arguments.py @@ -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. diff --git a/tools/ccc/ccclib/ToolChain.py b/tools/ccc/ccclib/ToolChain.py index cda9408379..ea35de9502 100644 --- a/tools/ccc/ccclib/ToolChain.py +++ b/tools/ccc/ccclib/ToolChain.py @@ -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' diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py index 3c80861b11..040cfac851 100644 --- a/tools/ccc/ccclib/Tools.py +++ b/tools/ccc/ccclib/Tools.py @@ -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 index 0000000000..34149226ea --- /dev/null +++ b/tools/ccc/test/ccc/x86-target-features.c @@ -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