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