public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Orlando Arias <orlandoarias@gmail.com>
To: newlib@sourceware.org
Subject: Re: Help porting newlib to a new CPU architecture (sorta)
Date: Wed, 7 Jul 2021 16:56:44 -0400	[thread overview]
Message-ID: <ad5a5585-94f4-b315-4ce2-a5f31b98cc36@gmail.com> (raw)
In-Reply-To: <CAK=1Datiu29UGqFv8t9HEC-U0YBJdBJR+Ztp+7Csquneo2vBvA@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2287 bytes --]

Greetings,

On 7/7/21 4:32 PM, ElijaxApps wrote:
> Hi all,
> 
> I started reading GCC Internals Book, chapter 16 & 17.
> 
> I am deciding how exactly define insn statements at this very right moment.
> I am using pdp11 as a template. However, there are lots of things I don't
> really need, in this config spec.
> 
> As far as I have understood, I can follow two paths:
> 
> a) Define instructions as my pseudo assy, and use my own "assembler".
> b) Define instructions as Linux ASM and use GAS, GNU Assembler.
> 

Please allow me to contribute to the discussion at hand rather than
derail it any further.

Nikolai Kim has a very nice series of videos in YouTube describing how
he added a back-end to gcc for his CPU [1]. Notice that the instructions
he is adding are actually pseudoassembly (as far as I can tell anyway).
From the perspective of gcc [technically cc1 and cc1plus], the code that
gets emitted by the back-end of the compiler does not matter. The
compiler's job stops there. It's the assembler's job to actually
generate object files. If you are in Linux (or any other platform that
allows for it), you can

strace -f -o trace_gcc_driver gcc -o test.elf my_code.c

and see how the driver program calls different portions of the toolchain
to actually build an executable. You will see calls to the fork() and
execve() family of functions calling things like the compiler proper,
assembler, and linker.

Anyway, Nikolai Kim also has videos on adding a backend to binutils,
which is also worth checking out if you are interested. I believe his
code is online somewhere. Keep in mind that his code works for the
versions of gcc [and binutils] that he is modifying. These projects are
moving targets and internals are bound to change across releases.

As for your question about ABIs, you can find a portion of the ABI for
avr in [2]. It is missing things like how to deal with unwind sections,
debug infos, and the likes. Since this is your own CPU, you define the
ABI as you wish it to be. The one for Arm is found in [3].

Cheers,
Orlando.

[1] https://www.youtube.com/playlist?list=PLqKduIIK_NvI_BPpsMKEQ7ZsURitDZShr

[2] https://gcc.gnu.org/wiki/avr-gcc

[3] https://developer.arm.com/documentation/ihi0036/latest/


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2021-07-07 20:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06  0:49 ElijaxApps
2021-07-06  4:35 ` Mike Frysinger
2021-07-06 13:05   ` Paul Koning
2021-07-07 20:32     ` ElijaxApps
2021-07-07 20:56       ` Orlando Arias [this message]
2021-07-06 14:02   ` Brian Inglis
2021-07-06 14:35     ` Orlando Arias
2021-07-06 18:08       ` Brian Inglis
2021-07-06 19:04         ` Orlando Arias
2021-07-06 20:01           ` Hans-Bernhard Bröker
2021-07-06 20:46             ` Orlando Arias
2021-07-07  5:45               ` Brian Inglis
2021-07-07 13:58                 ` Orlando Arias
2021-07-07 15:18                   ` Dave Nadler
2021-07-07 18:43               ` Hans-Bernhard Bröker
2021-07-07 20:23                 ` Orlando Arias
2021-07-06 21:08 ElijaxApps
2021-07-06 22:00 ` Joel Sherrill
2021-07-06 23:50   ` Paul Koning
2021-07-07  0:29     ` ElijaxApps
2021-07-07 15:09   ` Grant Edwards

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad5a5585-94f4-b315-4ce2-a5f31b98cc36@gmail.com \
    --to=orlandoarias@gmail.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).