Пример #1
0
/* 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);
}
Пример #2
0
/* 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);

}