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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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