Skip to content

Commit 57212c7

Browse files
committed
moved imulq to dynamic-typing, where it is first needed
1 parent 2e71eb3 commit 57212c7

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

dynamic-typing.rkt

+21
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@
442442
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
443443
;; select-instructions : C -> psuedo-x86
444444

445+
(define/override (instructions)
446+
(set-union (super instructions)
447+
(set 'imulq)))
448+
445449
(define/override (select-instructions)
446450
(lambda (x)
447451
(vomit "select instructions" x)
@@ -470,6 +474,23 @@
470474
(movq (int 0) ,lhs^))]
471475
[else ((super select-instructions) x)])))
472476

477+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
478+
;; patch-instructions
479+
480+
(define/override (patch-instructions)
481+
(lambda (e)
482+
(match e
483+
;; for imulq, destination must be a register -Jeremy
484+
[`(imulq ,s (reg ,d))
485+
`((imulq ,s (reg ,d)))]
486+
[`(imulq ,s ,d)
487+
`((movq ,d (reg rax))
488+
(imulq ,s (reg rax))
489+
(movq (reg rax) ,d))]
490+
[else
491+
((super patch-instructions) e)]
492+
)))
493+
473494
));; compile-R7
474495

475496

int_exp.rkt

+5-12
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
(super-new)
1111

1212
(define/public (primitives)
13-
(set '+ '- '* 'read))
13+
(set '+ '- 'read))
1414

1515
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1616
;; uniquify : env -> S0 -> S0
1717
(define/public (uniquify env)
1818
(lambda (e)
1919
(define recur (uniquify env))
2020
(match e
21-
['(void) '(void)]
2221
[(? symbol?) (cdr (assq e env))]
2322
[(? integer?) e]
2423
[`(let ([,x ,(app recur new-e)]) ,body)
@@ -68,7 +67,8 @@
6867

6968
(define/public (binary-op->inst op)
7069
(match op
71-
['+ 'addq] ['- 'subq] ['* 'imulq]
70+
['+ 'addq]
71+
['- 'subq]
7272
[else (error "in binary-op->inst unmatched" op)]
7373
))
7474

@@ -79,7 +79,7 @@
7979

8080
(define/public (commutative? op)
8181
(match op
82-
['+ #t] ['* #t]
82+
['+ #t]
8383
[else #f]))
8484

8585
(define/public (select-instructions)
@@ -136,7 +136,7 @@
136136
(define/public (first-offset) 8)
137137

138138
(define/public (instructions)
139-
(set 'addq 'subq 'imulq 'negq 'movq))
139+
(set 'addq 'subq 'negq 'movq))
140140

141141
(define/public (assign-homes homes)
142142
(lambda (e)
@@ -195,13 +195,6 @@
195195
[`(program ,stack-space ,ss ...)
196196
`(program ,stack-space
197197
,@(append* (map (patch-instructions) ss)))]
198-
;; for imulq, destination must be a register -Jeremy
199-
[`(imulq ,s (reg ,d))
200-
`((imulq ,s (reg ,d)))]
201-
[`(imulq ,s ,d)
202-
`((movq ,d (reg rax))
203-
(imulq ,s (reg rax))
204-
(movq (reg rax) ,d))]
205198
[`(,instr-name ,s ,d)
206199
#:when (set-member? (instructions) instr-name)
207200
(cond [(and (in-memory? s) (in-memory? d))

vectors.rkt

+8-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@
6464
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6565
;; uniqueify : S1 -> C1-expr x (C1-stmt list)
6666

67-
;; nothing to do
67+
(define/override (uniquify env)
68+
(lambda (e)
69+
(define recur (uniquify env))
70+
(match e
71+
['(void) '(void)]
72+
[else
73+
((super uniquify env) e)]
74+
)))
6875

6976
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7077
;; expose-allocation

0 commit comments

Comments
 (0)