Re: Challenge: CCL port to the RPi Pico (RP2040)

Carl Shapiro <[email protected]> Sun, 28 Jul 2024 12:53:03 -0700
Newsgroups gmane.lisp.openmcl.devel
Message-ID <CANVK_QhREmDkortJXZyApeAB0CAoGh4UZZN4F8HS1hMGaXp_dA@mail.gmail.com>
--000000000000da803a061e5419bc
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sun, Jul 28, 2024 at 11:10=E2=80=AFAM Ron Garret <[email protected]> wrote=
:

> Doesn't seem like it would be very hard.  They are the same ISA, just
> different encodings.
>
>
> https://stackoverflow.com/questions/28669905/what-is-the-difference-betwe=
en-the-arm-thumb-and-thumb-2-instruction-encodings
>

There is a lot of room for hair-splitting in terms of what constitutes an
encoding and what does not.  That is certainly more true if you are talking
about ARM being an alternate encoding for Thumb-2 and less true in the
other direction.  That aside, if you have an ARM backend that does not
excessively rely on the eccentricities of 32-bit ARM then, indeed,
targeting Thumb should not be very hard.

Anyway, to emit Thumb, this could just require a refactoring of the backend
to remove ARM-specific assumptions: instructions will encoding in 2-4 bytes
instead of always 4, the IT instruction is required for conditional
execution and not present on 32-bit ARM, and many instructions take 2
address instead of always having 3 addresses.  The smaller microcontrollers
also do not offer the full ISA.

Fortunately, since you can run Thumb code side-by-side with ARM code this
work can be done much less disruptively than targeting a new architecture.
It is real work but, again, not very hard.

--000000000000da803a061e5419bc
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail=
_attr">On Sun, Jul 28, 2024 at 11:10=E2=80=AFAM Ron Garret &lt;<a href=3D"m=
ailto:[email protected]" target=3D"_blank">[email protected]</a>&gt; wrote:<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b=
order-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div>Does=
n&#39;t seem like it would be very hard.=C2=A0 They are the same ISA, just =
different encodings.</div><div><br></div><div><a href=3D"https://stackoverf=
low.com/questions/28669905/what-is-the-difference-between-the-arm-thumb-and=
-thumb-2-instruction-encodings" target=3D"_blank">https://stackoverflow.com=
/questions/28669905/what-is-the-difference-between-the-arm-thumb-and-thumb-=
2-instruction-encodings</a></div></div></div></blockquote><div><br></div><d=
iv>There is a lot of room for hair-splitting in terms of what constitutes a=
n encoding and what does not.=C2=A0 That is certainly more true if you are =
talking about ARM being an alternate encoding for Thumb-2 and less true in =
the other direction.=C2=A0 That aside, if you have an ARM backend that does=
 not excessively rely on the eccentricities of 32-bit ARM then, indeed, tar=
geting Thumb should not be very hard.<br><br>Anyway, to emit Thumb, this co=
uld just require a refactoring of the backend to remove ARM-specific assump=
tions: instructions will encoding in 2-4 bytes instead of always 4, the IT =
instruction is required for conditional execution and not present on 32-bit=
 ARM, and many instructions take 2 address instead of always having 3 addre=
sses.=C2=A0 The smaller microcontrollers also do not offer the full ISA.<br=
></div><div><br></div><div>Fortunately, since you can run Thumb code side-b=
y-side with ARM code this work can be done much less disruptively than targ=
eting a new architecture.=C2=A0 It is real work but, again, not very hard.<=
/div></div></div>

--000000000000da803a061e5419bc--