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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [avr/] [avr-c.c] - Blame information for rev 749

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

Line No. Rev Author Line
1 709 jeremybenn
/* Copyright (C) 2009, 2010
2
   Free Software Foundation, Inc.
3
   Contributed by Anatoly Sokolov (aesok@post.ru)
4
 
5
   This file is part of GCC.
6
 
7
   GCC is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
 
12
   GCC is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
 
17
   You should have received a copy of the GNU General Public License
18
   along with GCC; see the file COPYING3.  If not see
19
   <http://www.gnu.org/licenses/>.  */
20
 
21
/* Not included in avr.c since this requires C front end.  */
22
 
23
#include "config.h"
24
#include "system.h"
25
#include "coretypes.h"
26
#include "tm.h"
27
#include "tm_p.h"
28
#include "cpplib.h"
29
#include "tree.h"
30
#include "c-family/c-common.h"
31
#include "langhooks.h"
32
 
33
 
34
/* Implement `REGISTER_TARGET_PRAGMAS'.  */
35
 
36
void
37
avr_register_target_pragmas (void)
38
{
39
  int i;
40
 
41
  gcc_assert (ADDR_SPACE_GENERIC == ADDR_SPACE_RAM);
42
 
43
  /* Register address spaces.  The order must be the same as in the respective
44
     enum from avr.h (or designated initialized must be used in avr.c).  */
45
 
46
  for (i = 0; avr_addrspace[i].name; i++)
47
    {
48
      gcc_assert (i == avr_addrspace[i].id);
49
 
50
      if (!ADDR_SPACE_GENERIC_P (i))
51
        c_register_addr_space (avr_addrspace[i].name, avr_addrspace[i].id);
52
    }
53
}
54
 
55
 
56
/* Transorm LO into uppercase and write the result to UP.
57
   You must provide enough space for UP.  Return UP.  */
58
 
59
static char*
60
avr_toupper (char *up, const char *lo)
61
{
62
  char *up0 = up;
63
 
64
  for (; *lo; lo++, up++)
65
    *up = TOUPPER (*lo);
66
 
67
  *up = '\0';
68
 
69
  return up0;
70
}
71
 
72
/* Worker function for TARGET_CPU_CPP_BUILTINS.  */
73
 
74
static const char *const avr_builtin_name[] =
75
  {
76
#define DEF_BUILTIN(NAME, N_ARGS, ID, TYPE, CODE) NAME,
77
#include "builtins.def"
78
#undef DEF_BUILTIN
79
    NULL
80
  };
81
 
82
void
83
avr_cpu_cpp_builtins (struct cpp_reader *pfile)
84
{
85
  int i;
86
 
87
  builtin_define_std ("AVR");
88
 
89
  if (avr_current_arch->macro)
90
    cpp_define_formatted (pfile, "__AVR_ARCH__=%s", avr_current_arch->macro);
91
  if (avr_extra_arch_macro)
92
    cpp_define (pfile, avr_extra_arch_macro);
93
  if (AVR_HAVE_RAMPD)    cpp_define (pfile, "__AVR_HAVE_RAMPD__");
94
  if (AVR_HAVE_RAMPX)    cpp_define (pfile, "__AVR_HAVE_RAMPX__");
95
  if (AVR_HAVE_RAMPY)    cpp_define (pfile, "__AVR_HAVE_RAMPY__");
96
  if (AVR_HAVE_RAMPZ)    cpp_define (pfile, "__AVR_HAVE_RAMPZ__");
97
  if (AVR_HAVE_ELPM)     cpp_define (pfile, "__AVR_HAVE_ELPM__");
98
  if (AVR_HAVE_ELPMX)    cpp_define (pfile, "__AVR_HAVE_ELPMX__");
99
  if (AVR_HAVE_MOVW)     cpp_define (pfile, "__AVR_HAVE_MOVW__");
100
  if (AVR_HAVE_LPMX)     cpp_define (pfile, "__AVR_HAVE_LPMX__");
101
 
102
  if (avr_current_arch->asm_only)
103
    cpp_define (pfile, "__AVR_ASM_ONLY__");
104
  if (AVR_HAVE_MUL)
105
    {
106
      cpp_define (pfile, "__AVR_ENHANCED__");
107
      cpp_define (pfile, "__AVR_HAVE_MUL__");
108
    }
109
  if (avr_current_arch->have_jmp_call)
110
    {
111
      cpp_define (pfile, "__AVR_MEGA__");
112
      cpp_define (pfile, "__AVR_HAVE_JMP_CALL__");
113
    }
114
  if (AVR_XMEGA)
115
    cpp_define (pfile, "__AVR_XMEGA__");
116
  if (avr_current_arch->have_eijmp_eicall)
117
    {
118
      cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__");
119
      cpp_define (pfile, "__AVR_3_BYTE_PC__");
120
    }
121
  else
122
    {
123
      cpp_define (pfile, "__AVR_2_BYTE_PC__");
124
    }
125
 
126
  if (AVR_HAVE_8BIT_SP)
127
    cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");
128
  else
129
    cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");
130
 
131
  if (TARGET_NO_INTERRUPTS)
132
    cpp_define (pfile, "__NO_INTERRUPTS__");
133
 
134
  if (avr_current_device->errata_skip)
135
    {
136
      cpp_define (pfile, "__AVR_ERRATA_SKIP__");
137
 
138
      if (avr_current_arch->have_jmp_call)
139
        cpp_define (pfile, "__AVR_ERRATA_SKIP_JMP_CALL__");
140
    }
141
 
142
  cpp_define_formatted (pfile, "__AVR_SFR_OFFSET__=0x%x",
143
                        avr_current_arch->sfr_offset);
144
 
145
  /* Define builtin macros so that the user can easily query if or if not
146
     non-generic address spaces (and which) are supported.
147
     This is only supported for C.  For C++, a language extension is needed
148
     (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not
149
     implemented in GCC up to now.  */
150
 
151
  if (!strcmp (lang_hooks.name, "GNU C"))
152
    {
153
      for (i = 0; avr_addrspace[i].name; i++)
154
        if (!ADDR_SPACE_GENERIC_P (i)
155
            /* Only supply __FLASH<n> macro if the address space is reasonable
156
               for this target.  The address space qualifier itself is still
157
               supported, but using it will throw an error.  */
158
            && avr_addrspace[i].segment < avr_current_device->n_flash)
159
          {
160
            const char *name = avr_addrspace[i].name;
161
            char *Name = (char*) alloca (1 + strlen (name));
162
 
163
            cpp_define_formatted (pfile, "%s=%s",
164
                                  avr_toupper (Name, name), name);
165
          }
166
    }
167
 
168
  /* Define builtin macros so that the user can
169
     easily query if or if not a specific builtin
170
     is available. */
171
 
172
  for (i = 0; avr_builtin_name[i]; i++)
173
    {
174
      const char *name = avr_builtin_name[i];
175
      char *Name = (char*) alloca (1 + strlen (name));
176
 
177
      cpp_define (pfile, avr_toupper (Name, name));
178
    }
179
}

powered by: WebSVN 2.1.0

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