1 Target Definitions for R8C/M16C/M32C 2 Copyright (C) 2005-2022 Free Software Foundation, Inc. 3 Contributed by Red Hat. 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published 9 by the Free Software Foundation; either version 3, or (at your 10 option) any later version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. 20 21 22These are just some random notes I used during development of this 23port. Please don't consider these to be "official" specifications, 24just additional information to help make the code easier to 25understand. 26 27 28Frame 29===== 30 31 +-------------------- 32 | incoming args 33 +-------------------- 34 | return Address 35osp -> +-------------------- 36 | saved fp 37fp -> +-------------------- 38 | local data 39 +-------------------- 40 | saved regs 41 +-------------------- 42 | outgoing args (opt) 43sp -> +-------------------- 44 45Argument Passing 46================ 47 48r8c, m16c 49--------- 50 51First arg may be passed in r1l or r1 if it (1) fits (QImode or 52HImode), (2) is named, and (3) is an integer or pointer type (no 53structs, floats, etc). Otherwise, it's passed on the stack. 54 55Second arg may be passed in r2, same restrictions (but not QImode), 56even if the first arg is passed on the stack. 57 58Third and further args are passed on the stack. No padding is used, 59stack "alignment" is 8 bits. 60 61m32cm, m32c 62----------- 63First arg may be passed in r0l or r0, same restrictions as above. 64 65Second and further args are passed on the stack. Padding is used 66after QImode parameters (i.e. lower-addressed byte is the value, 67higher-addressed byte is the padding), stack "alignment" is 16 bits. 68 69 70Return Value 71============ 72 73r8c, m16c 74--------- 75 76QImode in r0l 77HImode in r0 78near pointer in r0 79(desired) 80SImode in r2r0 81far pointer in r2r0 82(actual) 83Anything bigger than 16 bits is returned in memory, at mem0 (mem0 84through mem15 are provided by libgcc.a) 85 86Aggregate values (regardless of size) are returned by pushing a 87pointer to a temporary area on the stack after the args are pushed. 88The function fills in this area with the value. Note that this 89pointer on the stack does not affect how register arguments, if any, 90are configured. 91 92m32cm, m32c 93----------- 94Same. 95 96 97Registers Preserved Across Calls 98================================ 99 100r8c, m16c 101--------- 102sb, fb, sp (i.e. nearly all registers are call clobbered) 103 104m32cm, m32c 105----------- 106r1, r2, r3, a0, a1, sb, fb, sp 107(except when used for return values) 108 109 110Interrupt Handlers 111================== 112 113The stack frame is slightly different for interrupt handlers, because 114(1) we don't have a usable parent frame, and (2) we have to use 115special instructions to return and thus must save/restore everything 116differently. 117 118 +-------------------- 119 | program state 120osp -> +-------------------- 121 | return address 122 +-------------------- 123 | saved r0..fp (pushm) 124fp -> +-------------------- 125 | local data 126 +-------------------- 127 | saved regs mem0..mem15 128 +-------------------- 129 | outgoing args (opt) 130sp -> +-------------------- 131 132