| ... | ... | @@ -3108,6 +3108,30 @@ pub const Object = struct { |
| 3108 | 3108 | .value = .empty, |
| 3109 | 3109 | } }, &o.builder); |
| 3110 | 3110 | } |
| 3111 | if (target.floatAbi() == .soft) { |
| 3112 | // `use-soft-float` means "use software routines for floating point computations". In |
| 3113 | // other words, it configures how LLVM lowers basic float instructions like `fcmp`, |
| 3114 | // `fadd`, etc. The float calling convention is configured on `TargetMachine` and is |
| 3115 | // mostly an orthogonal concept, although obviously we do need hardware float operations |
| 3116 | // to actually be able to pass float values in float registers. |
| 3117 | // |
| 3118 | // Ideally, we would support something akin to the `-mfloat-abi=softfp` option that GCC |
| 3119 | // and Clang support for Arm32 and CSKY. We don't currently expose such an option in |
| 3120 | // Zig, and using CPU features as the source of truth for this makes for a miserable |
| 3121 | // user experience since people expect e.g. `arm-linux-gnueabi` to mean full soft float |
| 3122 | // unless the compiler has explicitly been told otherwise. (And note that our baseline |
| 3123 | // CPU models almost all include FPU features!) |
| 3124 | // |
| 3125 | // Revisit this at some point. |
| 3126 | try attributes.addFnAttr(.{ .string = .{ |
| 3127 | .kind = try o.builder.string("use-soft-float"), |
| 3128 | .value = try o.builder.string("true"), |
| 3129 | } }, &o.builder); |
| 3130 | |
| 3131 | // This prevents LLVM from using FPU/SIMD code for things like `memcpy`. As for the |
| 3132 | // above, this should be revisited if `softfp` support is added. |
| 3133 | try attributes.addFnAttr(.noimplicitfloat, &o.builder); |
| 3134 | } |
| 3111 | 3135 | } |
| 3112 | 3136 | |
| 3113 | 3137 | fn resolveGlobalUav( |