1/* Definitions of target machine for GNU compiler, for ARM with a.out 2 Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 3 Contributed by Richard Earnshaw (rearnsha@armltd.co.uk). 4 5This file is part of GNU CC. 6 7GNU CC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GNU CC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GNU CC; see the file COPYING. If not, write to 19the Free Software Foundation, 59 Temple Place - Suite 330, 20Boston, MA 02111-1307, USA. */ 21 22#ifndef ARM_OS_NAME 23#define ARM_OS_NAME "(generic)" 24#endif 25 26/* The text to go at the start of the assembler file */ 27#ifndef ASM_FILE_START 28#define ASM_FILE_START(STREAM) \ 29{ \ 30 fprintf (STREAM,"%srfp\t.req\t%sr9\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 31 fprintf (STREAM,"%ssl\t.req\t%sr10\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 32 fprintf (STREAM,"%sfp\t.req\t%sr11\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 33 fprintf (STREAM,"%sip\t.req\t%sr12\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 34 fprintf (STREAM,"%ssp\t.req\t%sr13\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 35 fprintf (STREAM,"%slr\t.req\t%sr14\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 36 fprintf (STREAM,"%spc\t.req\t%sr15\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 37} 38#endif 39 40#define ASM_APP_ON "" 41#define ASM_APP_OFF "" 42 43/* Switch to the text or data segment. */ 44#define TEXT_SECTION_ASM_OP ".text" 45#define DATA_SECTION_ASM_OP ".data" 46#define BSS_SECTION_ASM_OP ".bss" 47 48/* Note: If USER_LABEL_PREFIX or LOCAL_LABEL_PREFIX are changed, 49 make sure that this change is reflected in the function 50 coff_arm_is_local_label_name() in bfd/coff-arm.c */ 51#ifndef REGISTER_PREFIX 52#define REGISTER_PREFIX "" 53#endif 54 55#ifndef USER_LABEL_PREFIX 56#define USER_LABEL_PREFIX "_" 57#endif 58 59#ifndef LOCAL_LABEL_PREFIX 60#define LOCAL_LABEL_PREFIX "" 61#endif 62 63 64/* The assembler's names for the registers. */ 65#ifndef REGISTER_NAMES 66#define REGISTER_NAMES \ 67{ \ 68 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ 69 "r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc", \ 70 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ 71 "cc", "sfp", "afp" \ 72} 73#endif 74 75#ifndef ADDITIONAL_REGISTER_NAMES 76#define ADDITIONAL_REGISTER_NAMES \ 77{ \ 78 {"a1", 0}, \ 79 {"a2", 1}, \ 80 {"a3", 2}, \ 81 {"a4", 3}, \ 82 {"v1", 4}, \ 83 {"v2", 5}, \ 84 {"v3", 6}, \ 85 {"v4", 7}, \ 86 {"v5", 8}, \ 87 {"v6", 9}, \ 88 {"rfp", 9}, /* Gcc used to call it this */ \ 89 {"sb", 9}, \ 90 {"v7", 10}, \ 91 {"r10", 10}, /* sl */ \ 92 {"r11", 11}, /* fp */ \ 93 {"r12", 12}, /* ip */ \ 94 {"r13", 13}, /* sp */ \ 95 {"r14", 14}, /* lr */ \ 96 {"r15", 15} /* pc */ \ 97} 98#endif 99 100/* Arm Assembler barfs on dollars */ 101#define DOLLARS_IN_IDENTIFIERS 0 102 103#define NO_DOLLAR_IN_LABEL 104 105/* DBX register number for a given compiler register number */ 106#define DBX_REGISTER_NUMBER(REGNO) (REGNO) 107 108/* Generate DBX debugging information. riscix.h will undefine this because 109 the native assembler does not support stabs. */ 110#ifndef DBX_DEBUGGING_INFO 111#define DBX_DEBUGGING_INFO 1 112#endif 113 114/* Acorn dbx moans about continuation chars, so don't use any. */ 115#ifndef DBX_CONTIN_LENGTH 116#define DBX_CONTIN_LENGTH 0 117#endif 118 119/* Output a source filename for the debugger. RISCiX dbx insists that the 120 ``desc'' field is set to compiler version number >= 315 (sic). */ 121#define DBX_OUTPUT_MAIN_SOURCE_FILENAME(STREAM,NAME) \ 122do { \ 123 fprintf (STREAM, ".stabs "); \ 124 output_quoted_string (STREAM, NAME); \ 125 fprintf (STREAM, ",%d,0,315,%s\n", N_SO, <ext_label_name[1]); \ 126 text_section (); \ 127 ASM_OUTPUT_INTERNAL_LABEL (STREAM, "Ltext", 0); \ 128} while (0) 129 130/* Output a function label definition. */ 131#ifndef ASM_DECLARE_FUNCTION_NAME 132#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \ 133{ \ 134 if (TARGET_POKE_FUNCTION_NAME) \ 135 arm_poke_function_name ((STREAM), (NAME)); \ 136 ASM_OUTPUT_LABEL (STREAM, NAME); \ 137} 138#endif 139 140#ifndef ASM_OUTPUT_LABEL 141#define ASM_OUTPUT_LABEL(STREAM,NAME) \ 142do { \ 143 assemble_name (STREAM,NAME); \ 144 fputs (":\n", STREAM); \ 145} while (0) 146#endif 147 148/* Output a globalising directive for a label. */ 149#ifndef ASM_GLOBALIZE_LABEL 150#define ASM_GLOBALIZE_LABEL(STREAM,NAME) \ 151 (fprintf (STREAM, "\t.global\t"), \ 152 assemble_name (STREAM, NAME), \ 153 fputc ('\n',STREAM)) 154#endif 155 156/* Make an internal label into a string. */ 157#ifndef ASM_GENERATE_INTERNAL_LABEL 158#define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \ 159 sprintf (STRING, "*%s%s%u", LOCAL_LABEL_PREFIX, PREFIX, (unsigned int)(NUM)) 160#endif 161 162/* Nothing special is done about jump tables */ 163/* #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) */ 164/* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */ 165 166/* Construct a private name. */ 167#define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \ 168 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \ 169 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER))) 170 171/* Output an element of a dispatch table. */ 172#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \ 173 fprintf (STREAM, "\t.word\t%sL%d\n", LOCAL_LABEL_PREFIX, VALUE) 174 175#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \ 176 fprintf (STREAM, "\tb\t%sL%d\n", LOCAL_LABEL_PREFIX, (VALUE)) 177 178/* Output various types of constants. For real numbers we output hex, with 179 a comment containing the "human" value, this allows us to pass NaN's which 180 the riscix assembler doesn't understand (it also makes cross-assembling 181 less likely to fail). */ 182 183#define ASM_OUTPUT_LONG_DOUBLE(STREAM,VALUE) \ 184do { char dstr[30]; \ 185 long l[3]; \ 186 REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \ 187 REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ 188 fprintf (STREAM, "\t.long 0x%lx,0x%lx,0x%lx\t%s long double %s\n", \ 189 l[0], l[1], l[2], ASM_COMMENT_START, dstr); \ 190 } while (0) 191 192 193#define ASM_OUTPUT_DOUBLE(STREAM, VALUE) \ 194do { char dstr[30]; \ 195 long l[2]; \ 196 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \ 197 REAL_VALUE_TO_DECIMAL (VALUE, "%.14g", dstr); \ 198 fprintf (STREAM, "\t.long 0x%lx, 0x%lx\t%s double %s\n", l[0], \ 199 l[1], ASM_COMMENT_START, dstr); \ 200 } while (0) 201 202#define ASM_OUTPUT_FLOAT(STREAM, VALUE) \ 203do { char dstr[30]; \ 204 long l; \ 205 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ 206 REAL_VALUE_TO_DECIMAL (VALUE, "%.7g", dstr); \ 207 fprintf (STREAM, "\t.word 0x%lx\t%s float %s\n", l, \ 208 ASM_COMMENT_START, dstr); \ 209 } while (0); 210 211#define ASM_OUTPUT_INT(STREAM, EXP) \ 212 { \ 213 fprintf (STREAM, "\t.word\t"); \ 214 OUTPUT_INT_ADDR_CONST (STREAM, (EXP)); \ 215 fputc ('\n', STREAM); \ 216 } 217 218#define ASM_OUTPUT_SHORT(STREAM, EXP) \ 219 (fprintf (STREAM, "\t.short\t"), \ 220 output_addr_const (STREAM, (EXP)), \ 221 fputc ('\n', STREAM)) 222 223#define ASM_OUTPUT_CHAR(STREAM, EXP) \ 224 (fprintf (STREAM, "\t.byte\t"), \ 225 output_addr_const (STREAM, (EXP)), \ 226 fputc ('\n', STREAM)) 227 228#define ASM_OUTPUT_BYTE(STREAM, VALUE) \ 229 fprintf (STREAM, "\t.byte\t%d\n", VALUE) 230 231#define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \ 232 output_ascii_pseudo_op ((STREAM), (unsigned char *)(PTR), (LEN)) 233 234/* Output a gap. In fact we fill it with nulls. */ 235#define ASM_OUTPUT_SKIP(STREAM, NBYTES) \ 236 fprintf (STREAM, "\t.space\t%d\n", NBYTES) 237 238/* Align output to a power of two. Horrible /bin/as. */ 239#ifndef ASM_OUTPUT_ALIGN 240#define ASM_OUTPUT_ALIGN(STREAM, POWER) \ 241 do \ 242 { \ 243 register int amount = 1 << (POWER); \ 244 \ 245 if (amount == 2) \ 246 fprintf (STREAM, "\t.even\n"); \ 247 else if (amount != 1) \ 248 fprintf (STREAM, "\t.align\t%d\n", amount - 4); \ 249 } \ 250 while (0) 251#endif 252 253/* Output a common block */ 254#ifndef ASM_OUTPUT_COMMON 255#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \ 256 (fprintf (STREAM, "\t.comm\t"), \ 257 assemble_name ((STREAM), (NAME)), \ 258 fprintf (STREAM, ", %d\t%s %d\n", ROUNDED, ASM_COMMENT_START, SIZE)) 259#endif 260 261/* Output a local common block. /bin/as can't do this, so hack a 262 `.space' into the bss segment. Note that this is *bad* practice, 263 which is guaranteed NOT to work since it doesn't define STATIC 264 COMMON space but merely STATIC BSS space. */ 265#ifndef ASM_OUTPUT_ALIGNED_LOCAL 266#define ASM_OUTPUT_ALIGNED_LOCAL(STREAM,NAME,SIZE,ALIGN) \ 267 do { \ 268 bss_section (); \ 269 ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT)); \ 270 ASM_OUTPUT_LABEL (STREAM, NAME); \ 271 fprintf (STREAM, "\t.space\t%d\n", SIZE); \ 272 } while (0) 273#endif 274 275/* Output a zero-initialized block. */ 276#ifndef ASM_OUTPUT_ALIGNED_BSS 277#define ASM_OUTPUT_ALIGNED_BSS(STREAM,DECL,NAME,SIZE,ALIGN) \ 278 asm_output_aligned_bss (STREAM, DECL, NAME, SIZE, ALIGN) 279#endif 280 281/* Output a source line for the debugger. */ 282/* #define ASM_OUTPUT_SOURCE_LINE(STREAM,LINE) */ 283 284/* Output a #ident directive. */ 285#ifndef ASM_OUTPUT_IDENT 286#define ASM_OUTPUT_IDENT(STREAM,STRING) \ 287 fprintf (STREAM, "%s - - - ident %s\n", ASM_COMMENT_START, STRING) 288#endif 289 290/* The assembler's parentheses characters. */ 291#define ASM_OPEN_PAREN "(" 292#define ASM_CLOSE_PAREN ")" 293 294#ifndef ASM_COMMENT_START 295#define ASM_COMMENT_START "@" 296#endif 297 298/* This works for GAS and some other assemblers. */ 299#define SET_ASM_OP ".set" 300 301#include "arm/arm.h" 302