aboutsummaryrefslogtreecommitdiff
path: root/gcc/cil/cil1.c
blob: 3dea3c6e6964ef5842dd56db2088fae9d934ba64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* CIL Compiler almost main (cil1)
   Called by GCC's toplev.c

   Copyright (C) 2006 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.

   In other words, you are welcome to use, share and improve this program.
   You are forbidden to forbid anyone else to use, share and improve
   what you give them.   Help stamp out software-hoarding!

   Author:
     Ricardo Fernandez Pascual <ricardof@um.es>

*/

#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "flags.h"
#include "toplev.h"
#include "version.h"

#include "ggc.h"
#include "tree.h"
#include "cgraph.h"
#include "diagnostic.h"
#include "opts.h"
#include "options.h"
#include "value-prof.h"

#include "cil.h"
#include "cil-tree.h"
#include "parser.h"

/* Language for usage for messages.  */
const char *const language_string = "CIL front end for GCC ";

/* Prepare to handle switches.  */
unsigned int
cil_init_options (unsigned int argc ATTRIBUTE_UNUSED,
                  const char **argv ATTRIBUTE_UNUSED)
{
  return CL_CIL;
}

/* Process a switch - called by opts.c.  */
int
cil_handle_option (size_t scode, const char *arg, int value)
{
  enum opt_code code = (enum opt_code) scode;
  switch (code)
    {
    case OPT_fcompile_only_reachable:
      flag_parse_only_reachable = true;
      break;
    case OPT_ferror_unsupported:
      flag_unsupported_method_behavior = UMB_ERROR;
      break;
    case OPT_fcbuiltin:
      flag_no_cbuiltin = !value;
      break;
    default:
      gcc_unreachable ();
    }
  return 1;
}

/* Language dependent parser setup.  */

bool
cil_init (void)
{
#ifndef USE_MAPPED_LOCATION
  input_filename = main_input_filename;
#else
  linemap_add (&line_table, LC_ENTER, false, main_input_filename, 1);
#endif

  /* This error will not happen from GCC as it will always create a
     fake input file.  */
  if (!input_filename || input_filename[0] == ' ' || !input_filename[0])
    {
      fprintf (stderr, "No input file specified, try --help for help\n");
      exit (1);
      return false;
    }

#ifdef USE_MAPPED_LOCATION
  linemap_add (&line_table, LC_RENAME, false, "<built-in>", 1);
  linemap_line_start (&line_table, 0, 1);
#endif

  /* Disable strict aliasing rules. CIL semantics require that
     pointers of any type can alias pointer of any other types (unlike
     C), or at least that's our current understanding. Hence, strict
     aliasing is useless (and produces worng code). */
  flag_strict_aliasing = 0;

  /* Init decls, etc.  */
  cil_init_decl_processing ();

  return true;
}

/* Language dependent wrapup.  */

void
cil_finish (void)
{
}

/* Parse a file.  Debug flag doesn't seem to work. */

void
cil_parse_file (int debug_flag ATTRIBUTE_UNUSED)
{
#ifdef USE_MAPPED_LOCATION
  source_location s;
  linemap_add (&line_table, LC_RENAME, false, main_input_filename, 1);
  s = linemap_line_start (&line_table, 1, 80);
  input_location = s;
#else
  input_line = 1;
#endif

  parser_parse_file (input_filename);

  cgraph_finalize_compilation_unit ();
#ifdef USE_MAPPED_LOCATION
  linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
#endif
  cgraph_optimize ();
}

#include "debug.h" /* for debug_hooks */
#include "gtype-cil.h"