From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id 83D323855014 for ; Wed, 7 Jul 2021 20:55:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83D323855014 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-x72f.google.com with SMTP id j184so3432592qkd.6 for ; Wed, 07 Jul 2021 13:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:references:cc:from:subject:message-id:date:user-agent :mime-version:in-reply-to; bh=QIZ9KC0CAUKjQK2JPE/KfkwiSuoFx1mK0WpgNEoq/AA=; b=uhFn/tEgCzPWgHbqVZAuIvAFC8TJYdH8Zx2tipL/cdtfJwTasqWPJlExKPPP0BOf0W QvTuPJWtoyJn0VGPbtX9u68Z76+McYj3BTItt74ANE5TW8ehjiq0lmpT45VFKGGoYwgO tIZrXP8qXSiYU89osz6fyM8NwLgHMLXyeet/ubmDPDqCZmJF84TfdfeiWCSIBVDPagdO wf4tLcBnpZC8F2jXm85Q8Ef+TKF6YGGMcb18LuJlW0AvD30gWen9vpmKdiJW/ktIwoKg lBAnFgaMBurv46DNz/utAb0BM6l6/NCu8AHCdks76XXmTgtyRFbtpxxiOaQVXtd0WVJt 5dsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:references:cc:from:subject:message-id:date :user-agent:mime-version:in-reply-to; bh=QIZ9KC0CAUKjQK2JPE/KfkwiSuoFx1mK0WpgNEoq/AA=; b=nYFIM4r0Uj6MSwx0r4v7vAzYzWVgwJ1Y+JinDyiiz2ao4J5PTmOJlLI5nZwY3yoghK f5TwYcipAX9iEC8eoPxwhDfM0b+zXVJ4LKrI/wEBG6pCM5MLvdAUDPEAO5va9PPa6sV0 RIkk9PE18DfpnYc5UlzvHb920vDT5sV0PZuAD1qmJUl1eCyXkOf/CjH19YhCKxT15RBs EBgZZvc3c1UK7Ta8DCj+MJ+G5A9bt1sazKITXlgyAl7ZwU06Pu8RFJjkdwhXmbB5K/PS jqKwaQcNg9H8lphd9UhsCMMAwGVr0sbMoO5WQhGSRGqQXb8xX98hbgcBT3lZ7+vU3C7g iXFA== X-Gm-Message-State: AOAM533kRdb5o5qi09EFUbT5DSrSfhWSqbZyjgu5d3nmF+M60fbn3H3k bVECvpDMVVayH0Ege2c/DuY= X-Google-Smtp-Source: ABdhPJzFqCVHPxQIcz7vI5PqJQxF2kfQr6Y170NZeN8QgbRgzBFBCBZ1yVoj6Ov1jckLzdTuACyy+A== X-Received: by 2002:a05:620a:1032:: with SMTP id a18mr5807018qkk.462.1625691319185; Wed, 07 Jul 2021 13:55:19 -0700 (PDT) Received: from [0.0.0.0] (097-102-108-016.res.spectrum.com. [97.102.108.16]) by smtp.googlemail.com with ESMTPSA id 80sm39435qkn.128.2021.07.07.13.55.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jul 2021 13:55:18 -0700 (PDT) To: newlib@sourceware.org References: From: Orlando Arias Subject: Re: Help porting newlib to a new CPU architecture (sorta) Message-ID: Date: Wed, 7 Jul 2021 16:56:44 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RGr76Etus62dVesrwXMXQ7Wck168iw3YY" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2021 20:55:20 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --RGr76Etus62dVesrwXMXQ7Wck168iw3YY Content-Type: multipart/mixed; boundary="9um4OZXY9q1H2cjHjLF7Pl9pJdABfPzpr"; protected-headers="v1" From: Orlando Arias To: newlib@sourceware.org Cc: ElijaxApps Message-ID: Subject: Re: Help porting newlib to a new CPU architecture (sorta) References: In-Reply-To: --9um4OZXY9q1H2cjHjLF7Pl9pJdABfPzpr Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Greetings, On 7/7/21 4:32 PM, ElijaxApps wrote: > Hi all, >=20 > I started reading GCC Internals Book, chapter 16 & 17. >=20 > I am deciding how exactly define insn statements at this very right mom= ent. > I am using pdp11 as a template. However, there are lots of things I don= 't > really need, in this config spec. >=20 > As far as I have understood, I can follow two paths: >=20 > a) Define instructions as my pseudo assy, and use my own "assembler". > b) Define instructions as Linux ASM and use GAS, GNU Assembler. >=20 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). =46rom the perspective of gcc [technically cc1 and cc1plus], the code tha= t 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=3DPLqKduIIK_NvI_BPpsMKEQ7ZsURit= DZShr [2] https://gcc.gnu.org/wiki/avr-gcc [3] https://developer.arm.com/documentation/ihi0036/latest/ --9um4OZXY9q1H2cjHjLF7Pl9pJdABfPzpr-- --RGr76Etus62dVesrwXMXQ7Wck168iw3YY Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- iF0EAREKAB0WIQQNWDJzd34+k5noE3NTFb9QFn4uoQUCYOYVDAAKCRBTFb9QFn4u oZ8RAKCToDDV3/uGabqLXs+dPd83y1RM/ACePb1O80+qZjwnO2FUl3G9MlumU/k= =+tiy -----END PGP SIGNATURE----- --RGr76Etus62dVesrwXMXQ7Wck168iw3YY--