@@ -30,11 +30,156 @@ pub fn fmaf(mut x: f32, y: f32, z: f32) -> f32 {
3030 x
3131}
3232
33+ pub fn ceil ( mut x : f64 ) -> f64 {
34+ // SAFETY: `frintp` is available with neon and has no side effects.
35+ unsafe {
36+ asm ! (
37+ "frintp {x:d}, {x:d}" ,
38+ x = inout( vreg) x,
39+ options( nomem, nostack, pure)
40+ ) ;
41+ }
42+ x
43+ }
44+
45+ pub fn ceilf ( mut x : f32 ) -> f32 {
46+ // SAFETY: `frintp` is available with neon and has no side effects.
47+ unsafe {
48+ asm ! (
49+ "frintp {x:s}, {x:s}" ,
50+ x = inout( vreg) x,
51+ options( nomem, nostack, pure)
52+ ) ;
53+ }
54+ x
55+ }
56+
57+ #[ cfg( all( f16_enabled, target_feature = "fp16" ) ) ]
58+ pub fn ceilf16 ( mut x : f16 ) -> f16 {
59+ // SAFETY: `frintp` is available for `f16` with `fp16` (implies `neon`) and has no side effects.
60+ unsafe {
61+ asm ! (
62+ "frintp {x:h}, {x:h}" ,
63+ x = inout( vreg) x,
64+ options( nomem, nostack, pure)
65+ ) ;
66+ }
67+ x
68+ }
69+
70+ pub fn floor ( mut x : f64 ) -> f64 {
71+ // SAFETY: `frintm` is available with neon and has no side effects.
72+ unsafe {
73+ asm ! (
74+ "frintm {x:d}, {x:d}" ,
75+ x = inout( vreg) x,
76+ options( nomem, nostack, pure)
77+ ) ;
78+ }
79+ x
80+ }
81+
82+ pub fn floorf ( mut x : f32 ) -> f32 {
83+ // SAFETY: `frintm` is available with neon and has no side effects.
84+ unsafe {
85+ asm ! (
86+ "frintm {x:s}, {x:s}" ,
87+ x = inout( vreg) x,
88+ options( nomem, nostack, pure)
89+ ) ;
90+ }
91+ x
92+ }
93+
94+ #[ cfg( all( f16_enabled, target_feature = "fp16" ) ) ]
95+ pub fn floorf16 ( mut x : f16 ) -> f16 {
96+ // SAFETY: `frintm` is available for `f16` with `fp16` (implies `neon`) and has no side effects.
97+ unsafe {
98+ asm ! (
99+ "frintm {x:h}, {x:h}" ,
100+ x = inout( vreg) x,
101+ options( nomem, nostack, pure)
102+ ) ;
103+ }
104+ x
105+ }
106+
33107pub fn rint ( mut x : f64 ) -> f64 {
108+ // SAFETY: `frintx` is available with neon and has no side effects.
109+ unsafe {
110+ asm ! (
111+ "frintx {x:d}, {x:d}" ,
112+ x = inout( vreg) x,
113+ options( nomem, nostack, pure)
114+ ) ;
115+ }
116+ x
117+ }
118+
119+ pub fn rintf ( mut x : f32 ) -> f32 {
120+ // SAFETY: `frintx` is available with neon and has no side effects.
121+ unsafe {
122+ asm ! (
123+ "frintx {x:s}, {x:s}" ,
124+ x = inout( vreg) x,
125+ options( nomem, nostack, pure)
126+ ) ;
127+ }
128+ x
129+ }
130+
131+ #[ cfg( all( f16_enabled, target_feature = "fp16" ) ) ]
132+ pub fn rintf16 ( mut x : f16 ) -> f16 {
133+ // SAFETY: `frintx` is available for `f16` with `fp16` (implies `neon`) and has no side effects.
134+ unsafe {
135+ asm ! (
136+ "frintx {x:h}, {x:h}" ,
137+ x = inout( vreg) x,
138+ options( nomem, nostack, pure)
139+ ) ;
140+ }
141+ x
142+ }
143+
144+ pub fn round ( mut x : f64 ) -> f64 {
145+ // SAFETY: `frinta` is available with neon and has no side effects.
146+ unsafe {
147+ asm ! (
148+ "frinta {x:d}, {x:d}" ,
149+ x = inout( vreg) x,
150+ options( nomem, nostack, pure)
151+ ) ;
152+ }
153+ x
154+ }
155+
156+ pub fn roundf ( mut x : f32 ) -> f32 {
157+ // SAFETY: `frinta` is available with neon and has no side effects.
158+ unsafe {
159+ asm ! (
160+ "frinta {x:s}, {x:s}" ,
161+ x = inout( vreg) x,
162+ options( nomem, nostack, pure)
163+ ) ;
164+ }
165+ x
166+ }
167+
168+ #[ cfg( all( f16_enabled, target_feature = "fp16" ) ) ]
169+ pub fn roundf16 ( mut x : f16 ) -> f16 {
170+ // SAFETY: `frinta` is available for `f16` with `fp16` (implies `neon`) and has no side effects.
171+ unsafe {
172+ asm ! (
173+ "frinta {x:h}, {x:h}" ,
174+ x = inout( vreg) x,
175+ options( nomem, nostack, pure)
176+ ) ;
177+ }
178+ x
179+ }
180+
181+ pub fn roundeven ( mut x : f64 ) -> f64 {
34182 // SAFETY: `frintn` is available with neon and has no side effects.
35- //
36- // `frintn` is always round-to-nearest which does not match the C specification, but Rust does
37- // not support rounding modes.
38183 unsafe {
39184 asm ! (
40185 "frintn {x:d}, {x:d}" ,
@@ -45,11 +190,8 @@ pub fn rint(mut x: f64) -> f64 {
45190 x
46191}
47192
48- pub fn rintf ( mut x : f32 ) -> f32 {
193+ pub fn roundevenf ( mut x : f32 ) -> f32 {
49194 // SAFETY: `frintn` is available with neon and has no side effects.
50- //
51- // `frintn` is always round-to-nearest which does not match the C specification, but Rust does
52- // not support rounding modes.
53195 unsafe {
54196 asm ! (
55197 "frintn {x:s}, {x:s}" ,
@@ -61,11 +203,8 @@ pub fn rintf(mut x: f32) -> f32 {
61203}
62204
63205#[ cfg( all( f16_enabled, target_feature = "fp16" ) ) ]
64- pub fn rintf16 ( mut x : f16 ) -> f16 {
206+ pub fn roundevenf16 ( mut x : f16 ) -> f16 {
65207 // SAFETY: `frintn` is available for `f16` with `fp16` (implies `neon`) and has no side effects.
66- //
67- // `frintn` is always round-to-nearest which does not match the C specification, but Rust does
68- // not support rounding modes.
69208 unsafe {
70209 asm ! (
71210 "frintn {x:h}, {x:h}" ,
@@ -76,6 +215,43 @@ pub fn rintf16(mut x: f16) -> f16 {
76215 x
77216}
78217
218+ pub fn trunc ( mut x : f64 ) -> f64 {
219+ // SAFETY: `frintz` is available with neon and has no side effects.
220+ unsafe {
221+ asm ! (
222+ "frintz {x:d}, {x:d}" ,
223+ x = inout( vreg) x,
224+ options( nomem, nostack, pure)
225+ ) ;
226+ }
227+ x
228+ }
229+
230+ pub fn truncf ( mut x : f32 ) -> f32 {
231+ // SAFETY: `frintz` is available with neon and has no side effects.
232+ unsafe {
233+ asm ! (
234+ "frintz {x:s}, {x:s}" ,
235+ x = inout( vreg) x,
236+ options( nomem, nostack, pure)
237+ ) ;
238+ }
239+ x
240+ }
241+
242+ #[ cfg( all( f16_enabled, target_feature = "fp16" ) ) ]
243+ pub fn truncf16 ( mut x : f16 ) -> f16 {
244+ // SAFETY: `frintz` is available for `f16` with `fp16` (implies `neon`) and has no side effects.
245+ unsafe {
246+ asm ! (
247+ "frintz {x:h}, {x:h}" ,
248+ x = inout( vreg) x,
249+ options( nomem, nostack, pure)
250+ ) ;
251+ }
252+ x
253+ }
254+
79255pub fn sqrt ( mut x : f64 ) -> f64 {
80256 // SAFETY: `fsqrt` is available with neon and has no side effects.
81257 unsafe {
0 commit comments