mescc: Tinycc support: Respect word size better.
* stage0/x86.M1 (movzwl_0x32(%ebp),%eax,movzwl_0x8(%ebp),%eax): New define. * module/mes/as-i386.mes (i386:push-word-local-de-ref, i386:word-local->accu): New function. * module/mes/as-i386.scm: Export them. * module/language/c99/compiler.mes (push-local-de-ref): Respect word size. (ident->accu): Likewise.
This commit is contained in:
parent
808af5001f
commit
4ce75e8f4b
|
@ -564,9 +564,11 @@
|
||||||
(ptr (local:pointer local))
|
(ptr (local:pointer local))
|
||||||
(size (if (= ptr 1) (ast-type->size info (local:type o))
|
(size (if (= ptr 1) (ast-type->size info (local:type o))
|
||||||
4)))
|
4)))
|
||||||
(if (= size 1)
|
(case size
|
||||||
(wrap-as (i386:push-byte-local-de-ref (local:id o)))
|
((1) (wrap-as (i386:push-byte-local-de-ref (local:id o))))
|
||||||
(wrap-as (i386:push-local-de-ref (local:id o)))))))
|
((2) (wrap-as (i386:push-word-local-de-ref (local:id o))))
|
||||||
|
((4) (wrap-as (i386:push-local-de-ref (local:id o))))
|
||||||
|
(else (error (format #f "TODO: push size >4: ~a\n" size)))))))
|
||||||
|
|
||||||
(define (push-local-de-de-ref info)
|
(define (push-local-de-de-ref info)
|
||||||
(lambda (o)
|
(lambda (o)
|
||||||
|
@ -686,8 +688,10 @@
|
||||||
(size (if (= ptr 0) (ast-type->size info type)
|
(size (if (= ptr 0) (ast-type->size info type)
|
||||||
4)))
|
4)))
|
||||||
(cond ((< ptr 0) (wrap-as (i386:local-ptr->accu (local:id local))))
|
(cond ((< ptr 0) (wrap-as (i386:local-ptr->accu (local:id local))))
|
||||||
(else (wrap-as (if (= size 1) (i386:byte-local->accu (local:id local))
|
(else (wrap-as (case size
|
||||||
(i386:local->accu (local:id local)))))))
|
((1) (i386:byte-local->accu (local:id local)))
|
||||||
|
((2) (i386:word-local->accu (local:id local)))
|
||||||
|
(else (i386:local->accu (local:id local))))))))
|
||||||
(if global
|
(if global
|
||||||
(let* ((ptr (ident->pointer info o)))
|
(let* ((ptr (ident->pointer info o)))
|
||||||
(cond ((< ptr 0) (list (i386:label->accu `(#:address ,o))))
|
(cond ((< ptr 0) (list (i386:label->accu `(#:address ,o))))
|
||||||
|
|
|
@ -71,6 +71,14 @@
|
||||||
("movzbl_(%eax),%eax")
|
("movzbl_(%eax),%eax")
|
||||||
("push___%eax"))))
|
("push___%eax"))))
|
||||||
|
|
||||||
|
(define (i386:push-word-local-de-ref n)
|
||||||
|
(or n (error "invalid value: push-word-local-de-ref: " n))
|
||||||
|
(let ((n (- 0 (* 4 n))))
|
||||||
|
`(,(if (< (abs n) #x80) `("mov____0x8(%ebp),%eax" (#:immediate1 ,n))
|
||||||
|
`("mov____0x32(%ebp),%eax" (#:immediate ,n)))
|
||||||
|
("movzwl_(%eax),%eax")
|
||||||
|
("push___%eax"))))
|
||||||
|
|
||||||
(define (i386:push-byte-local-de-de-ref n)
|
(define (i386:push-byte-local-de-de-ref n)
|
||||||
(or n (error "invalid value: push-byte-local-de-de-ref: " n))
|
(or n (error "invalid value: push-byte-local-de-de-ref: " n))
|
||||||
(let ((n (- 0 (* 4 n))))
|
(let ((n (- 0 (* 4 n))))
|
||||||
|
@ -154,6 +162,12 @@
|
||||||
`(,(if (< (abs n) #x80) `("movzbl_0x8(%ebp),%eax" (#:immediate1 ,n))
|
`(,(if (< (abs n) #x80) `("movzbl_0x8(%ebp),%eax" (#:immediate1 ,n))
|
||||||
`("movzbl_0x32(%ebp),%eax" (#:immediate ,n))))))
|
`("movzbl_0x32(%ebp),%eax" (#:immediate ,n))))))
|
||||||
|
|
||||||
|
(define (i386:word-local->accu n)
|
||||||
|
(or n (error "invalid value: word-local->accu: " n))
|
||||||
|
(let ((n (- 0 (* 4 n))))
|
||||||
|
`(,(if (< (abs n) #x80) `("movzwl_0x8(%ebp),%eax" (#:immediate1 ,n))
|
||||||
|
`("movzwl_0x32(%ebp),%eax" (#:immediate ,n))))))
|
||||||
|
|
||||||
(define (i386:byte-local->base n)
|
(define (i386:byte-local->base n)
|
||||||
(or n (error "invalid value: byte-local->base: " n))
|
(or n (error "invalid value: byte-local->base: " n))
|
||||||
(let ((n (- 0 (* 4 n))))
|
(let ((n (- 0 (* 4 n))))
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
i386:accu->local+n
|
i386:accu->local+n
|
||||||
i386:byte-accu->local+n
|
i386:byte-accu->local+n
|
||||||
i386:word-accu->local+n
|
i386:word-accu->local+n
|
||||||
|
i386:accu->local+n
|
||||||
i386:accu-and-base
|
i386:accu-and-base
|
||||||
i386:accu-base
|
i386:accu-base
|
||||||
i386:accu-cmp-value
|
i386:accu-cmp-value
|
||||||
|
@ -78,6 +79,7 @@
|
||||||
i386:byte-base-mem->accu
|
i386:byte-base-mem->accu
|
||||||
i386:byte-base-sub
|
i386:byte-base-sub
|
||||||
i386:byte-local->accu
|
i386:byte-local->accu
|
||||||
|
i386:word-local->accu
|
||||||
i386:byte-local->base
|
i386:byte-local->base
|
||||||
i386:byte-mem->accu
|
i386:byte-mem->accu
|
||||||
i386:word-mem->accu
|
i386:word-mem->accu
|
||||||
|
@ -125,6 +127,7 @@
|
||||||
i386:push-base
|
i386:push-base
|
||||||
i386:push-byte-local-de-de-ref
|
i386:push-byte-local-de-de-ref
|
||||||
i386:push-byte-local-de-ref
|
i386:push-byte-local-de-ref
|
||||||
|
i386:push-word-local-de-ref
|
||||||
i386:push-label
|
i386:push-label
|
||||||
i386:push-label-mem
|
i386:push-label-mem
|
||||||
i386:push-local
|
i386:push-local
|
||||||
|
|
|
@ -150,7 +150,9 @@ DEFINE movzbl_0x8(%ebp),%eax 0fb645
|
||||||
DEFINE movzbl_0x8(%ebp),%edx 0fb655
|
DEFINE movzbl_0x8(%ebp),%edx 0fb655
|
||||||
DEFINE movzwl_(%eax),%eax 0fb700
|
DEFINE movzwl_(%eax),%eax 0fb700
|
||||||
DEFINE movzwl_0x32(%eax),%eax 0fb780
|
DEFINE movzwl_0x32(%eax),%eax 0fb780
|
||||||
|
DEFINE movzwl_0x32(%ebp),%eax 0fb785
|
||||||
DEFINE movzwl_0x8(%eax),%eax 0fb740
|
DEFINE movzwl_0x8(%eax),%eax 0fb740
|
||||||
|
DEFINE movzwl_0x8(%ebp),%eax 0fb745
|
||||||
DEFINE mul____%edx f7e2
|
DEFINE mul____%edx f7e2
|
||||||
DEFINE nop 90
|
DEFINE nop 90
|
||||||
DEFINE not____%eax f7d0
|
DEFINE not____%eax f7d0
|
||||||
|
|
Loading…
Reference in a new issue