Ejemplo n.º 1
0
int main(int argc, char **argv)
{
//  printf("%s ", *argv);
//  parseROM(argv[0]); 
  test_opcodes();
}
int
main (int argc, char *argv[])
{
  int i;
  OrcProgram **programs;
  const char *filename = NULL;

  orc_init ();
  orc_test_init ();

  for(i=1;i<argc;i++){
    if (strcmp(argv[i], "--help") == 0) {
      printf("Usage:\n");
      printf("  orc-bugreport [file.orc]\n");
      printf("\n");
      printf("Options:\n");
      printf("  --help                    Show help options\n");
      printf("  --verbose                 Increase debugging messages\n");
      printf("\n");
      printf("Environment Variables:\n");
      printf("  ORC_DEBUG=<LEVEL>         Set debugging level\n");
      printf("  ORC_CODE=[KEYWORDS,...]   Modify code generation\n");
      printf("    General keywords:\n");
      printf("      backup     Always use backup function\n");
      printf("      debug      Generate debuggable code (useful for backtraces on i386)\n");
      printf("    SSE keywords:\n");
      printf("      -sse2      Disable SSE2\n");
      printf("      -sse3      Disable SSE3\n");
      printf("      -ssse3     Disable SSEE3\n");
      printf("      -sse41     Disable SSE4.1\n");
      printf("      -sse42     Disable SSE4.2\n");
      printf("      -sse4a     Disable SSE4a\n");
      printf("      -sse5      Disable SSE5\n");
      printf("\n");
      exit (0);
    }

    filename = argv[i];
  }

  printf("Orc " VERSION " - integrated testing tool\n");

  printf("Active backend: %s\n",
      orc_target_get_name(orc_target_get_default()));

  {
    int level1, level2, level3;
    orc_get_data_cache_sizes(&level1, &level2, &level3);
    printf("L1 cache: %d\n", level1);
    printf("L2 cache: %d\n", level2);
    printf("L3 cache: %d\n", level3);
  }

  {
    int family, model, stepping;
    orc_get_cpu_family_model_stepping (&family, &model, &stepping);
    printf("Family/Model/Stepping: %d/%d/%d\n", family, model, stepping);
    printf("CPU name: %s\n", orc_get_cpu_name ());
  }

  {
    int i;
    int flags = orc_target_get_default_flags (orc_target_get_default());

    printf("Compiler options: ");
    for(i=0;i<32;i++){
      if (flags & (1<<i)) {
        printf("%s ", orc_target_get_flag_name (orc_target_get_default(), i));
      }
    }
    printf("\n");
  }

  if (filename) {
    int n;
    int ret;
    char *code;

    code = read_file (filename);
    if (!code) {
      printf("orc-bugreport: could not read file %s\n", filename);
      exit(1);
    }

    printf("Parsing %s\n", filename);
    n = orc_parse (code, &programs);

    for(i=0;i<n;i++){
      ret = orc_test_compare_output_full (programs[i], 0);
      if (!ret) {
        printf("FAIL: %s\n", programs[i]->name);
        error = TRUE;
      }
    }
  } else {
    printf("Opcode test:\n");
    test_opcodes();
  }

  if (error) {
    printf("Errors detected.  Please send entire output to [email protected].\n");
    return 1;
  } else {
    printf("No errors detected.\n");
    return 0;
  }
}