OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

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

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