예제 #1
0
static bool load_shader(cg_shader_data_t *cg, unsigned i)
{
   RARCH_LOG("Loading Cg shader: \"%s\".\n",
         cg->shader->pass[i].source.path);

   if (!load_program(cg, i + 1,
            cg->shader->pass[i].source.path, true))
      return false;

   return true;
}
예제 #2
0
int main(int argc, char * argv[]) {
   
    cpu* local_cpu = create_cpu();

    // Load program:
    load_program(local_cpu->program, "C:\\Users\\Daniel\\Documents\\Projects\\snowbird\\programs\\div");
    
    // Run Program:
    run_cpu(local_cpu);
    
    free_cpu(local_cpu);
}
예제 #3
0
파일: text.cpp 프로젝트: ALEXLCC/pyland
void Text::display() {
    window->use_context();
    if (dirty_texture) {
        try {
            render();
        }
        catch (Text::RenderException e) {
            LOG(WARNING) << e.what();
            return;
        }
    }
    if (dirty_vbo) {
        try {
            generate_vbo();
        }
        catch (Text::RenderException e) {
            LOG(WARNING) << e.what();
            return;
        }
    }

    if (shaders.count(window) == 0) {
        load_program(window);
    }
    if (vbo == 0) {
        // Assume that the size has not been initialized.
        return;
    }

    std::shared_ptr<Shader> shader = shaders.find(window)->second;
    glUseProgram(shader->get_program());
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture);
    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glDisable(GL_DEPTH_TEST);

    // Position data.
    glVertexAttribPointer(SHADER_LOCATION_POSITION, 2, GL_FLOAT, GL_FALSE, 4 * (GLsizei)sizeof(GLfloat), (GLvoid*)(0 * sizeof(GLfloat)));
    // Texture data.
    glVertexAttribPointer(SHADER_LOCATION_TEXTURE, 2, GL_FLOAT, GL_FALSE, 4 * (GLsizei)sizeof(GLfloat), (GLvoid*)(2 * sizeof(GLfloat)));
    glEnableVertexAttribArray(SHADER_LOCATION_POSITION);
    glEnableVertexAttribArray(SHADER_LOCATION_TEXTURE);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glDrawArrays(GL_TRIANGLES, 0, 6);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindTexture(GL_TEXTURE_2D, 0);
    glUseProgram(0);
    glEnable(GL_DEPTH_TEST);
}
예제 #4
0
파일: shader_cg.c 프로젝트: AreaScout/retro
static bool load_stock(void)
{
   if (!load_program(0, stock_cg_program, false))
   {
      RARCH_ERR("Failed to compile passthrough shader, is something wrong with your environment?\n");
      return false;
   }

   set_program_base_attrib(0);

   return true;
}
예제 #5
0
파일: machine.c 프로젝트: auzias/simulproc
/*!
 * Le fichier binaire a le format suivant :
 * 
 *    - 3 entiers non signés, la taille du segment de texte (\c textsize),
 *    celle du segment de données (\c datasize) et la première adresse libre de
 *    données (\c dataend) ;
 *
 *    - une suite de \c textsize entiers non signés représentant le contenu du
 *    segment de texte (les instructions) ;
 *
 *    - une suite de \c datasize entiers non signés représentant le contenu initial du
 *    segment de données.
 *
 * Tous les entiers font 32 bits et les adresses de chaque segment commencent à
 * 0. La fonction initialise complétement la machine.
 *
 * \param pmach la machine à simuler
 * \param programfile le nom du fichier binaire
 *
 */
void read_program(Machine *pmach, const char *programfile)
{
//  printf("Entree dans read_program\n");
  int bits_read;
  unsigned textsize;
  unsigned datasize;
  unsigned dataend;
  //Ouverture du fichier :
  int handle = open(programfile,O_RDONLY);
  if(handle < 0) {
    fprintf(stderr, "Erreur d'ouverture du fichier binaire dans <machine.c:read_program>\n");
    exit(1);
  }

  if( (bits_read = read(handle, &textsize, sizeof(pmach->_textsize))) != sizeof(pmach->_textsize)) {
    fprintf(stderr, "Erreur de lecture de 'textsize' dans <machine.c:read_program> dans '%s': %d bits lus au lieu de %ld\n", programfile, bits_read, sizeof(textsize));
    exit(1);
  }

  if( (bits_read = read(handle, &datasize, sizeof(pmach->_datasize))) != sizeof(pmach->_datasize)) {
    fprintf(stderr, "Erreur de lecture de 'datasize' dans <machine.c:read_program> dans '%s': %d bits lus au lieu de %ld\n",programfile,bits_read,sizeof(datasize));
    exit(1);
  }

  if( (bits_read = read(handle, &dataend, sizeof(pmach->_dataend))) != sizeof(pmach->_dataend)) {
    fprintf(stderr, "Erreur de lecture de 'dataend' dans <machine.c:read_program> '%s': %d bits lus au lieu de %ld\n",programfile,bits_read,sizeof(dataend));
    exit(1);
  }

  Instruction *text = malloc(textsize * sizeof(Instruction));
  //lecture des instructions :
  if( (bits_read = read(handle, text, textsize * sizeof(Instruction))) != (textsize * sizeof(Instruction)) ) {
    fprintf(stderr, "Erreur de lecture de 'text' dans <machine.c:read_program> '%s': %d bits lus au lieu de %ld\n",programfile,bits_read,textsize * sizeof(Instruction));
    exit(1);
  }

  Word *data = malloc(datasize * sizeof(Word));
  //lecture des données :
  if( (bits_read = read(handle, data, datasize * sizeof(Word))) != (datasize * sizeof(Word))) {
    fprintf(stderr, "Erreur de lecture de 'data' dans <machine.c:read_program> '%s': %d bits lus au lieu de %ld\n",programfile,bits_read,datasize * sizeof(Word));
    exit(1);
  }

  //Fermeture du fichier :
  if(close(handle) != 0) {
    fprintf(stderr, "Erreur de fermeture du fichier binaire dans <machine.c:read_program>\n");
    exit(1);
  }

  //On charge le programme dans la machine :
  load_program(pmach, textsize, text, datasize, data, dataend);
}
예제 #6
0
파일: shell.c 프로젝트: Skidro/MIPS_SIM
/*                                                          
 * Procedure : initialize                                  
 * Purpose   : Load machine language program              
 *             and set up initial state of the machine  
 */
void initialize(char* file_name) {
  int i;
  FILE* program_fd;

  program_fd = fopen (file_name, "r");

  init_memory();
  load_program(program_fd);

  /* Set the initial architectural state */
  NEXT_STATE = CURRENT_STATE;
  RUN_BIT = TRUE;
}
예제 #7
0
static bool load_shader(const char *cgp_path, unsigned i)
{
   char path_buf[PATH_MAX];
   fill_pathname_resolve_relative(path_buf, cgp_path,
      cg_shader->pass[i].source.cg, sizeof(path_buf));

   RARCH_LOG("Loading Cg/HLSL shader: \"%s\".\n", path_buf);

   if (!load_program(i + 1, path_buf, true))
      return false;

   return true;
}
예제 #8
0
int main()
{
    try {
        cl::Context context;
        std::vector<cl::Device> devices;
        std::tie(context, devices) = init_open_cl();
        cl::CommandQueue queue(context, devices[0]);
        cl::Program program = load_program("program.cl", context, devices);
        cl_fn reduce_fn(program, "do_reduce");
        cl_fn sweep_fn(program, "do_sweep");

        std::ifstream in(INPUT_FILE);
        size_t n, npow2;
        in >> n;
        npow2 = pow(2.0, ceil(log2(n)));
        std::vector<float> in_array(npow2);
        for (size_t i = 0; i < n; ++i)
            in >> in_array[i];

        cl::Buffer out_buf(context, std::begin(in_array), std::end(in_array), false);
        std::vector<cl::Event> events;

        for (size_t offset = 1; npow2 / (offset * 2) >= WORKGROUP_SIZE; offset *= 2)
            exec_fn(reduce_fn, out_buf, npow2, offset, npow2 / offset, events, queue);

        if (npow2 < 512)
            exec_fn(reduce_fn, out_buf, npow2, 1, WORKGROUP_SIZE, events, queue);

        exec_fn(sweep_fn, out_buf, npow2, npow2 / 2, WORKGROUP_SIZE, events, queue);

        for (size_t offset = npow2 / 1024; offset > 0; offset /= 2)
            exec_fn(sweep_fn, out_buf, npow2, offset, npow2 / offset, events, queue);

        std::vector<float> out_array(n);
        queue.enqueueReadBuffer(out_buf, CL_TRUE, 0, sizeof(float) * n, &out_array[0]);

        std::ofstream out(OUTPUT_FILE);
        out << std::fixed << std::setprecision(3);
        for (size_t i = 0; i < n; i++)
            out << out_array[i] << " ";
        out << std::endl;
    }
    catch (cl::Error &e) {
        std::cerr << "ERROR: " << e.what() << " (" << e.err() << ")" << std::endl;
    }
    catch (std::runtime_error &e) {
        std::cerr << e.what() << std::endl;
    }

    return 0;
}
    /// Creates a new linear_congruential_engine and seeds it with \p value.
    explicit linear_congruential_engine(command_queue &queue,
                                        result_type value = default_seed)
        : m_context(queue.get_context()),
          m_multiplicands(m_context, threads * sizeof(result_type))
    {
        // setup program
        load_program();

        // seed state
        seed(value);

        // generate multiplicands
        generate_multiplicands(queue);
    }
예제 #10
0
static bool load_plain(const char *path)
{
#if 0
   if (!load_stock())
      return false;
#endif

   RARCH_LOG("Loading HLSL file: %s\n", path);

   if (!load_program(0, path, true))
      return false;

   return true;
}
예제 #11
0
파일: test.c 프로젝트: npic/rtvmc
errcode_t init_test(test_t * test, const char * programfile, const char * testfile)
{
    errcode_t retval;
    FILE * in;
    uint16_t i;
    uint16_t next_gpio_value;
    char filename[256];

    retval = init_vm(&test->uut);
    CHECK_OK(retval, "Failed to init vm\n");
    retval = load_program(&test->uut, programfile);
    CHECK_OK(retval, "Failed to load program\n");
    
    in = fopen(testfile, "r");
    CHECK_NOT_NULL(in, IO, "Failed to open test file\n");
    fscanf(in, "%u", &test->test_length);
    CHECK_NOT_FERROR(in);

    /*
    test->uart_in = fopen("uartin.dat", "w");
    CHECK_NOT_NULL(test->uart_in, IO, "Failed to open UART in file\n");
    test->uart_out = fopen("uartout.dat", "w");
    CHECK_NOT_NULL(test->uart_out, IO, "Failed to open UART out file\n");
    */
    for (i = 0; i < TEST_PIN_COUNT; i++)
    {
        sprintf(filename, "gpio_%u.dat", i);
        test->gpio_files[i] = fopen(filename, "w");
        CHECK_NOT_NULL(test->gpio_files[i], IO, "Failed to open GPIO file\n");
    }

    test->input_size = 0;
    while (!feof(in))
    {
        fscanf(in, "%u %u %hu", &test->gpio_input[test->input_size].time, &test->gpio_input[test->input_size].pin, &next_gpio_value);
        test->gpio_input[test->input_size].value = (uint8_t)next_gpio_value;
        test->input_size++;
    }
    test->input_size--;  /* discard excessive read */
    fclose(in);

    for (i = 0; i < test->uut.proc_table_size; i++)
    {
        sprintf(filename, "sched_%u.dat", i);
        test->schedules[i] = fopen(filename, "w");
        CHECK_NOT_NULL(test->schedules[i], IO, "Failed to open schedule file\n");
    }
    return OK;
}
예제 #12
0
static bool load_shader(hlsl_shader_data_t *hlsl,
	void *data, const char *cgp_path, unsigned i)
{
   char path_buf[PATH_MAX_LENGTH] = {0};

   fill_pathname_resolve_relative(path_buf, cgp_path,
      hlsl->cg_shader->pass[i].source.path, sizeof(path_buf));

   RARCH_LOG("Loading Cg/HLSL shader: \"%s\".\n", path_buf);

   if (!load_program(hlsl, data, i + 1, path_buf, true))
      return false;

   return true;
}
예제 #13
0
int main(int argc, char* argv[])
{
  int error;
  int lines = 0;

  if (argc != 2)
    printf ("Usage: %s <name of riski file>\n", argv[0]);
  else
    lines = load_program (argv[1]);

  if (lines > 0)
    error = run_program (lines);

  return error;
}
예제 #14
0
파일: piet.c 프로젝트: frank-zago/piet
/* Arg1 is program file, arg2 is codel size in pixels. */
int main(int argc, char *argv[])
{
	if (argc != 3) {
		printf("Usage: piet <image> <codel size>\n");
		return 1;
	}

	load_program(argv[1], atoi(argv[2]));

	if (!program.image) {
		fprintf(stderr, "Program not found/not valid\n");
		return 1;
	}

	interp.dp = 0;
	interp.cc = -1;
	interp.current.x = 0;
	interp.current.y = 0;
	get_codel_color(&interp.current);

	int found;

	do {
		struct codel next;

		if (interp.current.color == WHITE) {
			if (slide_white(&next))
				interp.current = next;
			else
				break;
		}

		found = get_next_block(&next);
		if (found) {
			if (next.color == WHITE) {
				interp.current = next;
			} else {
				const struct operation *op = get_operation(&next);
				op->op();
				interp.current = next;
			}
		}
	} while(found);

	free(program.image);

	return 0;
}
예제 #15
0
파일: test_vm.c 프로젝트: mattixtech/mbvm
/**
 * Tests 'exec_program()'.
 */
void test_exec_program()
{
    allocate();
    uint32_t test_instructions[2] = {
            create_instruction(INSTR_NOOP, EMPTY_BYTE, EMPTY_BYTE, EMPTY_BYTE),
            create_instruction(INSTR_EXIT, EMPTY_BYTE, EMPTY_BYTE, EMPTY_BYTE)};
    load_program(test_instructions,
                 sizeof(test_instructions) / sizeof(test_instructions[0]),
                 flash);
    exec_program();
    // TODO: Maybe there is a better way to test this
    // This is a very trivial test just to check that the pc was incremented
    // after executing a no op
    CU_ASSERT(0 != pc);
    deallocate();
}
예제 #16
0
pwr_tStatus
ini_PlcLoad (
    pwr_tUInt32		plcversion,
    char			*plcfile,
    int			debugflag
)
{
    pwr_tStatus		sts;
    char			progname[255];
    char			filename[255];
    VARYING_STRING(255)	filenamevar;
    VARYING_STRING(41)	prognamevar;
    pwr_tBoolean		PlcDebug;

    /* Increase loadcount.  */

    PlcDebug = debugflag;
    loadcount++;

    /* Construct the filename and the progname.  */

    strcpy (filename, plcfile);
    CSTRING_TO_VARYING(filename, filenamevar);

    sprintf (progname, PLC_NAME, plcversion, loadcount);
    CSTRING_TO_VARYING(progname, prognamevar);

    /* Start loading.  */

    errh_Info("Loading plc '%s'", progname);

    eln$load_program (
        &filenamevar,		/* Name of .EXE-file		*/
        &prognamevar,		/* Internal ELN prog. name	*/
        TRUE,			/* Kernel mode? 		*/
        PlcDebug,		/* Start with debug?		*/
        FALSE,			/* Power recovery?		*/
        PLC_KERNELSTACK,	/* Kernel Stack size		*/
        1,			/* Initial User stack size	*/
        100,			/* Message limit		*/
        10,			/* Job Priority			*/
        8,			/* Process Priority		*/
        &sts);

    return sts;
}
예제 #17
0
파일: clamb.c 프로젝트: irori/clamb
int main(int argc, char *argv[])
{
    Cell root;
    clock_t start;
    char *prog_file = NULL;
    int i;
    int print_stats = 0;
    int parse_only = 0;
    
    for (i = 1; i < argc && argv[i][0] == '-'; i++) {
	if (strcmp(argv[i], "-g") == 0)
	    gc_notify = 1;
	else if (strcmp(argv[i], "-s") == 0)
	    print_stats = 1;
	else if (strcmp(argv[i], "-p") == 0)
	    parse_only = 1;
        else if (strcmp(argv[i], "-u") == 0)
	    setbuf(stdout, NULL);
	else
	    errexit("unknown option %s\n", argv[i]);
    }

    input_init(argv + i);
    storage_init(INITIAL_HEAP_SIZE);
    rs_init();

    root = load_program();
    if (parse_only) {
	unparse(root);
	return 0;
    }

    start = clock();
    eval_print(root);

    if (print_stats) {
	double evaltime = (clock() - start) / (double)CLOCKS_PER_SEC;

	printf("\n%d reductions\n", reductions);
	printf("  total eval time --- %5.2f sec.\n", evaltime - total_gc_time);
	printf("  total gc time   --- %5.2f sec.\n", total_gc_time);
	printf("  max stack depth --- %d\n", rs_max_depth());
    }
    return 0;
}
예제 #18
0
/*!
 * On initialise les segments aux valeurs lu dans le fichier
 * dans l'odre décrit dans machine.h.
 *
 * On initialise ensuite la machine à l'aide de la fonction load_program()
 *
 * \param pmach la machine à simuler
 * \param programfile le nom du fichier binaire
 *
 */
void read_program(Machine *mach, const char *programfile)
{
	// Pointeur sur le fichier binaire
	FILE * fp;
	int i;
	unsigned textsize;
	unsigned datasize;
	unsigned dataend;
	Instruction * text;
	Word * data;

	// On ouvre le fichier en lecture
	if ((fp = fopen(programfile, "r")) == NULL) {
		fprintf(stderr, "Ouverture du fichier impossible.\n");
		exit(1);
	}

	// Initialisation de textsize
	fread(&textsize, sizeof(unsigned), 1, fp);

	// Initialisation de datasize
	fread(&datasize, sizeof(unsigned), 1, fp);

	// Initialisation de dataend
	fread(&dataend, sizeof(unsigned), 1, fp);

	text = malloc(textsize * sizeof(Instruction));
	data = malloc(datasize * 4);

	// Initialisation du segment de texte
	for (i = 0; i < textsize; ++i) {
		fread(&text[i]._raw, sizeof(uint32_t), 1, fp);
	}

	// Initialisation du segment de donnée
	for (i = 0; i < dataend; ++i) {
		fread(&data[i], sizeof(uint32_t), 1, fp);
	}
	
	// Fermeture du fichier
	fclose(fp);

	// Initialisation des données dans la machine
	load_program(mach, textsize, text, datasize, data, dataend);
}
예제 #19
0
int main(void){
  program_fkvm_t program;
  unsigned long size;

  size = load_program("program_input",&program);
  if (size == 0){
    perror("Couldn't load program");
    return 1;
  }
  
  for (int i=0; i<size; i++){
    printf("%d -> %c\n",i,get_index(&program,i));
  }

  destroy_program(&program);
  
  return 0;
}
예제 #20
0
void read_program(Machine *mach, const char *programfile) {
  Word *data;
  Instruction *text;
  unsigned textsize, datasize, dataend;
  int fd = open(programfile, O_RDONLY);

  read(fd, &textsize, 4);
  read(fd, &datasize, 4);
  read(fd, &dataend, 4);

  text = malloc(sizeof(Instruction)*textsize);
  for(unsigned i=0; i < textsize; i++) read(fd, text + i, 4);
  data = malloc(sizeof(Word)*datasize);
  for(unsigned i=0; i < dataend; i++) read(fd, data + i, 4);

  close(fd);

  load_program(mach, textsize, text, datasize, data, dataend);
}
예제 #21
0
파일: vm_minimal.c 프로젝트: oriansj/stage0
/* Standard C main program */
int main(int argc, char **argv)
{
	/* Make sure we have a program tape to run */
	if (argc < 2)
	{
		fprintf(stderr, "Usage: %s $FileName\nWhere $FileName is the name of the paper tape of the program being run\n", argv[0]);
		return EXIT_FAILURE;
	}

	/* Perform all the essential stages in order */
	struct lilith* vm;
	tape_01_name = "tape_01";
	tape_02_name = "tape_02";
	vm = create_vm(1 << 21);
	load_program(vm, argv);
	execute_vm(vm);
	destroy_vm(vm);

	return EXIT_SUCCESS;
}
예제 #22
0
int main(int argc, char* argv[])
{
    if (argc < 2){
        printf("\nUsage: %s <brainfuck-code.txt>\n", argv[0]);
        free_memory();
        exit(EXIT_FAILURE);
    }
    clean_memory();
    reset_pointer();
    
    load_program(argv[1]);
    if (!is_balanced(program, program_size)){
        printf("ERROR: Unbalanced brackets found in the supplied Brainfuck code.\n");
        free_memory();
        exit(EXIT_FAILURE);
    }
    execute_program();
    free_memory();
    return 0;
}
예제 #23
0
void on_debug_run_continue(G_GNUC_UNUSED const MenuItem *menu_item)
{
	if (gdb_state == INACTIVE)
	{
		if (check_load_path(program_executable, TRUE, R_OK | X_OK) &&
			check_load_path(program_working_dir, FALSE, X_OK) &&
			check_load_path(program_load_script, TRUE, R_OK))
		{
			load_program();
		}
	}
	else if (thread_count)
		debug_send_thread("-exec-continue");
	else
	{
		breaks_apply();
		inspects_apply();
		debug_send_command(N, "-exec-run");
	}
}
예제 #24
0
파일: littlec.c 프로젝트: malpharo/AiPI
int main(int argc, char *argv[])
{
  if(argc != 2) {
    printf("Usage: littlec <filename>\n");
    exit(1);
  }

  /* allocate memory for the program */
  if((p_buf = (char *) malloc(PROG_SIZE))==NULL) {
    printf("Allocation Failure");
    exit(1);
  }

  /* load the program to execute */
  if(!load_program(p_buf, argv[1])) exit(1);
  if(setjmp(e_buf)) exit(1); /* initialize long jump buffer */

  gvar_index = 0;  /* initialize global variable index */

  /* set program pointer to start of program buffer */
  prog = p_buf;
  prescan(); /* find the location of all functions
                and global variables in the program */

  lvartos = 0;     /* initialize local variable stack index */
  functos = 0;     /* initialize the CALL stack index */

  /* setup call to main() */
  prog = find_func("main"); /* find program starting point */

  if(!prog) { /* incorrect or missing main() function in program */
    printf("main() not found.\n");
    exit(1);
  }

  prog--; /* back up to opening ( */
  strcpy(token, "main");
  call(); /* call main() to start interpreting */

  return 0;
}
예제 #25
0
int main() {

	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);

	video v;
	
  	input in;
	chip8cpu c8cpu;

	init_video(&v);
	chip8_init(&c8cpu);
	chip8_load_resources(&c8cpu, &v, &in);
	
	load_program(&c8cpu);


	for (;;) {
		/*
		parse_instruction(&c8cpu, 0x620A);  // set r2 to 0A
		parse_instruction(&c8cpu, 0x6308);  // set r3 to 09
		parse_instruction(&c8cpu, 0x8235);  // subtract r3 from r2
		parse_instruction(&c8cpu, 0xA003);  // set I to 123
		parse_instruction(&c8cpu, 0xF555);  // move r4 to [I]
		*/

		if (check_for_exit(c8cpu.p_input))
			break;

		SDL_Flip(c8cpu.p_video->screen);
		SDL_Delay(250);
		break;
	}
	print_chip8_state(&c8cpu);
	main_memory_dump(&c8cpu);
	
	SDL_Quit();

	return 0;
}
예제 #26
0
파일: 4em.c 프로젝트: yjerem/4917
int main(int argc, char *argv[]) {
  char program[MEMORY_LENGTH];
  FILE *in = stdin;

  if (argc == 2) {
    if ((in = fopen(argv[1], "r")) == NULL) {
      fprintf(stderr, "couldn't open file '%s'\n", argv[1]);
      exit(1);
    }
  } else if (argc > 2) {
    fprintf(stderr, "usage: %s [filename]\n", argv[0]);
    exit(1);
  }

  load_program(in, program);
  run_program(program);

  if (in != stdin) {
    fclose(in);
  }

  return 0;
}
예제 #27
0
int main(int argc, const char * argv[]) {
    
    if (argc == 3) {
        
        std::string filepath = argv[1];
        std::string filename = argv[2];
        
        std::cout << filepath <<std::endl;
        std::cout << filename << std::endl;
        
        if (load_program(filepath, filename) == -1)
            return -1;
        show_program();
        
        // 开始词法分析
        start_lexical_analysis();
        return 0;
    }
    
    std::cout << "用法: ./main.one file_path file_name" << std::endl;
    std::cout << "举例: ./main.one ~/编译原理提交/实验1/ data.txt" << std::endl;
    return -1;
}
예제 #28
0
static rtems_status_code pfpu_execute(struct pfpu_td *td)
{
  rtems_status_code sc;

  load_program(td->program, td->progsize);
  load_registers(td->registers);
  MM_WRITE(MM_PFPU_MESHBASE, (unsigned int)td->output);
  MM_WRITE(MM_PFPU_HMESHLAST, td->hmeshlast);
  MM_WRITE(MM_PFPU_VMESHLAST, td->vmeshlast);
  MM_WRITE(MM_PFPU_CTL, PFPU_CTL_START);

  sc = rtems_semaphore_obtain(done_sem, RTEMS_WAIT, 10);
  if (sc != RTEMS_SUCCESSFUL)
    return sc;

  if (td->update)
    update_registers(td->registers);
    if (td->invalidate) {
      __asm__ volatile( /* Invalidate Level-1 data cache */
      "wcsr DCC, r0\n"
      "nop\n"
    );
  }
예제 #29
0
int	load_all_programs(t_vm *vm)
{
  int	i;
  t_prog_param	*prog;
  t_program	*program;

  if ((vm->prog_list = create_list(NULL)) == 0)
    return (1);
  i = 0;
  while (i < vm->param->progs->nb_elm)
  {
    prog = get_data(vm->param->progs, i);
    program = NULL;
    if ((program = load_program(prog, vm)) == 0)
    {
      my_printf("Error: fail to load : %s\n", prog->prog_name);
      return (1);
    }
    add_last_elm(vm->prog_list, program);
    vm->progs_live[program->registre[0][REG_SIZE - 1]] = 0;
    ++i;
  }
  return (0);
}
static void test_runner_rc_regalloc(
	struct test_result *result,
	struct radeon_compiler *c,
	const char *filename)
{
	struct rc_test_file test_file;
	unsigned optimizations = 1;
	unsigned do_full_regalloc = 1;
	struct rc_instruction *inst;
	unsigned pass = 1;

	test_begin(result);

	if (!load_program(c, &test_file, filename)) {
		fprintf(stderr, "Failed to load program\n");
	}

	rc_pair_translate(c, NULL);
	rc_pair_schedule(c, &optimizations);
	rc_pair_remove_dead_sources(c, NULL);
	rc_pair_regalloc(c, &do_full_regalloc);

	for(inst = c->Program.Instructions.Next;
				inst != &c->Program.Instructions;
				inst = inst->Next) {
		if (inst->Type == RC_INSTRUCTION_NORMAL &&
				inst->U.I.Opcode != RC_OPCODE_BEGIN_TEX) {
			if (GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 0)
							!= RC_SWIZZLE_X) {
				pass = 0;
			}
		}
	}

	test_check(result, pass);
}