@@ -190,8 +190,12 @@ static void hide(llvm::StringMap<cl::Option *>& map, const char* name) {
190190// / Removes command line options exposed from within LLVM that are unlikely
191191// / to be useful for end users from the -help output.
192192static void hideLLVMOptions () {
193+ #if LDC_LLVM_VER >= 307
194+ llvm::StringMap<cl::Option *>& map = cl::getRegisteredOptions ();
195+ #else
193196 llvm::StringMap<cl::Option *> map;
194197 cl::getRegisteredOptions (map);
198+ #endif
195199 hide (map, " bounds-checking-single-trap" );
196200 hide (map, " disable-debug-info-verifier" );
197201 hide (map, " disable-spill-fusing" );
@@ -550,18 +554,25 @@ static void registerMipsABI()
550554}
551555
552556// / Register the float ABI.
553- // / Also defines D_SoftFloat or D_HardFloat depending on ABI type.
554- static void registerPredefinedFloatABI (const char *soft, const char *hard)
557+ // / Also defines D_HardFloat or D_SoftFloat depending if FPU should be used
558+ static void registerPredefinedFloatABI (const char *soft, const char *hard, const char *softfp= NULL )
555559{
560+ // Use target floating point unit instead of s/w float routines
561+ bool useFPU = !gTargetMachine ->Options .UseSoftFloat ;
562+ VersionCondition::addPredefinedGlobalIdent (useFPU ? " D_HardFloat" : " D_SoftFloat" );
563+
556564 if (gTargetMachine ->Options .FloatABIType == llvm::FloatABI::Soft)
557565 {
558- VersionCondition::addPredefinedGlobalIdent (soft);
559- VersionCondition::addPredefinedGlobalIdent (" D_SoftFloat" );
566+ VersionCondition::addPredefinedGlobalIdent (useFPU && softfp ? softfp : soft);
560567 }
561- if (gTargetMachine ->Options .FloatABIType == llvm::FloatABI::Hard)
568+ else if (gTargetMachine ->Options .FloatABIType == llvm::FloatABI::Hard)
562569 {
570+ assert (useFPU && " Should be using the FPU if using float-abi=hard" );
563571 VersionCondition::addPredefinedGlobalIdent (hard);
564- VersionCondition::addPredefinedGlobalIdent (" D_HardFloat" );
572+ }
573+ else
574+ {
575+ assert (0 && " FloatABIType neither Soft or Hard" );
565576 }
566577}
567578
@@ -603,14 +614,13 @@ static void registerPredefinedTargetVersions() {
603614 case llvm::Triple::armeb:
604615#endif
605616 VersionCondition::addPredefinedGlobalIdent (" ARM" );
606- // FIXME: What about ARM_SoftFP?.
607- registerPredefinedFloatABI (" ARM_SoftFloat" , " ARM_HardFloat" );
617+ registerPredefinedFloatABI (" ARM_SoftFloat" , " ARM_HardFloat" , " ARM_SoftFP" );
608618 break ;
609619 case llvm::Triple::thumb:
610620 VersionCondition::addPredefinedGlobalIdent (" ARM" );
611621 VersionCondition::addPredefinedGlobalIdent (" Thumb" ); // For backwards compatibility.
612622 VersionCondition::addPredefinedGlobalIdent (" ARM_Thumb" );
613- registerPredefinedFloatABI (" ARM_SoftFloat" , " ARM_HardFloat" );
623+ registerPredefinedFloatABI (" ARM_SoftFloat" , " ARM_HardFloat" , " ARM_SoftFP " );
614624 break ;
615625#if LDC_LLVM_VER == 305
616626 case llvm::Triple::arm64:
@@ -622,7 +632,7 @@ static void registerPredefinedTargetVersions() {
622632 case llvm::Triple::aarch64_be:
623633#endif
624634 VersionCondition::addPredefinedGlobalIdent (" AArch64" );
625- registerPredefinedFloatABI (" ARM_SoftFloat" , " ARM_HardFloat" );
635+ registerPredefinedFloatABI (" ARM_SoftFloat" , " ARM_HardFloat" , " ARM_SoftFP " );
626636 break ;
627637#endif
628638 case llvm::Triple::mips:
@@ -989,9 +999,8 @@ int main(int argc, char **argv)
989999 if (m64bits)
9901000 {
9911001 if (bitness != ExplicitBitness::None)
992- {
9931002 error (Loc (), " cannot use both -m32 and -m64 options" );
994- }
1003+ bitness = ExplicitBitness::M64;
9951004 }
9961005
9971006 if (global.errors )
@@ -1015,7 +1024,9 @@ int main(int argc, char **argv)
10151024 global.params .is64bit = triple.isArch64Bit ();
10161025 }
10171026
1018- #if LDC_LLVM_VER >= 306
1027+ #if LDC_LLVM_VER >= 307
1028+ gDataLayout = gTargetMachine ->getDataLayout ();
1029+ #elif LDC_LLVM_VER >= 306
10191030 gDataLayout = gTargetMachine ->getSubtargetImpl ()->getDataLayout ();
10201031#elif LDC_LLVM_VER >= 302
10211032 gDataLayout = gTargetMachine ->getDataLayout ();
@@ -1212,7 +1223,7 @@ int main(int argc, char **argv)
12121223 if (strcmp (m->srcfile ->name ->str , global.main_d ) == 0 )
12131224 {
12141225 static const char buf[] = " void main(){}" ;
1215- m->srcfile ->setbuffer (( void *) buf, sizeof (buf));
1226+ m->srcfile ->setbuffer (const_cast < char *>( buf) , sizeof (buf));
12161227 m->srcfile ->ref = 1 ;
12171228 }
12181229 else
0 commit comments