main.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef NORCSID
  2. static char rcsid[] = "$Id$";
  3. #endif
  4. #include "param.h"
  5. #include "mach.h"
  6. /*
  7. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  8. * See the copyright notice in the ACK home directory, in the file "Copyright".
  9. *
  10. * Author: Hans van Staveren
  11. */
  12. char *progname;
  13. extern char startupcode[];
  14. int maxply=1;
  15. #ifndef NDEBUG
  16. int Debug=0;
  17. #endif
  18. extern int endofprog;
  19. main(argc,argv) char **argv; {
  20. register unsigned n;
  21. extern unsigned cc1,cc2,cc3,cc4;
  22. unsigned ggd();
  23. progname = argv[0];
  24. while (--argc && **++argv == '-') {
  25. switch(argv[0][1]) {
  26. #ifndef NDEBUG
  27. case 'd':
  28. Debug++; break;
  29. #endif
  30. case 'p':
  31. maxply = atoi(argv[0]+2);
  32. break;
  33. case 'w': /* weight percentage for size */
  34. n=atoi(argv[0]+2);
  35. cc1 *= n;
  36. cc2 *= 50;
  37. cc3 *= (100-n);
  38. cc4 *= 50;
  39. n=ggd(cc1,cc2);
  40. cc1 /= n;
  41. cc2 /= n;
  42. n=ggd(cc3,cc4);
  43. cc3 /= n;
  44. cc4 /= n;
  45. break;
  46. default:
  47. #ifdef MACH_OPTIONS
  48. mach_option(argv[0]);
  49. #else
  50. error("Unknown flag %c",argv[0][1]);
  51. #endif
  52. break;
  53. }
  54. }
  55. if (argc < 1 || argc > 2)
  56. error("Usage: %s EMfile [ asfile ]",progname);
  57. in_init(argv[0]);
  58. out_init(argv[1]);
  59. in_start();
  60. codegen(startupcode,maxply,TRUE,MAXINT,0);
  61. in_finish();
  62. if (!endofprog)
  63. error("Bombed out of codegen");
  64. out_finish();
  65. }
  66. unsigned ggd(a,b) register unsigned a,b; {
  67. register unsigned c;
  68. do {
  69. c = a%b; a=b; b=c;
  70. } while (c!=0);
  71. return(a);
  72. }