@@ -755,6 +755,14 @@ pub const Abi = enum {
755
755
else = > .soft ,
756
756
};
757
757
}
758
+
759
+ pub inline fn isSoftFloat (abi : Abi ) bool {
760
+ return abi .floatAbi ().isSoft ();
761
+ }
762
+
763
+ pub inline fn isHardFloat (abi : Abi ) bool {
764
+ return abi .floatAbi ().isHard ();
765
+ }
758
766
};
759
767
760
768
pub const ObjectFormat = enum {
@@ -1645,15 +1653,41 @@ pub inline fn isSpirV(target: Target) bool {
1645
1653
return target .cpu .arch .isSpirV ();
1646
1654
}
1647
1655
1656
+ /// Most architectures only make the distinction between soft float and hard float, and assume that
1657
+ /// hard float implies that both `f32` and `f64` have hardware support, while soft float implies
1658
+ /// that both are emulated. We use `.soft` and `.hard` for these cases.
1659
+ ///
1660
+ /// Some architectures, however, have three floating point ABIs: Soft float, hard float for just
1661
+ /// `f32`, and hard float for both `f32` and `f64`. Here, hard float for both is usually the norm,
1662
+ /// with hard float for just `f32` being more common in embedded scenarios. This is the case for
1663
+ /// RISC-V and LoongArch, for example. We use `.hard32` to refer to the case where only `f32` has
1664
+ /// hardware support.
1648
1665
pub const FloatAbi = enum {
1649
- hard ,
1650
1666
soft ,
1667
+ hard ,
1668
+ hard32 ,
1669
+
1670
+ pub inline fn isSoft (abi : FloatAbi ) bool {
1671
+ return abi == .soft ;
1672
+ }
1673
+
1674
+ pub inline fn isHard (abi : FloatAbi ) bool {
1675
+ return ! abi .isSoft ();
1676
+ }
1651
1677
};
1652
1678
1653
- pub inline fn getFloatAbi (target : Target ) FloatAbi {
1679
+ pub inline fn floatAbi (target : Target ) FloatAbi {
1654
1680
return target .abi .floatAbi ();
1655
1681
}
1656
1682
1683
+ pub inline fn isSoftFloat (target : Target ) bool {
1684
+ return target .floatAbi ().isSoft ();
1685
+ }
1686
+
1687
+ pub inline fn isHardFloat (target : Target ) bool {
1688
+ return target .floatAbi ().isHard ();
1689
+ }
1690
+
1657
1691
pub inline fn hasDynamicLinker (target : Target ) bool {
1658
1692
if (target .cpu .arch .isWasm ()) {
1659
1693
return false ;
@@ -1733,7 +1767,7 @@ pub const DynamicLinker = struct {
1733
1767
.thumbeb = > .armeb ,
1734
1768
else = > cpu .arch ,
1735
1769
}),
1736
- if (cpu .arch .isArmOrThumb () and abi .floatAbi () == .hard ) "hf" else "" ,
1770
+ if (cpu .arch .isArmOrThumb () and abi .isHardFloat () ) "hf" else "" ,
1737
1771
}) catch unreachable else switch (os_tag ) {
1738
1772
.freebsd = > init ("/libexec/ld-elf.so.1" ),
1739
1773
.netbsd = > init ("/libexec/ld.elf_so" ),
@@ -1754,10 +1788,7 @@ pub const DynamicLinker = struct {
1754
1788
.armeb ,
1755
1789
.thumb ,
1756
1790
.thumbeb ,
1757
- = > initFmt ("/lib/ld-linux{s}.so.3" , .{switch (abi .floatAbi ()) {
1758
- .hard = > "-armhf" ,
1759
- else = > "" ,
1760
- }}) catch unreachable ,
1791
+ = > initFmt ("/lib/ld-linux{s}.so.3" , .{if (abi .isHardFloat ()) "-armhf" else "" }) catch unreachable ,
1761
1792
1762
1793
.mips ,
1763
1794
.mipsel ,
0 commit comments