bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mes] mescc and Load/Store architectures


From: Danny Milosavljevic
Subject: Re: [bug-mes] mescc and Load/Store architectures
Date: Thu, 7 Feb 2019 18:40:24 +0100

Hi Janneke,

On Thu, 07 Feb 2019 15:48:32 +0100
Jan Nieuwenhuizen <address@hidden> wrote:
> It seems that an abstraction is missing or is just in the wrong place,
> I don't see it very clearly just yet, so I'm open for any suggestions.

Usually, compilers use registers aggressively to avoid stack accesses.

That's why I was not confident to just designate a random register a scratch
register statically and always use that one.  That would be an easy solution
but it only works if we ensure that compiler.scm doesn't scribble all over it
and expects us to conserve it--and I just don't know enough about compile.scm
in mescc to be able to choose one.

> What if we appoint
> one scratch register 's' and do something like
> 
> --8<---------------cut here---------------start------------->8---
> (define (armv4:label->arg info label i)
>   `(("ldr____$i32,%s" (#:address ,label))
>     ("push___%s)))
> --8<---------------cut here---------------end--------------->8---
> 
> Would that be good enough for (2), 

Yes, although it would be slower than if the compiler remembered which values
are in which registers and thus avoids the second ldr if possible (if the
value is already supposed to be loaded in there).

>or does the compiler need to know
> about scratch register `s' and save it in certain cases?

I guess for a bootstrapping compiler that's not necessary, so let's just
use a fixed scratch register and not save, restore or track its value in
any way.

This

>            `(,(string-append "ldr___(%" "r),%s")
>              ,(string-append "add____$i32,(%" r ")") (#:immediate ,v)
>              ,(string-append "str___%s,(" r ")"))))))

... probably meant this:

>            `(,(string-append "ldr___(%" "r),%s")
>              ,(string-append "add____$i32,%s") (#:immediate ,v)
>              ,(string-append "str___%s,(" r ")"))))))

> Even if this works it could still be a better idea to pull it further
> into the compiler (compile.scm) where these are used...I'm not sure.
> WDYT?

It depends on how much we want to optimize for runtime speed (with all
the usual traps caching causes - cache invalidation, stale cache etc).

Optimizing compilers usually use registers as a kind of "fast cache" and
remember which original thing they put in which register and then later
on avoid a second load and just use that register again.

The speed difference between register and memory is about a factor 1000
(memory takes 1000 times as long as register), except if the the memory
cell is in a cache (then it's supposedly 1:1).

Attachment: pgpCiXz6lwVd5.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]