зеркало из https://github.com/microsoft/clang-1.git
Add support for soft/hard float options to the Sparc target
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118514 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
19ddda83f9
Коммит
9284d21502
|
@ -1976,17 +1976,37 @@ namespace {
|
|||
class SparcV8TargetInfo : public TargetInfo {
|
||||
static const TargetInfo::GCCRegAlias GCCRegAliases[];
|
||||
static const char * const GCCRegNames[];
|
||||
bool SoftFloat;
|
||||
public:
|
||||
SparcV8TargetInfo(const std::string& triple) : TargetInfo(triple) {
|
||||
// FIXME: Support Sparc quad-precision long double?
|
||||
DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
|
||||
"i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32";
|
||||
}
|
||||
virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
|
||||
const std::string &Name,
|
||||
bool Enabled) const {
|
||||
if (Name == "soft-float")
|
||||
Features[Name] = Enabled;
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
|
||||
SoftFloat = false;
|
||||
for (unsigned i = 0, e = Features.size(); i != e; ++i)
|
||||
if (Features[i] == "+soft-float")
|
||||
SoftFloat = true;
|
||||
}
|
||||
virtual void getTargetDefines(const LangOptions &Opts,
|
||||
MacroBuilder &Builder) const {
|
||||
DefineStd(Builder, "sparc", Opts);
|
||||
Builder.defineMacro("__sparcv8");
|
||||
Builder.defineMacro("__REGISTER_PREFIX__", "");
|
||||
|
||||
if (SoftFloat)
|
||||
Builder.defineMacro("SOFT_FLOAT", "1");
|
||||
}
|
||||
virtual void getTargetBuiltins(const Builtin::Info *&Records,
|
||||
unsigned &NumRecords) const {
|
||||
|
|
|
@ -619,6 +619,51 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
|
|||
}
|
||||
}
|
||||
|
||||
void Clang::AddSparcTargetArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const {
|
||||
const Driver &D = getToolChain().getDriver();
|
||||
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
|
||||
llvm::StringRef MArch = A->getValue(Args);
|
||||
CmdArgs.push_back("-target-cpu");
|
||||
CmdArgs.push_back(MArch.str().c_str());
|
||||
}
|
||||
|
||||
// Select the float ABI as determined by -msoft-float, -mhard-float, and
|
||||
llvm::StringRef FloatABI;
|
||||
if (Arg *A = Args.getLastArg(options::OPT_msoft_float,
|
||||
options::OPT_mhard_float)) {
|
||||
if (A->getOption().matches(options::OPT_msoft_float))
|
||||
FloatABI = "soft";
|
||||
else if (A->getOption().matches(options::OPT_mhard_float))
|
||||
FloatABI = "hard";
|
||||
}
|
||||
|
||||
// If unspecified, choose the default based on the platform.
|
||||
if (FloatABI.empty()) {
|
||||
switch (getToolChain().getTriple().getOS()) {
|
||||
default:
|
||||
// Assume "soft", but warn the user we are guessing.
|
||||
FloatABI = "soft";
|
||||
D.Diag(clang::diag::warn_drv_assuming_mfloat_abi_is) << "soft";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (FloatABI == "soft") {
|
||||
// Floating point operations and argument passing are soft.
|
||||
//
|
||||
// FIXME: This changes CPP defines, we need -target-soft-float.
|
||||
CmdArgs.push_back("-msoft-float");
|
||||
CmdArgs.push_back("soft");
|
||||
CmdArgs.push_back("-target-feature");
|
||||
CmdArgs.push_back("+soft-float");
|
||||
} else {
|
||||
assert(FloatABI == "hard" && "Invalid float abi!");
|
||||
CmdArgs.push_back("-mhard-float");
|
||||
}
|
||||
}
|
||||
|
||||
void Clang::AddX86TargetArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const {
|
||||
if (!Args.hasFlag(options::OPT_mred_zone,
|
||||
|
@ -1006,6 +1051,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
AddMIPSTargetArgs(Args, CmdArgs);
|
||||
break;
|
||||
|
||||
case llvm::Triple::sparc:
|
||||
AddSparcTargetArgs(Args, CmdArgs);
|
||||
break;
|
||||
|
||||
case llvm::Triple::x86:
|
||||
case llvm::Triple::x86_64:
|
||||
AddX86TargetArgs(Args, CmdArgs);
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace tools {
|
|||
|
||||
void AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
|
||||
void AddMIPSTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
|
||||
void AddSparcTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
|
||||
void AddX86TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
|
||||
|
||||
public:
|
||||
|
|
Загрузка…
Ссылка в новой задаче