bug-mes
[Top][All Lists]
Advanced

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

Re: Operand sizes in mescc compiler


From: Jan Nieuwenhuizen
Subject: Re: Operand sizes in mescc compiler
Date: Fri, 16 Apr 2021 09:14:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

W. J. van der Laan writes:

> Hello,
>
> I am still working on porting to RISC-V 64 bit, and am now running into some 
> difficulties around handling operand sizes; there are quite a few 
> constructions like this
>
>       ((0) (wrap-as (as info 'mem->r))) ((1) (append (wrap-as (as info
>'byte-mem->r)) (convert-r0 info type))) ((2) (append (wrap-as (as info
>'word-mem->r)) (convert-r0 info type))) ((4) (append (wrap-as (as info
>'long-mem->r)) (convert-r0 info type)))
>
> a) What does reading or writing a size of 0 mean?

You'll notice that these cases are preceded by something like

--8<---------------cut here---------------start------------->8---
(size (if (= size reg-size) 0 size))
--8<---------------cut here---------------end--------------->8---

So 0 means register-size.  The other sizes are byte counts, for if you
need to move smaller units.

You'll notice that it's implemented by <cpu>/as.scm

--8<---------------cut here---------------start------------->8---
(define (i386:mem->r info)
  (let ((r (get-r info)))
    `((,(string-append "mov____(%" r "),%" r)))))
--8<---------------cut here---------------end--------------->8---

so this just means: default register size.

> b) Does this mean that "byte" is 8 bits, "word" is 16 bits, and "long" always 
> 32 bits, or are these the C types and depend on the architecture? For example 
> "long int" on RISC-V 64 bit is 64 bit. However from what I understand 
> info.scm already represents this mapping
>
>     ("void" . ,(make-type 'void 1 #f))
>     ("signed char" . ,(make-type 'signed 1 #f))
>     ("unsigned char" . ,(make-type 'unsigned 1 #f))
>     ("unsigned short" . ,(make-type 'unsigned 2 #f))
>     ("unsigned" . ,(make-type 'unsigned 4 #f))
>     ("unsigned int" . ,(make-type 'unsigned 4 #f))
>     ("unsigned long" . ,(make-type 'unsigned 8 #f))
>     ("unsigned long long" . ,(make-type 'unsigned 8 #f))
>     ("unsigned long long int" . ,(make-type 'unsigned 8 #f))
>
> If it is fixed, where are the cases for 64 bit? Shouldn't we have an (8) too? 
> Or is this what (0) is?

Yes, that's it.  The sizes are byte-sizes, and translation from C-types
is done here.

Janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com



reply via email to

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