]> git.lizzy.rs Git - rust.git/commitdiff
add -Z soft-float option
authorJyun-Yan You <jyyou@cs.nctu.edu.tw>
Mon, 30 Sep 2013 05:20:52 +0000 (13:20 +0800)
committerJyun-Yan You <jyyou@cs.nctu.edu.tw>
Tue, 1 Oct 2013 03:19:18 +0000 (11:19 +0800)
This change adds -Z soft-float option for generating
software floating point library calls.
It also implies using soft float ABI, that is the same as llc.

It is useful for targets that have no FPU.

mk/platform.mk
src/librustc/back/link.rs
src/librustc/driver/session.rs
src/librustc/lib/llvm.rs
src/rustllvm/PassWrapper.cpp

index 2956c6cd251e61f62e7ff36b3edfac07b3a1aa96..b3d38fc074a31d62f944b8d487f7adfb41bfaac4 100644 (file)
@@ -343,7 +343,7 @@ CFG_PATH_MUNGE_mips-unknown-linux-gnu := true
 CFG_LDPATH_mips-unknown-linux-gnu :=
 CFG_RUN_mips-unknown-linux-gnu=
 CFG_RUN_TARG_mips-unknown-linux-gnu=
-RUSTC_FLAGS_mips-unknown-linux-gnu := --linker=$(CXX_mips-unknown-linux-gnu) --target-cpu mips32r2 --target-feature +mips32r2,+o32
+RUSTC_FLAGS_mips-unknown-linux-gnu := --linker=$(CXX_mips-unknown-linux-gnu) --target-cpu mips32r2 --target-feature +mips32r2,+o32 -Z soft-float
 
 # i686-pc-mingw32 configuration
 CC_i686-pc-mingw32=$(CC)
index ee7fbed9e9f1183846e4cd515f93aa75bef2c22f..dfa7a2a7a1000d9c1eb28ab7c4a2707bc0c30594 100644 (file)
@@ -264,6 +264,7 @@ pub fn run_passes(sess: Session,
               session::Default => lib::llvm::CodeGenLevelDefault,
               session::Aggressive => lib::llvm::CodeGenLevelAggressive,
             };
+            let use_softfp = sess.opts.debugging_opts & session::use_softfp != 0;
 
             let tm = do sess.targ_cfg.target_strs.target_triple.with_c_str |T| {
                 do sess.opts.target_cpu.with_c_str |CPU| {
@@ -273,7 +274,8 @@ pub fn run_passes(sess: Session,
                             lib::llvm::CodeModelDefault,
                             lib::llvm::RelocPIC,
                             OptLevel,
-                            true
+                            true,
+                            use_softfp
                         )
                     }
                 }
index 19e866c70a3fe64314b4822ce2125b3e44d19f4b..aa321a11548b9713c8eb9ddbb857930de3d50eeb 100644 (file)
@@ -80,6 +80,7 @@ pub struct config {
 pub static no_vectorize_loops:      uint = 1 << 27;
 pub static no_vectorize_slp:        uint = 1 << 28;
 pub static no_prepopulate_passes:   uint = 1 << 29;
+pub static use_softfp:              uint = 1 << 30;
 
 pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
     ~[(~"verbose", ~"in general, enable more debug printouts", verbose),
@@ -135,6 +136,7 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
      (~"no-vectorize-slp",
       ~"Don't run LLVM's SLP vectorization passes",
       no_vectorize_slp),
+     (~"soft-float", ~"Generate software floating point library calls", use_softfp),
     ]
 }
 
index 49798288d40d0820b4343e4911b787be5176ab33..8e77f98eeba1291a437399005f93fc80255f41d5 100644 (file)
@@ -2149,7 +2149,8 @@ pub fn LLVMRustCreateTargetMachine(Triple: *c_char,
                                            Model: CodeGenModel,
                                            Reloc: RelocMode,
                                            Level: CodeGenOptLevel,
-                                           EnableSegstk: bool) -> TargetMachineRef;
+                                           EnableSegstk: bool,
+                                           UseSoftFP: bool) -> TargetMachineRef;
         pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
         pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
                                          PM: PassManagerRef,
index 615c2cc61cbee738e77fc3429337b524109dac26..8d0b447fa4a1e4bbcdf90a532bebba3912e34d51 100644 (file)
@@ -67,7 +67,8 @@ LLVMRustCreateTargetMachine(const char *triple,
                             CodeModel::Model CM,
                             Reloc::Model RM,
                             CodeGenOpt::Level OptLevel,
-                            bool EnableSegmentedStacks) {
+                            bool EnableSegmentedStacks,
+                            bool UseSoftFloat) {
     std::string Error;
     Triple Trip(Triple::normalize(triple));
     const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Trip.getTriple(),
@@ -84,6 +85,10 @@ LLVMRustCreateTargetMachine(const char *triple,
     Options.FloatABIType =
          (Trip.getEnvironment() == Triple::GNUEABIHF) ? FloatABI::Hard :
                                                         FloatABI::Default;
+    Options.UseSoftFloat = UseSoftFloat;
+    if (UseSoftFloat) {
+        Options.FloatABIType = FloatABI::Soft;
+    }
 
     TargetMachine *TM = TheTarget->createTargetMachine(Trip.getTriple(),
                                                        cpu,