| 1 |
/* PowerPC asm definitions for GNU C. |
| 2 |
|
| 3 |
Copyright (C) 2002-2025 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 3, or (at your option) any later |
| 10 |
version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
for more details. |
| 16 |
|
| 17 |
Under Section 7 of GPL version 3, you are granted additional |
| 18 |
permissions described in the GCC Runtime Library Exception, version |
| 19 |
3.1, as published by the Free Software Foundation. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License and |
| 22 |
a copy of the GCC Runtime Library Exception along with this program; |
| 23 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 24 |
<http://www.gnu.org/licenses/>. */ |
| 25 |
|
| 26 |
/* Under winnt, 1) gas supports the following as names and 2) in particular |
| 27 |
defining "toc" breaks the FUNC_START macro as ".toc" becomes ".2" */ |
| 28 |
|
| 29 |
#define r0 0 |
| 30 |
#define sp 1 |
| 31 |
#define toc 2 |
| 32 |
#define r3 3 |
| 33 |
#define r4 4 |
| 34 |
#define r5 5 |
| 35 |
#define r6 6 |
| 36 |
#define r7 7 |
| 37 |
#define r8 8 |
| 38 |
#define r9 9 |
| 39 |
#define r10 10 |
| 40 |
#define r11 11 |
| 41 |
#define r12 12 |
| 42 |
#define r13 13 |
| 43 |
#define r14 14 |
| 44 |
#define r15 15 |
| 45 |
#define r16 16 |
| 46 |
#define r17 17 |
| 47 |
#define r18 18 |
| 48 |
#define r19 19 |
| 49 |
#define r20 20 |
| 50 |
#define r21 21 |
| 51 |
#define r22 22 |
| 52 |
#define r23 23 |
| 53 |
#define r24 24 |
| 54 |
#define r25 25 |
| 55 |
#define r26 26 |
| 56 |
#define r27 27 |
| 57 |
#define r28 28 |
| 58 |
#define r29 29 |
| 59 |
#define r30 30 |
| 60 |
#define r31 31 |
| 61 |
|
| 62 |
#define cr0 0 |
| 63 |
#define cr1 1 |
| 64 |
#define cr2 2 |
| 65 |
#define cr3 3 |
| 66 |
#define cr4 4 |
| 67 |
#define cr5 5 |
| 68 |
#define cr6 6 |
| 69 |
#define cr7 7 |
| 70 |
|
| 71 |
#define f0 0 |
| 72 |
#define f1 1 |
| 73 |
#define f2 2 |
| 74 |
#define f3 3 |
| 75 |
#define f4 4 |
| 76 |
#define f5 5 |
| 77 |
#define f6 6 |
| 78 |
#define f7 7 |
| 79 |
#define f8 8 |
| 80 |
#define f9 9 |
| 81 |
#define f10 10 |
| 82 |
#define f11 11 |
| 83 |
#define f12 12 |
| 84 |
#define f13 13 |
| 85 |
#define f14 14 |
| 86 |
#define f15 15 |
| 87 |
#define f16 16 |
| 88 |
#define f17 17 |
| 89 |
#define f18 18 |
| 90 |
#define f19 19 |
| 91 |
#define f20 20 |
| 92 |
#define f21 21 |
| 93 |
#define f22 22 |
| 94 |
#define f23 23 |
| 95 |
#define f24 24 |
| 96 |
#define f25 25 |
| 97 |
#define f26 26 |
| 98 |
#define f27 27 |
| 99 |
#define f28 28 |
| 100 |
#define f29 29 |
| 101 |
#define f30 30 |
| 102 |
#define f31 31 |
| 103 |
|
| 104 |
#ifdef __VSX__ |
| 105 |
#define f32 32 |
| 106 |
#define f33 33 |
| 107 |
#define f34 34 |
| 108 |
#define f35 35 |
| 109 |
#define f36 36 |
| 110 |
#define f37 37 |
| 111 |
#define f38 38 |
| 112 |
#define f39 39 |
| 113 |
#define f40 40 |
| 114 |
#define f41 41 |
| 115 |
#define f42 42 |
| 116 |
#define f43 43 |
| 117 |
#define f44 44 |
| 118 |
#define f45 45 |
| 119 |
#define f46 46 |
| 120 |
#define f47 47 |
| 121 |
#define f48 48 |
| 122 |
#define f49 49 |
| 123 |
#define f50 50 |
| 124 |
#define f51 51 |
| 125 |
#define f52 52 |
| 126 |
#define f53 53 |
| 127 |
#define f54 54 |
| 128 |
#define f55 55 |
| 129 |
#define f56 56 |
| 130 |
#define f57 57 |
| 131 |
#define f58 58 |
| 132 |
#define f59 59 |
| 133 |
#define f60 60 |
| 134 |
#define f61 61 |
| 135 |
#define f62 62 |
| 136 |
#define f63 63 |
| 137 |
#endif |
| 138 |
|
| 139 |
#ifdef __ALTIVEC__ |
| 140 |
#define v0 0 |
| 141 |
#define v1 1 |
| 142 |
#define v2 2 |
| 143 |
#define v3 3 |
| 144 |
#define v4 4 |
| 145 |
#define v5 5 |
| 146 |
#define v6 6 |
| 147 |
#define v7 7 |
| 148 |
#define v8 8 |
| 149 |
#define v9 9 |
| 150 |
#define v10 10 |
| 151 |
#define v11 11 |
| 152 |
#define v12 12 |
| 153 |
#define v13 13 |
| 154 |
#define v14 14 |
| 155 |
#define v15 15 |
| 156 |
#define v16 16 |
| 157 |
#define v17 17 |
| 158 |
#define v18 18 |
| 159 |
#define v19 19 |
| 160 |
#define v20 20 |
| 161 |
#define v21 21 |
| 162 |
#define v22 22 |
| 163 |
#define v23 23 |
| 164 |
#define v24 24 |
| 165 |
#define v25 25 |
| 166 |
#define v26 26 |
| 167 |
#define v27 27 |
| 168 |
#define v28 28 |
| 169 |
#define v29 29 |
| 170 |
#define v30 30 |
| 171 |
#define v31 31 |
| 172 |
#endif |
| 173 |
|
| 174 |
#ifdef __VSX__ |
| 175 |
#define vs0 0 |
| 176 |
#define vs1 1 |
| 177 |
#define vs2 2 |
| 178 |
#define vs3 3 |
| 179 |
#define vs4 4 |
| 180 |
#define vs5 5 |
| 181 |
#define vs6 6 |
| 182 |
#define vs7 7 |
| 183 |
#define vs8 8 |
| 184 |
#define vs9 9 |
| 185 |
#define vs10 10 |
| 186 |
#define vs11 11 |
| 187 |
#define vs12 12 |
| 188 |
#define vs13 13 |
| 189 |
#define vs14 14 |
| 190 |
#define vs15 15 |
| 191 |
#define vs16 16 |
| 192 |
#define vs17 17 |
| 193 |
#define vs18 18 |
| 194 |
#define vs19 19 |
| 195 |
#define vs20 20 |
| 196 |
#define vs21 21 |
| 197 |
#define vs22 22 |
| 198 |
#define vs23 23 |
| 199 |
#define vs24 24 |
| 200 |
#define vs25 25 |
| 201 |
#define vs26 26 |
| 202 |
#define vs27 27 |
| 203 |
#define vs28 28 |
| 204 |
#define vs29 29 |
| 205 |
#define vs30 30 |
| 206 |
#define vs31 31 |
| 207 |
#define vs32 32 |
| 208 |
#define vs33 33 |
| 209 |
#define vs34 34 |
| 210 |
#define vs35 35 |
| 211 |
#define vs36 36 |
| 212 |
#define vs37 37 |
| 213 |
#define vs38 38 |
| 214 |
#define vs39 39 |
| 215 |
#define vs40 40 |
| 216 |
#define vs41 41 |
| 217 |
#define vs42 42 |
| 218 |
#define vs43 43 |
| 219 |
#define vs44 44 |
| 220 |
#define vs45 45 |
| 221 |
#define vs46 46 |
| 222 |
#define vs47 47 |
| 223 |
#define vs48 48 |
| 224 |
#define vs49 49 |
| 225 |
#define vs50 50 |
| 226 |
#define vs51 51 |
| 227 |
#define vs52 52 |
| 228 |
#define vs53 53 |
| 229 |
#define vs54 54 |
| 230 |
#define vs55 55 |
| 231 |
#define vs56 56 |
| 232 |
#define vs57 57 |
| 233 |
#define vs58 58 |
| 234 |
#define vs59 59 |
| 235 |
#define vs60 60 |
| 236 |
#define vs61 61 |
| 237 |
#define vs62 62 |
| 238 |
#define vs63 63 |
| 239 |
#endif |
| 240 |
|
| 241 |
/* |
| 242 |
* Macros to glue together two tokens. |
| 243 |
*/ |
| 244 |
|
| 245 |
#ifdef __STDC__ |
| 246 |
#define XGLUE(a,b) a##b |
| 247 |
#else |
| 248 |
#define XGLUE(a,b) a/**/b |
| 249 |
#endif |
| 250 |
|
| 251 |
#define GLUE(a,b) XGLUE(a,b) |
| 252 |
|
| 253 |
/* |
| 254 |
* Macros to begin and end a function written in assembler. If -mcall-aixdesc |
| 255 |
* or -mcall-nt, create a function descriptor with the given name, and create |
| 256 |
* the real function with one or two leading periods respectively. |
| 257 |
*/ |
| 258 |
|
| 259 |
#if defined(__powerpc64__) && _CALL_ELF == 2 |
| 260 |
|
| 261 |
/* Defining "toc" above breaks @toc in assembler code. */ |
| 262 |
#undef toc |
| 263 |
|
| 264 |
#define FUNC_NAME(name) GLUE(__USER_LABEL_PREFIX__,name) |
| 265 |
#ifdef __PCREL__ |
| 266 |
#define JUMP_TARGET(name) GLUE(FUNC_NAME(name),@notoc) |
| 267 |
#define FUNC_START(name) \ |
| 268 |
.type FUNC_NAME(name),@function; \ |
| 269 |
.globl FUNC_NAME(name); \ |
| 270 |
FUNC_NAME(name): \ |
| 271 |
.localentry FUNC_NAME(name),1 |
| 272 |
#else |
| 273 |
#define JUMP_TARGET(name) FUNC_NAME(name) |
| 274 |
#define FUNC_START(name) \ |
| 275 |
.type FUNC_NAME(name),@function; \ |
| 276 |
.globl FUNC_NAME(name); \ |
| 277 |
FUNC_NAME(name): \ |
| 278 |
0: addis 2,12,(.TOC.-0b)@ha; \ |
| 279 |
addi 2,2,(.TOC.-0b)@l; \ |
| 280 |
.localentry FUNC_NAME(name),.-FUNC_NAME(name) |
| 281 |
#endif /* !__PCREL__ */ |
| 282 |
|
| 283 |
#define HIDDEN_FUNC(name) \ |
| 284 |
FUNC_START(name) \ |
| 285 |
.hidden FUNC_NAME(name); |
| 286 |
|
| 287 |
#define FUNC_END(name) \ |
| 288 |
.size FUNC_NAME(name),.-FUNC_NAME(name) |
| 289 |
|
| 290 |
#elif defined (__powerpc64__) |
| 291 |
|
| 292 |
#define FUNC_NAME(name) GLUE(.,name) |
| 293 |
#define JUMP_TARGET(name) FUNC_NAME(name) |
| 294 |
#define FUNC_START(name) \ |
| 295 |
.section ".opd","aw"; \ |
| 296 |
name: \ |
| 297 |
.quad GLUE(.,name); \ |
| 298 |
.quad .TOC.@tocbase; \ |
| 299 |
.quad 0; \ |
| 300 |
.previous; \ |
| 301 |
.type GLUE(.,name),@function; \ |
| 302 |
.globl name; \ |
| 303 |
.globl GLUE(.,name); \ |
| 304 |
GLUE(.,name): |
| 305 |
|
| 306 |
#define HIDDEN_FUNC(name) \ |
| 307 |
FUNC_START(name) \ |
| 308 |
.hidden name; \ |
| 309 |
.hidden GLUE(.,name); |
| 310 |
|
| 311 |
#define FUNC_END(name) \ |
| 312 |
GLUE(.L,name): \ |
| 313 |
.size GLUE(.,name),GLUE(.L,name)-GLUE(.,name) |
| 314 |
|
| 315 |
#elif defined(_CALL_AIXDESC) |
| 316 |
|
| 317 |
#ifdef _RELOCATABLE |
| 318 |
#define DESC_SECTION ".got2" |
| 319 |
#else |
| 320 |
#define DESC_SECTION ".got1" |
| 321 |
#endif |
| 322 |
|
| 323 |
#define FUNC_NAME(name) GLUE(.,name) |
| 324 |
#define JUMP_TARGET(name) FUNC_NAME(name) |
| 325 |
#define FUNC_START(name) \ |
| 326 |
.section DESC_SECTION,"aw"; \ |
| 327 |
name: \ |
| 328 |
.long GLUE(.,name); \ |
| 329 |
.long _GLOBAL_OFFSET_TABLE_; \ |
| 330 |
.long 0; \ |
| 331 |
.previous; \ |
| 332 |
.type GLUE(.,name),@function; \ |
| 333 |
.globl name; \ |
| 334 |
.globl GLUE(.,name); \ |
| 335 |
GLUE(.,name): |
| 336 |
|
| 337 |
#define HIDDEN_FUNC(name) \ |
| 338 |
FUNC_START(name) \ |
| 339 |
.hidden name; \ |
| 340 |
.hidden GLUE(.,name); |
| 341 |
|
| 342 |
#define FUNC_END(name) \ |
| 343 |
GLUE(.L,name): \ |
| 344 |
.size GLUE(.,name),GLUE(.L,name)-GLUE(.,name) |
| 345 |
|
| 346 |
#else |
| 347 |
|
| 348 |
#define FUNC_NAME(name) GLUE(__USER_LABEL_PREFIX__,name) |
| 349 |
#if defined __PIC__ || defined __pic__ |
| 350 |
#define JUMP_TARGET(name) FUNC_NAME(name@plt) |
| 351 |
#else |
| 352 |
#define JUMP_TARGET(name) FUNC_NAME(name) |
| 353 |
#endif |
| 354 |
#define FUNC_START(name) \ |
| 355 |
.type FUNC_NAME(name),@function; \ |
| 356 |
.globl FUNC_NAME(name); \ |
| 357 |
FUNC_NAME(name): |
| 358 |
|
| 359 |
#define HIDDEN_FUNC(name) \ |
| 360 |
FUNC_START(name) \ |
| 361 |
.hidden FUNC_NAME(name); |
| 362 |
|
| 363 |
#define FUNC_END(name) \ |
| 364 |
GLUE(.L,name): \ |
| 365 |
.size FUNC_NAME(name),GLUE(.L,name)-FUNC_NAME(name) |
| 366 |
#endif |
| 367 |
|
| 368 |
#ifdef IN_GCC |
| 369 |
/* For HAVE_GAS_CFI_DIRECTIVE. */ |
| 370 |
#include "auto-host.h" |
| 371 |
|
| 372 |
#ifdef HAVE_GAS_CFI_DIRECTIVE |
| 373 |
# define CFI_STARTPROC .cfi_startproc |
| 374 |
# define CFI_ENDPROC .cfi_endproc |
| 375 |
# define CFI_OFFSET(reg, off) .cfi_offset reg, off |
| 376 |
# define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg |
| 377 |
# define CFI_RESTORE(reg) .cfi_restore reg |
| 378 |
#else |
| 379 |
# define CFI_STARTPROC |
| 380 |
# define CFI_ENDPROC |
| 381 |
# define CFI_OFFSET(reg, off) |
| 382 |
# define CFI_DEF_CFA_REGISTER(reg) |
| 383 |
# define CFI_RESTORE(reg) |
| 384 |
#endif |
| 385 |
#endif |
| 386 |
|
| 387 |
#if defined __linux__ && !defined __powerpc64__ |
| 388 |
.section .note.GNU-stack |
| 389 |
.previous |
| 390 |
#endif |