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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [m32c/] [m32c-pragma.c] - Blame information for rev 724

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

Line No. Rev Author Line
1 709 jeremybenn
/* M32C Pragma support
2
   Copyright (C) 2004, 2007, 2010 Free Software Foundation, Inc.
3
   Contributed by Red Hat, Inc.
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
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "tm.h"
25
#include "tree.h"
26
#include "c-family/c-pragma.h"
27
#include "c-family/c-common.h"
28
#include "diagnostic-core.h"
29
#include "cpplib.h"
30
#include "hard-reg-set.h"
31
#include "output.h"
32
#include "m32c-protos.h"
33
#include "function.h"
34
#define MAX_RECOG_OPERANDS 10
35
#include "reload.h"
36
#include "target.h"
37
 
38
/* Implements the "GCC memregs" pragma.  This pragma takes only an
39
   integer, and is semantically identical to the -memregs= command
40
   line option.  The only catch is, the programmer should only use
41
   this pragma at the beginning of the file (preferably, in some
42
   project-wide header) to avoid ABI changes related to changing the
43
   list of available "registers".  */
44
static void
45
m32c_pragma_memregs (cpp_reader * reader ATTRIBUTE_UNUSED)
46
{
47
  /* on off */
48
  tree val;
49
  enum cpp_ttype type;
50
  HOST_WIDE_INT i;
51
 
52
  type = pragma_lex (&val);
53
  if (type == CPP_NUMBER)
54
    {
55
      if (host_integerp (val, 1))
56
        {
57
          i = tree_low_cst (val, 1);
58
 
59
          type = pragma_lex (&val);
60
          if (type != CPP_EOF)
61
            warning (0, "junk at end of #pragma GCC memregs [0..16]");
62
 
63
          if (0 <= i && i <= 16)
64
            {
65
              if (!ok_to_change_target_memregs)
66
                {
67
                  warning (0,
68
                           "#pragma GCC memregs must precede any function decls");
69
                  return;
70
                }
71
              target_memregs = i;
72
              m32c_conditional_register_usage ();
73
            }
74
          else
75
            {
76
              warning (0, "#pragma GCC memregs takes a number [0..16]");
77
            }
78
 
79
          return;
80
        }
81
    }
82
 
83
  error ("#pragma GCC memregs takes a number [0..16]");
84
}
85
 
86
/* Implements the "pragma ADDRESS" pragma.  This pragma takes a
87
   variable name and an address, and arranges for that variable to be
88
   "at" that address.  The variable is also made volatile.  */
89
static void
90
m32c_pragma_address (cpp_reader * reader ATTRIBUTE_UNUSED)
91
{
92
  /* on off */
93
  tree var, addr;
94
  enum cpp_ttype type;
95
 
96
  type = pragma_lex (&var);
97
  if (type == CPP_NAME)
98
    {
99
      type = pragma_lex (&addr);
100
      if (type == CPP_NUMBER)
101
        {
102
          if (var != error_mark_node)
103
            {
104
              unsigned uaddr = tree_low_cst (addr, 1);
105
              m32c_note_pragma_address (IDENTIFIER_POINTER (var), uaddr);
106
            }
107
 
108
          type = pragma_lex (&var);
109
          if (type != CPP_EOF)
110
            {
111
              error ("junk at end of #pragma ADDRESS");
112
            }
113
          return;
114
        }
115
    }
116
  error ("malformed #pragma ADDRESS variable address");
117
}
118
 
119
/* Implements REGISTER_TARGET_PRAGMAS.  */
120
void
121
m32c_register_pragmas (void)
122
{
123
  c_register_pragma ("GCC", "memregs", m32c_pragma_memregs);
124
  c_register_pragma (NULL, "ADDRESS", m32c_pragma_address);
125
  c_register_pragma (NULL, "address", m32c_pragma_address);
126
 
127
  /* R8C and M16C have 16-bit pointers in a 20-bit address zpace.
128
     M32C has 24-bit pointers in a 24-bit address space, so does not
129
     need far pointers, but we accept the qualifier anyway, as a
130
     no-op.  */
131
  if (TARGET_A16)
132
    c_register_addr_space ("__far", ADDR_SPACE_FAR);
133
  else
134
    c_register_addr_space ("__far", ADDR_SPACE_GENERIC);
135
}

powered by: WebSVN 2.1.0

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