[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] Add ARM backend.
From: |
Danny Milosavljevic |
Subject: |
Re: [PATCH v2] Add ARM backend. |
Date: |
Sat, 6 Jun 2020 21:26:03 +0200 |
On Sat, 6 Jun 2020 20:01:34 +0200
Danny Milosavljevic <dannym@scratchpost.org> wrote:
> +++ b/lib/arm-mes/arm.M1
> @@ -0,0 +1,401 @@
> +### GNU Mes --- Maxwell Equations of Software
> +### Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
> +### Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
2020
> +DEFINE R14 E
> +DEFINE PC F
Add R9, although that whole thing is unused.
> +DEFINE mov____$i8,%r1 10a0e3 # mov r1, #66
I should remove that useless comment.
> +# fp -> r0
> +DEFINE mov____%r11,%r0 0b00a0e1
Is that used?
> +DEFINE mov____%r0,0x32 04909fe5000089e5000000ea
r1 and r2 can't happen?
> +DEFINE mov____%r2,0x32 04909fe5002089e5000000ea
> +DEFINE add____$i32,(%r1)
> 05002de9000091e50c209fe5020080e0000081e50500bde8000000ea
r0 and r2 can't happen?
> +DEFINE mov____0x32(%ebp),%r1 08909fe50b9089e0001099e5000000ea
> +DEFINE mov____0x32(%ebp),%r0 08909fe50b9089e0000099e5000000ea
The lines the other way around for better review?
> +DEFINE add____$i32,%r1 04909fe5091091e0000000ea
> +DEFINE add____$i32,%r0 04909fe5090090e0000000ea
> +DEFINE add____$i32,%r2 04909fe5092092e0000000ea
Sort the lines for better review?
> + (display (string-append "\n\n<\n:" name "\n"))
Add comment that "<" aligns?
> +(define (armv4:call-label info label n)
> + `(((#:branch-offset3 ,label) bl)
> + ; FIXME: Can n be negative?
> + ((#:immediate1 ,(* n 4)) "add____$i8,%esp")))
@Janneke: Can n be negative? Probably not, but just to make sure.
> +(define (armv4:r0*r1 info)
> + ;; FIXME: Signedness.
> + (let ((r0 (get-r0 info))
> + (r1 (get-r1 info)))
> + `((,(string-append "mul____%" r0 ",%" r1)))))
Probably would need a helper procedure again in libmescc.a to do that nicely.
@Janneke: How come this doesn't have SIGNED? like the other ones below?
> +;; FIXME: lsr??! Signed or unsigned r0?
> +(define (armv4:r0>>r1 info)
> + (let ((r0 (get-r0 info))
> + (r1 (get-r1 info)))
> + `((,(string-append "lsr____%" r0 ",%" r0 ",%" r1)))))
Is r0 supposed to be signed or not?
I take it that r1 > 0, right?
> +;; FIXME: Signed or not?
> +(define (armv4:r0/r1 info signed?)
> + (let ((r0 (get-r0 info))
> + (r1 (get-r1 info)))
> + ;; __mesabi_uldiv(a, b, remainderp)
> + (cons* `(,(string-append "push___0"))
> + `(,(string-append "push___%" r1))
> + `(,(string-append "push___%" r0))
> + (armv4:call-label #f "__mesabi_uldiv" (* 4 3)))))
Probably better to call something like __aeabi_idiv if signed.
> +(define (armv4:r0%r1 info signed?)
> + (let ((r0 (get-r0 info))
> + (r1 (get-r1 info)))
> + ;; __mesabi_uldiv(a, b, remainderp)
> + (append `(("push___%r0") ; slot for remainder
> + ("mov____%esp,%r0")
> + ("push___%r0") ; pointer to remainder
> + (,(string-append "push___%" r1))
> + (,(string-append "push___%" r0)))
> + (armv4:call-label #f "__mesabi_uldiv" (* 4 3))
> + `(("pop____%r0")))))
Probably better to call something like __aeabi_uidivmod if signed.
> + ("double" . ,(make-type 'float 4 #f)) ; FIXME
> + ("long double" . ,(make-type 'float 4 #f)) ; FIXME
Weird...
Although the i386 backend does that too.
The x86_64 backend has sizes 8 and 8, respectively. That's weird, too.
I guess that's in order to pretend that value of these types fit into a
register?
gcc 10 on i686-linux has 8 and 12, respectively.
pgpNEma97dQN8.pgp
Description: OpenPGP digital signature