Skip to content

Commit

Permalink
Set version ARM_SoftFP
Browse files Browse the repository at this point in the history
Set versions ARM_SoftFP & D_HardFloat instead of ARM_SoftFloat &
D_SoftFloat for option -mfloat-abi=softfp (function calls use soft float
ABI but using hardware floating point instruction).
  • Loading branch information
smolt committed Jan 28, 2015
1 parent 2f273bd commit 5a19080
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 16 additions & 10 deletions driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,25 @@ static void registerMipsABI()
}

/// Register the float ABI.
/// Also defines D_SoftFloat or D_HardFloat depending on ABI type.
static void registerPredefinedFloatABI(const char *soft, const char *hard)
/// Also defines D_HardFloat or D_SoftFloat depending if FPU should be used
static void registerPredefinedFloatABI(const char *soft, const char *hard, const char *softfp=NULL)
{
// Use target floating point unit instead of s/w float routines
bool useFPU = !gTargetMachine->Options.UseSoftFloat;
VersionCondition::addPredefinedGlobalIdent(useFPU ? "D_HardFloat" : "D_SoftFloat");

if (gTargetMachine->Options.FloatABIType == llvm::FloatABI::Soft)
{
VersionCondition::addPredefinedGlobalIdent(soft);
VersionCondition::addPredefinedGlobalIdent("D_SoftFloat");
VersionCondition::addPredefinedGlobalIdent(useFPU && softfp ? softfp : soft);
}
if (gTargetMachine->Options.FloatABIType == llvm::FloatABI::Hard)
else if (gTargetMachine->Options.FloatABIType == llvm::FloatABI::Hard)
{
assert(useFPU && "Should be using the FPU if using float-abi=hard");
VersionCondition::addPredefinedGlobalIdent(hard);
VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
}
else
{
assert(0 && "FloatABIType neither Soft or Hard");
}
}

Expand Down Expand Up @@ -604,14 +611,13 @@ static void registerPredefinedTargetVersions() {
case llvm::Triple::armeb:
#endif
VersionCondition::addPredefinedGlobalIdent("ARM");
// FIXME: What about ARM_SoftFP?.
registerPredefinedFloatABI("ARM_SoftFloat", "ARM_HardFloat");
registerPredefinedFloatABI("ARM_SoftFloat", "ARM_HardFloat", "ARM_SoftFP");
break;
case llvm::Triple::thumb:
VersionCondition::addPredefinedGlobalIdent("ARM");
VersionCondition::addPredefinedGlobalIdent("Thumb"); // For backwards compatibility.
VersionCondition::addPredefinedGlobalIdent("ARM_Thumb");
registerPredefinedFloatABI("ARM_SoftFloat", "ARM_HardFloat");
registerPredefinedFloatABI("ARM_SoftFloat", "ARM_HardFloat", "ARM_SoftFP");
break;
#if LDC_LLVM_VER == 305
case llvm::Triple::arm64:
Expand All @@ -623,7 +629,7 @@ static void registerPredefinedTargetVersions() {
case llvm::Triple::aarch64_be:
#endif
VersionCondition::addPredefinedGlobalIdent("AArch64");
registerPredefinedFloatABI("ARM_SoftFloat", "ARM_HardFloat");
registerPredefinedFloatABI("ARM_SoftFloat", "ARM_HardFloat", "ARM_SoftFP");
break;
#endif
case llvm::Triple::mips:
Expand Down
2 changes: 2 additions & 0 deletions driver/targetmachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ llvm::TargetMachine* createTargetMachine(
floatABI = getARMFloatABI(triple, getLLVMArchSuffixForARM(cpu));
break;
case llvm::Triple::thumb:
// TODO: Not sure this is generally true. clang arm-apple-darwin seems
// to default to thumb and softfp. Need to look into it.
floatABI = FloatABI::Soft;
break;
}
Expand Down

0 comments on commit 5a19080

Please sign in to comment.