-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.c
69 lines (62 loc) · 1.41 KB
/
main.c
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
/*
* Compiler pass main loop
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "compiler.h"
FILE *debug;
unsigned deffunctype; /* The type of an undeclared function */
unsigned funcbody; /* Parser global for function body */
unsigned voltrack; /* Track possible volatiles */
unsigned in_sizeof; /* Set if we are in sizeof() */
unsigned cputype; /* So the target specific code can make decisions */
unsigned long cpufeat; /* CPU feature flags from user for target specific code */
/*
* A C program consists of a series of declarations that by default
* are external definitions.
*/
static void toplevel(void)
{
if (token == T_TYPEDEF) {
next_token();
dotypedef();
} else {
funcbody = 0;
voltrack = 0;
target_reginit();
declaration(S_EXTDEF);
}
}
/* A function defined by use is taken to be int f(); */
static unsigned functype[2] = {
1, ELLIPSIS
};
int main(int argc, char *argv[])
{
if (argc != 3) {
error("cc1 cpuname features");
exit(1);
}
cputype = atoi(argv[1]);
cpufeat = atol(argv[2]);
next_token();
init_nodes();
/* A function with no type info returning INT */
deffunctype = make_function(CINT, functype);
#ifdef DEBUG
if (argv[1]) {
debug = fopen(argv[1], "w");
if (debug == NULL) {
perror(argv[1]);
return 255;
}
}
#endif
while (token != T_EOF)
toplevel();
/* No write out any uninitialized variables */
write_bss();
out_write();
return errors;
}