MIPS: Move code calculates CPU and ABI names to the separate function to reuse this function later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154269 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Atanasyan 2012-04-07 22:09:23 +00:00
Родитель 3be55cdbb5
Коммит a2768be144
1 изменённых файлов: 21 добавлений и 13 удалений

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

@ -787,38 +787,46 @@ static const char* getMipsABIFromArch(StringRef ArchName) {
return "n64";
}
void Clang::AddMIPSTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
const Driver &D = getToolChain().getDriver();
// Get CPU and ABI names. They are not independent
// so we have to calculate them together.
static void getMipsCPUAndABI(const ArgList &Args,
const ToolChain &TC,
StringRef &CPUName,
StringRef &ABIName) {
StringRef ArchName;
const char *CPUName;
// Set target cpu and architecture.
// Select target cpu and architecture.
if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
CPUName = A->getValue(Args);
ArchName = getMipsArchFromCPU(CPUName);
}
else {
ArchName = Args.MakeArgString(getToolChain().getArchName());
ArchName = Args.MakeArgString(TC.getArchName());
if (!checkMipsArchName(ArchName))
D.Diag(diag::err_drv_invalid_arch_name) << ArchName;
TC.getDriver().Diag(diag::err_drv_invalid_arch_name) << ArchName;
else
CPUName = getMipsCPUFromArch(ArchName);
}
CmdArgs.push_back("-target-cpu");
CmdArgs.push_back(CPUName);
// Select the ABI to use.
const char *ABIName = 0;
if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
ABIName = A->getValue(Args);
else
ABIName = getMipsABIFromArch(ArchName);
}
void Clang::AddMIPSTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
const Driver &D = getToolChain().getDriver();
StringRef CPUName;
StringRef ABIName;
getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName);
CmdArgs.push_back("-target-cpu");
CmdArgs.push_back(CPUName.data());
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName);
CmdArgs.push_back(ABIName.data());
// Select the float ABI as determined by -msoft-float, -mhard-float,
// and -mfloat-abi=.