ccc: Basic translation of gcc subtarget feature options to LLVM

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
This commit is contained in:
Daniel Dunbar 2009-02-20 07:35:04 +00:00
Родитель c4556d1151
Коммит 4311e4507a
4 изменённых файлов: 97 добавлений и 2 удалений

Просмотреть файл

@ -846,6 +846,7 @@ class OptionParser:
self.f_timeReportOption = self.addOption(FlagOption('-ftime-report', self.Clang_fGroup)) self.f_timeReportOption = self.addOption(FlagOption('-ftime-report', self.Clang_fGroup))
self.f_traditionalOption = self.addOption(FlagOption('-ftraditional', self.fGroup)) self.f_traditionalOption = self.addOption(FlagOption('-ftraditional', self.fGroup))
self.f_unwindTablesOption = self.addOption(FlagOption('-funwind-tables', 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_writableStringsOption = self.addOption(FlagOption('-fwritable-strings', self.Clang_fGroup))
self.f_zeroInitializedInBssOption = self.addOption(FlagOption('-fzero-initialized-in-bss', self.fGroup)) self.f_zeroInitializedInBssOption = self.addOption(FlagOption('-fzero-initialized-in-bss', self.fGroup))
self.fOption = self.addOption(JoinedOption('-f', 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_noPascalStringsOption = self.addOption(FlagOption('-mno-pascal-strings', self.mGroup))
self.m_tuneOption = self.addOption(JoinedOption('-mtune=', 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 # Ugh. Need to disambiguate our naming convetion. -m x goes to
# the linker sometimes, wheres -mxxxx is used for a variety of # the linker sometimes, wheres -mxxxx is used for a variety of
# other things. # other things.

Просмотреть файл

@ -86,6 +86,12 @@ class ToolChain(object):
def isMathErrnoDefault(self): def isMathErrnoDefault(self):
return True return True
def isUnwindTablesDefault(self):
# FIXME: Target hook.
if self.archName == 'x86_64':
return True
return False
def getRelocationModel(self, picEnabled, picDisabled): def getRelocationModel(self, picEnabled, picDisabled):
if picEnabled: if picEnabled:
return 'pic' return 'pic'

Просмотреть файл

@ -272,8 +272,67 @@ class Clang_CompileTool(Tool):
if arglist.getLastArg(arglist.parser.f_debugPassArgumentsOption): if arglist.getLastArg(arglist.parser.f_debugPassArgumentsOption):
cmd_args.append('--debug-pass=Arguments') cmd_args.append('--debug-pass=Arguments')
# FIXME: set --inline-threshhold=50 if (optimize_size || optimize < 3) # FIXME: set --inline-threshhold=50 if (optimize_size || optimize < 3)
if arglist.getLastArg(arglist.parser.f_unwindTablesOption): cmd_args.append('--unwind-tables=%d' %
cmd_args.append('--unwind-tables') 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, if arglist.hasFFlag(arglist.parser.f_mathErrnoOption,
arglist.parser.f_noMathErrnoOption, arglist.parser.f_noMathErrnoOption,

Просмотреть файл

@ -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