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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [lib/] [gcc/] [or1knd-elf/] [4.8.0/] [plugin/] [include/] [config/] [or1k/] [or1k.h] - Blame information for rev 35

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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