/* control multiple files */ int main(int argc, char *argv[]) { int ch; #ifdef TIMING struct timeval t1, t2; (void)gettimeofday(&t1, NULL); #endif prgname = argv[0]; while ((ch = getopt(argc, argv, "OT:VW:X:Z:f:gkm:psvwx:")) != -1) { switch (ch) { #if !defined(MULTIPASS) || defined(PASS1) case 'X': /* pass1 debugging */ while (*optarg) switch (*optarg++) { case 'b': ++bdebug; break; /* buildtree */ case 'd': ++ddebug; break; /* declarations */ case 'e': ++edebug; break; /* pass1 exit */ case 'i': ++idebug; break; /* initializations */ case 'n': ++ndebug; break; /* node allocation */ case 'o': ++odebug; break; /* optim */ case 'p': ++pdebug; break; /* prototype */ case 's': ++sdebug; break; /* inline */ case 't': ++tdebug; break; /* type match */ case 'x': ++xdebug; break; /* MD code */ default: fprintf(stderr, "unknown -X flag '%c'\n", optarg[-1]); exit(1); } break; #endif #if !defined(MULTIPASS) || defined(PASS2) case 'Z': /* pass2 debugging */ while (*optarg) switch (*optarg++) { case 'b': /* basic block and SSA building */ ++b2debug; break; case 'c': /* code printout */ ++c2debug; break; case 'e': /* print tree upon pass2 enter */ ++e2debug; break; case 'f': /* instruction matching */ ++f2debug; break; case 'g': /* print flow graphs */ ++g2debug; break; case 'n': /* node allocation */ ++ndebug; break; case 'o': /* instruction generator */ ++o2debug; break; case 'r': /* register alloc/graph coloring */ ++r2debug; break; case 's': /* shape matching */ ++s2debug; break; case 't': /* type matching */ ++t2debug; break; case 'u': /* Sethi-Ullman debugging */ ++u2debug; break; case 'x': /* target specific */ ++x2debug; break; default: fprintf(stderr, "unknown -Z flag '%c'\n", optarg[-1]); exit(1); } break; #endif case 'f': /* Language */ fflags(optarg); break; case 'g': /* Debugging */ ++gflag; break; case 'k': /* PIC code */ ++kflag; break; case 'm': /* Target-specific */ mflags(optarg); break; case 'p': /* Profiling */ ++pflag; break; case 's': /* Statistics */ ++sflag; break; case 'W': /* Enable different warnings */ Wflags(optarg); break; case 'x': /* Different settings */ xopt(optarg); break; case 'v': printf("ccom: %s\n", VERSSTR); break; case '?': default: usage(); } } argc -= optind; argv += optind; if (argc > 0 && strcmp(argv[0], "-") != 0) { if (freopen(argv[0], "r", stdin) == NULL) { fprintf(stderr, "open input file '%s':", argv[0]); perror(NULL); exit(1); } } if (argc > 1 && strcmp(argv[1], "-") != 0) { if (freopen(argv[1], "w", stdout) == NULL) { fprintf(stderr, "open output file '%s':", argv[1]); perror(NULL); exit(1); } } mkdope(); signal(SIGSEGV, segvcatch); #ifdef SIGBUS signal(SIGBUS, segvcatch); #endif fregs = FREGS; /* number of free registers */ lineno = 1; #ifdef GCC_COMPAT gcc_init(); #endif /* starts past any of the above */ reached = 1; bjobcode(); #ifndef TARGET_VALIST { NODE *p = block(NAME, NIL, NIL, PTR|CHAR, NULL, 0); struct symtab *sp = lookup(addname("__builtin_va_list"), 0); p->n_sp = sp; defid(p, TYPEDEF); nfree(p); } #endif complinit(); #ifdef STABS if (gflag) { stabs_file(argc ? argv[0] : ""); stabs_init(); } #endif if (sspflag) sspinit(); (void) yyparse(); yyaccpt(); if (!nerrors) lcommprint(); #ifdef STABS if (gflag) stabs_efile(argc ? argv[0] : ""); #endif ejobcode( nerrors ? 1 : 0 ); #ifdef TIMING (void)gettimeofday(&t2, NULL); t2.tv_sec -= t1.tv_sec; t2.tv_usec -= t1.tv_usec; if (t2.tv_usec < 0) { t2.tv_usec += 1000000; t2.tv_sec -= 1; } fprintf(stderr, "ccom total time: %ld s %ld us\n", t2.tv_sec, t2.tv_usec); #endif if (sflag) prtstats(); return(nerrors?1:0); }
int main(int argc, char **argv) { int ch; int k, retcode; infile = stdin; diagfile = stderr; #if 1 /* RAGGE */ char file[] = "/tmp/initfile.XXXXXX"; char buf[100]; close(mkstemp(file)); sprintf(buf, "sort > %s", file); initfile = popen(buf, "w"); #endif #define DONE(c) { retcode = c; goto finis; } while ((ch = getopt(argc, argv, "qw:UuOdpC1I:Z:X:")) != -1) switch (ch) { case 'q': quietflag = YES; break; case 'w': if(optarg[0]=='6' && optarg[1]=='6') { ftn66flag = YES; } else nowarnflag = YES; break; case 'U': shiftcase = NO; break; case 'u': undeftype = YES; break; case 'O': optimflag = YES; #ifdef notyet xdeljumps = 1; xtemps = 1; #endif break; case 'd': debugflag = YES; break; case 'p': profileflag = YES; break; case 'C': checksubs = YES; break; case '1': onetripflag = YES; break; case 'I': if(*optarg == '2') tyint = TYSHORT; else if(*optarg == '4') { shortsubs = NO; tyint = TYLONG; } else if(*optarg == 's') shortsubs = YES; else fatal1("invalid flag -I%c\n", *optarg); tylogical = tyint; break; case 'Z': /* pass2 debugging */ while (*optarg) switch (*optarg++) { case 'b': /* basic block and SSA building */ ++b2debug; break; case 'c': /* code printout */ ++c2debug; break; case 'e': /* print tree upon pass2 enter */ ++e2debug; break; case 'f': /* instruction matching */ ++f2debug; break; case 'g': ++g2debug; break; case 'n': ++ndebug; break; case 'o': ++o2debug; break; case 'r': /* register alloc/graph coloring */ ++r2debug; break; case 's': /* shape matching */ ++s2debug; break; case 't': ++t2debug; break; case 'u': /* Sethi-Ullman debugging */ ++u2debug; break; case 'x': ++x2debug; break; default: fprintf(stderr, "unknown Z flag '%c'\n", optarg[-1]); exit(1); } break; case 'X': /* pass1 debugging */ while (*optarg) switch (*optarg++) { case 'm': /* memory allocation */ ++mflag; break; case 't': /* tree debugging */ tflag++; break; default: usage(); } break; default: usage(); } argc -= optind; argv += optind; mkdope(); initkey(); if (argc > 0) { if (inilex(copys(argv[0]))) DONE(1); if (!quietflag) fprintf(diagfile, "%s:\n", argv[0]); if (argc != 1) if (freopen(argv[1], "w", stdout) == NULL) { fprintf(stderr, "open output file '%s':", argv[1]); perror(NULL); exit(1); } } else { inilex(copys("")); } fileinit(); procinit(); if((k = yyparse())) { fprintf(diagfile, "Bad parse, return code %d\n", k); DONE(1); } if(nerr > 0) DONE(1); if(parstate != OUTSIDE) { warn("missing END statement"); endproc(); } doext(); preven(ALIDOUBLE); prtail(); puteof(); DONE(0); finis: pclose(initfile); retcode |= dodata(file); unlink(file); done(retcode); return(retcode); }
/* control multiple files */ int main(int argc, char *argv[]) { int ch; prgname = argv[0]; while ((ch = getopt(argc, argv, "OT:VW:X:Z:f:gklm:psvwx:")) != -1) switch (ch) { #if !defined(MULTIPASS) || defined(PASS1) case 'X': while (*optarg) switch (*optarg++) { case 'd': ++ddebug; break; /* declarations */ case 'i': ++idebug; break; /* initializations */ case 'b': ++bdebug; break; case 't': ++tdebug; break; case 'e': ++edebug; break; /* pass1 exit */ case 'x': ++xdebug; break; /* MD code */ case 's': ++sdebug; break; case 'n': ++nflag; break; case 'o': ++oflag; break; case 'p': ++pdebug; break; /* prototype */ default: fprintf(stderr, "unknown X flag '%c'\n", optarg[-1]); exit(1); } #endif break; #if !defined(MULTIPASS) || defined(PASST) case 'T': while (*optarg) switch (*optarg++) { case 'i': ++iTflag; break; case 'o': ++oTflag; break; case 'n': ++nflag; break; default: fprintf(stderr, "unknown T flag '%c'\n", optarg[-1]); exit(1); } #endif break; #if !defined(MULTIPASS) || defined(PASS2) case 'Z': while (*optarg) switch (*optarg++) { case 'f': /* instruction matching */ ++f2debug; break; case 'e': /* print tree upon pass2 enter */ ++e2debug; break; case 'o': ++odebug; break; case 'r': /* register alloc/graph coloring */ ++rdebug; break; case 'b': /* basic block and SSA building */ ++b2debug; break; case 'c': /* code printout */ ++c2debug; break; case 't': ++t2debug; break; case 's': /* shape matching */ ++s2debug; break; case 'u': /* Sethi-Ullman debugging */ ++udebug; break; case 'x': ++x2debug; break; case 'n': ++nflag; break; default: fprintf(stderr, "unknown Z flag '%c'\n", optarg[-1]); exit(1); } #endif break; case 'f': /* Language */ fflags(optarg); break; case 'g': /* Debugging */ gflag = 1; break; case 'k': /* PIC code */ ++kflag; break; case 'l': /* Linenos */ ++lflag; break; case 'm': /* Target-specific */ mflags(optarg); break; case 'p': /* Profiling */ pflag = 1; break; case 's': /* Statistics */ ++sflag; break; case 'W': /* Enable different warnings */ Wflags(optarg); break; case 'x': /* Different optimizations */ if (strcmp(optarg, "ssa") == 0) xssaflag++; else if (strcmp(optarg, "tailcall") == 0) xtailcallflag++; else if (strcmp(optarg, "temps") == 0) xtemps++; else if (strcmp(optarg, "deljumps") == 0) xdeljumps++; else usage(); break; case 'v': printf("ccom: %s\n", VERSSTR); break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc > 0 && strcmp(argv[0], "-") != 0) { if (freopen(argv[0], "r", stdin) == NULL) { fprintf(stderr, "open input file '%s':", argv[0]); perror(NULL); exit(1); } } if (argc > 1 && strcmp(argv[1], "-") != 0) { if (freopen(argv[1], "w", stdout) == NULL) { fprintf(stderr, "open output file '%s':", argv[1]); perror(NULL); exit(1); } } mkdope(); signal(SIGSEGV, segvcatch); fregs = FREGS; /* number of free registers */ lineno = 1; #ifdef GCC_COMPAT gcc_init(); #endif /* dimension table initialization */ btdims[VOID].suesize = 0; btdims[BOOL].suesize = SZBOOL; btdims[CHAR].suesize = SZCHAR; btdims[INT].suesize = SZINT; btdims[FLOAT].suesize = SZFLOAT; btdims[DOUBLE].suesize = SZDOUBLE; btdims[LDOUBLE].suesize = SZLDOUBLE; btdims[LONG].suesize = SZLONG; btdims[LONGLONG].suesize = SZLONGLONG; btdims[SHORT].suesize = SZSHORT; btdims[UCHAR].suesize = SZCHAR; btdims[USHORT].suesize = SZSHORT; btdims[UNSIGNED].suesize = SZINT; btdims[ULONG].suesize = SZLONG; btdims[ULONGLONG].suesize = SZLONGLONG; btdims[FCOMPLEX].suesize = SZFLOAT * 2; btdims[COMPLEX].suesize = SZDOUBLE * 2; btdims[LCOMPLEX].suesize = SZLDOUBLE * 2; /* starts past any of the above */ reached = 1; bjobcode(); #ifdef STABS if (gflag) { stabs_file(argc ? argv[0] : ""); stabs_init(); } #endif if (sspflag) sspinit(); (void) yyparse(); yyaccpt(); if (!nerrors) lcommprint(); ejobcode( nerrors ? 1 : 0 ); if (sflag) prtstats(); return(nerrors?1:0); }