arm.h 86.5 KB
Newer Older
nickc's avatar
nickc committed
1
/* Definitions of target machine for GNU compiler, for ARM.
2
   Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3
   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4
   Free Software Foundation, Inc.
rms's avatar
rms committed
5
   Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
kenner's avatar
kenner committed
6
   and Martin Simmons (@harleqn.co.uk).
7
   More major hacks by Richard Earnshaw (rearnsha@arm.com)
nickc's avatar
nickc committed
8 9
   Minor hacks by Nick Clifton (nickc@cygnus.com)

10
   This file is part of GCC.
rms's avatar
rms committed
11

12 13
   GCC is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published
14
   by the Free Software Foundation; either version 3, or (at your
15
   option) any later version.
rms's avatar
rms committed
16

17 18 19 20
   GCC is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   License for more details.
rms's avatar
rms committed
21

22
   You should have received a copy of the GNU General Public License
23 24
   along with GCC; see the file COPYING3.  If not see
   <http://www.gnu.org/licenses/>.  */
rms's avatar
rms committed
25

rth's avatar
rth committed
26 27
#ifndef GCC_ARM_H
#define GCC_ARM_H
28

29 30 31 32 33 34 35 36 37 38
/* We can't use enum machine_mode inside a generator file because it
   hasn't been created yet; we shouldn't be using any code that
   needs the real definition though, so this ought to be safe.  */
#ifdef GENERATOR_FILE
#define MACHMODE int
#else
#include "insn-modes.h"
#define MACHMODE enum machine_mode
#endif

rsandifo's avatar
gcc/  
rsandifo committed
39 40
#include "config/vxworks-dummy.h"

41
/* The architecture define.  */
42 43
extern char arm_arch_name[];

neil's avatar
config:  
neil committed
44 45 46 47
/* Target CPU builtins.  */
#define TARGET_CPU_CPP_BUILTINS()			\
  do							\
    {							\
pbrook's avatar
pbrook committed
48 49 50
	/* Define __arm__ even when in thumb mode, for	\
	   consistency with armcc.  */			\
	builtin_define ("__arm__");			\
rearnsha's avatar
rearnsha committed
51
	builtin_define ("__APCS_32__");			\
pbrook's avatar
pbrook committed
52
	if (TARGET_THUMB)				\
neil's avatar
config:  
neil committed
53
	  builtin_define ("__thumb__");			\
54 55
	if (TARGET_THUMB2)				\
	  builtin_define ("__thumb2__");		\
neil's avatar
config:  
neil committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
							\
	if (TARGET_BIG_END)				\
	  {						\
	    builtin_define ("__ARMEB__");		\
	    if (TARGET_THUMB)				\
	      builtin_define ("__THUMBEB__");		\
	    if (TARGET_LITTLE_WORDS)			\
	      builtin_define ("__ARMWEL__");		\
	  }						\
        else						\
	  {						\
	    builtin_define ("__ARMEL__");		\
	    if (TARGET_THUMB)				\
	      builtin_define ("__THUMBEL__");		\
	  }						\
							\
	if (TARGET_SOFT_FLOAT)				\
	  builtin_define ("__SOFTFP__");		\
							\
pbrook's avatar
pbrook committed
75
	if (TARGET_VFP)					\
76 77
	  builtin_define ("__VFP_FP__");		\
							\
jules's avatar
gcc/  
jules committed
78 79 80
	if (TARGET_NEON)				\
	  builtin_define ("__ARM_NEON__");		\
							\
neil's avatar
config:  
neil committed
81 82
	/* Add a define for interworking.		\
	   Needed when building libgcc.a.  */		\
83
	if (arm_cpp_interwork)				\
neil's avatar
config:  
neil committed
84 85 86 87
	  builtin_define ("__THUMB_INTERWORK__");	\
							\
	builtin_assert ("cpu=arm");			\
	builtin_assert ("machine=arm");			\
88 89 90 91 92 93 94 95
							\
	builtin_define (arm_arch_name);			\
	if (arm_arch_cirrus)				\
	  builtin_define ("__MAVERICK__");		\
	if (arm_arch_xscale)				\
	  builtin_define ("__XSCALE__");		\
	if (arm_arch_iwmmxt)				\
	  builtin_define ("__IWMMXT__");		\
96
	if (TARGET_AAPCS_BASED)				\
97 98 99 100 101 102 103
	  {						\
	    if (arm_pcs_default == ARM_PCS_AAPCS_VFP)	\
	      builtin_define ("__ARM_PCS_VFP");		\
	    else if (arm_pcs_default == ARM_PCS_AAPCS)	\
	      builtin_define ("__ARM_PCS");		\
	    builtin_define ("__ARM_EABI__");		\
	  }						\
neil's avatar
config:  
neil committed
104 105
    } while (0)

pbrook's avatar
pbrook committed
106 107 108
/* The various ARM cores.  */
enum processor_type
{
109 110
#define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \
  IDENT,
pbrook's avatar
pbrook committed
111 112 113 114 115 116
#include "arm-cores.def"
#undef ARM_CORE
  /* Used to indicate that no processor has been specified.  */
  arm_none
};

117 118
enum target_cpus
{
119 120
#define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \
  TARGET_CPU_##IDENT,
121 122 123 124 125
#include "arm-cores.def"
#undef ARM_CORE
  TARGET_CPU_generic
};

pbrook's avatar
pbrook committed
126 127 128
/* The processor for which instructions should be scheduled.  */
extern enum processor_type arm_tune;

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
enum arm_sync_generator_tag
  {
    arm_sync_generator_omn,
    arm_sync_generator_omrn
  };

/* Wrapper to pass around a polymorphic pointer to a sync instruction
   generator and.  */
struct arm_sync_generator
{
  enum arm_sync_generator_tag op;
  union
  {
    rtx (* omn) (rtx, rtx, rtx);
    rtx (* omrn) (rtx, rtx, rtx, rtx);
  } u;
};

147
typedef enum arm_cond_code
148 149 150
{
  ARM_EQ = 0, ARM_NE, ARM_CS, ARM_CC, ARM_MI, ARM_PL, ARM_VS, ARM_VC,
  ARM_HI, ARM_LS, ARM_GE, ARM_LT, ARM_GT, ARM_LE, ARM_AL, ARM_NV
151 152
}
arm_cc;
nickc's avatar
nickc committed
153

154
extern arm_cc arm_current_cc;
155

156
#define ARM_INVERSE_CONDITION_CODE(X)  ((arm_cc) (((int)X) ^ 1))
157

nickc's avatar
nickc committed
158 159
extern int arm_target_label;
extern int arm_ccfsm_state;
160
extern GTY(()) rtx arm_target_insn;
161
/* The label of the current constant pool.  */
162
extern rtx pool_vector_label;
163
/* Set to 1 when a return insn is output, this means that the epilogue
164
   is not needed.  */
165
extern int return_used_this_function;
166 167
/* Callback to output language specific object attributes.  */
extern void (*arm_lang_output_object_attributes_hook)(void);
rms's avatar
rms committed
168

169
/* Just in case configure has failed to define anything.  */
170 171 172 173 174
#ifndef TARGET_CPU_DEFAULT
#define TARGET_CPU_DEFAULT TARGET_CPU_generic
#endif


175
#undef  CPP_SPEC
176
#define CPP_SPEC "%(subtarget_cpp_spec)					\
177 178
%{mfloat-abi=soft:%{mfloat-abi=hard:					\
	%e-mfloat-abi=soft and -mfloat-abi=hard may not be used together}} \
neil's avatar
config:  
neil committed
179 180
%{mbig-endian:%{mlittle-endian:						\
	%e-mbig-endian and -mlittle-endian may not be used together}}"
181

nickc's avatar
nickc committed
182
#ifndef CC1_SPEC
183
#define CC1_SPEC ""
nickc's avatar
nickc committed
184
#endif
185 186 187 188 189 190

/* This macro defines names of additional specifications to put in the specs
   that can be used in various specifications like CC1_SPEC.  Its definition
   is an initializer with a subgrouping for each command option.

   Each subgrouping contains a string constant, that defines the
191
   specification name, and a string constant that used by the GCC driver
192 193 194 195
   program.

   Do not define this macro if it does not need to do anything.  */
#define EXTRA_SPECS						\
erich's avatar
erich committed
196
  { "subtarget_cpp_spec",	SUBTARGET_CPP_SPEC },           \
197 198
  SUBTARGET_EXTRA_SPECS

nickc's avatar
nickc committed
199
#ifndef SUBTARGET_EXTRA_SPECS
200
#define SUBTARGET_EXTRA_SPECS
nickc's avatar
nickc committed
201 202
#endif

nickc's avatar
nickc committed
203
#ifndef SUBTARGET_CPP_SPEC
erich's avatar
erich committed
204
#define SUBTARGET_CPP_SPEC      ""
nickc's avatar
nickc committed
205
#endif
rms's avatar
rms committed
206 207

/* Run-time Target Specification.  */
208
#ifndef TARGET_VERSION
nickc's avatar
nickc committed
209
#define TARGET_VERSION fputs (" (ARM/generic)", stderr);
210
#endif
rms's avatar
rms committed
211

pbrook's avatar
pbrook committed
212
#define TARGET_SOFT_FLOAT		(arm_float_abi == ARM_FLOAT_ABI_SOFT)
213 214 215 216
/* Use hardware floating point instructions. */
#define TARGET_HARD_FLOAT		(arm_float_abi != ARM_FLOAT_ABI_SOFT)
/* Use hardware floating point calling convention.  */
#define TARGET_HARD_FLOAT_ABI		(arm_float_abi == ARM_FLOAT_ABI_HARD)
217 218 219
#define TARGET_FPA		(arm_fpu_desc->model == ARM_FP_MODEL_FPA)
#define TARGET_MAVERICK		(arm_fpu_desc->model == ARM_FP_MODEL_MAVERICK)
#define TARGET_VFP		(arm_fpu_desc->model == ARM_FP_MODEL_VFP)
220
#define TARGET_IWMMXT			(arm_arch_iwmmxt)
221 222
#define TARGET_REALLY_IWMMXT		(TARGET_IWMMXT && TARGET_32BIT)
#define TARGET_IWMMXT_ABI (TARGET_32BIT && arm_abi == ARM_ABI_IWMMXT)
223 224
#define TARGET_ARM                      (! TARGET_THUMB)
#define TARGET_EITHER			1 /* (TARGET_ARM | TARGET_THUMB) */
225 226 227
#define TARGET_BACKTRACE	        (leaf_function_p () \
				         ? TARGET_TPCS_LEAF_FRAME \
				         : TARGET_TPCS_FRAME)
228
#define TARGET_LDRD			(arm_arch5e && ARM_DOUBLEWORD_ALIGN)
229 230
#define TARGET_AAPCS_BASED \
    (arm_abi != ARM_ABI_APCS && arm_abi != ARM_ABI_ATPCS)
231

232 233 234
#define TARGET_HARD_TP			(target_thread_pointer == TP_CP15)
#define TARGET_SOFT_TP			(target_thread_pointer == TP_SOFT)

235 236 237 238 239 240
/* Only 16-bit thumb code.  */
#define TARGET_THUMB1			(TARGET_THUMB && !arm_arch_thumb2)
/* Arm or Thumb-2 32-bit code.  */
#define TARGET_32BIT			(TARGET_ARM || arm_arch_thumb2)
/* 32-bit Thumb-2 code.  */
#define TARGET_THUMB2			(TARGET_THUMB && arm_arch_thumb2)
241 242
/* Thumb-1 only.  */
#define TARGET_THUMB1_ONLY		(TARGET_THUMB1 && !arm_arch_notm)
243 244
/* FPA emulator without LFM.  */
#define TARGET_FPA_EMU2			(TARGET_FPA && arm_fpu_desc->rev == 2)
245

jules's avatar
gcc/  
jules committed
246
/* The following two macros concern the ability to execute coprocessor
247 248 249
   instructions for VFPv3 or NEON.  TARGET_VFP3/TARGET_VFPD32 are currently
   only ever tested when we know we are generating for VFP hardware; we need
   to be more careful with TARGET_NEON as noted below.  */
jules's avatar
gcc/  
jules committed
250

251
/* FPU is has the full VFPv3/NEON register file of 32 D registers.  */
252
#define TARGET_VFPD32 (TARGET_VFP && arm_fpu_desc->regs == VFP_REG_D32)
253 254

/* FPU supports VFPv3 instructions.  */
255
#define TARGET_VFP3 (TARGET_VFP && arm_fpu_desc->rev >= 3)
256

257 258 259 260 261 262 263
/* FPU only supports VFP single-precision instructions.  */
#define TARGET_VFP_SINGLE (TARGET_VFP && arm_fpu_desc->regs == VFP_REG_SINGLE)

/* FPU supports VFP double-precision instructions.  */
#define TARGET_VFP_DOUBLE (TARGET_VFP && arm_fpu_desc->regs != VFP_REG_SINGLE)

/* FPU supports half-precision floating-point with NEON element load/store.  */
264 265
#define TARGET_NEON_FP16 \
  (TARGET_VFP && arm_fpu_desc->neon && arm_fpu_desc->fp16)
266

267 268 269
/* FPU supports VFP half-precision floating-point.  */
#define TARGET_FP16 (TARGET_VFP && arm_fpu_desc->fp16)

jules's avatar
gcc/  
jules committed
270 271 272 273 274
/* FPU supports Neon instructions.  The setting of this macro gets
   revealed via __ARM_NEON__ so we add extra guards upon TARGET_32BIT
   and TARGET_HARD_FLOAT to ensure that NEON instructions are
   available.  */
#define TARGET_NEON (TARGET_32BIT && TARGET_HARD_FLOAT \
275
		     && TARGET_VFP && arm_fpu_desc->neon)
jules's avatar
gcc/  
jules committed
276

277 278
/* "DSP" multiply instructions, eg. SMULxy.  */
#define TARGET_DSP_MULTIPLY \
279
  (TARGET_32BIT && arm_arch5e && (arm_arch_notm || arm_arch7em))
280 281
/* Integer SIMD instructions, and extend-accumulate instructions.  */
#define TARGET_INT_SIMD \
282
  (TARGET_32BIT && arm_arch6 && (arm_arch_notm || arm_arch7em))
283

284 285 286
/* Should MOVW/MOVT be used in preference to a constant pool.  */
#define TARGET_USE_MOVT (arm_arch_thumb2 && !optimize_size)

287 288 289 290
/* We could use unified syntax for arm mode, but for now we just use it
   for Thumb-2.  */
#define TARGET_UNIFIED_ASM TARGET_THUMB2

291 292 293 294 295 296 297 298 299 300 301 302 303 304
/* Nonzero if this chip provides the DMB instruction.  */
#define TARGET_HAVE_DMB		(arm_arch7)

/* Nonzero if this chip implements a memory barrier via CP15.  */
#define TARGET_HAVE_DMB_MCR	(arm_arch6k && ! TARGET_HAVE_DMB)

/* Nonzero if this chip implements a memory barrier instruction.  */
#define TARGET_HAVE_MEMORY_BARRIER (TARGET_HAVE_DMB || TARGET_HAVE_DMB_MCR)

/* Nonzero if this chip supports ldrex and strex */
#define TARGET_HAVE_LDREX	((arm_arch6 && TARGET_ARM) || arm_arch7)

/* Nonzero if this chip supports ldrex{bhd} and strex{bhd}.  */
#define TARGET_HAVE_LDREXBHD	((arm_arch6k && TARGET_ARM) || arm_arch7)
305

306 307 308 309 310 311
/* True iff the full BPABI is being used.  If TARGET_BPABI is true,
   then TARGET_AAPCS_BASED must be true -- but the converse does not
   hold.  TARGET_BPABI implies the use of the BPABI runtime library,
   etc., in addition to just the AAPCS calling conventions.  */
#ifndef TARGET_BPABI
#define TARGET_BPABI false
312
#endif
313

314 315 316 317 318 319
/* Support for a compile-time default CPU, et cetera.  The rules are:
   --with-arch is ignored if -march or -mcpu are specified.
   --with-cpu is ignored if -march or -mcpu are specified, and is overridden
    by --with-arch.
   --with-tune is ignored if -mtune or -mcpu are specified (but not affected
     by -march).
320
   --with-float is ignored if -mfloat-abi is specified.
pbrook's avatar
pbrook committed
321 322
   --with-fpu is ignored if -mfpu is specified.
   --with-abi is ignored is -mabi is specified.  */
323 324 325 326
#define OPTION_DEFAULT_SPECS \
  {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
  {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
  {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \
327
  {"float", "%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}" }, \
pbrook's avatar
pbrook committed
328
  {"fpu", "%{!mfpu=*:-mfpu=%(VALUE)}"}, \
329 330
  {"abi", "%{!mabi=*:-mabi=%(VALUE)}"}, \
  {"mode", "%{!marm:%{!mthumb:-m%(VALUE)}}"},
331

pbrook's avatar
pbrook committed
332 333 334 335 336 337 338 339 340 341 342 343
/* Which floating point model to use.  */
enum arm_fp_model
{
  ARM_FP_MODEL_UNKNOWN,
  /* FPA model (Hardware or software).  */
  ARM_FP_MODEL_FPA,
  /* Cirrus Maverick floating point model.  */
  ARM_FP_MODEL_MAVERICK,
  /* VFP floating point model.  */
  ARM_FP_MODEL_VFP
};

344
enum vfp_reg_type
345
{
346
  VFP_NONE = 0,
347 348 349
  VFP_REG_D16,
  VFP_REG_D32,
  VFP_REG_SINGLE
350 351
};

352 353 354 355 356 357 358 359 360 361 362 363
extern const struct arm_fpu_desc
{
  const char *name;
  enum arm_fp_model model;
  int rev;
  enum vfp_reg_type regs;
  int neon;
  int fp16;
} *arm_fpu_desc;

/* Which floating point hardware to schedule for.  */
extern int arm_fpu_attr;
erich's avatar
erich committed
364

pbrook's avatar
pbrook committed
365 366 367 368 369 370 371 372 373
enum float_abi_type
{
  ARM_FLOAT_ABI_SOFT,
  ARM_FLOAT_ABI_SOFTFP,
  ARM_FLOAT_ABI_HARD
};

extern enum float_abi_type arm_float_abi;

374 375 376 377
#ifndef TARGET_DEFAULT_FLOAT_ABI
#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
#endif

378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
/* Which __fp16 format to use.
   The enumeration values correspond to the numbering for the
   Tag_ABI_FP_16bit_format attribute.
 */
enum arm_fp16_format_type
{
  ARM_FP16_FORMAT_NONE = 0,
  ARM_FP16_FORMAT_IEEE = 1,
  ARM_FP16_FORMAT_ALTERNATIVE = 2
};

extern enum arm_fp16_format_type arm_fp16_format;
#define LARGEST_EXPONENT_IS_NORMAL(bits) \
    ((bits) == 16 && arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE)

pbrook's avatar
pbrook committed
393 394 395 396 397 398
/* Which ABI to use.  */
enum arm_abi_type
{
  ARM_ABI_APCS,
  ARM_ABI_ATPCS,
  ARM_ABI_AAPCS,
kazu's avatar
/  
kazu committed
399 400
  ARM_ABI_IWMMXT,
  ARM_ABI_AAPCS_LINUX
pbrook's avatar
pbrook committed
401 402 403 404 405 406 407 408
};

extern enum arm_abi_type arm_abi;

#ifndef ARM_DEFAULT_ABI
#define ARM_DEFAULT_ABI ARM_ABI_APCS
#endif

409 410 411 412 413 414 415 416 417
/* Which thread pointer access sequence to use.  */
enum arm_tp_type {
  TP_AUTO,
  TP_SOFT,
  TP_CP15
};

extern enum arm_tp_type target_thread_pointer;

pbrook's avatar
pbrook committed
418 419
/* Nonzero if this chip supports the ARM Architecture 3M extensions.  */
extern int arm_arch3m;
420

pbrook's avatar
pbrook committed
421
/* Nonzero if this chip supports the ARM Architecture 4 extensions.  */
422 423
extern int arm_arch4;

rearnsha's avatar
rearnsha committed
424 425 426
/* Nonzero if this chip supports the ARM Architecture 4T extensions.  */
extern int arm_arch4t;

pbrook's avatar
pbrook committed
427
/* Nonzero if this chip supports the ARM Architecture 5 extensions.  */
428 429
extern int arm_arch5;

pbrook's avatar
pbrook committed
430
/* Nonzero if this chip supports the ARM Architecture 5E extensions.  */
rearnsha's avatar
rearnsha committed
431 432
extern int arm_arch5e;

pbrook's avatar
pbrook committed
433 434 435
/* Nonzero if this chip supports the ARM Architecture 6 extensions.  */
extern int arm_arch6;

436 437 438 439 440 441
/* Nonzero if this chip supports the ARM Architecture 6k extensions.  */
extern int arm_arch6k;

/* Nonzero if this chip supports the ARM Architecture 7 extensions.  */
extern int arm_arch7;

442 443 444
/* Nonzero if instructions not present in the 'M' profile can be used.  */
extern int arm_arch_notm;

445 446 447
/* Nonzero if instructions present in ARMv7E-M can be used.  */
extern int arm_arch7em;

nickc's avatar
nickc committed
448 449 450
/* Nonzero if this chip can benefit from load scheduling.  */
extern int arm_ld_sched;

451
/* Nonzero if generating Thumb code, either Thumb-1 or Thumb-2.  */
452 453
extern int thumb_code;

454 455 456
/* Nonzero if generating Thumb-1 code.  */
extern int thumb1_code;

nickc's avatar
nickc committed
457
/* Nonzero if this chip is a StrongARM.  */
rearnsha's avatar
rearnsha committed
458
extern int arm_tune_strongarm;
nickc's avatar
nickc committed
459

460
/* Nonzero if this chip is a Cirrus variant.  */
461
extern int arm_arch_cirrus;
462

463 464 465
/* Nonzero if this chip supports Intel XScale with Wireless MMX technology.  */
extern int arm_arch_iwmmxt;

nickc's avatar
nickc committed
466
/* Nonzero if this chip is an XScale.  */
467 468
extern int arm_arch_xscale;

rearnsha's avatar
rearnsha committed
469
/* Nonzero if tuning for XScale.  */
470
extern int arm_tune_xscale;
nickc's avatar
nickc committed
471

rearnsha's avatar
rearnsha committed
472 473
/* Nonzero if tuning for stores via the write buffer.  */
extern int arm_tune_wbuf;
nickc's avatar
nickc committed
474

475 476 477
/* Nonzero if tuning for Cortex-A9.  */
extern int arm_tune_cortex_a9;

478
/* Nonzero if we should define __THUMB_INTERWORK__ in the
479
   preprocessor.
480 481 482 483 484
   XXX This is a bit of a hack, it's intended to help work around
   problems in GLD which doesn't understand that armv5t code is
   interworking clean.  */
extern int arm_cpp_interwork;

485 486 487 488 489 490
/* Nonzero if chip supports Thumb 2.  */
extern int arm_arch_thumb2;

/* Nonzero if chip supports integer division instruction.  */
extern int arm_arch_hwdiv;

erich's avatar
erich committed
491
#ifndef TARGET_DEFAULT
492
#define TARGET_DEFAULT  (MASK_APCS_FRAME)
erich's avatar
erich committed
493
#endif
rms's avatar
rms committed
494

495 496
/* Nonzero if PIC code requires explicit qualifiers to generate
   PLT and GOT relocs rather than the assembler doing so implicitly.
497 498 499 500 501 502
   Subtargets can override these if required.  */
#ifndef NEED_GOT_RELOC
#define NEED_GOT_RELOC	0
#endif
#ifndef NEED_PLT_RELOC
#define NEED_PLT_RELOC	0
503
#endif
law's avatar
 
law committed
504 505 506 507

/* Nonzero if we need to refer to the GOT with a PC-relative
   offset.  In other words, generate

508
   .word	_GLOBAL_OFFSET_TABLE_ - [. - (.Lxx + 8)]
law's avatar
 
law committed
509 510 511 512 513

   rather than

   .word	_GLOBAL_OFFSET_TABLE_ - (.Lxx + 8)

514
   The default is true, which matches NetBSD.  Subtargets can
law's avatar
 
law committed
515 516 517 518
   override this if required.  */
#ifndef GOT_PCREL
#define GOT_PCREL   1
#endif
rms's avatar
rms committed
519 520 521

/* Target machine storage Layout.  */

522 523 524 525 526 527 528 529 530

/* Define this macro if it is advisable to hold scalars in registers
   in a wider mode than that declared by the program.  In such cases,
   the value is constrained to be within the bounds of the declared
   type, but kept valid in the wider mode.  The signedness of the
   extension may differ from that of the type.  */

/* It is far faster to zero extend chars than to sign extend them */

nickc's avatar
nickc committed
531
#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE)	\
erich's avatar
erich committed
532 533 534 535 536 537
  if (GET_MODE_CLASS (MODE) == MODE_INT		\
      && GET_MODE_SIZE (MODE) < 4)      	\
    {						\
      if (MODE == QImode)			\
	UNSIGNEDP = 1;				\
      else if (MODE == HImode)			\
rearnsha's avatar
rearnsha committed
538
	UNSIGNEDP = 1;				\
erich's avatar
erich committed
539
      (MODE) = SImode;				\
540 541
    }

rms's avatar
rms committed
542 543 544 545
/* Define this if most significant bit is lowest numbered
   in instructions that operate on numbered bit-fields.  */
#define BITS_BIG_ENDIAN  0

546
/* Define this if most significant byte of a word is the lowest numbered.
547 548 549
   Most ARM processors are run in little endian mode, so that is the default.
   If you want to have it run-time selectable, change the definition in a
   cover file to be TARGET_BIG_ENDIAN.  */
550
#define BYTES_BIG_ENDIAN  (TARGET_BIG_END != 0)
rms's avatar
rms committed
551 552

/* Define this if most significant word of a multiword number is the lowest
553 554
   numbered.
   This is always false, even when in big-endian mode.  */
555 556
#define WORDS_BIG_ENDIAN  (BYTES_BIG_ENDIAN && ! TARGET_LITTLE_WORDS)

557
/* Define this if most significant word of doubles is the lowest numbered.
558 559
   The rules are different based on whether or not we use FPA-format,
   VFP-format or some other floating point co-processor's format doubles.  */
560
#define FLOAT_WORDS_BIG_ENDIAN (arm_float_words_big_endian ())
561

rms's avatar
rms committed
562 563
#define UNITS_PER_WORD	4

pbrook's avatar
pbrook committed
564
/* True if natural alignment is used for doubleword types.  */
565 566
#define ARM_DOUBLEWORD_ALIGN	TARGET_AAPCS_BASED

pbrook's avatar
pbrook committed
567
#define DOUBLEWORD_ALIGNMENT 64
rms's avatar
rms committed
568

pbrook's avatar
pbrook committed
569
#define PARM_BOUNDARY  	32
570

pbrook's avatar
pbrook committed
571
#define STACK_BOUNDARY  (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32)
rms's avatar
rms committed
572

pbrook's avatar
pbrook committed
573 574
#define PREFERRED_STACK_BOUNDARY \
    (arm_abi == ARM_ABI_ATPCS ? 64 : STACK_BOUNDARY)
575

ramana's avatar
ramana committed
576
#define FUNCTION_BOUNDARY  ((TARGET_THUMB && optimize_size) ? 16 : 32)
rms's avatar
rms committed
577

578 579 580 581 582
/* The lowest bit is used to indicate Thumb-mode functions, so the
   vbit must go into the delta field of pointers to member
   functions.  */
#define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta

rms's avatar
rms committed
583 584
#define EMPTY_FIELD_BOUNDARY  32

pbrook's avatar
pbrook committed
585
#define BIGGEST_ALIGNMENT (ARM_DOUBLEWORD_ALIGN ? DOUBLEWORD_ALIGNMENT : 32)
586

587 588 589 590
/* XXX Blah -- this macro is used directly by libobjc.  Since it
   supports no vector modes, cut out the complexity and fall back
   on BIGGEST_FIELD_ALIGNMENT.  */
#ifdef IN_TARGET_LIBS
591
#define BIGGEST_FIELD_ALIGNMENT 64
592
#endif
593

594
/* Make strings word-aligned so strcpy from constants will be faster.  */
595
#define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2)
596

nickc's avatar
nickc committed
597
#define CONSTANT_ALIGNMENT(EXP, ALIGN)				\
pbrook's avatar
pbrook committed
598
   ((TREE_CODE (EXP) == STRING_CST				\
599
     && !optimize_size						\
pbrook's avatar
pbrook committed
600 601
     && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR)	\
    ? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN))
602

603 604 605
/* Align definitions of arrays, unions and structures so that
   initializations and copies can be made more efficient.  This is not
   ABI-changing, so it only affects places where we can see the
606 607 608 609
   definition. Increasing the alignment tends to introduce padding,
   so don't do this when optimizing for size/conserving stack space. */
#define ARM_EXPAND_ALIGNMENT(COND, EXP, ALIGN)				\
  (((COND) && ((ALIGN) < BITS_PER_WORD)					\
610 611 612 613
    && (TREE_CODE (EXP) == ARRAY_TYPE					\
	|| TREE_CODE (EXP) == UNION_TYPE				\
	|| TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))

614 615 616 617
/* Align global data. */
#define DATA_ALIGNMENT(EXP, ALIGN)			\
  ARM_EXPAND_ALIGNMENT(!optimize_size, EXP, ALIGN)

618
/* Similarly, make sure that objects on the stack are sensibly aligned.  */
619 620
#define LOCAL_ALIGNMENT(EXP, ALIGN)				\
  ARM_EXPAND_ALIGNMENT(!flag_conserve_stack, EXP, ALIGN)
621

622 623 624
/* Setting STRUCTURE_SIZE_BOUNDARY to 32 produces more efficient code, but the
   value set in previous versions of this toolchain was 8, which produces more
   compact structures.  The command line option -mstructure_size_boundary=<n>
625
   can be used to change this value.  For compatibility with the ARM SDK
626
   however the value should be left at 32.  ARM SDT Reference Manual (ARM DUI
pbrook's avatar
pbrook committed
627 628
   0020D) page 2-20 says "Structures are aligned on word boundaries".
   The AAPCS specifies a value of 8.  */
629 630
#define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
extern int arm_structure_size_boundary;
631

632
/* This is the value used to initialize arm_structure_size_boundary.  If a
633
   particular arm target wants to change the default value it should change
634
   the definition of this macro, not STRUCTURE_SIZE_BOUNDARY.  See netbsd.h
635 636 637
   for an example of this.  */
#ifndef DEFAULT_STRUCTURE_SIZE_BOUNDARY
#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 32
638
#endif
639

640
/* Nonzero if move instructions will actually fail to work
641
   when given unaligned data.  */
rms's avatar
rms committed
642
#define STRICT_ALIGNMENT 1
643 644 645 646 647 648 649 650 651 652 653

/* wchar_t is unsigned under the AAPCS.  */
#ifndef WCHAR_TYPE
#define WCHAR_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "int")

#define WCHAR_TYPE_SIZE BITS_PER_WORD
#endif

#ifndef SIZE_TYPE
#define SIZE_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "long unsigned int")
#endif
654

kazu's avatar
/  
kazu committed
655 656 657 658
#ifndef PTRDIFF_TYPE
#define PTRDIFF_TYPE (TARGET_AAPCS_BASED ? "int" : "long int")
#endif

659 660 661 662 663
/* AAPCS requires that structure alignment is affected by bitfields.  */
#ifndef PCC_BITFIELD_TYPE_MATTERS
#define PCC_BITFIELD_TYPE_MATTERS TARGET_AAPCS_BASED
#endif

rms's avatar
rms committed
664 665 666 667 668 669 670 671 672 673 674

/* Standard register usage.  */

/* Register allocation in ARM Procedure Call Standard (as used on RISCiX):
   (S - saved over call).

	r0	   *	argument word/integer result
	r1-r3		argument word

	r4-r8	     S	register variable
	r9	     S	(rfp) register variable (real frame pointer)
675

nickc's avatar
nickc committed
676
	r10  	   F S	(sl) stack limit (used by -mapcs-stack-check)
rms's avatar
rms committed
677 678 679 680 681 682 683 684 685 686 687
	r11 	   F S	(fp) argument pointer
	r12		(ip) temp workspace
	r13  	   F S	(sp) lower end of current stack frame
	r14		(lr) link address/workspace
	r15	   F	(pc) program counter

	f0		floating point result
	f1-f3		floating point scratch

	f4-f7	     S	floating point variable

688 689 690 691 692 693 694 695 696 697 698
	cc		This is NOT a real register, but is used internally
	                to represent things that use or set the condition
			codes.
	sfp             This isn't either.  It is used during rtl generation
	                since the offset between the frame pointer and the
			auto's isn't known until after register allocation.
	afp		Nor this, we only need this because of non-local
	                goto.  Without it fp appears to be used and the
			elimination code won't get rid of sfp.  It tracks
			fp exactly at all times.

699
   *: See TARGET_CONDITIONAL_REGISTER_USAGE  */
rms's avatar
rms committed
700

701 702 703 704 705
/*
  	mvf0		Cirrus floating point result
	mvf1-mvf3	Cirrus floating point scratch
	mvf4-mvf15   S	Cirrus floating point variable.  */

pbrook's avatar
pbrook committed
706 707 708 709 710
/*	s0-s15		VFP scratch (aka d0-d7).
	s16-s31	      S	VFP variable (aka d8-d15).
	vfpcc		Not a real register.  Represents the VFP condition
			code flags.  */

711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
/* The stack backtrace structure is as follows:
  fp points to here:  |  save code pointer  |      [fp]
                      |  return link value  |      [fp, #-4]
                      |  return sp value    |      [fp, #-8]
                      |  return fp value    |      [fp, #-12]
                     [|  saved r10 value    |]
                     [|  saved r9 value     |]
                     [|  saved r8 value     |]
                     [|  saved r7 value     |]
                     [|  saved r6 value     |]
                     [|  saved r5 value     |]
                     [|  saved r4 value     |]
                     [|  saved r3 value     |]
                     [|  saved r2 value     |]
                     [|  saved r1 value     |]
                     [|  saved r0 value     |]
                     [|  saved f7 value     |]     three words
                     [|  saved f6 value     |]     three words
                     [|  saved f5 value     |]     three words
                     [|  saved f4 value     |]     three words
  r0-r3 are not normally saved in a C function.  */

rms's avatar
rms committed
733 734
/* 1 for registers that have pervasive standard uses
   and are not available for the register allocator.  */
pbrook's avatar
pbrook committed
735 736 737 738 739
#define FIXED_REGISTERS \
{                       \
  0,0,0,0,0,0,0,0,	\
  0,0,0,0,0,1,0,1,	\
  0,0,0,0,0,0,0,0,	\
740 741
  1,1,1,		\
  1,1,1,1,1,1,1,1,	\
pbrook's avatar
pbrook committed
742 743 744 745 746 747 748 749
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,		\
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
jules's avatar
gcc/  
jules committed
750 751 752 753
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
  1,1,1,1,1,1,1,1,	\
pbrook's avatar
pbrook committed
754
  1			\
rms's avatar
rms committed
755 756 757 758 759 760 761
}

/* 1 for registers not available across function calls.
   These must include the FIXED_REGISTERS and also any
   registers that can be used without being saved.
   The latter must include the registers where values are returned
   and the register where structure-value addresses are passed.
762
   Aside from that, you can include as many other registers as you like.
763
   The CC is not preserved over function calls on the ARM 6, so it is
764
   easier to assume this for all.  SFP is preserved, since FP is.  */
rms's avatar
rms committed
765 766 767
#define CALL_USED_REGISTERS  \
{                            \
  1,1,1,1,0,0,0,0,	     \
768
  0,0,0,0,1,1,1,1,	     \
769
  1,1,1,1,0,0,0,0,	     \
770 771
  1,1,1,		     \
  1,1,1,1,1,1,1,1,	     \
772 773 774
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
pbrook's avatar
pbrook committed
775 776 777 778 779
  1,1,1,1,		     \
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
jules's avatar
gcc/  
jules committed
780 781 782 783
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
  1,1,1,1,1,1,1,1,	     \
pbrook's avatar
pbrook committed
784
  1			     \
rms's avatar
rms committed
785 786
}

nickc's avatar
nickc committed
787 788 789 790
#ifndef SUBTARGET_CONDITIONAL_REGISTER_USAGE
#define SUBTARGET_CONDITIONAL_REGISTER_USAGE
#endif

791
/* These are a couple of extensions to the formats accepted
nickc's avatar
nickc committed
792 793 794 795 796 797 798 799 800 801 802 803 804
   by asm_fprintf:
     %@ prints out ASM_COMMENT_START
     %r prints out REGISTER_PREFIX reg_names[arg]  */
#define ASM_FPRINTF_EXTENSIONS(FILE, ARGS, P)		\
  case '@':						\
    fputs (ASM_COMMENT_START, FILE);			\
    break;						\
							\
  case 'r':						\
    fputs (REGISTER_PREFIX, FILE);			\
    fputs (reg_names [va_arg (ARGS, int)], FILE);	\
    break;

805
/* Round X up to the nearest word.  */
806
#define ROUND_UP_WORD(X) (((X) + 3) & ~3)
807

nickc's avatar
nickc committed
808
/* Convert fron bytes to ints.  */
809
#define ARM_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
nickc's avatar
nickc committed
810

pbrook's avatar
pbrook committed
811 812
/* The number of (integer) registers required to hold a quantity of type MODE.
   Also used for VFP registers.  */
813 814
#define ARM_NUM_REGS(MODE)				\
  ARM_NUM_INTS (GET_MODE_SIZE (MODE))
nickc's avatar
nickc committed
815 816

/* The number of (integer) registers required to hold a quantity of TYPE MODE.  */
817 818
#define ARM_NUM_REGS2(MODE, TYPE)                   \
  ARM_NUM_INTS ((MODE) == BLKmode ? 		\
819
  int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
nickc's avatar
nickc committed
820 821

/* The number of (integer) argument register available.  */
822
#define NUM_ARG_REGS		4
nickc's avatar
nickc committed
823

rearnsha's avatar
rearnsha committed
824 825 826
/* And similarly for the VFP.  */
#define NUM_VFP_ARG_REGS	16

827
/* Return the register number of the N'th (integer) argument.  */
828
#define ARG_REGISTER(N) 	(N - 1)
nickc's avatar
nickc committed
829

830 831
/* Specify the registers used for certain standard purposes.
   The values of these macros are register numbers.  */
rms's avatar
rms committed
832

833 834
/* The number of the last argument register.  */
#define LAST_ARG_REGNUM 	ARG_REGISTER (NUM_ARG_REGS)
rms's avatar
rms committed
835

836 837
/* The numbers of the Thumb register ranges.  */
#define FIRST_LO_REGNUM  	0
838
#define LAST_LO_REGNUM  	7
839 840
#define FIRST_HI_REGNUM		8
#define LAST_HI_REGNUM		11
841

rth's avatar
rth committed
842 843 844
/* Overridden by config/arm/bpabi.h.  */
#ifndef ARM_UNWIND_INFO
#define ARM_UNWIND_INFO  0
845 846
#endif

847 848 849
/* Use r0 and r1 to pass exception handling information.  */
#define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM)

850
/* The register that holds the return address in exception handlers.  */
851 852
#define ARM_EH_STACKADJ_REGNUM	2
#define EH_RETURN_STACKADJ_RTX	gen_rtx_REG (SImode, ARM_EH_STACKADJ_REGNUM)
rms's avatar
rms committed
853

854 855 856
/* The native (Norcroft) Pascal compiler for the ARM passes the static chain
   as an invisible last argument (possible since varargs don't exist in
   Pascal), so the following is not true.  */
857
#define STATIC_CHAIN_REGNUM	12
rms's avatar
rms committed
858

859 860 861 862 863 864
/* Define this to be where the real frame pointer is if it is not possible to
   work out the offset between the frame pointer and the automatic variables
   until after register allocation has taken place.  FRAME_POINTER_REGNUM
   should point to a special register that we will make sure is eliminated.

   For the Thumb we have another problem.  The TPCS defines the frame pointer
865
   as r11, and GCC believes that it is always possible to use the frame pointer
866 867 868 869 870 871 872
   as base register for addressing purposes.  (See comments in
   find_reloads_address()).  But - the Thumb does not allow high registers,
   including r11, to be used as base address registers.  Hence our problem.

   The solution used here, and in the old thumb port is to use r7 instead of
   r11 as the hard frame pointer and to have special code to generate
   backtrace structures on the stack (if required to do so via a command line
873
   option) using r11.  This is the only 'user visible' use of r11 as a frame
874 875 876
   pointer.  */
#define ARM_HARD_FRAME_POINTER_REGNUM	11
#define THUMB_HARD_FRAME_POINTER_REGNUM	 7
rms's avatar
rms committed
877

rearnsha's avatar
rearnsha committed
878 879 880 881
#define HARD_FRAME_POINTER_REGNUM		\
  (TARGET_ARM					\
   ? ARM_HARD_FRAME_POINTER_REGNUM		\
   : THUMB_HARD_FRAME_POINTER_REGNUM)
882

jsm28's avatar
gcc:  
jsm28 committed
883 884 885
#define HARD_FRAME_POINTER_IS_FRAME_POINTER 0
#define HARD_FRAME_POINTER_IS_ARG_POINTER 0

rearnsha's avatar
rearnsha committed
886
#define FP_REGNUM	                HARD_FRAME_POINTER_REGNUM
887

rearnsha's avatar
rearnsha committed
888 889
/* Register to use for pushing function arguments.  */
#define STACK_POINTER_REGNUM	SP_REGNUM
890 891

/* ARM floating pointer registers.  */
pbrook's avatar
pbrook committed
892 893
#define FIRST_FPA_REGNUM 	16
#define LAST_FPA_REGNUM  	23
894 895
#define IS_FPA_REGNUM(REGNUM) \
  (((REGNUM) >= FIRST_FPA_REGNUM) && ((REGNUM) <= LAST_FPA_REGNUM))
896

897 898 899 900 901 902 903 904 905
#define FIRST_IWMMXT_GR_REGNUM	43
#define LAST_IWMMXT_GR_REGNUM	46
#define FIRST_IWMMXT_REGNUM	47
#define LAST_IWMMXT_REGNUM	62
#define IS_IWMMXT_REGNUM(REGNUM) \
  (((REGNUM) >= FIRST_IWMMXT_REGNUM) && ((REGNUM) <= LAST_IWMMXT_REGNUM))
#define IS_IWMMXT_GR_REGNUM(REGNUM) \
  (((REGNUM) >= FIRST_IWMMXT_GR_REGNUM) && ((REGNUM) <= LAST_IWMMXT_GR_REGNUM))

rms's avatar
rms committed
906
/* Base register for access to local variables of the function.  */
907 908
#define FRAME_POINTER_REGNUM	25

909 910
/* Base register for access to arguments of the function.  */
#define ARG_POINTER_REGNUM	26
911

912 913 914 915 916
#define FIRST_CIRRUS_FP_REGNUM	27
#define LAST_CIRRUS_FP_REGNUM	42
#define IS_CIRRUS_REGNUM(REGNUM) \
  (((REGNUM) >= FIRST_CIRRUS_FP_REGNUM) && ((REGNUM) <= LAST_CIRRUS_FP_REGNUM))

pbrook's avatar
pbrook committed
917
#define FIRST_VFP_REGNUM	63
jules's avatar
gcc/  
jules committed
918 919
#define D7_VFP_REGNUM		78  /* Registers 77 and 78 == VFP reg D7.  */
#define LAST_VFP_REGNUM	\
920
  (TARGET_VFPD32 ? LAST_HI_VFP_REGNUM : LAST_LO_VFP_REGNUM)
jules's avatar
gcc/  
jules committed
921

pbrook's avatar
pbrook committed
922 923 924
#define IS_VFP_REGNUM(REGNUM) \
  (((REGNUM) >= FIRST_VFP_REGNUM) && ((REGNUM) <= LAST_VFP_REGNUM))

jules's avatar
gcc/  
jules committed
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
/* VFP registers are split into two types: those defined by VFP versions < 3
   have D registers overlaid on consecutive pairs of S registers. VFP version 3
   defines 16 new D registers (d16-d31) which, for simplicity and correctness
   in various parts of the backend, we implement as "fake" single-precision
   registers (which would be S32-S63, but cannot be used in that way).  The
   following macros define these ranges of registers.  */
#define LAST_LO_VFP_REGNUM	94
#define FIRST_HI_VFP_REGNUM	95
#define LAST_HI_VFP_REGNUM	126

#define VFP_REGNO_OK_FOR_SINGLE(REGNUM) \
  ((REGNUM) <= LAST_LO_VFP_REGNUM)

/* DFmode values are only valid in even register pairs.  */
#define VFP_REGNO_OK_FOR_DOUBLE(REGNUM) \
  ((((REGNUM) - FIRST_VFP_REGNUM) & 1) == 0)

jules's avatar
gcc/  
jules committed
942 943 944 945 946 947 948 949 950 951 952 953
/* Neon Quad values must start at a multiple of four registers.  */
#define NEON_REGNO_OK_FOR_QUAD(REGNUM) \
  ((((REGNUM) - FIRST_VFP_REGNUM) & 3) == 0)

/* Neon structures of vectors must be in even register pairs and there
   must be enough registers available.  Because of various patterns
   requiring quad registers, we require them to start at a multiple of
   four.  */
#define NEON_REGNO_OK_FOR_NREGS(REGNUM, N) \
  ((((REGNUM) - FIRST_VFP_REGNUM) & 3) == 0 \
   && (LAST_VFP_REGNUM - (REGNUM) >= 2 * (N) - 1))

954 955
/* The number of hard registers is 16 ARM + 8 FPA + 1 CC + 1 SFP + 1 AFP.  */
/* + 16 Cirrus registers take us up to 43.  */
956
/* Intel Wireless MMX Technology registers add 16 + 4 more.  */
jules's avatar
gcc/  
jules committed
957 958
/* VFP (VFP3) adds 32 (64) + 1 more.  */
#define FIRST_PSEUDO_REGISTER   128
959

960 961
#define DBX_REGISTER_NUMBER(REGNO) arm_dbx_register_number (REGNO)

rms's avatar
rms committed
962 963
/* Value should be nonzero if functions must have frame pointers.
   Zero means the frame pointer need not be set up (and parms may be accessed
964
   via the stack pointer) in functions that seem suitable.
965 966
   If we have to have a frame pointer we might as well make use of it.
   APCS says that the frame pointer does not need to be pushed in leaf
967
   functions, or simple tail call functions.  */
968 969 970 971 972

#ifndef SUBTARGET_FRAME_POINTER_REQUIRED
#define SUBTARGET_FRAME_POINTER_REQUIRED 0
#endif

973 974 975 976
/* Return number of consecutive hard regs needed starting at reg REGNO
   to hold something of mode MODE.
   This is ordinarily the length in words of a value of mode MODE
   but can be less for certain modes in special long registers.
rms's avatar
rms committed
977

978
   On the ARM regs are UNITS_PER_WORD bits wide; FPA regs can hold any FP
979 980
   mode.  */
#define HARD_REGNO_NREGS(REGNO, MODE)  	\
981
  ((TARGET_32BIT			\
pbrook's avatar
pbrook committed
982
    && REGNO >= FIRST_FPA_REGNUM	\
983 984
    && REGNO != FRAME_POINTER_REGNUM	\
    && REGNO != ARG_POINTER_REGNUM)	\
pbrook's avatar
pbrook committed
985
    && !IS_VFP_REGNUM (REGNO)		\
986
   ? 1 : ARM_NUM_REGS (MODE))
rms's avatar
rms committed
987

988
/* Return true if REGNO is suitable for holding a quantity of type MODE.  */
989
#define HARD_REGNO_MODE_OK(REGNO, MODE)					\
990
  arm_hard_regno_mode_ok ((REGNO), (MODE))
rms's avatar
rms committed
991

992 993 994 995 996 997
/* Value is 1 if it is a good idea to tie two pseudo registers
   when one has mode MODE1 and one has mode MODE2.
   If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
   for any hard reg, then this must be 0 for correct output.  */
#define MODES_TIEABLE_P(MODE1, MODE2)  \
  (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
998

999
#define VALID_IWMMXT_REG_MODE(MODE) \
1000
 (arm_vector_mode_supported_p (MODE) || (MODE) == DImode)
1001

jules's avatar
gcc/  
jules committed
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
/* Modes valid for Neon D registers.  */
#define VALID_NEON_DREG_MODE(MODE) \
  ((MODE) == V2SImode || (MODE) == V4HImode || (MODE) == V8QImode \
   || (MODE) == V2SFmode || (MODE) == DImode)

/* Modes valid for Neon Q registers.  */
#define VALID_NEON_QREG_MODE(MODE) \
  ((MODE) == V4SImode || (MODE) == V8HImode || (MODE) == V16QImode \
   || (MODE) == V4SFmode || (MODE) == V2DImode)

/* Structure modes valid for Neon registers.  */
#define VALID_NEON_STRUCT_MODE(MODE) \
  ((MODE) == TImode || (MODE) == EImode || (MODE) == OImode \
   || (MODE) == CImode || (MODE) == XImode)

bernds's avatar
bernds committed
1017 1018 1019
/* The register numbers in sequence, for passing to arm_gen_load_multiple.  */
extern int arm_regs_in_sequence[];

rms's avatar
rms committed
1020
/* The order in which register should be allocated.  It is good to use ip
1021 1022
   since no saving is required (though calls clobber it) and it never contains
   function parameters.  It is quite good to use lr since other calls may
1023
   clobber it anyway.  Allocate r0 through r3 in reverse order since r3 is
1024
   least likely to contain a function parameter; in addition results are
jules's avatar
gcc/  
jules committed
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
   returned in r0.
   For VFP/VFPv3, allocate D16-D31 first, then caller-saved registers (D0-D7),
   then D8-D15.  The reason for doing this is to attempt to reduce register
   pressure when both single- and double-precision registers are used in a
   function.  */

#define REG_ALLOC_ORDER				\
{						\
     3,  2,  1,  0, 12, 14,  4,  5,		\
     6,  7,  8, 10,  9, 11, 13, 15,		\
    16, 17, 18, 19, 20, 21, 22, 23,		\
    27, 28, 29, 30, 31, 32, 33, 34,		\
    35, 36, 37, 38, 39, 40, 41, 42,		\
    43, 44, 45, 46, 47, 48, 49, 50,		\
    51, 52, 53, 54, 55, 56, 57, 58,		\
    59, 60, 61, 62,				\
    24, 25, 26,					\
    95,  96,  97,  98,  99, 100, 101, 102,	\
   103, 104, 105, 106, 107, 108, 109, 110,	\
   111, 112, 113, 114, 115, 116, 117, 118,	\
   119, 120, 121, 122, 123, 124, 125, 126,	\
    78,  77,  76,  75,  74,  73,  72,  71,	\
    70,  69,  68,  67,  66,  65,  64,  63,	\
    79,  80,  81,  82,  83,  84,  85,  86,	\
    87,  88,  89,  90,  91,  92,  93,  94,	\
   127						\
rms's avatar
rms committed
1051
}
1052

1053
/* Use different register alloc ordering for Thumb.  */
bernds's avatar
bernds committed
1054 1055 1056 1057 1058
#define ADJUST_REG_ALLOC_ORDER arm_order_regs_for_local_alloc ()

/* Tell IRA to use the order we define rather than messing it up with its
   own cost calculations.  */
#define HONOR_REG_ALLOC_ORDER
1059

1060 1061 1062 1063 1064
/* Interrupt functions can only use registers that have already been
   saved by the prologue, even if they would normally be
   call-clobbered.  */
#define HARD_REGNO_RENAME_OK(SRC, DST)					\
	(! IS_INTERRUPT (cfun->machine->func_type) ||			\
dberlin's avatar
dberlin committed
1065
	 df_regs_ever_live_p (DST))
rms's avatar
rms committed
1066 1067 1068

/* Register and constant classes.  */

1069
/* Register classes: used to be simple, just all ARM regs or all FPA regs
1070
   Now that the Thumb is involved it has become more complicated.  */
rms's avatar
rms committed
1071 1072 1073
enum reg_class
{
  NO_REGS,
1074
  FPA_REGS,
1075
  CIRRUS_REGS,
jules's avatar
gcc/  
jules committed
1076 1077 1078
  VFP_D0_D7_REGS,
  VFP_LO_REGS,
  VFP_HI_REGS,
pbrook's avatar
pbrook committed
1079
  VFP_REGS,
1080 1081
  IWMMXT_GR_REGS,
  IWMMXT_REGS,
1082 1083 1084 1085 1086
  LO_REGS,
  STACK_REG,
  BASE_REGS,
  HI_REGS,
  CC_REG,
pbrook's avatar
pbrook committed
1087
  VFPCC_REG,
rms's avatar
rms committed
1088
  GENERAL_REGS,
1089
  CORE_REGS,
rms's avatar
rms committed
1090 1091 1092 1093 1094 1095
  ALL_REGS,
  LIM_REG_CLASSES
};

#define N_REG_CLASSES  (int) LIM_REG_CLASSES

1096
/* Give names of register classes as strings for dump file.  */
rms's avatar
rms committed
1097 1098 1099
#define REG_CLASS_NAMES  \
{			\
  "NO_REGS",		\
1100
  "FPA_REGS",		\
1101
  "CIRRUS_REGS",	\
jules's avatar
gcc/  
jules committed
1102 1103 1104
  "VFP_D0_D7_REGS",	\
  "VFP_LO_REGS",	\
  "VFP_HI_REGS",	\
pbrook's avatar
pbrook committed
1105
  "VFP_REGS",		\
1106 1107
  "IWMMXT_GR_REGS",	\
  "IWMMXT_REGS",	\
1108 1109 1110 1111 1112
  "LO_REGS",		\
  "STACK_REG",		\
  "BASE_REGS",		\
  "HI_REGS",		\
  "CC_REG",		\
1113
  "VFPCC_REG",		\
rms's avatar
rms committed
1114
  "GENERAL_REGS",	\
1115
  "CORE_REGS",		\
rms's avatar
rms committed
1116 1117 1118 1119 1120 1121
  "ALL_REGS",		\
}

/* Define which registers fit in which classes.
   This is an initializer for a vector of HARD_REG_SET
   of length N_REG_CLASSES.  */
jules's avatar
gcc/  
jules committed
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
#define REG_CLASS_CONTENTS						\
{									\
  { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS  */	\
  { 0x00FF0000, 0x00000000, 0x00000000, 0x00000000 }, /* FPA_REGS */	\
  { 0xF8000000, 0x000007FF, 0x00000000, 0x00000000 }, /* CIRRUS_REGS */	\
  { 0x00000000, 0x80000000, 0x00007FFF, 0x00000000 }, /* VFP_D0_D7_REGS  */ \
  { 0x00000000, 0x80000000, 0x7FFFFFFF, 0x00000000 }, /* VFP_LO_REGS  */ \
  { 0x00000000, 0x00000000, 0x80000000, 0x7FFFFFFF }, /* VFP_HI_REGS  */ \
  { 0x00000000, 0x80000000, 0xFFFFFFFF, 0x7FFFFFFF }, /* VFP_REGS  */	\
  { 0x00000000, 0x00007800, 0x00000000, 0x00000000 }, /* IWMMXT_GR_REGS */ \
  { 0x00000000, 0x7FFF8000, 0x00000000, 0x00000000 }, /* IWMMXT_REGS */	\
  { 0x000000FF, 0x00000000, 0x00000000, 0x00000000 }, /* LO_REGS */	\
  { 0x00002000, 0x00000000, 0x00000000, 0x00000000 }, /* STACK_REG */	\
  { 0x000020FF, 0x00000000, 0x00000000, 0x00000000 }, /* BASE_REGS */	\
1136
  { 0x0000DF00, 0x00000000, 0x00000000, 0x00000000 }, /* HI_REGS */	\
jules's avatar
gcc/  
jules committed
1137 1138
  { 0x01000000, 0x00000000, 0x00000000, 0x00000000 }, /* CC_REG */	\
  { 0x00000000, 0x00000000, 0x00000000, 0x80000000 }, /* VFPCC_REG */	\
jules's avatar
gcc/  
jules committed
1139 1140
  { 0x0000DFFF, 0x00000000, 0x00000000, 0x00000000 }, /* GENERAL_REGS */ \
  { 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000 }, /* CORE_REGS */	\
jules's avatar
gcc/  
jules committed
1141
  { 0xFAFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF }  /* ALL_REGS */	\
rms's avatar
rms committed
1142
}
1143

jules's avatar
gcc/  
jules committed
1144 1145 1146 1147 1148
/* Any of the VFP register classes.  */
#define IS_VFP_CLASS(X) \
  ((X) == VFP_D0_D7_REGS || (X) == VFP_LO_REGS \
   || (X) == VFP_HI_REGS || (X) == VFP_REGS)

rms's avatar
rms committed
1149 1150 1151 1152
/* The same information, inverted:
   Return the class number of the smallest class containing
   reg number REGNO.  This could be a conditional expression
   or could index an array.  */
1153
#define REGNO_REG_CLASS(REGNO)  arm_regno_class (REGNO)
rms's avatar
rms committed
1154

1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168
/* The following macro defines cover classes for Integrated Register
   Allocator.  Cover classes is a set of non-intersected register
   classes covering all hard registers used for register allocation
   purpose.  Any move between two registers of a cover class should be
   cheaper than load or store of the registers.  The macro value is
   array of register classes with LIM_REG_CLASSES used as the end
   marker.  */

#define IRA_COVER_CLASSES						     \
{									     \
  GENERAL_REGS, FPA_REGS, CIRRUS_REGS, VFP_REGS, IWMMXT_GR_REGS, IWMMXT_REGS,\
  LIM_REG_CLASSES							     \
}

pbrook's avatar
pbrook committed
1169
/* FPA registers can't do subreg as all values are reformatted to internal
1170
   precision.  VFP registers may only be accessed in the mode they
pbrook's avatar
pbrook committed
1171
   were set.  */
rearnsha's avatar
rearnsha committed
1172 1173
#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS)	\
  (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO)		\
pbrook's avatar
pbrook committed
1174 1175 1176
   ? reg_classes_intersect_p (FPA_REGS, (CLASS))	\
     || reg_classes_intersect_p (VFP_REGS, (CLASS))	\
   : 0)
rearnsha's avatar
rearnsha committed
1177

rms's avatar
rms committed
1178
/* The class value for index registers, and the one for base regs.  */
1179
#define INDEX_REG_CLASS  (TARGET_THUMB1 ? LO_REGS : GENERAL_REGS)
1180
#define BASE_REG_CLASS   (TARGET_THUMB1 ? LO_REGS : CORE_REGS)
1181

1182
/* For the Thumb the high registers cannot be used as base registers
1183
   when addressing quantities in QI or HI mode; if we don't know the
1184
   mode, then we must be conservative.  */
nickc's avatar
nickc committed
1185
#define MODE_BASE_REG_CLASS(MODE)					\
1186
    (TARGET_32BIT ? CORE_REGS :					\
1187 1188 1189 1190 1191
     (((MODE) == SImode) ? BASE_REGS : LO_REGS))

/* For Thumb we can not support SP+reg addressing, so we return LO_REGS
   instead of BASE_REGS.  */
#define MODE_BASE_REG_REG_CLASS(MODE) BASE_REG_CLASS
nickc's avatar
nickc committed
1192

1193
/* When this hook returns true for MODE, the compiler allows
1194 1195
   registers explicitly used in the rtl to be used as spill registers
   but prevents the compiler from extending the lifetime of these
1196
   registers.  */
1197 1198
#define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \
  arm_small_register_classes_for_mode_p 
rms's avatar
rms committed
1199 1200 1201

/* Given an rtx X being reloaded into a reg required to be
   in class CLASS, return the class of reg to actually use.
1202 1203 1204
   In general this is just CLASS, but for the Thumb core registers and
   immediate constants we prefer a LO_REGS class or a subset.  */
#define PREFERRED_RELOAD_CLASS(X, CLASS)		\
jules's avatar
gcc/  
jules committed
1205
  (TARGET_32BIT ? (CLASS) :				\
1206
   ((CLASS) == GENERAL_REGS || (CLASS) == HI_REGS	\
1207 1208
    || (CLASS) == NO_REGS || (CLASS) == STACK_REG	\
   ? LO_REGS : (CLASS)))
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218

/* Must leave BASE_REGS reloads alone */
#define THUMB_SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X)		\
  ((CLASS) != LO_REGS && (CLASS) != BASE_REGS				\
   ? ((true_regnum (X) == -1 ? LO_REGS					\
       : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS	\
       : NO_REGS)) 							\
   : NO_REGS)

#define THUMB_SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X)		\
rearnsha's avatar
rearnsha committed
1219
  ((CLASS) != LO_REGS && (CLASS) != BASE_REGS				\
1220 1221 1222 1223
   ? ((true_regnum (X) == -1 ? LO_REGS					\
       : (true_regnum (X) + HARD_REGNO_NREGS (0, MODE) > 8) ? LO_REGS	\
       : NO_REGS)) 							\
   : NO_REGS)
rms's avatar
rms committed
1224

1225 1226 1227
/* Return the register class of a scratch register needed to copy IN into
   or out of a register in CLASS in MODE.  If it can be done directly,
   NO_REGS is returned.  */
1228
#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X)		\
1229
  /* Restrict which direct reloads are allowed for VFP/iWMMXt regs.  */ \
pbrook's avatar
pbrook committed
1230
  ((TARGET_VFP && TARGET_HARD_FLOAT				\
jules's avatar
gcc/  
jules committed
1231
    && IS_VFP_CLASS (CLASS))					\
1232 1233 1234
   ? coproc_secondary_reload_class (MODE, X, FALSE)		\
   : (TARGET_IWMMXT && (CLASS) == IWMMXT_REGS)			\
   ? coproc_secondary_reload_class (MODE, X, TRUE)		\
1235
   : TARGET_32BIT						\
pbrook's avatar
pbrook committed
1236
   ? (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \
1237 1238
    ? GENERAL_REGS : NO_REGS)					\
   : THUMB_SECONDARY_OUTPUT_RELOAD_CLASS (CLASS, MODE, X))
1239

1240
/* If we need to load shorts byte-at-a-time, then we need a scratch.  */
1241
#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X)		\
1242
  /* Restrict which direct reloads are allowed for VFP/iWMMXt regs.  */ \
pbrook's avatar
pbrook committed
1243
  ((TARGET_VFP && TARGET_HARD_FLOAT				\
jules's avatar
gcc/  
jules committed
1244
    && IS_VFP_CLASS (CLASS))					\
1245 1246 1247
    ? coproc_secondary_reload_class (MODE, X, FALSE) :		\
    (TARGET_IWMMXT && (CLASS) == IWMMXT_REGS) ?			\
    coproc_secondary_reload_class (MODE, X, TRUE) :		\
1248
  /* Cannot load constants into Cirrus registers.  */		\
pbrook's avatar
pbrook committed
1249
   (TARGET_MAVERICK && TARGET_HARD_FLOAT			\
1250 1251 1252
     && (CLASS) == CIRRUS_REGS					\
     && (CONSTANT_P (X) || GET_CODE (X) == SYMBOL_REF))		\
    ? GENERAL_REGS :						\
1253
  (TARGET_32BIT ?						\
1254 1255 1256
   (((CLASS) == IWMMXT_REGS || (CLASS) == IWMMXT_GR_REGS)	\
      && CONSTANT_P (X))					\
   ? GENERAL_REGS :						\
rearnsha's avatar
rearnsha committed
1257
   (((MODE) == HImode && ! arm_arch4				\
1258 1259 1260 1261
     && (GET_CODE (X) == MEM					\
	 || ((GET_CODE (X) == REG || GET_CODE (X) == SUBREG)	\
	     && true_regnum (X) == -1)))			\
    ? GENERAL_REGS : NO_REGS)					\
1262
   : THUMB_SECONDARY_INPUT_RELOAD_CLASS (CLASS, MODE, X)))
erich's avatar
erich committed
1263

1264 1265 1266 1267 1268 1269
/* Try a machine-dependent way of reloading an illegitimate address
   operand.  If we find one, push the reload and jump to WIN.  This
   macro is used in only one place: `find_reloads_address' in reload.c.

   For the ARM, we wish to handle large displacements off a base
   register by splitting the addend across a MOV and the mem insn.
1270 1271 1272 1273
   This can cut the number of reloads needed.  */
#define ARM_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND, WIN)	   \
  do									   \
    {									   \
1274 1275
      if (arm_legitimize_reload_address (&X, MODE, OPNUM, TYPE, IND))	   \
	goto WIN;							   \
1276
    }									   \
1277
  while (0)
1278

1279
/* XXX If an HImode FP+large_offset address is converted to an HImode
1280 1281 1282 1283 1284 1285 1286
   SP+large_offset address, then reload won't know how to fix it.  It sees
   only that SP isn't valid for HImode, and so reloads the SP into an index
   register, but the resulting address is still invalid because the offset
   is too big.  We fix it here instead by reloading the entire address.  */
/* We could probably achieve better results by defining PROMOTE_MODE to help
   cope with the variances between the Thumb's signed and unsigned byte and
   halfword load instructions.  */
1287
/* ??? This should be safe for thumb2, but we may be able to do better.  */
rearnsha's avatar
rearnsha committed
1288 1289 1290 1291 1292 1293 1294 1295 1296
#define THUMB_LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_L, WIN)     \
do {									      \
  rtx new_x = thumb_legitimize_reload_address (&X, MODE, OPNUM, TYPE, IND_L); \
  if (new_x)								      \
    {									      \
      X = new_x;							      \
      goto WIN;								      \
    }									      \
} while (0)
1297 1298 1299 1300 1301 1302

#define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)   \
  if (TARGET_ARM)							   \
    ARM_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN); \
  else									   \
    THUMB_LEGITIMIZE_RELOAD_ADDRESS (X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)
1303

rms's avatar
rms committed
1304 1305
/* Return the maximum number of consecutive registers
   needed to represent mode MODE in a register of class CLASS.
1306
   ARM regs are UNITS_PER_WORD bits while FPA regs can hold any FP mode */
rms's avatar
rms committed
1307
#define CLASS_MAX_NREGS(CLASS, MODE)  \
1308
  (((CLASS) == FPA_REGS || (CLASS) == CIRRUS_REGS) ? 1 : ARM_NUM_REGS (MODE))
1309 1310 1311

/* If defined, gives a class of registers that cannot be used as the
   operand of a SUBREG that changes the mode of the object illegally.  */
rms's avatar
rms committed
1312

1313 1314 1315 1316 1317
/* Moves between FPA_REGS and GENERAL_REGS are two memory insns.
   Moves between VFP_REGS and GENERAL_REGS are a single insn, but
   it is typically more expensive than a single memory access.  We set
   the cost to less than two memory accesses so that floating
   point to integer conversion does not go through memory.  */
1318
#define REGISTER_MOVE_COST(MODE, FROM, TO)		\
1319
  (TARGET_32BIT ?						\
1320 1321
   ((FROM) == FPA_REGS && (TO) != FPA_REGS ? 20 :	\
    (FROM) != FPA_REGS && (TO) == FPA_REGS ? 20 :	\
1322 1323
    IS_VFP_CLASS (FROM) && !IS_VFP_CLASS (TO) ? 15 :	\
    !IS_VFP_CLASS (FROM) && IS_VFP_CLASS (TO) ? 15 :	\
1324 1325 1326
    (FROM) == IWMMXT_REGS && (TO) != IWMMXT_REGS ? 4 :  \
    (FROM) != IWMMXT_REGS && (TO) == IWMMXT_REGS ? 4 :  \
    (FROM) == IWMMXT_GR_REGS || (TO) == IWMMXT_GR_REGS ? 20 :  \
1327 1328 1329
    (FROM) == CIRRUS_REGS && (TO) != CIRRUS_REGS ? 20 :	\
    (FROM) != CIRRUS_REGS && (TO) == CIRRUS_REGS ? 20 :	\
   2)							\
1330 1331
   :							\
   ((FROM) == HI_REGS || (TO) == HI_REGS) ? 4 : 2)
rms's avatar
rms committed
1332 1333 1334 1335 1336 1337 1338

/* Stack layout; function entry, exit and calling.  */

/* Define this if pushing a word on the stack
   makes the stack pointer a smaller address.  */
#define STACK_GROWS_DOWNWARD  1

1339
/* Define this to nonzero if the nominal address of the stack frame
rms's avatar
rms committed
1340 1341 1342 1343 1344
   is at the high-address end of the local variables;
   that is, each additional local variable allocated
   goes at a more negative offset in the frame.  */
#define FRAME_GROWS_DOWNWARD 1

1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355
/* The amount of scratch space needed by _interwork_{r7,r11}_call_via_rN().
   When present, it is one word in size, and sits at the top of the frame,
   between the soft frame pointer and either r7 or r11.

   We only need _interwork_rM_call_via_rN() for -mcaller-super-interworking,
   and only then if some outgoing arguments are passed on the stack.  It would
   be tempting to also check whether the stack arguments are passed by indirect
   calls, but there seems to be no reason in principle why a post-reload pass
   couldn't convert a direct call into an indirect one.  */
#define CALLER_INTERWORKING_SLOT_SIZE			\
  (TARGET_CALLER_INTERWORKING				\
hubicka's avatar
 
hubicka committed
1356
   && crtl->outgoing_args_size != 0		\
1357 1358
   ? UNITS_PER_WORD : 0)

rms's avatar
rms committed
1359 1360 1361 1362 1363 1364 1365 1366
/* Offset within stack frame to start allocating local variables at.
   If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
   first local allocated.  Otherwise, it is the offset to the BEGINNING
   of the first local allocated.  */
#define STARTING_FRAME_OFFSET  0

/* If we generate an insn to push BYTES bytes,
   this says how many the stack pointer really advances by.  */
1367
/* The push insns do not do this rounding implicitly.
1368
   So don't define this.  */
1369
/* #define PUSH_ROUNDING(NPUSHED)  ROUND_UP_WORD (NPUSHED) */
1370 1371 1372

/* Define this if the maximum size of all the outgoing args is to be
   accumulated and pushed during the prologue.  The amount can be
hubicka's avatar
 
hubicka committed
1373
   found in the variable crtl->outgoing_args_size.  */
nickc's avatar
nickc committed
1374
#define ACCUMULATE_OUTGOING_ARGS 1
rms's avatar
rms committed
1375 1376

/* Offset of first parameter from the argument pointer register value.  */
1377
#define FIRST_PARM_OFFSET(FNDECL)  (TARGET_ARM ? 4 : 0)
rms's avatar
rms committed
1378 1379 1380

/* Define how to find the value returned by a library function
   assuming the value has mode MODE.  */
rearnsha's avatar
rearnsha committed
1381 1382 1383 1384
#define LIBCALL_VALUE(MODE)  						\
  (TARGET_AAPCS_BASED ? aapcs_libcall_value (MODE)			\
   : (TARGET_32BIT && TARGET_HARD_FLOAT_ABI && TARGET_FPA		\
      && GET_MODE_CLASS (MODE) == MODE_FLOAT)				\
pbrook's avatar
pbrook committed
1385
   ? gen_rtx_REG (MODE, FIRST_FPA_REGNUM)				\
1386
   : TARGET_32BIT && TARGET_HARD_FLOAT_ABI && TARGET_MAVERICK		\
pbrook's avatar
pbrook committed
1387
     && GET_MODE_CLASS (MODE) == MODE_FLOAT				\
1388
   ? gen_rtx_REG (MODE, FIRST_CIRRUS_FP_REGNUM) 			\
1389
   : TARGET_IWMMXT_ABI && arm_vector_mode_supported_p (MODE)    	\
1390
   ? gen_rtx_REG (MODE, FIRST_IWMMXT_REGNUM) 				\
1391
   : gen_rtx_REG (MODE, ARG_REGISTER (1)))
rms's avatar
rms committed
1392

rearnsha's avatar
rearnsha committed
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402
/* 1 if REGNO is a possible register number for a function value.  */
#define FUNCTION_VALUE_REGNO_P(REGNO)				\
  ((REGNO) == ARG_REGISTER (1)					\
   || (TARGET_AAPCS_BASED && TARGET_32BIT 			\
       && TARGET_VFP && TARGET_HARD_FLOAT			\
       && (REGNO) == FIRST_VFP_REGNUM)				\
   || (TARGET_32BIT && ((REGNO) == FIRST_CIRRUS_FP_REGNUM)	\
       && TARGET_HARD_FLOAT_ABI && TARGET_MAVERICK)		\
   || ((REGNO) == FIRST_IWMMXT_REGNUM && TARGET_IWMMXT_ABI)	\
   || (TARGET_32BIT && ((REGNO) == FIRST_FPA_REGNUM)		\
1403
       && TARGET_HARD_FLOAT_ABI && TARGET_FPA))
rms's avatar
rms committed
1404

rearnsha's avatar
rearnsha committed
1405 1406 1407 1408
/* Amount of memory needed for an untyped call to save all possible return
   registers.  */
#define APPLY_RESULT_SIZE arm_apply_result_size()

1409 1410
/* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return
   values must be in memory.  On the ARM, they need only do so if larger
1411
   than a word, or if they contain elements offset from zero in the struct.  */
1412 1413
#define DEFAULT_PCC_STRUCT_RETURN 0

1414
/* These bits describe the different types of function supported
1415
   by the ARM backend.  They are exclusive.  i.e. a function cannot be both a
1416 1417 1418 1419 1420 1421
   normal function and an interworked function, for example.  Knowing the
   type of a function is important for determining its prologue and
   epilogue sequences.
   Note value 7 is currently unassigned.  Also note that the interrupt
   function types all have bit 2 set, so that they can be tested for easily.
   Note that 0 is deliberately chosen for ARM_FT_UNKNOWN so that when the
1422
   machine_function structure is initialized (to zero) func_type will
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
   default to unknown.  This will force the first use of arm_current_func_type
   to call arm_compute_func_type.  */
#define ARM_FT_UNKNOWN		 0 /* Type has not yet been determined.  */
#define ARM_FT_NORMAL		 1 /* Your normal, straightforward function.  */
#define ARM_FT_INTERWORKED	 2 /* A function that supports interworking.  */
#define ARM_FT_ISR		 4 /* An interrupt service routine.  */
#define ARM_FT_FIQ		 5 /* A fast interrupt service routine.  */
#define ARM_FT_EXCEPTION	 6 /* An ARM exception handler (subcase of ISR).  */

#define ARM_FT_TYPE_MASK	((1 << 3) - 1)

/* In addition functions can have several type modifiers,
   outlined by these bit masks:  */
#define ARM_FT_INTERRUPT	(1 << 2) /* Note overlap with FT_ISR and above.  */
#define ARM_FT_NAKED		(1 << 3) /* No prologue or epilogue.  */
#define ARM_FT_VOLATILE		(1 << 4) /* Does not return.  */
1439
#define ARM_FT_NESTED		(1 << 5) /* Embedded inside another func.  */
1440
#define ARM_FT_STACKALIGN	(1 << 6) /* Called with misaligned stack.  */
1441 1442 1443 1444 1445 1446 1447

/* Some macros to test these flags.  */
#define ARM_FUNC_TYPE(t)	(t & ARM_FT_TYPE_MASK)
#define IS_INTERRUPT(t)		(t & ARM_FT_INTERRUPT)
#define IS_VOLATILE(t)     	(t & ARM_FT_VOLATILE)
#define IS_NAKED(t)        	(t & ARM_FT_NAKED)
#define IS_NESTED(t)       	(t & ARM_FT_NESTED)
1448
#define IS_STACKALIGN(t)       	(t & ARM_FT_STACKALIGN)
1449

pbrook's avatar
pbrook committed
1450 1451 1452 1453 1454 1455

/* Structure used to hold the function stack frame layout.  Offsets are
   relative to the stack pointer on function entry.  Positive offsets are
   in the direction of stack growth.
   Only soft_frame is used in thumb mode.  */

1456
typedef struct GTY(()) arm_stack_offsets
pbrook's avatar
pbrook committed
1457 1458 1459 1460 1461
{
  int saved_args;	/* ARG_POINTER_REGNUM.  */
  int frame;		/* ARM_HARD_FRAME_POINTER_REGNUM.  */
  int saved_regs;
  int soft_frame;	/* FRAME_POINTER_REGNUM.  */
1462
  int locals_base;	/* THUMB_HARD_FRAME_POINTER_REGNUM.  */
pbrook's avatar
pbrook committed
1463
  int outgoing_args;	/* STACK_POINTER_REGNUM.  */
1464
  unsigned int saved_regs_mask;
pbrook's avatar
pbrook committed
1465 1466 1467
}
arm_stack_offsets;

1468
#ifndef GENERATOR_FILE
1469 1470
/* A C structure for machine-specific, per-function data.
   This is added to the cfun structure.  */
1471
typedef struct GTY(()) machine_function
1472
{
1473
  /* Additional stack adjustment in __builtin_eh_throw.  */
1474
  rtx eh_epilogue_sp_ofs;
1475 1476 1477 1478
  /* Records if LR has to be saved for far jumps.  */
  int far_jump_used;
  /* Records if ARG_POINTER was ever live.  */
  int arg_pointer_live;
1479 1480
  /* Records if the save of LR has been eliminated.  */
  int lr_save_eliminated;
1481
  /* The size of the stack frame.  Only valid after reload.  */
pbrook's avatar
pbrook committed
1482
  arm_stack_offsets stack_offsets;
1483 1484
  /* Records the type of the current function.  */
  unsigned long func_type;
1485 1486
  /* Record if the function has a variable argument list.  */
  int uses_anonymous_args;
1487 1488 1489
  /* Records if sibcalls are blocked because an argument
     register is needed to preserve stack alignment.  */
  int sibcall_blocked;
rearnsha's avatar
rearnsha committed
1490 1491
  /* The PIC register for this function.  This might be a pseudo.  */
  rtx pic_reg;
rearnsha's avatar
rearnsha committed
1492
  /* Labels for per-function Thumb call-via stubs.  One per potential calling
1493 1494 1495
     register.  We can never call via LR or PC.  We can call via SP if a
     trampoline happens to be on the top of the stack.  */
  rtx call_via[14];
1496 1497 1498
  /* Set to 1 when a return insn is output, this means that the epilogue
     is not needed.  */
  int return_used_this_function;
1499 1500 1501 1502 1503 1504 1505
  /* When outputting Thumb-1 code, record the last insn that provides
     information about condition codes, and the comparison operands.  */
  rtx thumb1_cc_insn;
  rtx thumb1_cc_op0;
  rtx thumb1_cc_op1;
  /* Also record the CC mode that is supported.  */
  enum machine_mode thumb1_cc_mode;
1506 1507
}
machine_function;
1508
#endif
1509

rearnsha's avatar
rearnsha committed
1510
/* As in the machine_function, a global set of call-via labels, for code 
1511
   that is in text_section.  */
1512
extern GTY(()) rtx thumb_call_via_label[14];
rearnsha's avatar
rearnsha committed
1513

rearnsha's avatar
rearnsha committed
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530
/* The number of potential ways of assigning to a co-processor.  */
#define ARM_NUM_COPROC_SLOTS 1

/* Enumeration of procedure calling standard variants.  We don't really 
   support all of these yet.  */
enum arm_pcs
{
  ARM_PCS_AAPCS,	/* Base standard AAPCS.  */
  ARM_PCS_AAPCS_VFP,	/* Use VFP registers for floating point values.  */
  ARM_PCS_AAPCS_IWMMXT, /* Use iWMMXT registers for vectors.  */
  /* This must be the last AAPCS variant.  */
  ARM_PCS_AAPCS_LOCAL,	/* Private call within this compilation unit.  */
  ARM_PCS_ATPCS,	/* ATPCS.  */
  ARM_PCS_APCS,		/* APCS (legacy Linux etc).  */
  ARM_PCS_UNKNOWN
};

1531 1532 1533
/* Default procedure calling standard of current compilation unit. */
extern enum arm_pcs arm_pcs_default;

1534
/* A C type for declaring a variable that is used as the first argument of
rearnsha's avatar
rearnsha committed
1535
   `FUNCTION_ARG' and other related values.  */
1536 1537
typedef struct
{
1538
  /* This is the number of registers of arguments scanned so far.  */
1539
  int nregs;
1540 1541 1542 1543
  /* This is the number of iWMMXt register arguments scanned so far.  */
  int iwmmxt_nregs;
  int named_count;
  int nargs;
rearnsha's avatar
rearnsha committed
1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564
  /* Which procedure call variant to use for this call.  */
  enum arm_pcs pcs_variant;

  /* AAPCS related state tracking.  */
  int aapcs_arg_processed;  /* No need to lay out this argument again.  */
  int aapcs_cprc_slot;      /* Index of co-processor rules to handle
			       this argument, or -1 if using core
			       registers.  */
  int aapcs_ncrn;
  int aapcs_next_ncrn;
  rtx aapcs_reg;	    /* Register assigned to this argument.  */
  int aapcs_partial;	    /* How many bytes are passed in regs (if
			       split between core regs and stack.
			       Zero otherwise.  */
  int aapcs_cprc_failed[ARM_NUM_COPROC_SLOTS];
  int can_split;	    /* Argument can be split between core regs
			       and the stack.  */
  /* Private data for tracking VFP register allocation */
  unsigned aapcs_vfp_regs_free;
  unsigned aapcs_vfp_reg_alloc;
  int aapcs_vfp_rcount;
1565
  MACHMODE aapcs_vfp_rmode;
1566
} CUMULATIVE_ARGS;
1567

1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578
#define FUNCTION_ARG_PADDING(MODE, TYPE) \
  (arm_pad_arg_upward (MODE, TYPE) ? upward : downward)

#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
  (arm_pad_reg_upward (MODE, TYPE, FIRST) ? upward : downward)

/* For AAPCS, padding should never be below the argument. For other ABIs,
 * mimic the default.  */
#define PAD_VARARGS_DOWN \
  ((TARGET_AAPCS_BASED) ? 0 : BYTES_BIG_ENDIAN)

rms's avatar
rms committed
1579 1580 1581 1582
/* Initialize a variable CUM of type CUMULATIVE_ARGS
   for a call to a function whose data type is FNTYPE.
   For a library call, FNTYPE is 0.
   On the ARM, the offset starts at 0.  */
1583
#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
1584
  arm_init_cumulative_args (&(CUM), (FNTYPE), (LIBNAME), (FNDECL))
rms's avatar
rms committed
1585 1586 1587

/* 1 if N is a possible register number for function argument passing.
   On the ARM, r0-r3 are used to pass args.  */
rearnsha's avatar
rearnsha committed
1588 1589 1590 1591 1592
#define FUNCTION_ARG_REGNO_P(REGNO)					\
   (IN_RANGE ((REGNO), 0, 3)						\
    || (TARGET_AAPCS_BASED && TARGET_VFP && TARGET_HARD_FLOAT		\
	&& IN_RANGE ((REGNO), FIRST_VFP_REGNUM, FIRST_VFP_REGNUM + 15))	\
    || (TARGET_IWMMXT_ABI						\
pbrook's avatar
pbrook committed
1593
	&& IN_RANGE ((REGNO), FIRST_IWMMXT_REGNUM, FIRST_IWMMXT_REGNUM + 9)))
rms's avatar
rms committed
1594

1595

nickc's avatar
nickc committed
1596
/* If your target environment doesn't prefix user functions with an
1597
   underscore, you may wish to re-define this to prevent any conflicts.  */
nickc's avatar
nickc committed
1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616
#ifndef ARM_MCOUNT_NAME
#define ARM_MCOUNT_NAME "*mcount"
#endif

/* Call the function profiler with a given profile label.  The Acorn
   compiler puts this BEFORE the prolog but gcc puts it afterwards.
   On the ARM the full profile code will look like:
	.data
	LP1
		.word	0
	.text
		mov	ip, lr
		bl	mcount
		.word	LP1

   profile_function() in final.c outputs the .data section, FUNCTION_PROFILER
   will output the .text section.

   The ``mov ip,lr'' seems like a good idea to stick with cc convention.
nickc's avatar
nickc committed
1617 1618 1619 1620
   ``prof'' doesn't seem to mind about this!

   Note - this version of the code is designed to work in both ARM and
   Thumb modes.  */
nickc's avatar
nickc committed
1621
#ifndef ARM_FUNCTION_PROFILER
1622
#define ARM_FUNCTION_PROFILER(STREAM, LABELNO)  	\
nickc's avatar
nickc committed
1623 1624 1625 1626
{							\
  char temp[20];					\
  rtx sym;						\
							\
nickc's avatar
nickc committed
1627
  asm_fprintf (STREAM, "\tmov\t%r, %r\n\tbl\t",		\
1628
	   IP_REGNUM, LR_REGNUM);			\
nickc's avatar
nickc committed
1629 1630 1631
  assemble_name (STREAM, ARM_MCOUNT_NAME);		\
  fputc ('\n', STREAM);					\
  ASM_GENERATE_INTERNAL_LABEL (temp, "LP", LABELNO);	\
1632
  sym = gen_rtx_SYMBOL_REF (Pmode, temp);		\
1633
  assemble_aligned_integer (UNITS_PER_WORD, sym);	\
rms's avatar
rms committed
1634
}
nickc's avatar
nickc committed
1635
#endif
rms's avatar
rms committed
1636

nickc's avatar
nickc committed
1637
#ifdef THUMB_FUNCTION_PROFILER
1638 1639 1640 1641 1642
#define FUNCTION_PROFILER(STREAM, LABELNO)		\
  if (TARGET_ARM)					\
    ARM_FUNCTION_PROFILER (STREAM, LABELNO)		\
  else							\
    THUMB_FUNCTION_PROFILER (STREAM, LABELNO)
nickc's avatar
nickc committed
1643 1644 1645 1646
#else
#define FUNCTION_PROFILER(STREAM, LABELNO)		\
    ARM_FUNCTION_PROFILER (STREAM, LABELNO)
#endif
1647

rms's avatar
rms committed
1648 1649 1650 1651 1652 1653 1654 1655 1656
/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
   the stack pointer does not matter.  The value is tested only in
   functions that have frame pointers.
   No definition is equivalent to always zero.

   On the ARM, the function epilogue recovers the stack pointer from the
   frame.  */
#define EXIT_IGNORE_STACK 1

dberlin's avatar
dberlin committed
1657
#define EPILOGUE_USES(REGNO) ((REGNO) == LR_REGNUM)
1658

rms's avatar
rms committed
1659 1660
/* Determine if the epilogue should be output as RTL.
   You should override this if you define FUNCTION_EXTRA_EPILOGUE.  */
1661
#define USE_RETURN_INSN(ISCOND)				\
jules's avatar
gcc/  
jules committed
1662
  (TARGET_32BIT ? use_return_insn (ISCOND, NULL) : 0)
1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674

/* Definitions for register eliminations.

   This is an array of structures.  Each structure initializes one pair
   of eliminable registers.  The "from" register number is given first,
   followed by "to".  Eliminations of the same "from" register are listed
   in order of preference.

   We have two registers that can be eliminated on the ARM.  First, the
   arg pointer register can often be eliminated in favor of the stack
   pointer register.  Secondly, the pseudo frame pointer register can always
   be eliminated; it is replaced with either the stack or the real frame
1675
   pointer.  Note we have to use {ARM|THUMB}_HARD_FRAME_POINTER_REGNUM
1676
   because the definition of HARD_FRAME_POINTER_REGNUM is not a constant.  */
1677

1678 1679 1680 1681 1682 1683 1684 1685
#define ELIMINABLE_REGS						\
{{ ARG_POINTER_REGNUM,        STACK_POINTER_REGNUM            },\
 { ARG_POINTER_REGNUM,        FRAME_POINTER_REGNUM            },\
 { ARG_POINTER_REGNUM,        ARM_HARD_FRAME_POINTER_REGNUM   },\
 { ARG_POINTER_REGNUM,        THUMB_HARD_FRAME_POINTER_REGNUM },\
 { FRAME_POINTER_REGNUM,      STACK_POINTER_REGNUM            },\
 { FRAME_POINTER_REGNUM,      ARM_HARD_FRAME_POINTER_REGNUM   },\
 { FRAME_POINTER_REGNUM,      THUMB_HARD_FRAME_POINTER_REGNUM }}
1686

1687 1688 1689 1690
/* Define the offset between two registers, one to be eliminated, and the
   other its replacement, at the start of a routine.  */
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)			\
  if (TARGET_ARM)							\
pbrook's avatar
pbrook committed
1691
    (OFFSET) = arm_compute_initial_elimination_offset (FROM, TO);	\
1692
  else									\
pbrook's avatar
pbrook committed
1693 1694
    (OFFSET) = thumb_compute_initial_elimination_offset (FROM, TO)

1695 1696
/* Special case handling of the location of arguments passed on the stack.  */
#define DEBUGGER_ARG_OFFSET(value, addr) value ? value : arm_debugger_arg_offset (value, addr)
1697

1698 1699 1700 1701
/* Initialize data used by insn expanders.  This is called from insn_emit,
   once for every function before code is generated.  */
#define INIT_EXPANDERS  arm_init_expanders ()

rms's avatar
rms committed
1702
/* Length in units of the trampoline for entering a nested function.  */
1703
#define TRAMPOLINE_SIZE  (TARGET_32BIT ? 16 : 20)
rms's avatar
rms committed
1704

1705 1706
/* Alignment required for a trampoline in bits.  */
#define TRAMPOLINE_ALIGNMENT  32
rms's avatar
rms committed
1707 1708

/* Addressing modes, and classification of registers for them.  */
1709
#define HAVE_POST_INCREMENT   1
1710 1711 1712 1713 1714 1715 1716
#define HAVE_PRE_INCREMENT    TARGET_32BIT
#define HAVE_POST_DECREMENT   TARGET_32BIT
#define HAVE_PRE_DECREMENT    TARGET_32BIT
#define HAVE_PRE_MODIFY_DISP  TARGET_32BIT
#define HAVE_POST_MODIFY_DISP TARGET_32BIT
#define HAVE_PRE_MODIFY_REG   TARGET_32BIT
#define HAVE_POST_MODIFY_REG  TARGET_32BIT
rms's avatar
rms committed
1717 1718 1719 1720 1721 1722 1723

/* Macros to check register numbers against specific register classes.  */

/* These assume that REGNO is a hard or pseudo reg number.
   They give nonzero only if REGNO is a hard reg of the suitable class
   or a pseudo reg currently allocated to a suitable hard reg.
   Since they use reg_renumber, they are safe only once reg_renumber
1724
   has been allocated, which happens in local-alloc.c.  */
1725 1726 1727
#define TEST_REGNO(R, TEST, VALUE) \
  ((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE))

1728
/* Don't allow the pc to be used.  */
1729 1730 1731 1732 1733
#define ARM_REGNO_OK_FOR_BASE_P(REGNO)			\
  (TEST_REGNO (REGNO, <, PC_REGNUM)			\
   || TEST_REGNO (REGNO, ==, FRAME_POINTER_REGNUM)	\
   || TEST_REGNO (REGNO, ==, ARG_POINTER_REGNUM))

1734
#define THUMB1_REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE)		\
1735 1736 1737 1738 1739
  (TEST_REGNO (REGNO, <=, LAST_LO_REGNUM)			\
   || (GET_MODE_SIZE (MODE) >= 4				\
       && TEST_REGNO (REGNO, ==, STACK_POINTER_REGNUM)))

#define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE)		\
1740 1741
  (TARGET_THUMB1					\
   ? THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO, MODE)	\
1742 1743
   : ARM_REGNO_OK_FOR_BASE_P (REGNO))

1744 1745 1746
/* Nonzero if X can be the base register in a reg+reg addressing mode.
   For Thumb, we can not use SP + reg, so reject SP.  */
#define REGNO_MODE_OK_FOR_REG_BASE_P(X, MODE)	\
1747
  REGNO_MODE_OK_FOR_BASE_P (X, QImode)
1748

1749 1750
/* For ARM code, we don't care about the mode, but for Thumb, the index
   must be suitable for use in a QImode load.  */
1751
#define REGNO_OK_FOR_INDEX_P(REGNO)	\
1752 1753
  (REGNO_MODE_OK_FOR_BASE_P (REGNO, QImode) \
   && !TEST_REGNO (REGNO, ==, STACK_POINTER_REGNUM))
rms's avatar
rms committed
1754 1755

/* Maximum number of registers that can appear in a valid memory address.
1756
   Shifts in addresses can't be by a register.  */
1757
#define MAX_REGS_PER_ADDRESS 2
rms's avatar
rms committed
1758 1759 1760

/* Recognize any constant value that is a valid address.  */
/* XXX We can address any constant, eventually...  */
1761
/* ??? Should the TARGET_ARM here also apply to thumb2?  */
erich's avatar
erich committed
1762 1763 1764
#define CONSTANT_ADDRESS_P(X)  			\
  (GET_CODE (X) == SYMBOL_REF 			\
   && (CONSTANT_POOL_ADDRESS_P (X)		\
1765
       || (TARGET_ARM && optimize > 0 && SYMBOL_REF_FLAG (X))))
rms's avatar
rms committed
1766

rsandifo's avatar
gcc/  
rsandifo committed
1767 1768 1769 1770
/* True if SYMBOL + OFFSET constants must refer to something within
   SYMBOL's section.  */
#define ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P 0

1771 1772 1773 1774 1775
/* Nonzero if all target requires all absolute relocations be R_ARM_ABS32.  */
#ifndef TARGET_DEFAULT_WORD_RELOCATIONS
#define TARGET_DEFAULT_WORD_RELOCATIONS 0
#endif

rms's avatar
rms committed
1776 1777 1778 1779 1780
/* Nonzero if the constant value X is a legitimate general operand.
   It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.

   On the ARM, allow any integer (invalid ones are removed later by insn
   patterns), nice doubles and symbol_refs which refer to the function's
1781
   constant pool XXX.
1782

1783
   When generating pic allow anything.  */
1784 1785 1786 1787 1788
#define ARM_LEGITIMATE_CONSTANT_P(X)	(flag_pic || ! label_mentioned_p (X))

#define THUMB_LEGITIMATE_CONSTANT_P(X)	\
 (   GET_CODE (X) == CONST_INT		\
  || GET_CODE (X) == CONST_DOUBLE	\
1789 1790
  || CONSTANT_ADDRESS_P (X)		\
  || flag_pic)
1791

1792
#define LEGITIMATE_CONSTANT_P(X)			\
rsandifo's avatar
gcc/  
rsandifo committed
1793
  (!arm_cannot_force_const_mem (X)			\
1794 1795
   && (TARGET_32BIT ? ARM_LEGITIMATE_CONSTANT_P (X)	\
		    : THUMB_LEGITIMATE_CONSTANT_P (X)))
1796

1797 1798 1799 1800
#ifndef SUBTARGET_NAME_ENCODING_LENGTHS
#define SUBTARGET_NAME_ENCODING_LENGTHS
#endif

1801
/* This is a C fragment for the inside of a switch statement.
1802 1803 1804 1805
   Each case label should return the number of characters to
   be stripped from the start of a function's name, if that
   name starts with the indicated character.  */
#define ARM_NAME_ENCODING_LENGTHS		\
nickc's avatar
nickc committed
1806
  case '*':  return 1;				\
1807
  SUBTARGET_NAME_ENCODING_LENGTHS
1808 1809 1810

/* This is how to output a reference to a user-level label named NAME.
   `assemble_name' uses this.  */
1811
#undef  ASM_OUTPUT_LABELREF
1812
#define ASM_OUTPUT_LABELREF(FILE, NAME)		\
1813
   arm_asm_output_labelref (FILE, NAME)
1814

1815
/* Output IT instructions for conditionally executed Thumb-2 instructions.  */
1816 1817 1818 1819
#define ASM_OUTPUT_OPCODE(STREAM, PTR)	\
  if (TARGET_THUMB2)			\
    thumb2_asm_output_opcode (STREAM);

1820 1821
/* The EABI specifies that constructors should go in .init_array.
   Other targets use .ctors for compatibility.  */
1822
#ifndef ARM_EABI_CTORS_SECTION_OP
1823 1824
#define ARM_EABI_CTORS_SECTION_OP \
  "\t.section\t.init_array,\"aw\",%init_array"
1825 1826
#endif
#ifndef ARM_EABI_DTORS_SECTION_OP
1827 1828
#define ARM_EABI_DTORS_SECTION_OP \
  "\t.section\t.fini_array,\"aw\",%fini_array"
1829
#endif
1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865
#define ARM_CTORS_SECTION_OP \
  "\t.section\t.ctors,\"aw\",%progbits"
#define ARM_DTORS_SECTION_OP \
  "\t.section\t.dtors,\"aw\",%progbits"

/* Define CTORS_SECTION_ASM_OP.  */
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
#ifndef IN_LIBGCC2
# define CTORS_SECTION_ASM_OP \
   (TARGET_AAPCS_BASED ? ARM_EABI_CTORS_SECTION_OP : ARM_CTORS_SECTION_OP)
# define DTORS_SECTION_ASM_OP \
   (TARGET_AAPCS_BASED ? ARM_EABI_DTORS_SECTION_OP : ARM_DTORS_SECTION_OP)
#else /* !defined (IN_LIBGCC2) */
/* In libgcc, CTORS_SECTION_ASM_OP must be a compile-time constant,
   so we cannot use the definition above.  */
# ifdef __ARM_EABI__
/* The .ctors section is not part of the EABI, so we do not define
   CTORS_SECTION_ASM_OP when in libgcc; that prevents crtstuff
   from trying to use it.  We do define it when doing normal
   compilation, as .init_array can be used instead of .ctors.  */
/* There is no need to emit begin or end markers when using
   init_array; the dynamic linker will compute the size of the
   array itself based on special symbols created by the static
   linker.  However, we do need to arrange to set up
   exception-handling here.  */
#   define CTOR_LIST_BEGIN asm (ARM_EABI_CTORS_SECTION_OP)
#   define CTOR_LIST_END /* empty */
#   define DTOR_LIST_BEGIN asm (ARM_EABI_DTORS_SECTION_OP)
#   define DTOR_LIST_END /* empty */
# else /* !defined (__ARM_EABI__) */
#   define CTORS_SECTION_ASM_OP ARM_CTORS_SECTION_OP
#   define DTORS_SECTION_ASM_OP ARM_DTORS_SECTION_OP
# endif /* !defined (__ARM_EABI__) */
#endif /* !defined (IN_LIBCC2) */

1866 1867 1868 1869 1870 1871
/* True if the operating system can merge entities with vague linkage
   (e.g., symbols in COMDAT group) during dynamic linking.  */
#ifndef TARGET_ARM_DYNAMIC_VAGUE_LINKAGE_P
#define TARGET_ARM_DYNAMIC_VAGUE_LINKAGE_P true
#endif

1872 1873
#define ARM_OUTPUT_FN_UNWIND(F, PROLOGUE) arm_output_fn_unwind (F, PROLOGUE)

rms's avatar
rms committed
1874 1875 1876 1877 1878
/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
   and check its validity for a certain class.
   We have two alternate definitions for each of them.
   The usual definition accepts all pseudo regs; the other rejects
   them unless they have been allocated suitable hard regs.
1879
   The symbol REG_OK_STRICT causes the latter definition to be used.
1880
   Thumb-2 has the same restrictions as arm.  */
rms's avatar
rms committed
1881
#ifndef REG_OK_STRICT
1882

1883 1884 1885 1886 1887
#define ARM_REG_OK_FOR_BASE_P(X)		\
  (REGNO (X) <= LAST_ARM_REGNUM			\
   || REGNO (X) >= FIRST_PSEUDO_REGISTER	\
   || REGNO (X) == FRAME_POINTER_REGNUM		\
   || REGNO (X) == ARG_POINTER_REGNUM)
1888

1889 1890 1891 1892 1893 1894 1895
#define ARM_REG_OK_FOR_INDEX_P(X)		\
  ((REGNO (X) <= LAST_ARM_REGNUM		\
    && REGNO (X) != STACK_POINTER_REGNUM)	\
   || REGNO (X) >= FIRST_PSEUDO_REGISTER	\
   || REGNO (X) == FRAME_POINTER_REGNUM		\
   || REGNO (X) == ARG_POINTER_REGNUM)

1896
#define THUMB1_REG_MODE_OK_FOR_BASE_P(X, MODE)	\
1897 1898 1899 1900 1901 1902
  (REGNO (X) <= LAST_LO_REGNUM			\
   || REGNO (X) >= FIRST_PSEUDO_REGISTER	\
   || (GET_MODE_SIZE (MODE) >= 4		\
       && (REGNO (X) == STACK_POINTER_REGNUM	\
	   || (X) == hard_frame_pointer_rtx	\
	   || (X) == arg_pointer_rtx)))
1903

1904 1905
#define REG_STRICT_P 0

1906
#else /* REG_OK_STRICT */
1907

1908 1909
#define ARM_REG_OK_FOR_BASE_P(X) 		\
  ARM_REGNO_OK_FOR_BASE_P (REGNO (X))
1910

1911 1912 1913
#define ARM_REG_OK_FOR_INDEX_P(X) 		\
  ARM_REGNO_OK_FOR_INDEX_P (REGNO (X))

1914 1915
#define THUMB1_REG_MODE_OK_FOR_BASE_P(X, MODE)	\
  THUMB1_REGNO_MODE_OK_FOR_BASE_P (REGNO (X), MODE)
1916

1917 1918
#define REG_STRICT_P 1

1919
#endif /* REG_OK_STRICT */
1920 1921 1922 1923

/* Now define some helpers in terms of the above.  */

#define REG_MODE_OK_FOR_BASE_P(X, MODE)		\
1924 1925
  (TARGET_THUMB1				\
   ? THUMB1_REG_MODE_OK_FOR_BASE_P (X, MODE)	\
1926 1927
   : ARM_REG_OK_FOR_BASE_P (X))

1928
/* For 16-bit Thumb, a valid index register is anything that can be used in
1929
   a byte load instruction.  */
1930 1931
#define THUMB1_REG_OK_FOR_INDEX_P(X) \
  THUMB1_REG_MODE_OK_FOR_BASE_P (X, QImode)
1932 1933 1934 1935 1936

/* Nonzero if X is a hard reg that can be used as an index
   or if it is a pseudo reg.  On the Thumb, the stack pointer
   is not suitable.  */
#define REG_OK_FOR_INDEX_P(X)			\
1937 1938
  (TARGET_THUMB1				\
   ? THUMB1_REG_OK_FOR_INDEX_P (X)		\
1939 1940
   : ARM_REG_OK_FOR_INDEX_P (X))

1941 1942 1943 1944
/* Nonzero if X can be the base register in a reg+reg addressing mode.
   For Thumb, we can not use SP + reg, so reject SP.  */
#define REG_MODE_OK_FOR_REG_BASE_P(X, MODE)	\
  REG_OK_FOR_INDEX_P (X)
rms's avatar
rms committed
1945

1946 1947
#define ARM_BASE_REGISTER_RTX_P(X)  \
  (GET_CODE (X) == REG && ARM_REG_OK_FOR_BASE_P (X))
rms's avatar
rms committed
1948

1949 1950
#define ARM_INDEX_REGISTER_RTX_P(X)  \
  (GET_CODE (X) == REG && ARM_REG_OK_FOR_INDEX_P (X))
rms's avatar
rms committed
1951 1952 1953

/* Specify the machine mode that this machine uses
   for the index in the tablejump instruction.  */
1954
#define CASE_VECTOR_MODE Pmode
rms's avatar
rms committed
1955

1956
#define CASE_VECTOR_PC_RELATIVE (TARGET_THUMB2				\
ramana's avatar
ramana committed
1957
				 || (TARGET_THUMB1			\
1958 1959 1960
				     && (optimize_size || flag_pic)))

#define CASE_VECTOR_SHORTEN_MODE(min, max, body)			\
ramana's avatar
ramana committed
1961
  (TARGET_THUMB1							\
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973
   ? (min >= 0 && max < 512						\
      ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 1, QImode)	\
      : min >= -256 && max < 256					\
      ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 0, QImode)	\
      : min >= 0 && max < 8192						\
      ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 1, HImode)	\
      : min >= -4096 && max < 4096					\
      ? (ADDR_DIFF_VEC_FLAGS (body).offset_unsigned = 0, HImode)	\
      : SImode)								\
   : ((min < 0 || max >= 0x2000 || !TARGET_THUMB2) ? SImode		\
      : (max >= 0x200) ? HImode						\
      : QImode))
1974

1975 1976 1977
/* signed 'char' is most compatible, but RISC OS wants it unsigned.
   unsigned is probably best, but may break some code.  */
#ifndef DEFAULT_SIGNED_CHAR
erich's avatar
erich committed
1978
#define DEFAULT_SIGNED_CHAR  0
rms's avatar
rms committed
1979 1980 1981
#endif

/* Max number of bytes we can move from memory to memory
tege's avatar
tege committed
1982 1983
   in one reasonably fast instruction.  */
#define MOVE_MAX 4
rms's avatar
rms committed
1984

nickc's avatar
nickc committed
1985
#undef  MOVE_RATIO
hubicka's avatar
 
hubicka committed
1986
#define MOVE_RATIO(speed) (arm_tune_xscale ? 4 : 2)
nickc's avatar
nickc committed
1987

1988 1989 1990 1991 1992 1993 1994
/* Define if operations between registers always perform the operation
   on the full register even if a narrower mode is specified.  */
#define WORD_REGISTER_OPERATIONS

/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
   will either zero-extend or sign-extend.  The value of this macro should
   be the code that says which one of the two operations is implicitly
zack's avatar
zack committed
1995
   done, UNKNOWN if none.  */
1996
#define LOAD_EXTEND_OP(MODE)						\
1997 1998
  (TARGET_THUMB ? ZERO_EXTEND :						\
   ((arm_arch4 || (MODE) == QImode) ? ZERO_EXTEND			\
zack's avatar
zack committed
1999
    : ((BYTES_BIG_ENDIAN && (MODE) == HImode) ? SIGN_EXTEND : UNKNOWN)))
2000

rms's avatar
rms committed
2001 2002 2003
/* Nonzero if access to memory by bytes is slow and undesirable.  */
#define SLOW_BYTE_ACCESS 0

2004
#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 1
2005

rms's avatar
rms committed
2006 2007 2008 2009 2010
/* Immediate shift counts are truncated by the output routines (or was it
   the assembler?).  Shift counts in a register are truncated by ARM.  Note
   that the native compiler puts too large (> 32) immediate shift counts
   into a register and shifts by the register, letting the ARM decide what
   to do instead of doing that itself.  */
2011 2012 2013
/* This is all wrong.  Defining SHIFT_COUNT_TRUNCATED tells combine that
   code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
   On the arm, Y in a register is used modulo 256 for the shift. Only for
2014
   rotates is modulo 32 used.  */
2015
/* #define SHIFT_COUNT_TRUNCATED 1 */
rms's avatar
rms committed
2016 2017

/* All integers have the same format so truncation is easy.  */
2018
#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC)  1
rms's avatar
rms committed
2019 2020 2021 2022 2023 2024 2025 2026

/* Calling from registers is a massive pain.  */
#define NO_FUNCTION_CSE 1

/* The machine modes of pointers and functions */
#define Pmode  SImode
#define FUNCTION_MODE  Pmode

2027 2028
#define ARM_FRAME_RTX(X)					\
  (   (X) == frame_pointer_rtx || (X) == stack_pointer_rtx	\
erich's avatar
erich committed
2029 2030
   || (X) == arg_pointer_rtx)

2031
/* Moves to and from memory are quite expensive */
2032
#define MEMORY_MOVE_COST(M, CLASS, IN)			\
2033
  (TARGET_32BIT ? 10 :					\
2034 2035
   ((GET_MODE_SIZE (M) < 4 ? 8 : 2 * GET_MODE_SIZE (M))	\
    * (CLASS == LO_REGS ? 1 : 2)))
2036

2037 2038
/* Try to generate sequences that don't involve branches, we can then use
   conditional instructions */
2039
#define BRANCH_COST(speed_p, predictable_p) \
2040
  (TARGET_32BIT ? 4 : (optimize > 0 ? 2 : 0))
2041 2042 2043 2044 2045

/* Position Independent Code.  */
/* We decide which register to use based on the compilation options and
   the assembler in use; this is more general than the APCS restriction of
   using sb (r9) all the time.  */
rearnsha's avatar
rearnsha committed
2046
extern unsigned arm_pic_register;
2047 2048 2049 2050 2051

/* The register number of the register used to address a table of static
   data addresses in memory.  */
#define PIC_OFFSET_TABLE_REGNUM arm_pic_register

nickc's avatar
nickc committed
2052
/* We can't directly access anything that contains a symbol,
2053 2054
   nor can we indirect via the constant pool.  One exception is
   UNSPEC_TLS, which is always PIC.  */
2055
#define LEGITIMATE_PIC_OPERAND_P(X)					\
2056 2057 2058 2059 2060
	(!(symbol_mentioned_p (X)					\
	   || label_mentioned_p (X)					\
	   || (GET_CODE (X) == SYMBOL_REF				\
	       && CONSTANT_POOL_ADDRESS_P (X)				\
	       && (symbol_mentioned_p (get_pool_constant (X))		\
2061 2062
		   || label_mentioned_p (get_pool_constant (X)))))	\
	 || tls_mentioned_p (X))
2063

2064 2065 2066 2067
/* We need to know when we are making a constant pool; this determines
   whether data needs to be in the GOT or can be referenced via a GOT
   offset.  */
extern int making_const_table;
2068

2069
/* Handle pragmas for compatibility with Intel's compilers.  */
2070
/* Also abuse this to register additional C specific EABI attributes.  */
2071 2072 2073 2074
#define REGISTER_TARGET_PRAGMAS() do {					\
  c_register_pragma (0, "long_calls", arm_pr_long_calls);		\
  c_register_pragma (0, "no_long_calls", arm_pr_no_long_calls);		\
  c_register_pragma (0, "long_calls_off", arm_pr_long_calls_off);	\
2075
  arm_lang_object_attributes_init(); \
2076 2077
} while (0)

2078
/* Condition code information.  */
2079
/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
2080
   return the mode to be used for the comparison.  */
2081 2082

#define SELECT_CC_MODE(OP, X, Y)  arm_select_cc_mode (OP, X, Y)
2083

2084 2085 2086 2087 2088 2089
#define REVERSIBLE_CC_MODE(MODE) 1

#define REVERSE_CONDITION(CODE,MODE) \
  (((MODE) == CCFPmode || (MODE) == CCFPEmode) \
   ? reverse_condition_maybe_unordered (code) \
   : reverse_condition (code))
erich's avatar
erich committed
2090

2091
#define CANONICALIZE_COMPARISON(CODE, OP0, OP1)				\
2092
  (CODE) = arm_canonicalize_comparison (CODE, &(OP0), &(OP1))
2093

2094 2095
/* The arm5 clz instruction returns 32.  */
#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 32, 1)
2096
#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 32, 1)
rms's avatar
rms committed
2097

2098 2099 2100
#define CC_STATUS_INIT \
  do { cfun->machine->thumb1_cc_insn = NULL_RTX; } while (0)

2101
#undef  ASM_APP_OFF
2102 2103
#define ASM_APP_OFF (TARGET_THUMB1 ? "\t.code\t16\n" : \
		     TARGET_THUMB2 ? "\t.thumb\n" : "")
rms's avatar
rms committed
2104

jules's avatar
gcc/  
jules committed
2105 2106 2107 2108 2109 2110
/* Output a push or a pop instruction (only used when profiling).
   We can't push STATIC_CHAIN_REGNUM (r12) directly with Thumb-1.  We know
   that ASM_OUTPUT_REG_PUSH will be matched with ASM_OUTPUT_REG_POP, and
   that r7 isn't used by the function profiler, so we can use it as a
   scratch reg.  WARNING: This isn't safe in the general case!  It may be
   sensitive to future changes in final.c:profile_function.  */
2111
#define ASM_OUTPUT_REG_PUSH(STREAM, REGNO)		\
2112 2113 2114 2115 2116
  do							\
    {							\
      if (TARGET_ARM)					\
	asm_fprintf (STREAM,"\tstmfd\t%r!,{%r}\n",	\
		     STACK_POINTER_REGNUM, REGNO);	\
jules's avatar
gcc/  
jules committed
2117 2118 2119 2120 2121 2122 2123
      else if (TARGET_THUMB1				\
	       && (REGNO) == STATIC_CHAIN_REGNUM)	\
	{						\
	  asm_fprintf (STREAM, "\tpush\t{r7}\n");	\
	  asm_fprintf (STREAM, "\tmov\tr7, %r\n", REGNO);\
	  asm_fprintf (STREAM, "\tpush\t{r7}\n");	\
	}						\
2124 2125 2126
      else						\
	asm_fprintf (STREAM, "\tpush {%r}\n", REGNO);	\
    } while (0)
2127 2128


jules's avatar
gcc/  
jules committed
2129
/* See comment for ASM_OUTPUT_REG_PUSH concerning Thumb-1 issue.  */
2130
#define ASM_OUTPUT_REG_POP(STREAM, REGNO)		\
2131 2132 2133 2134 2135
  do							\
    {							\
      if (TARGET_ARM)					\
	asm_fprintf (STREAM, "\tldmfd\t%r!,{%r}\n",	\
		     STACK_POINTER_REGNUM, REGNO);	\
jules's avatar
gcc/  
jules committed
2136 2137 2138 2139 2140 2141 2142
      else if (TARGET_THUMB1				\
	       && (REGNO) == STATIC_CHAIN_REGNUM)	\
	{						\
	  asm_fprintf (STREAM, "\tpop\t{r7}\n");	\
	  asm_fprintf (STREAM, "\tmov\t%r, r7\n", REGNO);\
	  asm_fprintf (STREAM, "\tpop\t{r7}\n");	\
	}						\
2143 2144 2145
      else						\
	asm_fprintf (STREAM, "\tpop {%r}\n", REGNO);	\
    } while (0)
2146

2147 2148 2149
/* Jump table alignment is explicit in ASM_OUTPUT_CASE_LABEL.  */
#define ADDR_VEC_ALIGN(JUMPTABLE) 0

2150 2151
/* This is how to output a label which precedes a jumptable.  Since
   Thumb instructions are 2 bytes, we may need explicit alignment here.  */
nickc's avatar
nickc committed
2152
#undef  ASM_OUTPUT_CASE_LABEL
2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168
#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)		\
  do									\
    {									\
      if (TARGET_THUMB && GET_MODE (PATTERN (JUMPTABLE)) == SImode)	\
        ASM_OUTPUT_ALIGN (FILE, 2);					\
      (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM);		\
    }									\
  while (0)

/* Make sure subsequent insns are aligned after a TBB.  */
#define ASM_OUTPUT_CASE_END(FILE, NUM, JUMPTABLE)	\
  do							\
    {							\
      if (GET_MODE (PATTERN (JUMPTABLE)) == QImode)	\
	ASM_OUTPUT_ALIGN (FILE, 1);			\
    }							\
2169
  while (0)
rms's avatar
rms committed
2170

nickc's avatar
nickc committed
2171 2172 2173
#define ARM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) 	\
  do							\
    {							\
2174 2175
      if (TARGET_THUMB) 				\
        {						\
2176
          if (is_called_in_ARM_mode (DECL)		\
2177
	      || (TARGET_THUMB1 && !TARGET_THUMB1_ONLY	\
2178
		  && cfun->is_thunk))	\
2179
            fprintf (STREAM, "\t.code 32\n") ;		\
2180 2181
          else if (TARGET_THUMB1)			\
           fprintf (STREAM, "\t.code\t16\n\t.thumb_func\n") ;	\
2182
          else						\
2183
           fprintf (STREAM, "\t.thumb\n\t.thumb_func\n") ;	\
2184
        }						\
nickc's avatar
nickc committed
2185
      if (TARGET_POKE_FUNCTION_NAME)			\
2186
        arm_poke_function_name (STREAM, (const char *) NAME);	\
nickc's avatar
nickc committed
2187 2188
    }							\
  while (0)
rms's avatar
rms committed
2189

2190 2191 2192 2193
/* For aliases of functions we use .thumb_set instead.  */
#define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL1, DECL2)		\
  do						   		\
    {								\
2194 2195
      const char *const LABEL1 = XSTR (XEXP (DECL_RTL (decl), 0), 0); \
      const char *const LABEL2 = IDENTIFIER_POINTER (DECL2);	\
2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209
								\
      if (TARGET_THUMB && TREE_CODE (DECL1) == FUNCTION_DECL)	\
	{							\
	  fprintf (FILE, "\t.thumb_set ");			\
	  assemble_name (FILE, LABEL1);			   	\
	  fprintf (FILE, ",");			   		\
	  assemble_name (FILE, LABEL2);		   		\
	  fprintf (FILE, "\n");					\
	}							\
      else							\
	ASM_OUTPUT_DEF (FILE, LABEL1, LABEL2);			\
    }								\
  while (0)

2210 2211 2212 2213
#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
/* To support -falign-* switches we need to use .p2align so
   that alignment directives in code sections will be padded
   with no-op instructions, rather than zeroes.  */
2214
#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)		\
2215 2216 2217
  if ((LOG) != 0)						\
    {								\
      if ((MAX_SKIP) == 0)					\
2218
        fprintf ((FILE), "\t.p2align %d\n", (int) (LOG));	\
2219 2220
      else							\
        fprintf ((FILE), "\t.p2align %d,,%d\n",			\
2221
                 (int) (LOG), (int) (MAX_SKIP));		\
2222 2223
    }
#endif
rms's avatar
rms committed
2224

2225 2226 2227 2228 2229 2230
/* Add two bytes to the length of conditionally executed Thumb-2
   instructions for the IT instruction.  */
#define ADJUST_INSN_LENGTH(insn, length) \
  if (TARGET_THUMB2 && GET_CODE (PATTERN (insn)) == COND_EXEC) \
    length += 2;

rms's avatar
rms committed
2231
/* Only perform branch elimination (by making instructions conditional) if
2232 2233
   we're optimizing.  For Thumb-2 check if any IT instructions need
   outputting.  */
2234 2235 2236
#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS)	\
  if (TARGET_ARM && optimize)				\
    arm_final_prescan_insn (INSN);			\
2237 2238 2239 2240
  else if (TARGET_THUMB2)				\
    thumb2_final_prescan_insn (INSN);			\
  else if (TARGET_THUMB1)				\
    thumb1_final_prescan_insn (INSN)
rms's avatar
rms committed
2241

2242 2243
#define ARM_SIGN_EXTEND(x)  ((HOST_WIDE_INT)			\
  (HOST_BITS_PER_WIDE_INT <= 32 ? (unsigned HOST_WIDE_INT) (x)	\
2244 2245 2246 2247
   : ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0xffffffff) |\
      ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0x80000000) \
       ? ((~ (unsigned HOST_WIDE_INT) 0)			\
	  & ~ (unsigned HOST_WIDE_INT) 0xffffffff)		\
2248
       : 0))))
rms's avatar
rms committed
2249

mrs's avatar
mrs committed
2250 2251 2252
/* A C expression whose value is RTL representing the value of the return
   address for the frame COUNT steps up from the current frame.  */

2253 2254 2255
#define RETURN_ADDR_RTX(COUNT, FRAME) \
  arm_return_addr (COUNT, FRAME)

2256
/* Mask of the bits in the PC that contain the real return address
2257 2258
   when running in 26-bit mode.  */
#define RETURN_ADDR_MASK26 (0x03fffffc)
mrs's avatar
mrs committed
2259

2260 2261 2262 2263 2264 2265
/* Pick up the return address upon entry to a procedure. Used for
   dwarf2 unwind information.  This also enables the table driven
   mechanism.  */
#define INCOMING_RETURN_ADDR_RTX	gen_rtx_REG (Pmode, LR_REGNUM)
#define DWARF_FRAME_RETURN_COLUMN	DWARF_FRAME_REGNUM (LR_REGNUM)

mrs's avatar
mrs committed
2266 2267 2268 2269 2270 2271 2272
/* Used to mask out junk bits from the return address, such as
   processor state, interrupt status, condition codes and the like.  */
#define MASK_RETURN_ADDR \
  /* If we are generating code for an ARM2/ARM3 machine or for an ARM6	\
     in 26 bit mode, the condition codes must be masked out of the	\
     return address.  This does not apply to ARM6 and later processors	\
     when running in 32 bit mode.  */					\
rearnsha's avatar
rearnsha committed
2273 2274
  ((arm_arch4 || TARGET_THUMB)						\
   ? (gen_int_mode ((unsigned long)0xffffffff, Pmode))			\
2275
   : arm_gen_return_addr_mask ())
2276 2277


jules's avatar
gcc/  
jules committed
2278 2279 2280
/* Neon defines builtins from ARM_BUILTIN_MAX upwards, though they don't have
   symbolic names defined here (which would require too much duplication).
   FIXME?  */
2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390
enum arm_builtins
{
  ARM_BUILTIN_GETWCX,
  ARM_BUILTIN_SETWCX,

  ARM_BUILTIN_WZERO,

  ARM_BUILTIN_WAVG2BR,
  ARM_BUILTIN_WAVG2HR,
  ARM_BUILTIN_WAVG2B,
  ARM_BUILTIN_WAVG2H,

  ARM_BUILTIN_WACCB,
  ARM_BUILTIN_WACCH,
  ARM_BUILTIN_WACCW,

  ARM_BUILTIN_WMACS,
  ARM_BUILTIN_WMACSZ,
  ARM_BUILTIN_WMACU,
  ARM_BUILTIN_WMACUZ,

  ARM_BUILTIN_WSADB,
  ARM_BUILTIN_WSADBZ,
  ARM_BUILTIN_WSADH,
  ARM_BUILTIN_WSADHZ,

  ARM_BUILTIN_WALIGN,

  ARM_BUILTIN_TMIA,
  ARM_BUILTIN_TMIAPH,
  ARM_BUILTIN_TMIABB,
  ARM_BUILTIN_TMIABT,
  ARM_BUILTIN_TMIATB,
  ARM_BUILTIN_TMIATT,

  ARM_BUILTIN_TMOVMSKB,
  ARM_BUILTIN_TMOVMSKH,
  ARM_BUILTIN_TMOVMSKW,

  ARM_BUILTIN_TBCSTB,
  ARM_BUILTIN_TBCSTH,
  ARM_BUILTIN_TBCSTW,

  ARM_BUILTIN_WMADDS,
  ARM_BUILTIN_WMADDU,

  ARM_BUILTIN_WPACKHSS,
  ARM_BUILTIN_WPACKWSS,
  ARM_BUILTIN_WPACKDSS,
  ARM_BUILTIN_WPACKHUS,
  ARM_BUILTIN_WPACKWUS,
  ARM_BUILTIN_WPACKDUS,

  ARM_BUILTIN_WADDB,
  ARM_BUILTIN_WADDH,
  ARM_BUILTIN_WADDW,
  ARM_BUILTIN_WADDSSB,
  ARM_BUILTIN_WADDSSH,
  ARM_BUILTIN_WADDSSW,
  ARM_BUILTIN_WADDUSB,
  ARM_BUILTIN_WADDUSH,
  ARM_BUILTIN_WADDUSW,
  ARM_BUILTIN_WSUBB,
  ARM_BUILTIN_WSUBH,
  ARM_BUILTIN_WSUBW,
  ARM_BUILTIN_WSUBSSB,
  ARM_BUILTIN_WSUBSSH,
  ARM_BUILTIN_WSUBSSW,
  ARM_BUILTIN_WSUBUSB,
  ARM_BUILTIN_WSUBUSH,
  ARM_BUILTIN_WSUBUSW,

  ARM_BUILTIN_WAND,
  ARM_BUILTIN_WANDN,
  ARM_BUILTIN_WOR,
  ARM_BUILTIN_WXOR,

  ARM_BUILTIN_WCMPEQB,
  ARM_BUILTIN_WCMPEQH,
  ARM_BUILTIN_WCMPEQW,
  ARM_BUILTIN_WCMPGTUB,
  ARM_BUILTIN_WCMPGTUH,
  ARM_BUILTIN_WCMPGTUW,
  ARM_BUILTIN_WCMPGTSB,
  ARM_BUILTIN_WCMPGTSH,
  ARM_BUILTIN_WCMPGTSW,

  ARM_BUILTIN_TEXTRMSB,
  ARM_BUILTIN_TEXTRMSH,
  ARM_BUILTIN_TEXTRMSW,
  ARM_BUILTIN_TEXTRMUB,
  ARM_BUILTIN_TEXTRMUH,
  ARM_BUILTIN_TEXTRMUW,
  ARM_BUILTIN_TINSRB,
  ARM_BUILTIN_TINSRH,
  ARM_BUILTIN_TINSRW,

  ARM_BUILTIN_WMAXSW,
  ARM_BUILTIN_WMAXSH,
  ARM_BUILTIN_WMAXSB,
  ARM_BUILTIN_WMAXUW,
  ARM_BUILTIN_WMAXUH,
  ARM_BUILTIN_WMAXUB,
  ARM_BUILTIN_WMINSW,
  ARM_BUILTIN_WMINSH,
  ARM_BUILTIN_WMINSB,
  ARM_BUILTIN_WMINUW,
  ARM_BUILTIN_WMINUH,
  ARM_BUILTIN_WMINUB,

bje's avatar
bje committed
2391 2392
  ARM_BUILTIN_WMULUM,
  ARM_BUILTIN_WMULSM,
2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442
  ARM_BUILTIN_WMULUL,

  ARM_BUILTIN_PSADBH,
  ARM_BUILTIN_WSHUFH,

  ARM_BUILTIN_WSLLH,
  ARM_BUILTIN_WSLLW,
  ARM_BUILTIN_WSLLD,
  ARM_BUILTIN_WSRAH,
  ARM_BUILTIN_WSRAW,
  ARM_BUILTIN_WSRAD,
  ARM_BUILTIN_WSRLH,
  ARM_BUILTIN_WSRLW,
  ARM_BUILTIN_WSRLD,
  ARM_BUILTIN_WRORH,
  ARM_BUILTIN_WRORW,
  ARM_BUILTIN_WRORD,
  ARM_BUILTIN_WSLLHI,
  ARM_BUILTIN_WSLLWI,
  ARM_BUILTIN_WSLLDI,
  ARM_BUILTIN_WSRAHI,
  ARM_BUILTIN_WSRAWI,
  ARM_BUILTIN_WSRADI,
  ARM_BUILTIN_WSRLHI,
  ARM_BUILTIN_WSRLWI,
  ARM_BUILTIN_WSRLDI,
  ARM_BUILTIN_WRORHI,
  ARM_BUILTIN_WRORWI,
  ARM_BUILTIN_WRORDI,

  ARM_BUILTIN_WUNPCKIHB,
  ARM_BUILTIN_WUNPCKIHH,
  ARM_BUILTIN_WUNPCKIHW,
  ARM_BUILTIN_WUNPCKILB,
  ARM_BUILTIN_WUNPCKILH,
  ARM_BUILTIN_WUNPCKILW,

  ARM_BUILTIN_WUNPCKEHSB,
  ARM_BUILTIN_WUNPCKEHSH,
  ARM_BUILTIN_WUNPCKEHSW,
  ARM_BUILTIN_WUNPCKEHUB,
  ARM_BUILTIN_WUNPCKEHUH,
  ARM_BUILTIN_WUNPCKEHUW,
  ARM_BUILTIN_WUNPCKELSB,
  ARM_BUILTIN_WUNPCKELSH,
  ARM_BUILTIN_WUNPCKELSW,
  ARM_BUILTIN_WUNPCKELUB,
  ARM_BUILTIN_WUNPCKELUH,
  ARM_BUILTIN_WUNPCKELUW,

2443 2444
  ARM_BUILTIN_THREAD_POINTER,

jules's avatar
gcc/  
jules committed
2445 2446 2447
  ARM_BUILTIN_NEON_BASE,

  ARM_BUILTIN_MAX = ARM_BUILTIN_NEON_BASE  /* FIXME: Wrong!  */
2448
};
2449 2450 2451 2452 2453 2454

/* Do not emit .note.GNU-stack by default.  */
#ifndef NEED_INDICATE_EXEC_STACK
#define NEED_INDICATE_EXEC_STACK	0
#endif

2455 2456 2457 2458
/* The maximum number of parallel loads or stores we support in an ldm/stm
   instruction.  */
#define MAX_LDM_STM_OPS 4

rth's avatar
rth committed
2459
#endif /* ! GCC_ARM_H */