OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [or32/] [or32.h] - Blame information for rev 515

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
/* Definitions of target machine for GNU compiler.  OpenRISC 1000 version.
2
   Copyright (C) 1987, 1988, 1992, 1995, 1996, 1999, 2000, 2001, 2002,
3
   2003, 2004, 2005 Free Software Foundation, Inc.
4 399 jeremybenn
   Copyright (C) 2010 Embecosm Limited
5 282 jeremybenn
   Contributed by Damjan Lampret <damjanl@bsemi.com> in 1999.
6
   Major optimizations by Matjaz Breskvar <matjazb@bsemi.com> in 2005.
7
 
8
This file is part of GNU CC.
9
 
10
GNU CC is free software; you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation; either version 1, or (at your option)
13
any later version.
14
 
15
GNU CC is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
GNU General Public License for more details.
19
 
20
You should have received a copy of the GNU General Public License
21
along with GNU CC; see the file COPYING.  If not, write to
22
the Free Software Foundation, 59 Temple Place - Suite 330,
23
Boston, MA 02111-1307, USA.  */
24
 
25
#ifndef _OR32_H_
26
#define _OR32_H_
27
 
28
/* Target CPU builtins */
29
#define TARGET_CPU_CPP_BUILTINS()               \
30
  do                                            \
31
    {                                           \
32
      builtin_define_std ("OR32");              \
33
      builtin_define_std ("or32");              \
34 452 jeremybenn
      if (or32_libc == or32_libc_uclibc)        \
35
        builtin_define ("__UCLIBC__");          \
36 282 jeremybenn
      builtin_assert ("cpu=or32");              \
37
      builtin_assert ("machine=or32");          \
38
    }                                           \
39
  while (0)
40
 
41
/* A string corresponding to the installation directory for target libraries
42
   and includes. Make it available to SPEC definitions via EXTRA_SPECS */
43
#define CONC_DIR(dir1, dir2) dir1 "/../../" dir2
44
#define TARGET_PREFIX CONC_DIR (STANDARD_EXEC_PREFIX, DEFAULT_TARGET_MACHINE)
45
 
46
#define EXTRA_SPECS                                   \
47
  { "target_prefix", TARGET_PREFIX }
48
 
49
#undef CPP_SPEC
50 473 jeremybenn
#define CPP_SPEC \
51 507 julius
  "%{!mnewlib*:%{pthread:-D_XOPEN_SOURCE=700}}" \
52
  "%{mnewlib*:-idirafter %(target_prefix)/newlib-include}"
53 282 jeremybenn
 
54 402 jeremybenn
/* Make sure we pick up the crti.o, crtbegin.o, crtend.o and crtn.o files. */
55 282 jeremybenn
#undef STARTFILE_SPEC
56 514 jeremybenn
#define STARTFILE_SPEC \
57
  "%{!shared:"\
58
    "%{mnewlib*:%(target_prefix)/lib/crt0.o} "\
59
    "%{mnewlib-*:%(target_prefix)/lib/crtparam-%*.o} "\
60
    "%{!mnewlib*:crt0.o%s} crti.o%s crtbegin.o%s}"
61 282 jeremybenn
 
62
#undef ENDFILE_SPEC
63 399 jeremybenn
#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
64 282 jeremybenn
 
65
/* Specify the newlib library path if necessary */
66
#undef LINK_SPEC
67 507 julius
#define LINK_SPEC "%{mnewlib:-L%(target_prefix)/newlib}"
68 282 jeremybenn
 
69
/* Override previous definitions (linux.h). Newlib doesn't have a profiling
70
   version of the library, but it does have a debugging version (libg.a) */
71
#undef LIB_SPEC 
72 514 jeremybenn
#define LIB_SPEC "%{!mnewlib:"                                           \
73
                   "%{pthread:"                                          \
74
                     "--whole-archive -lpthread --no-whole-archive} "    \
75
                   "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}               \
76
                  %{mnewlib:%{!g:-lc -lor32 -lboard -u free -lc}         \
77
                            %{g:-lg -lor32 -lboard -u free -lg}          \
78
                            %{mboard=*:-L%(target_prefix)/lib/boards/%*} \
79
                            %{!mboard=*:-L%(target_prefix)/lib/boards/or1ksim}}"
80 282 jeremybenn
 
81 333 jeremybenn
#define TARGET_VERSION fprintf (stderr, " (OpenRISC 1000) Mask 0x%x", MASK_HARD_MUL);
82 282 jeremybenn
 
83
/* Run-time compilation parameters selecting different hardware subsets.  */
84
 
85
extern int target_flags;
86
 
87
/* Target machine storage layout */
88
 
89
/* Define this if most significant bit is lowest numbered
90
   in instructions that operate on numbered bit-fields.
91
   This is not true on the or32.  */
92
#define BITS_BIG_ENDIAN 0
93
 
94
/* Define this if most significant byte of a word is the lowest numbered.  */
95
#define BYTES_BIG_ENDIAN 1
96
 
97
/* Define this if most significant word of a multiword number is numbered.  */
98
#define WORDS_BIG_ENDIAN 1
99
 
100
/* Number of bits in an addressable storage unit */
101
#define BITS_PER_UNIT 8
102
 
103
#define BITS_PER_WORD 32
104
#define SHORT_TYPE_SIZE 16
105
#define INT_TYPE_SIZE 32
106
#define LONG_TYPE_SIZE 32
107
#define LONG_LONG_TYPE_SIZE 64
108
#define FLOAT_TYPE_SIZE 32
109
#define DOUBLE_TYPE_SIZE 64
110
#define LONG_DOUBLE_TYPE_SIZE 64
111
 
112
/* Width of a word, in units (bytes).  */
113
#define UNITS_PER_WORD 4
114
 
115
/* Width in bits of a pointer.
116
   See also the macro `Pmode' defined below.  */
117
#define POINTER_SIZE 32
118
 
119
/* Allocation boundary (in *bits*) for storing pointers in memory.  */
120
#define POINTER_BOUNDARY 32
121
 
122
/* Allocation boundary (in *bits*) for storing arguments in argument list.  */
123
#define PARM_BOUNDARY 32
124
 
125
/* Boundary (in *bits*) on which stack pointer should be aligned.  */
126
#define STACK_BOUNDARY 32
127
 
128
/* Allocation boundary (in *bits*) for the code of a function.  */
129
#define FUNCTION_BOUNDARY 32
130
 
131
/* Alignment of field after `int : 0' in a structure.  */
132
#define EMPTY_FIELD_BOUNDARY 8
133
 
134
/* Every structure's size must be a multiple of this.  */
135 399 jeremybenn
#define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
136 282 jeremybenn
 
137
/* A bitfield declared as `int' forces `int' alignment for the struct.  */
138
#define PCC_BITFIELD_TYPE_MATTERS 1
139
 
140
/* No data type wants to be aligned rounder than this.  */
141
#define BIGGEST_ALIGNMENT 32
142
 
143
/* The best alignment to use in cases where we have a choice.  */
144
#define FASTEST_ALIGNMENT 32
145
 
146 399 jeremybenn
#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)   \
147
  ((TREE_CODE (STRUCT) == RECORD_TYPE                   \
148
    || TREE_CODE (STRUCT) == UNION_TYPE                 \
149
    || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)           \
150
   && !TYPE_PACKED (STRUCT)                             \
151
   && TYPE_FIELDS (STRUCT) != 0                         \
152
     ? MAX (MAX ((COMPUTED), (SPECIFIED)), or32_struct_alignment (STRUCT)) \
153
     : MAX ((COMPUTED), (SPECIFIED)))                   \
154
 
155 282 jeremybenn
/* Make strings word-aligned so strcpy from constants will be faster.  */
156
/*
157
#define CONSTANT_ALIGNMENT(EXP, ALIGN)                                  \
158
  ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR)    \
159
    && (ALIGN) < FASTEST_ALIGNMENT                                      \
160
   ? FASTEST_ALIGNMENT : (ALIGN))
161
*/
162
 
163
/* One use of this macro is to increase alignment of medium-size
164
   data to make it all fit in fewer cache lines.  Another is to
165
   cause character arrays to be word-aligned so that `strcpy' calls
166
   that copy constants to character arrays can be done inline.  */
167
/*
168
#define DATA_ALIGNMENT(TYPE, ALIGN)                                     \
169
  ((((ALIGN) < FASTEST_ALIGNMENT)                                       \
170
    && (TREE_CODE (TYPE) == ARRAY_TYPE                                  \
171
        || TREE_CODE (TYPE) == UNION_TYPE                               \
172
        || TREE_CODE (TYPE) == RECORD_TYPE)) ? FASTEST_ALIGNMENT : (ALIGN))
173
*/ /* CHECK - btw code gets bigger with this one */
174 399 jeremybenn
#define DATA_ALIGNMENT(TYPE, ALIGN) \
175
  ((ALIGN) < FASTEST_ALIGNMENT \
176
   ? or32_data_alignment ((TYPE), (ALIGN)) : (ALIGN))
177 282 jeremybenn
 
178 399 jeremybenn
#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
179
  ((ALIGN) < FASTEST_ALIGNMENT \
180
   ? or32_data_alignment ((TYPE), (ALIGN)) : (ALIGN))
181
 
182 282 jeremybenn
/* Define this if move instructions will actually fail to work
183
   when given unaligned data.  */
184
#define STRICT_ALIGNMENT 1 /* CHECK */
185
 
186
/* Align an address */
187
#define OR32_ALIGN(n,a) (((n) + (a) - 1) & ~((a) - 1))
188
 
189
/* Define if operations between registers always perform the operation
190
   on the full register even if a narrower mode is specified.  */
191
#define WORD_REGISTER_OPERATIONS  /* CHECK */
192
 
193
 
194
/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
195
   will either zero-extend or sign-extend.  The value of this macro should
196
   be the code that says which one of the two operations is implicitly
197
   done, NIL if none.  */
198
#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
199
 
200
/* Define this macro if it is advisable to hold scalars in registers
201
   in a wider mode than that declared by the program.  In such cases,
202
   the value is constrained to be within the bounds of the declared
203
   type, but kept valid in the wider mode.  The signedness of the
204
   extension may differ from that of the type. */
205
#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE)     \
206
  if (GET_MODE_CLASS (MODE) == MODE_INT         \
207
      && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
208
    (MODE) = SImode;
209
  /* CHECK */
210
 
211
 
212
/*
213
 * brings 0.4% improvment in static size for linux
214
 *
215
#define PROMOTE_FOR_CALL_ONLY
216
*/
217
 
218
/* Define this macro if it is as good or better to call a constant
219
   function address than to call an address kept in a register.  */
220
#define NO_FUNCTION_CSE 1 /* check */
221
 
222
/* Standard register usage.  */
223
 
224
/* Number of actual hardware registers.
225
   The hardware registers are assigned numbers for the compiler
226
   from 0 to just below FIRST_PSEUDO_REGISTER.
227
   All registers that the compiler knows about must be given numbers,
228 399 jeremybenn
   even those that are not normally considered general registers.  */
229 282 jeremybenn
 
230 399 jeremybenn
#define OR32_LAST_ACTUAL_REG       31
231
#define ARG_POINTER_REGNUM     (OR32_LAST_ACTUAL_REG + 1)
232
#define FRAME_POINTER_REGNUM   (ARG_POINTER_REGNUM + 1)
233
#define OR32_LAST_INT_REG      FRAME_POINTER_REGNUM
234
#define OR32_FLAGS_REG         (OR32_LAST_INT_REG + 1)
235 282 jeremybenn
#define FIRST_PSEUDO_REGISTER  (OR32_FLAGS_REG + 1)
236
 
237
/* 1 for registers that have pervasive standard uses
238
   and are not available for the register allocator.
239
   On the or32, these are r1 as stack pointer and
240
   r2 as frame/arg pointer.  r9 is link register, r0
241
   is zero, r10 is linux thread */
242
#define FIXED_REGISTERS { \
243 399 jeremybenn
  1, 1, 0, 0, 0, 0, 0, 0, \
244 282 jeremybenn
  0, 1, 1, 0, 0, 0, 0, 0, \
245
  0, 0, 0, 0, 0, 0, 0, 0, \
246 399 jeremybenn
  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }
247 282 jeremybenn
/* 1 for registers not available across function calls.
248
   These must include the FIXED_REGISTERS and also any
249
   registers that can be used without being saved.
250
   The latter must include the registers where values are returned
251
   and the register where structure-value addresses are passed.
252
   Aside from that, you can include as many other registers as you like.  */
253
#define CALL_USED_REGISTERS { \
254 399 jeremybenn
  1, 1, 0, 1, 1, 1, 1, 1, \
255 484 jeremybenn
  1, 1, 1, 1, 1, 1, 0, 1, \
256 282 jeremybenn
  0, 1, 0, 1, 0, 1, 0, 1, \
257 399 jeremybenn
  0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1}
258 282 jeremybenn
 
259
/* stack pointer: must be FIXED and CALL_USED */
260 402 jeremybenn
/* hard frame pointer: must be call saved.  */
261
/* soft frame pointer / arg pointer: must be FIXED and CALL_USED */
262 282 jeremybenn
 
263
/* Return number of consecutive hard regs needed starting at reg REGNO
264
   to hold something of mode MODE.
265
   This is ordinarily the length in words of a value of mode MODE
266
   but can be less for certain modes in special long registers.
267
   On the or32, all registers are one word long.  */
268
#define HARD_REGNO_NREGS(REGNO, MODE)   \
269
 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
270
 
271
/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
272
#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
273
 
274
/* Value is 1 if it is a good idea to tie two pseudo registers
275
   when one has mode MODE1 and one has mode MODE2.
276
   If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
277
   for any hard reg, then this must be 0 for correct output.  */
278
#define MODES_TIEABLE_P(MODE1, MODE2)  1
279
 
280
/* A C expression for the cost of moving data of mode mode from a register in
281
   class "from" to one in class "to". The classes are expressed using the
282
   enumeration values such as GENERAL_REGS. A value of 2 is the default; other
283
   values are interpreted relative to that.
284
 
285
   It is not required that the cost always equal 2 when "from" is the same as
286
   "to"; on some machines it is expensive to move between registers if they are
287
   not general registers.
288
 
289
   If reload sees an insn consisting of a single set between two hard
290
   registers, and if REGISTER_MOVE_COST applied to their classes returns a
291
   value of 2, reload does not check to ensure that the constraints of the
292
   insn are met. Setting a cost of other than 2 will allow reload to verify
293
   that the constraints are met. You should do this if the "movm" pattern's
294
   constraints do not allow such copying.
295
 
296
   JPB 31-Aug-10: This is just the default. */
297
#define REGISTER_MOVE_COST(mode, from, to)  2
298
 
299
/* A C expression for the cost of moving data of mode mode between a register
300
   of class "class" and memory; "in" is zero if the value is to be written to
301
   memory, nonzero if it is to be read in. This cost is relative to those in
302
   REGISTER_MOVE_COST. If moving between registers and memory is more
303
   expensive than between two registers, you should define this macro to
304
   express the relative cost.
305
 
306
   If you do not define this macro, GCC uses a default cost of 4 plus the cost
307
   of copying via a secondary reload register, if one is needed. If your
308
   machine requires a secondary reload register to copy between memory and a
309
   register of class but the reload mechanism is more complex than copying via
310
   an intermediate, define this macro to reflect the actual cost of the move.
311
 
312
   GCC defines the function "memory_move_secondary_cost" if secondary reloads
313
   are needed. It computes the costs due to copying via a secondary
314
   register. If your machine copies from memory using a secondary register in
315
   the conventional way but the default base value of 4 is not correct for
316
   your machine, define this macro to add some other value to the result of
317
   that function. The arguments to that function are the same as to this
318
   macro.
319
 
320
   JPB 31-Aug-10. Is this really correct? I suppose the OR32 only takes one
321
                  cycle, notionally, to access memory, but surely that will
322
                  often stall the  pipeline. Needs more investigation. */
323
#define MEMORY_MOVE_COST(mode, class, in)  2
324
 
325
/* A C expression for the cost of a branch instruction. A value of 1 is the
326
   default; other values are interpreted relative to that. Parameter "speed_p"
327
   is TRUE when the branch in question should be optimized for speed. When it
328
   is FALSE, BRANCH_COST should be returning value optimal for code size
329
   rather then performance considerations. "predictable_p" is true for well
330
   predictable branches. On many architectures the BRANCH_COST can be reduced
331
   then.
332
 
333
   JPB 31-Aug-10. The original code had the comment that "... this should
334
                  specify the cost of a branch insn; roughly the number of
335
                  extra insns that should be added to avoid a branch.
336
 
337
                  Set this to 3 on the or32 since that is roughly the average
338
                  cost of an unscheduled conditional branch.
339
 
340
                  Cost of 2 and 3 give equal and ~0.7% bigger binaries
341
                  respectively."
342
 
343
                  This seems ad-hoc. Probably we need some experiments. */
344
#define BRANCH_COST(speed_p, predictable_p)  2
345
 
346
/* Specify the registers used for certain standard purposes.
347
   The values of these macros are register numbers.  */
348
 
349
/* Register to use for pushing function arguments.  */
350
#define STACK_POINTER_REGNUM 1
351
 
352
/* Base register for access to local variables of the function.  */
353 399 jeremybenn
#define HARD_FRAME_POINTER_REGNUM 2
354 282 jeremybenn
 
355
/* Link register. */
356
#define LINK_REGNUM 9
357
 
358
/* Define this macro if debugging can be performed even without a frame pointer.
359
   If this macro is de ned, GCC will turn on the `-fomit-frame-pointer' option
360
   whenever `-O' is specifed.
361
 
362
   This should work for the OpenRISC architecture. Particularly if we
363
   generate DWARF2 output OK. */
364
#define CAN_DEBUG_WITHOUT_FP 
365
 
366
/* This function computes the initial size of the frame (difference between SP
367
   and FP) after the function prologue. */
368
#define INITIAL_FRAME_POINTER_OFFSET(depth)                             \
369
  {                                                                     \
370
    int regno;                                                          \
371
    int offset = 0;                                                      \
372
                                                                        \
373
    for (regno=0; regno < FIRST_PSEUDO_REGISTER;  regno++)               \
374
      {                                                                 \
375
        if (df_regs_ever_live_p (regno) && !call_used_regs[regno])      \
376
          {                                                             \
377
            offset += 4;                                                \
378
          }                                                             \
379
      }                                                                 \
380
                                                                        \
381
    (depth) = ((!current_function_is_leaf                               \
382
                || df_regs_ever_live_p (LINK_REGNUM)) ? 4 : 0)           \
383
      + (frame_pointer_needed ? 4 : 0)                                   \
384
      + offset                                                          \
385
      + OR32_ALIGN (crtl->outgoing_args_size, 4)                        \
386
      + OR32_ALIGN (get_frame_size(), 4);                               \
387
  }
388
 
389 399 jeremybenn
/* Register in which static-chain is passed to a function.  */
390 282 jeremybenn
 
391 332 jeremybenn
#define STATIC_CHAIN_REGNUM 11
392
 
393 399 jeremybenn
#define PROLOGUE_TMP 13
394
#define EPILOGUE_TMP 3
395
 
396 282 jeremybenn
/* Register in which address to store a structure value
397
   is passed to a function.  */
398
/*#define STRUCT_VALUE_REGNUM 0*/
399
 
400
/* Pass address of result struct to callee as "invisible" first argument */
401
#define STRUCT_VALUE 0
402
 
403
/* -----------------------[ PHX start ]-------------------------------- */
404
 
405
/* Define the classes of registers for register constraints in the
406
   machine description.  Also define ranges of constants.
407
 
408
   One of the classes must always be named ALL_REGS and include all hard regs.
409
   If there is more than one class, another class must be named NO_REGS
410
   and contain no registers.
411
 
412
   The name GENERAL_REGS must be the name of a class (or an alias for
413
   another name such as ALL_REGS).  This is the class of registers
414
   that is allowed by "g" or "r" in a register constraint.
415
   Also, registers outside this class are allocated only when
416
   instructions express preferences for them.
417
 
418
   GENERAL_REGS and BASE_REGS classess are the same on or32.
419
 
420
   The classes must be numbered in nondecreasing order; that is,
421
   a larger-numbered class must never be contained completely
422
   in a smaller-numbered class.
423
 
424
   For any two classes, it is very desirable that there be another
425
   class that represents their union.  */
426
 
427
/* The or32 has only one kind of registers, so NO_REGS, GENERAL_REGS
428
   and ALL_REGS are the only classes.  */
429
/* JPB 26-Aug-10: Based on note from Mikhael (mirekez@gmail.com), we don't
430
   need CR_REGS and it is in the wrong place for later things! */
431
enum reg_class
432
{
433
  NO_REGS,
434
  GENERAL_REGS,
435
  ALL_REGS,
436
  LIM_REG_CLASSES
437
};
438
 
439
#define N_REG_CLASSES (int) LIM_REG_CLASSES
440
 
441
/* Give names of register classes as strings for dump file.   */
442
#define REG_CLASS_NAMES                                                 \
443
{                                                                       \
444
  "NO_REGS",                                                            \
445
  "GENERAL_REGS",                                                       \
446
  "ALL_REGS"                                                            \
447
}
448
 
449
/* Define which registers fit in which classes.  This is an initializer for a
450
   vector of HARD_REG_SET of length N_REG_CLASSES.
451
 
452
   An initializer containing the contents of the register classes, as integers
453
   which are bit masks.  The Nth integer specifies the contents of class N.
454
   The way the integer MASK is interpreted is that register R is in the class
455
   if `MASK & (1 << R)' is 1.
456
 
457
   When the machine has more than 32 registers, an integer does not suffice.
458
   Then the integers are replaced by sub-initializers, braced groupings
459
   containing several integers.  Each sub-initializer must be suitable as an
460
   initializer for the type `HARD_REG_SET' which is defined in
461
   `hard-reg-set.h'.
462
 
463
   For the OR32 we have the minimal set. GENERAL_REGS is all except r0, which
464
   it permanently zero. */
465
#define REG_CLASS_CONTENTS                                              \
466
  {                                                                     \
467
    { 0x00000000, 0x00000000 },         /* NO_REGS */                   \
468 399 jeremybenn
    { 0xffffffff, 0x00000003 },         /* GENERAL_REGS */              \
469
    { 0xffffffff, 0x00000007 }          /* ALL_REGS */                  \
470 282 jeremybenn
  }
471
 
472
/* The same information, inverted:
473
 
474
   Return the class number of the smallest class containing reg number REGNO.
475
   This could be a conditional expression or could index an array.
476
 
477 399 jeremybenn
   ??? 0 is not really a register, but a constant.  */
478 282 jeremybenn
#define REGNO_REG_CLASS(regno)                                          \
479 399 jeremybenn
  ((0 == regno) ? ALL_REGS : ((1 <= regno) && (regno <= OR32_LAST_INT_REG))              \
480 282 jeremybenn
   ? GENERAL_REGS : NO_REGS)
481
 
482
/* The class value for index registers, and the one for base regs.  */
483
#define INDEX_REG_CLASS GENERAL_REGS
484
#define BASE_REG_CLASS  GENERAL_REGS
485
 
486
/* Given an rtx X being reloaded into a reg required to be in class CLASS,
487
   return the class of reg to actually use.  In general this is just CLASS;
488
   but on some machines in some cases it is preferable to use a more
489
   restrictive class.  */
490
#define PREFERRED_RELOAD_CLASS(X,CLASS)  (CLASS)
491
 
492
/* Return the maximum number of consecutive registers needed to represent mode
493
   MODE in a register of class CLASS.
494
 
495
   On the or32, this is always the size of MODE in words, since all registers
496
   are the same size.  */
497
#define CLASS_MAX_NREGS(CLASS, MODE)                                    \
498
  ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
499
 
500
 
501
/* -------------------------------------------------------------------------- */
502
/* Stack layout; function entry, exit and calling.  */
503
 
504
/* Define this if pushing a word on the stack makes the stack pointer a
505
   smaller address.  */
506
#define STACK_GROWS_DOWNWARD 1
507
 
508
/* Define this if the nominal address of the stack frame is at the
509
   high-address end of the local variables; that is, each additional local
510
   variable allocated goes at a more negative offset in the frame.  */
511
#define FRAME_GROWS_DOWNWARD 1
512
 
513
/* Offset within stack frame to start allocating local variables at.  If
514
   FRAME_GROWS_DOWNWARD, this is the offset to the END of the first local
515
   allocated.  Otherwise, it is the offset to the BEGINNING of the first local
516
   allocated.  */
517
#define STARTING_FRAME_OFFSET 0
518
 
519
/* Offset of first parameter from the argument pointer register value.  */
520
#define FIRST_PARM_OFFSET(FNDECL) 0
521
 
522
/* Define this if stack space is still allocated for a parameter passed
523
   in a register.  The value is the number of bytes allocated to this
524
   area.
525
 
526
   No such allocation for OR32. */
527
/* #define REG_PARM_STACK_SPACE(FNDECL) (UNITS_PER_WORD * GP_ARG_NUM_REG) */
528
 
529
/* Define this if the above stack space is to be considered part of the
530
   space allocated by the caller.
531
 
532
   N/a for OR32. */
533
/* #define OUTGOING_REG_PARM_STACK_SPACE */
534
 
535
/* Define this macro if `REG_PARM_STACK_SPACE' is defined, but the
536
   stack parameters don't skip the area specified by it.
537
 
538
   N/a for OR32. */
539
/* #define STACK_PARMS_IN_REG_PARM_AREA */
540
 
541
/* If nonzero, the maximum amount of space required for outgoing arguments
542
   will be computed and placed into the variable
543
   current_function_outgoing_args_size. No space will be pushed onto the stack
544
   for each call; instead, the function prologue should increase the stack
545
   frame size by this amount.
546
 
547
   Setting both PUSH_ARGS and ACCUMULATE_OUTGOING_ARGS is not proper.
548
 
549
   This is the approached used by OR32. */
550
#define ACCUMULATE_OUTGOING_ARGS 1
551
 
552 399 jeremybenn
#define ELIMINABLE_REGS                                                 \
553
{{ ARG_POINTER_REGNUM,   STACK_POINTER_REGNUM},                         \
554
 { ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM},                    \
555
 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},                         \
556
 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
557
 
558
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
559
  (OFFSET) = or32_initial_elimination_offset ((FROM), (TO))
560
 
561 282 jeremybenn
/* A C expression that should indicate the number of bytes of its own
562
   arguments that a function pops on returning, or 0 if the function pops no
563
   arguments and the caller must therefore pop them all after the function
564
   returns.
565
 
566
   "fundecl" is a C variable whose value is a tree node that describes the
567
   function in question. Normally it is a node of type FUNCTION_DECL that
568
   describes the declaration of the function. From this you can obtain the
569
   DECL_ATTRIBUTES of the function.
570
 
571
   "funtype" is a C variable whose value is a tree node that describes the
572
   function in question. Normally it is a node of type FUNCTION_TYPE that
573
   describes the data type of the function. From this it is possible to obtain
574
   the data types of the value and arguments (if known).
575
 
576
   When a call to a library function is being considered, "fundecl" will
577
   contain an identifier node for the library function. Thus, if you need to
578
   distinguish among various library functions, you can do so by their
579
   names. Note that “library function” in this context means a function used
580
   to perform arithmetic, whose name is known specially in the compiler and
581
   was not mentioned in the C code being compiled.
582
 
583
   "size" is the number of bytes of arguments passed on the stack. If a
584
   variable number of bytes is passed, it is zero, and argument popping will
585
   always be the re- sponsibility of the calling function.
586
 
587
   On the VAX, all functions always pop their arguments, so the definition of
588
   this macro is stack-size. On the 68000, using the standard calling
589
   convention, no functions pop their arguments, so the value of the macro is
590
   always 0 in this case. But an alternative calling convention is available
591
   in which functions that take a fixed number of argu- ments pop them but
592
   other functions (such as printf) pop nothing (the caller pops all). When
593
   this convention is in use, funtype is examined to determine whether a
594
   function takes a fixed number of arguments.
595
 
596
   On the OR32, no functions pop their arguments.
597
   JPB 29-Aug-10: Is this really correct? */
598
#define RETURN_POPS_ARGS(fundecl, funtype, size) 0
599
 
600
/* Minimum and maximum general purpose registers used to hold arguments.  */
601
#define GP_ARG_MIN_REG 3
602
#define GP_ARG_MAX_REG 8
603
#define GP_ARG_NUM_REG (GP_ARG_MAX_REG - GP_ARG_MIN_REG + 1) 
604
 
605
/* Return register */
606
#define GP_ARG_RETURN  11 
607
#define GP_ARG_RETURNH 12 
608
 
609
/* A C expression to create an RTX representing the place where a library
610
   function returns a value of mode mode.
611
 
612
   Note that “library function” in this context means a compiler support
613
   routine, used to perform arithmetic, whose name is known specially by the
614
   compiler and was not mentioned in the C code being compiled.
615
 
616
   For the OR32, return value is in R11 (GP_ARG_RETURN).  */
617
#define LIBCALL_VALUE(mode)                                             \
618
  gen_rtx_REG(                                                          \
619
           ((GET_MODE_CLASS (mode) != MODE_INT                          \
620
             || GET_MODE_SIZE (mode) >= 4)                              \
621
            ? (mode)                                                    \
622
            : SImode),                                                  \
623
            GP_ARG_RETURN)
624
 
625
/* Define this if PCC uses the nonreentrant convention for returning
626
   structure and union values.
627
 
628
   Not needed for OR32. */
629
/*#define PCC_STATIC_STRUCT_RETURN */
630
 
631
/* A C expression that is nonzero if regno is the number of a hard register in
632
   which the values of called function may come back.
633
 
634
   A register whose use for returning values is limited to serving as the
635
   second of a pair (for a value of type double, say) need not be recognized
636
   by this macro. So for most machines, this definition suffices:
637
 
638
       #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
639
 
640
   If the machine has register windows, so that the caller and the called
641
   function use different registers for the return value, this macro should
642
   recognize only the caller's register numbers.
643
 
644
   For OR32, we must check if we have the return register.
645
 
646
   From GCC 4.6, this will be replaced by TARGET_FUNCION_VALUE_REGNO_P target
647
   hook function. */
648
#define FUNCTION_VALUE_REGNO_P(N)  ((N) == GP_ARG_RETURN)
649
 
650
/* 1 if N is a possible register number for function argument passing. */
651
#define FUNCTION_ARG_REGNO_P(N) \
652
   ((N) >= GP_ARG_MIN_REG && (N) <= GP_ARG_MAX_REG)
653
 
654
/* A code distinguishing the floating point format of the target
655
   machine.  There are three defined values: IEEE_FLOAT_FORMAT,
656
   VAX_FLOAT_FORMAT, and UNKNOWN_FLOAT_FORMAT.  */
657
#define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
658
#define FLOAT_WORDS_BIG_ENDIAN 1
659
 
660
/* A C type for declaring a variable that is used as the first argument of
661
   FUNCTION_ARG and other related values. For some target machines, the type
662
   int suffices and can hold the number of bytes of argument so far.
663
 
664
   There is no need to record in CUMULATIVE_ARGS anything about the arguments
665
   that have been passed on the stack. The compiler has other variables to
666
   keep track of that.  For target machines on which all arguments are passed
667
   on the stack, there is no need to store anything in CUMULATIVE_ARGS;
668
   however, the data structure must exist and should not be empty, so use
669
   int. */
670
#define CUMULATIVE_ARGS int
671
 
672
/* A C statement (sans semicolon) for initializing the variable "cum" for the
673
   state at the beginning of the argument list. The variable has type
674
   CUMULATIVE_ARGS. The value of "fntype" is the tree node for the data type
675
   of the function which will receive the args, or 0 if the args are to a
676
   compiler support library function. For direct calls that are not libcalls,
677
   "fndecl" contain the declaration node of the function. "fndecl" is also set
678
   when INIT_CUMULATIVE_ARGS is used to find arguments for the function being
679
   compiled.  "n_named_args" is set to the number of named arguments,
680
   including a structure return address if it is passed as a parameter, when
681
   making a call. When processing incoming arguments, "n_named_args" is set to
682
   −1.
683
 
684
   When processing a call to a compiler support library function, "libname"
685
   identifies which one. It is a symbol_ref rtx which contains the name of the
686
   function, as a string. "libname" is 0 when an ordinary C function call is
687
   being processed. Thus, each time this macro is called, either "libname" or
688
   "fntype" is nonzero, but never both of them at once.
689
 
690
   For the OR32, we set "cum" to zero each time.
691
   JPB 29-Aug-10: Is this correct? */
692
#define INIT_CUMULATIVE_ARGS(cum, fntype, libname, fndecl, n_named_args) \
693
  (cum = 0)
694
 
695
/* -------------------------------------------------------------------------- */
696
/* Define intermediate macro to compute the size (in registers) of an argument
697
   for the or32.
698
 
699
   The OR32_ROUND_ADVANCE* macros are local to this file.  */
700
 
701
/* Round "size" up to a word boundary.  */
702
#define OR32_ROUND_ADVANCE(size)                                        \
703
  (((size) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
704
 
705
/* Round arg "mode"/"type" up to the next word boundary.  */
706
#define OR32_ROUND_ADVANCE_ARG(mode, type)                              \
707
  ((mode) == BLKmode                                                    \
708
   ? OR32_ROUND_ADVANCE (int_size_in_bytes (type))                      \
709
   : OR32_ROUND_ADVANCE (GET_MODE_SIZE (mode)))
710
 
711
/* Round "cum" up to the necessary point for argument "mode"/"type".  This is
712
   either rounded to nearest reg or nearest double-reg boundary */
713
#define OR32_ROUND_ADVANCE_CUM(cum, mode, type)                         \
714
  ((((mode) == BLKmode ? TYPE_ALIGN (type) : GET_MODE_BITSIZE (mode))   \
715
    > BITS_PER_WORD)                                                    \
716
   ? (((cum) + 1) & ~1)                                                 \
717
   : (cum))
718
 
719
/* Update the data in "cum" to advance over an argument of mode "mode" and
720
   data type "type".  ("type" is null for libcalls where that information may
721
   not be available.)  */
722
#define FUNCTION_ARG_ADVANCE(cum, mode, type, named)                    \
723
  ((cum) = (OR32_ROUND_ADVANCE_CUM ((cum), (mode), (type))              \
724
            + OR32_ROUND_ADVANCE_ARG ((mode), (type))))
725
 
726
/* Return boolean indicating if arg of type "type" and mode "mode" will be
727
   passed in a reg.  This includes arguments that have to be passed by
728
   reference as the pointer to them is passed in a reg if one is available
729
   (and that is what we're given).
730
 
731
   When passing arguments "named" is always 1.  When receiving arguments
732
   "named" is 1 for each argument except the last in a stdarg/varargs
733
   function.  In a stdarg function we want to treat the last named arg as
734
   named.  In a varargs function we want to treat the last named arg (which is
735
   `__builtin_va_alist') as unnamed.
736
 
737
   This macro is only used in this file.  */
738
#define OR32_PASS_IN_REG_P(cum, mode, type, named)                      \
739
  ((named)                                                              \
740
   && ((OR32_ROUND_ADVANCE_CUM ((cum), (mode), (type))                  \
741
        + OR32_ROUND_ADVANCE_ARG ((mode), (type))                       \
742
        <= GP_ARG_NUM_REG)))
743
 
744
/* Determine where to put an argument to a function.  Value is zero to push
745
   the argument on the stack, or a hard register in which to store the
746
   argument.
747
 
748
   "mode" is the argument's machine mode.
749
 
750
   "type" is the data type of the argument (as a tree).  This is null for
751
    libcalls where that information may not be available.
752
 
753
   "cum" is a variable of type CUMULATIVE_ARGS which gives info about the
754
    preceding args and about the function being called.
755
 
756
   "named" is nonzero if this argument is a named parameter (otherwise it is
757
    an extra parameter matching an ellipsis).
758
 
759
    On the ARC the first MAX_ARC_PARM_REGS args are normally in registers and
760
    the rest are pushed.  */
761
#define FUNCTION_ARG(cum, mode, type, named)                            \
762
  (OR32_PASS_IN_REG_P ((cum), (mode), (type), (named))                  \
763
   ? gen_rtx_REG ((mode),                                               \
764
                  OR32_ROUND_ADVANCE_CUM ((cum), (mode), (type))        \
765
                  + GP_ARG_MIN_REG)                                     \
766
   : 0)
767
 
768
/* Output assembler code to FILE to increment profiler label # LABELNO
769
   for profiling a function entry.
770
 
771
   JPB 29-Aug-10: This patently doesn't work. It is not even OR32 code! */
772
#define FUNCTION_PROFILER(FILE, LABELNO)  \
773
   fprintf (FILE, "\tl.load32u\tr0,LP%d\n\tcall\tmcount\n", (LABELNO));
774
 
775
/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, the
776
   stack pointer does not matter.  The value is tested only in functions that
777
   have frame pointers.  No definition is equivalent to always zero.
778
 
779
   The default suffices for OR32. */
780
#define EXIT_IGNORE_STACK 0
781
 
782
/* A C expression whose value is RTL representing the location of the
783
   incoming return address at the beginning of any function, before the
784
   prologue.  This RTL is either a REG, indicating that the return
785
   value is saved in REG, or a MEM representing a location in
786
   the stack.  */
787 399 jeremybenn
#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_REGNUM)
788 282 jeremybenn
 
789 399 jeremybenn
#define RETURN_ADDR_RTX(COUNT, FP) \
790
  ((COUNT) ? NULL_RTX : get_hard_reg_initial_val (Pmode, LINK_REGNUM))
791 282 jeremybenn
 
792 399 jeremybenn
 
793 282 jeremybenn
/* Addressing modes, and classification of registers for them.  */
794
 
795
/* #define HAVE_POST_INCREMENT */
796
/* #define HAVE_POST_DECREMENT */
797
 
798
/* #define HAVE_PRE_DECREMENT */
799
/* #define HAVE_PRE_INCREMENT */
800
 
801
/* Macros to check register numbers against specific register classes.  */
802
#define MAX_REGS_PER_ADDRESS 1
803
 
804
/* True if X is an rtx for a constant that is a valid address.
805
 
806
   JPB 29-Aug-10: Why is the default implementation not OK? */
807
#define CONSTANT_ADDRESS_P(X)                                           \
808
  (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF              \
809
   || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST                \
810
   || GET_CODE (X) == HIGH)
811
 
812
/* A C expression which is nonzero if register number num is suitable for use
813
   as a base register in operand addresses. Like TARGET_LEGITIMATE_ADDRESS_P,
814
   this macro should also define a strict and a non-strict variant. Both
815
   variants behave the same for hard register; for pseudos, the strict variant
816
   will pass only those that have been allocated to a valid hard registers,
817
   while the non-strict variant will pass all pseudos.
818
 
819
   Compiler source files that want to use the strict variant of this and other
820
   macros define the macro REG_OK_STRICT. You should use an #ifdef
821
   REG_OK_STRICT conditional to define the strict variant in that case and the
822
   non-strict variant otherwise.
823
 
824
   JPB 29-Aug-10: This has been conflated with the old REG_OK_FOR_BASE_P
825
                  function, which is no longer part of GCC.
826
 
827
                  I'm not sure this is right. r0 can be a base register, just
828
                  it can't get set by the user. */
829
#ifdef REG_OK_STRICT
830
#define REGNO_OK_FOR_BASE_P(num)                                             \
831
  (   ((0 < (num))             && ((num)             <= OR32_LAST_INT_REG))  \
832
   || ((0 < reg_renumber[num]) && (reg_renumber[num] <= OR32_LAST_INT_REG)))
833
 
834
#else
835
/* Accept an int register or a pseudo reg.
836
 
837
   JPB 1-Sep-10: Should this allow r0, if the strict version does not? */
838
#define REGNO_OK_FOR_BASE_P(num) ((num) <= OR32_LAST_INT_REG ||         \
839
                                  (num) >= FIRST_PSEUDO_REGISTER)
840
#endif
841
 
842
/* OR32 doesn't have any indexed addressing. */
843
#define REG_OK_FOR_INDEX_P(X) 0
844
#define REGNO_OK_FOR_INDEX_P(X) 0
845
 
846
 
847
/* OR32 addresses do not depend on the machine mode they are being used in. */
848
#define GO_IF_MODE_DEPENDENT_ADDRESS(addr,label)
849
 
850
/* Is this suitable for an immediate operand.
851
 
852
   JPB 1-Sep-10: Is this correct. We can only do 16-bit immediates directly. */
853 515 jeremybenn
#define LEGITIMATE_CONSTANT_P(x) \
854
  (GET_CODE(x) != CONST_DOUBLE || GET_MODE (x) == VOIDmode)
855 282 jeremybenn
 
856
/* Specify the machine mode that this machine uses for the index in the
857
   tablejump instruction.  */
858
#define CASE_VECTOR_MODE SImode
859
 
860
/* Define as C expression which evaluates to nonzero if the tablejump
861
   instruction expects the table to contain offsets from the address of the
862
   table.
863
 
864
   Do not define this if the table should contain absolute addresses. */
865
/* #define CASE_VECTOR_PC_RELATIVE 1 */
866
 
867
/* Define this as 1 if `char' should by default be signed; else as 0.  */
868
#define DEFAULT_SIGNED_CHAR 1
869
 
870
/* This flag, if defined, says the same insns that convert to a signed fixnum
871
   also convert validly to an unsigned one.  */
872
#define FIXUNS_TRUNC_LIKE_FIX_TRUNC
873
 
874
/* The maximum number of bytes that a single instruction can move quickly
875
   between memory and registers or between two memory locations. */
876
#define MOVE_MAX 4
877
 
878
/* Define this if zero-extension is slow (more than one real instruction).  */
879
/* #define SLOW_ZERO_EXTEND */
880
 
881
/* Nonzero if access to memory by bytes is slow and undesirable.
882
   For RISC chips, it means that access to memory by bytes is no
883
   better than access by words when possible, so grab a whole word
884
   and maybe make use of that.  */
885
#define SLOW_BYTE_ACCESS 1
886
 
887
/* Define if shifts truncate the shift count
888
   which implies one can omit a sign-extension or zero-extension
889
   of a shift count.  */
890
/* #define SHIFT_COUNT_TRUNCATED */
891
 
892
/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
893
   is done just by pretending it is already truncated.  */
894
#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
895
 
896
/* Specify the machine mode that pointers have.
897
   After generation of rtl, the compiler makes no further distinction
898
   between pointers and any other objects of this machine mode.  */
899
#define Pmode SImode
900
 
901
/* A function address in a call instruction
902
   is a byte address (for indexing purposes)
903
   so give the MEM rtx a byte's mode.  */
904
#define FUNCTION_MODE SImode
905
 
906
 
907
/* -------------------------------------------------------------------------- */
908
/* Condition code stuff */
909
 
910
/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
911
   return the mode to be used for the comparison. */
912
#define SELECT_CC_MODE(op, x, y)                                        \
913
   ((EQ  == (op)) ? CCEQmode                                            \
914
  : (NE  == (op)) ? CCNEmode                                            \
915
  : (GEU == (op)) ? CCGEUmode                                           \
916
  : (GTU == (op)) ? CCGTUmode                                           \
917
  : (LTU == (op)) ? CCLTUmode                                           \
918
  : (LEU == (op)) ? CCLEUmode                                           \
919
  : (GE  == (op)) ? CCGEmode                                            \
920
  : (LT  == (op)) ? CCLTmode                                            \
921
  : (GT  == (op)) ? CCGTmode                                            \
922
  : (LE  == (op)) ? CCLEmode                                            \
923
  : (abort (), 0))
924
 
925
/* Can the condition code MODE be safely reversed?  This is safe in
926
   all cases on this port, because at present it doesn't use the
927
   trapping FP comparisons (fcmpo).  */
928
#define REVERSIBLE_CC_MODE(mode) 1
929
 
930
/* Given a condition code and a mode, return the inverse condition.
931
 
932
   JPB 31-Aug-10: This seems like the default. Do we even need this? */
933
#define REVERSE_CONDITION(code, mode) reverse_condition (code)
934
 
935
 
936
/* -------------------------------------------------------------------------- */
937
/* Control the assembler format that we output.  */
938
 
939
/* A C string constant describing how to begin a comment in the target
940
   assembler language.  The compiler assumes that the comment will end at
941
   the end of the line.  */
942
#define ASM_COMMENT_START "#"
943
 
944
/* Output to assembler file text saying following lines may contain character
945
   constants, extra white space, comments, etc.
946
 
947
   JPB 29-Aug-10: Default would seem to be OK here. */
948
#define ASM_APP_ON "#APP\n"
949
 
950
/* Output to assembler file text saying following lines no longer contain
951
   unusual constructs.
952
 
953
   JPB 29-Aug-10: Default would seem to be OK here. */
954
#define ASM_APP_OFF "#NO_APP\n"
955
 
956
/* Switch to the text or data segment.  */
957
 
958
/* Output before read-only data.  */
959
#define TEXT_SECTION_ASM_OP "\t.section .text"
960
 
961
/* Output before writable data.  */
962
#define DATA_SECTION_ASM_OP "\t.section .data"
963
 
964
/* Output before uninitialized data. */
965
#define BSS_SECTION_ASM_OP  "\t.section .bss"
966
 
967
/* How to refer to registers in assembler output.  This sequence is indexed by
968
   compiler's hard-register-number (see above).  */
969
#define REGISTER_NAMES                                                  \
970
  {"r0",   "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",              \
971
   "r8",   "r9", "r10", "r11", "r12", "r13", "r14", "r15",              \
972
   "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",              \
973
   "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",              \
974 399 jeremybenn
   "argp", "frame", "cc-flag"}
975 282 jeremybenn
 
976
 
977
/* -------------------------------------------------------------------------- */
978
/* Debug things for DBX (STABS)                                               */
979
/*                                                                            */
980
/* Note. Our config.gcc includes dbxelf.h, which sets up appropriate          */
981
/*       defaults. Choice of which debug format to use is in our elf.h        */
982
/* -------------------------------------------------------------------------- */
983
 
984
/* Don't try to use the  type-cross-reference character in DBX data.
985
   Also has the consequence of putting each struct, union or enum
986
   into a separate .stabs, containing only cross-refs to the others.  */
987
/* JPB 24-Aug-10: Is this really correct. Can't GDB use this info? */
988
#define DBX_NO_XREFS
989
 
990
/* -------------------------------------------------------------------------- */
991
/* Debug things for DWARF2                                                    */
992
/*                                                                            */
993
/* Note. Choice of which debug format to use is in our elf.h                  */
994
/* -------------------------------------------------------------------------- */
995
 
996
/* We support frame unwind info including for exceptions handling. This needs
997
   INCOMING_RETURN_ADDR_RTX to be set and OBJECT_FORMAT_ELF to be defined (in
998
   elfos.h). Override any default value. */
999
#undef  DWARF2_UNWIND_INFO
1000
#define DWARF2_UNWIND_INFO 1
1001
 
1002
/* We want frame info produced. Note that this is superfluous if
1003
   DWARF2_UNWIND_INFO is non-zero, but we set so this so, we can produce frame
1004
   info even when it is zero. Override any default value. */
1005
#undef  DWARF2_FRAME_INFO
1006
#define DWARF2_FRAME_INFO 1
1007
 
1008
/* Macro to idenfity where the incoming return address is on a function call
1009
   before the start of the prologue (i.e. the link register). Used to produce
1010
   DWARF2 frame debug info when DWARF2_UNWIND_INFO is non-zero. Override any
1011
   default value. */
1012
#undef  INCOMING_RETURN_ADDR_RTX
1013
#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_REGNUM)
1014
 
1015
/* Where is the start of our stack frame in relation to the end of the
1016
   previous stack frame at the start of a function, before the prologue */
1017
#define INCOMING_FRAME_SP_OFFSET  0
1018
 
1019
 
1020
 
1021
/* This doesn't work for the OR32 assembler at present. If it did, we'd have
1022
   more compact debug tables. */
1023
/* #undef  DWARF2_ASM_LINE_DEBUG_INFO */
1024
/* #define DWARF2_ASM_LINE_DEBUG_INFO 1 */
1025
 
1026
/* We don't need an alternative return address for now. */
1027
/* DWARF_ALT_FRAME_RETURN_COLUMN */
1028
 
1029
/* We always save registers in the prologue with word alignment, so don't
1030
   need this. */
1031
/* DWARF_CIE_DATA_ALIGNMENT */
1032
 
1033
/* This specifies the maximum number of registers we can save in a frame. We
1034
   could note that only SP, FP, LR, arg regs and callee saved regs come into
1035
   this category. However this is only an efficiency thing, so for now we
1036
   don't use it. */
1037
/* DWARF_FRAME_REGISTERS */
1038
 
1039
/* This specifies a mapping from register numbers in .dwarf_frame to
1040
   .eh_frame. However for us they are the same, so we don't need it. */
1041
/* DWARF_FRAME_REGNUM */
1042
 
1043
/* Defined if the DWARF column numbers do not match register numbers. For us
1044
   they do, so this is not needed. */
1045
/* DWARF_REG_TO_UNWIND_COLUMN */
1046
 
1047
/* Can be used to define a register guaranteed to be zero. Only useful if zero
1048
   is used to terminate backtraces, and not recommended for new ports, so we
1049
   don't use it. */
1050
/* DWARF_ZERO_REG */
1051
 
1052
/* This is the inverse function for DWARF_FRAME_REGNUM. Again not needed. */
1053
/* DWARF2_FRAME_REG_OUT  */
1054
 
1055
 
1056
/* -------------------------------------------------------------------------- */
1057
/* Node: Label Output */
1058
 
1059
/* Globalizing directive for a label.  */
1060
#define GLOBAL_ASM_OP "\t.global "
1061
 
1062
#define SUPPORTS_WEAK 1
1063
 
1064
/* This is how to output the definition of a user-level label named NAME,
1065
   such as the label on a static function or variable NAME.  */
1066
#define ASM_OUTPUT_LABEL(FILE,NAME)                                     \
1067
  { assemble_name (FILE, NAME); fputs (":\n", FILE); }
1068
 
1069
/* We use -fleading-underscore to add it, when necessary.
1070
   JPB: No prefix for global symbols */
1071
#define USER_LABEL_PREFIX ""
1072
 
1073
/* Remove any previous definition (elfos.h).  */
1074
#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
1075
  sprintf (LABEL, "*%s%d", PREFIX, NUM)
1076
 
1077
/* This is how to output an assembler line defining an int constant.  */
1078
#define ASM_OUTPUT_INT(stream, value)                                   \
1079
  {                                                                     \
1080
    fprintf (stream, "\t.word\t");                                      \
1081
    output_addr_const (stream, (value));                                \
1082
    fprintf (stream, "\n")}
1083
 
1084
/* This is how to output an assembler line defining a float constant.  */
1085
#define ASM_OUTPUT_FLOAT(stream, value)                                 \
1086
  { long l;                                                             \
1087
    REAL_VALUE_TO_TARGET_SINGLE (value,l);                              \
1088
    fprintf(stream,"\t.word\t0x%08x\t\t# float %26.7e\n", l, value); }
1089
 
1090
/* This is how to output an assembler line defining a double constant.  */
1091
#define ASM_OUTPUT_DOUBLE(stream, value)                                \
1092
  { long l[2];                                                          \
1093
    REAL_VALUE_TO_TARGET_DOUBLE (value,&l[0]);                           \
1094
    fprintf(stream,"\t.word\t0x%08x,0x%08x\t# float %26.16le\n",        \
1095
            l[0],l[1],value); }
1096
 
1097
/* This is how to output an assembler line defining a long double constant.
1098
 
1099
   JPB 29-Aug-10: Do we really mean this. I thought long double on OR32 was
1100
                  the same as double. */
1101
#define ASM_OUTPUT_LONG_DOUBLE(stream, value)                           \
1102
  { long l[4];                                                          \
1103
    REAL_VALUE_TO_TARGET_DOUBLE (value,&l[0]);                           \
1104
    fprintf (stream,                                                    \
1105
             "\t.word\t0x%08x,0x%08x,0x%08x,0x%08x\t# float %26.18lle\n", \
1106
             l[0],l[1],l[2],l[3],value); }
1107
 
1108
/* This is how to output an assembler line defining a short constant.  */
1109
#define ASM_OUTPUT_SHORT(stream, value)                                 \
1110
  { fprintf (stream, "\t.half\t");                                      \
1111
    output_addr_const (stream, (value));                                \
1112
    fprintf (stream, "\n"); }
1113
 
1114
/* This is how to output an assembler line defining a char constant.  */
1115
#define ASM_OUTPUT_CHAR(stream, value)                                  \
1116
  { fprintf (stream, "\t.byte\t");                                      \
1117
    output_addr_const (stream, (value));                                \
1118
    fprintf (stream, "\n")}
1119
 
1120
/* This is how to output an assembler line for a numeric constant byte.  */
1121
#define ASM_OUTPUT_BYTE(stream, value)  \
1122
  fprintf (stream, "\t.byte\t0x%02x\n", (value))
1123
 
1124
/* This is how to output an insn to push a register on the stack.
1125
   It need not be very fast code.
1126
 
1127
    JPB 29-Aug-10: This was using l.sub (since we don't have l.subi), so it
1128
                   was potty code. Replaced by adding immediate -1. */
1129
#define ASM_OUTPUT_REG_PUSH(stream, regno)                              \
1130
  { fprintf (stream, "\tl.addi\tr1,-4\n");                              \
1131
    fprintf (stream, "\tl.sw\t0(r1),%s\n", reg_names[regno]); }
1132
 
1133
/* This is how to output an insn to pop a register from the stack.
1134
   It need not be very fast code.  */
1135
#define ASM_OUTPUT_REG_POP(stream,REGNO)                                \
1136
  { fprintf (stream, "\tl.lwz\t%s,0(r1)\n", reg_names[REGNO]);          \
1137
    fprintf (stream, "\tl.addi\tr1,4\n"); }
1138
 
1139
/* This is how to output an element of a case-vector that is absolute.
1140
   (The Vax does not use such vectors,
1141
   but we must define this macro anyway.)  */
1142
#define ASM_OUTPUT_ADDR_VEC_ELT(stream, value)                          \
1143
  fprintf (stream, "\t.word\t.L%d\n", value)
1144
 
1145
/* This is how to output an element of a case-vector that is relative.  */
1146
#define ASM_OUTPUT_ADDR_DIFF_ELT(stream, body, value, rel)              \
1147 399 jeremybenn
  fprintf (stream, "\t.word\t.L%d-.L%d\n", value, rel)
1148 282 jeremybenn
 
1149 399 jeremybenn
#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
1150
/* ??? If we were serious about PIC, we should also use l.jal to get
1151
   the table start address.  */
1152
 
1153 282 jeremybenn
/* This is how to output an assembler line that says to advance the location
1154
   counter to a multiple of 2**log bytes.  */
1155
#define ASM_OUTPUT_ALIGN(stream, log)                                   \
1156
  if ((log) != 0)                                                        \
1157
    {                                                                   \
1158
      fprintf (stream, "\t.align\t%d\n", 1 << (log));                   \
1159
    }
1160
 
1161
/* This is how to output an assembler line that says to advance the location
1162
   counter by "size" bytes.  */
1163
#define ASM_OUTPUT_SKIP(stream, size)                                   \
1164
  fprintf (stream, "\t.space %d\n", (size))
1165
 
1166
/* Need to split up .ascii directives to avoid breaking
1167
   the linker. */
1168
 
1169
/* This is how to output a string.  */
1170
#define ASM_OUTPUT_ASCII(stream, ptr, len)                              \
1171
  output_ascii_pseudo_op (stream, (const unsigned char *) (ptr), len)
1172
 
1173
/* Invoked just before function output. */
1174
#define ASM_OUTPUT_FUNCTION_PREFIX(stream, fnname)                      \
1175
  { fputs (".proc\t", stream); assemble_name (stream, fnname);          \
1176
    fputs ("\n", stream); }
1177
 
1178
/* This says how to output an assembler line to define a global common
1179
   symbol. */
1180
#define ASM_OUTPUT_COMMON(stream,name,size,rounded)                     \
1181
  { data_section ();                                                    \
1182
    fputs ("\t.global\t", stream);                                      \
1183
    assemble_name(stream, name);                                        \
1184
    fputs ("\n", stream);                                               \
1185
    assemble_name (stream, name);                                       \
1186
    fputs (":\n", stream);                                              \
1187
    fprintf (stream, "\t.space\t%d\n", rounded); }
1188
 
1189
/* This says how to output an assembler line to define a local common
1190
   symbol.
1191
 
1192
   JPB 29-Aug-10: I'm sure this doesn't work - we don't have a .bss directive
1193
   like this. */
1194
#define ASM_OUTPUT_LOCAL(stream, name, size, rounded)                   \
1195
  { fputs ("\t.bss\t", (stream));                                       \
1196
    assemble_name ((stream), (name));                                   \
1197
    fprintf ((stream), ",%d,%d\n", (size), (rounded)); }
1198
 
1199
/* This says how to output an assembler line to define a global common symbol
1200
   with size "size" (in bytes) and alignment "align" (in bits).  */
1201
#define ASM_OUTPUT_ALIGNED_COMMON(stream, name, size, align)            \
1202
  { data_section();                                                     \
1203
    if ((ALIGN) > 8)                                                    \
1204
      {                                                                 \
1205
        fprintf(stream, "\t.align %d\n", ((align) / BITS_PER_UNIT));    \
1206
      }                                                                 \
1207
    fputs("\t.global\t", stream); assemble_name(stream, name);          \
1208
    fputs("\n", stream);                                                \
1209
    assemble_name(stream, name);                                        \
1210
    fputs (":\n", stream);                                              \
1211
    fprintf(stream, "\t.space\t%d\n", size); }
1212
 
1213
/* This says how to output an assembler line to define a local common symbol
1214
   with size "size" (in bytes) and alignment "align" (in bits).  */
1215
#define ASM_OUTPUT_ALIGNED_LOCAL(stream, name, size, align)             \
1216
  { data_section();                                                     \
1217
    if ((align) > 8)                                                    \
1218
      {                                                                 \
1219
        fprintf(stream, "\t.align %d\n", ((align) / BITS_PER_UNIT));    \
1220
      }                                                                 \
1221
    assemble_name(stream, name);                                        \
1222
    fputs (":\n", stream);                                              \
1223
    fprintf(stream, "\t.space %d\n", size); }
1224
 
1225
/* Store in "output" a string (made with alloca) containing an assembler-name
1226
   for a local static variable named "name".  "labelno" is an integer which is
1227
   different for each call.  */
1228
#define ASM_FORMAT_PRIVATE_NAME(output, name, labelno)                  \
1229
  { (output) = (char *) alloca (strlen ((name)) + 10);                  \
1230
    sprintf ((output), "%s.%lu", (name), (unsigned long int) (labelno)); }
1231
 
1232
/* Macro for %code validation. Returns nonzero if valid.
1233
 
1234
   The acceptance of '(' is an idea taken from SPARC; output nop for %( if not
1235
   optimizing or the slot is not filled. */
1236
#define PRINT_OPERAND_PUNCT_VALID_P(code)  (('(' == code) || ('%' == code))
1237
 
1238
/* Print an instruction operand "x" on file "stream".  "code" is the code from
1239
   the %-spec that requested printing this operand; if `%z3' was used to print
1240
   operand 3, then CODE is 'z'.  */
1241
#define PRINT_OPERAND(stream, x, code)                                  \
1242
{                                                                       \
1243
  if (code == 'r'                                                       \
1244
      && GET_CODE (x) == MEM                                            \
1245
      && GET_CODE (XEXP (x, 0)) == REG)                                  \
1246
    {                                                                   \
1247
      fprintf (stream, "%s", reg_names[REGNO (XEXP (x, 0))]);            \
1248
    }                                                                   \
1249
  else if (code == '(')                                                 \
1250
    {                                                                   \
1251
      if (dbr_sequence_length ())                                       \
1252
        fprintf (stream, "\t# delay slot filled");                      \
1253
      else                                                              \
1254
        fprintf (stream, "\n\tl.nop\t\t\t# nop delay slot");            \
1255
    }                                                                   \
1256
  else if (code == 'C')                                                 \
1257
    {                                                                   \
1258
      switch (GET_CODE (x))                                             \
1259
        {                                                               \
1260
        case EQ:                                                        \
1261
          fputs ("eq", stream);                                         \
1262
          break;                                                        \
1263
        case NE:                                                        \
1264
          fputs ("ne", stream);                                         \
1265
          break;                                                        \
1266
        case GT:                                                        \
1267
          fputs ("gts", stream);                                        \
1268
          break;                                                        \
1269
        case GE:                                                        \
1270
          fputs ("ges", stream);                                        \
1271
          break;                                                        \
1272
        case LT:                                                        \
1273
          fputs ("lts", stream);                                        \
1274
          break;                                                        \
1275
        case LE:                                                        \
1276
          fputs ("les", stream);                                        \
1277
          break;                                                        \
1278
        case GTU:                                                       \
1279
          fputs ("gtu", stream);                                        \
1280
          break;                                                        \
1281
        case GEU:                                                       \
1282
          fputs ("geu", stream);                                        \
1283
          break;                                                        \
1284
        case LTU:                                                       \
1285
          fputs ("ltu", stream);                                        \
1286
          break;                                                        \
1287
        case LEU:                                                       \
1288
          fputs ("leu", stream);                                        \
1289
          break;                                                        \
1290
        default:                                                        \
1291
          abort ();                                                     \
1292
        }                                                               \
1293
    }                                                                   \
1294
  else if (code == 'H')                                                 \
1295
    {                                                                   \
1296
      if (GET_CODE (x) == REG)                                          \
1297
        fprintf (stream, "%s", reg_names[REGNO (x) + 1]);               \
1298
      else                                                              \
1299
        abort ();                                                       \
1300
    }                                                                   \
1301 399 jeremybenn
  else if (code == 'J')                                                 \
1302
    or32_print_jump_restore (x);                                        \
1303 282 jeremybenn
  else if (GET_CODE (x) == REG)                                         \
1304
    fprintf (stream, "%s", reg_names[REGNO (x)]);                       \
1305
  else if (GET_CODE (x) == MEM)                                         \
1306
    output_address (XEXP (x, 0));                                        \
1307
  else                                                                  \
1308
    output_addr_const (stream, x);                                      \
1309
}
1310
 
1311
/* Print a memory operand whose address is "addr", on file "stream".
1312
   This uses a function in output-vax.c.  */
1313
#define PRINT_OPERAND_ADDRESS(stream, addr)                             \
1314
{                                                                       \
1315
  rtx offset;                                                           \
1316
                                                                        \
1317
  switch (GET_CODE (addr))                                              \
1318
    {                                                                   \
1319
    case MEM:                                                           \
1320
      if (GET_CODE (XEXP (addr, 0)) == REG)                              \
1321
        fprintf (stream, "%s", reg_names[REGNO (addr)]);                \
1322
      else                                                              \
1323
        abort ();                                                       \
1324
      break;                                                            \
1325
                                                                        \
1326
    case REG:                                                           \
1327
      fprintf (stream, "0(%s)", reg_names[REGNO (addr)]);               \
1328
      break;                                                            \
1329
                                                                        \
1330
    case PLUS:                                                          \
1331
      offset = 0;                                                        \
1332
      if (GET_CODE (XEXP (addr, 0)) == REG)                              \
1333
        {                                                               \
1334
          offset = XEXP (addr, 1);                                      \
1335
          addr   = XEXP (addr, 0);                                       \
1336
        }                                                               \
1337
      else if (GET_CODE (XEXP (addr, 1)) == REG)                        \
1338
        {                                                               \
1339
          offset = XEXP (addr, 0);                                       \
1340
          addr   = XEXP (addr, 1);                                      \
1341
        }                                                               \
1342
      output_address (offset);                                          \
1343
      fprintf (stream, "(%s)", reg_names[REGNO (addr)]);                \
1344
      break;                                                            \
1345
                                                                        \
1346
    default:                                                            \
1347
      output_addr_const (stream, addr);                                 \
1348
    }                                                                   \
1349
}
1350
 
1351 332 jeremybenn
/* The size of the trampoline in bytes. This is a block of code followed by
1352
   two words specifying the function address and static chain pointer. */
1353
#define TRAMPOLINE_SIZE                                                 \
1354 399 jeremybenn
  (or32_trampoline_code_size () + GET_MODE_SIZE (ptr_mode) * 2)
1355 282 jeremybenn
 
1356 332 jeremybenn
/* Alignment required for trampolines, in bits.
1357 282 jeremybenn
 
1358 332 jeremybenn
   For the OR32, there is no need for anything other than word alignment. */
1359
#define TRAMPOLINE_ALIGNMENT  32
1360
 
1361 282 jeremybenn
/* Mark functions for garbage collection. */
1362
extern GTY(()) rtx or32_compare_op0;
1363
extern GTY(()) rtx or32_compare_op1;
1364
 
1365 402 jeremybenn
/* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop).  */
1366
#define HANDLE_PRAGMA_PACK_PUSH_POP
1367 282 jeremybenn
 
1368 452 jeremybenn
/* GLIBC is not implemented, but we handle the selection for consistency
1369
   with the Linux framework.  */
1370
enum or32_libc_kind {  or32_libc_newlib, or32_libc_uclibc, or32_libc_glibc };
1371 402 jeremybenn
 
1372 282 jeremybenn
#endif /* _OR32_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.