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

Subversion Repositories openrisc_me

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

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