Skip to content

Commit b5b9413

Browse files
committed
Fix c platform
1 parent 63f40ec commit b5b9413

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/platforms/c.rkt

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
(require math/bigfloat
77
math/flonum
8-
"runtime/float32.rkt" ; float representation helper functions
98
"runtime/libm.rkt" ; libm wrapper
109
"../utils/float.rkt" ; for shift/unshift
1110
"../syntax/platform.rkt")
@@ -16,7 +15,7 @@
1615
(define 32bit-move-cost 0.12961999999999974)
1716
(define boolean-move-cost 0.1)
1817

19-
(define c-platform
18+
(define platform
2019
(make-empty-platform 'c #:if-cost boolean-move-cost))
2120

2221
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BOOLEAN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -34,12 +33,12 @@
3433
#:total-bits 1
3534
#:special-value? (const #f)))
3635

37-
(platform-register-representation! c-platform #:repr bool #:cost boolean-move-cost)
36+
(platform-register-representation! platform #:repr bool #:cost boolean-move-cost)
3837

3938
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4039

4140
(platform-register-implementations!
42-
c-platform
41+
platform
4342
([TRUE () bool (TRUE) (const true) (! TRUE) boolean-move-cost]
4443
[FALSE () bool (FALSE) (const false) (! FALSE) boolean-move-cost]))
4544

@@ -51,7 +50,7 @@
5150
(ormap identity as))
5251

5352
(platform-register-implementations!
54-
c-platform
53+
platform
5554
([not ([x : bool]) bool (not x) not (not x) boolean-move-cost]
5655
[and ([x : bool] [y : bool]) bool (and x y) and-fn (and x y) boolean-move-cost]
5756
[or ([x : bool] [y : bool]) bool (or x y) or-fn (or x y) boolean-move-cost]))
@@ -71,12 +70,12 @@
7170
#:total-bits 32
7271
#:special-value? nan?))
7372

74-
(platform-register-representation! c-platform #:repr binary32 #:cost 32bit-move-cost)
73+
(platform-register-representation! platform #:repr binary32 #:cost 32bit-move-cost)
7574

7675
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7776

7877
(platform-register-implementations!
79-
c-platform
78+
platform
8079
([PI.f32 () binary32 (PI) (const (flsingle pi)) (! :precision binary32 (PI)) 32bit-move-cost]
8180
[E.f32 () binary32 (E) (const (flsingle (exp 1.0))) (! :precision binary32 (E)) 32bit-move-cost]
8281
[INFINITY.f32 () binary32 (INFINITY) (const +inf.0) (! :precision binary32 (INFINITY)) 32bit-move-cost]
@@ -86,7 +85,7 @@
8685

8786
; ([name ([var : repr] ...) otype spec fl fpcore cost])
8887
(platform-register-implementations!
89-
c-platform
88+
platform
9089
([neg.f32 ([x : binary32]) binary32 (neg x) fl32- (! :precision binary32 (- x)) 0.11567699999999992]
9190
[+.f32 ([x : binary32] [y : binary32]) binary32 (+ x y) fl32+ (! :precision binary32 (+ x y)) 0.200445]
9291
[-.f32 ([x : binary32] [y : binary32]) binary32 (- x y) fl32- (! :precision binary32 (- x y)) 0.19106800000000014]
@@ -144,7 +143,7 @@
144143
[remainder 1.030245])]))
145144

146145
(for ([libm-impl.f32 (in-list libm-impls.f32)])
147-
(platform-register-implementation! c-platform libm-impl.f32))
146+
(platform-register-implementation! platform libm-impl.f32))
148147

149148
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; libm accelerators ;;;;;;;;;;;;;;;;;;;;;
150149

@@ -156,7 +155,7 @@
156155

157156
; ([name ([var : repr] ...) otype spec fl fpcore cost])
158157
(platform-register-implementations!
159-
c-platform
158+
platform
160159
([erfc.f32 ([x : binary32]) binary32 (- 1 (erf x)) c_erfcf (! :precision binary32 (erfc x)) 0.907758]
161160
[expm1.f32 ([x : binary32]) binary32 (- (exp x) 1) c_expm1f (! :precision binary32 (expm1 x)) 0.906484]
162161
[log1p.f32 ([x : binary32]) binary32 (log (+ 1 x)) c_log1pf (! :precision binary32 (log1p x)) 1.302969]
@@ -178,12 +177,12 @@
178177
#:total-bits 64
179178
#:special-value? nan?))
180179

181-
(platform-register-representation! c-platform #:repr binary64 #:cost 64bit-move-cost)
180+
(platform-register-representation! platform #:repr binary64 #:cost 64bit-move-cost)
182181

183182
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
184183

185184
(platform-register-implementations!
186-
c-platform
185+
platform
187186
([PI.f64 () binary64 (PI) (const pi) (! :precision binary64 (PI)) 64bit-move-cost]
188187
[E.f64 () binary64 (E) (const (exp 1.0)) (! :precision binary64 (E)) 64bit-move-cost]
189188
[INFINITY.f64 () binary64 (INFINITY) (const +inf.0) (! :precision binary64 (INFINITY)) 64bit-move-cost]
@@ -192,7 +191,7 @@
192191
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; operators ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
193192

194193
(platform-register-implementations!
195-
c-platform
194+
platform
196195
([neg.f64 ([x : binary64]) binary64 (neg x) - (! :precision binary64 (- x)) 0.12114199999999964]
197196
[+.f64 ([x : binary64] [y : binary64]) binary64 (+ x y) + (! :precision binary64 (+ x y)) 0.2174189999999998]
198197
[-.f64 ([x : binary64] [y : binary64]) binary64 (- x y) - (! :precision binary64 (- x y)) 0.20265700000000008]
@@ -250,7 +249,7 @@
250249
[remainder 0.9494380000000005])]))
251250

252251
(for ([libm-impl.f64 (in-list libm-impls.f64)])
253-
(platform-register-implementation! c-platform libm-impl.f64))
252+
(platform-register-implementation! platform libm-impl.f64))
254253

255254
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; libm accelerators ;;;;;;;;;;;;;;;;;;;;;
256255

@@ -262,7 +261,7 @@
262261

263262
; ([name ([var : repr] ...) otype spec fl fpcore cost])
264263
(platform-register-implementations!
265-
c-platform
264+
platform
266265
([erfc.f64 ([x : binary64]) binary64 (- 1 (erf x)) c_erfc (! :precision binary64 (erfc x)) 0.8588620000000002]
267266
[expm1.f64 ([x : binary64]) binary64 (- (exp x) 1) c_expm1 (! :precision binary64 (expm1 x)) 0.8483490000000002]
268267
[log1p.f64 ([x : binary64]) binary64 (log (+ 1 x)) c_log1p (! :precision binary64 (log1p x)) 1.2416829999999997]
@@ -271,15 +270,15 @@
271270

272271
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; additional converters ;;;;;;;;;;;;;;;;;
273272

274-
#;(platform-register-implementation! c-platform
273+
#;(platform-register-implementation! platform
275274
(make-operator-impl (binary64->binary32 [x : binary64])
276275
binary32
277276
#:spec x
278277
#:fpcore (! :precision binary32 (cast x))
279278
#:fl flsingle
280279
#:cost 32bit-move-cost))
281280

282-
#;(platform-register-implementation! c-platform
281+
#;(platform-register-implementation! platform
283282
(make-operator-impl (binary32->binary64 [x : binary32])
284283
binary64
285284
#:spec x
@@ -289,10 +288,10 @@
289288

290289
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; REGISTER PLATFORM ;;;;;;;;;;;;;;;;;;;;;
291290

292-
(register-platform! c-platform)
291+
(register-platform! platform)
293292

294293
(module+ main
295-
(display-platform c-platform))
294+
(display-platform platform))
296295

297296
;; Do not run this file during testing
298297
(module test racket/base

0 commit comments

Comments
 (0)