void vips_vector_constant( VipsVector *vector, char *name, int value, int size ) { #ifdef HAVE_ORC char *sname; if( size == 1 ) sname = "b"; else if( size == 2 ) sname = "w"; else if( size == 4 ) sname = "l"; else { printf( "vips_vector_constant: bad constant size\n" ); /* Not really correct, heh. */ sname = "x"; } if( value > 0 ) vips_snprintf( name, 256, "c%d%s", value, sname ); else vips_snprintf( name, 256, "cm%d%s", -value, sname ); if( orc_program_find_var_by_name( vector->program, name ) == -1 ) { orc_program_add_constant( vector->program, size, value, name ); vector->n_constant += 1; } #endif /*HAVE_ORC*/ }
/** * orc_program_append_ds_str: * @program: a pointer to an OrcProgram structure * @name: name of instruction * @arg0: name of first variable * @arg1: name of second variable * * Appends an instruction to the program, with arguments @arg0 and * @arg2. The instruction must take 2 operands. */ void orc_program_append_ds_str (OrcProgram *program, const char *name, const char *arg1, const char *arg2) { OrcInstruction *insn; insn = program->insns + program->n_insns; insn->opcode = orc_opcode_find_by_name (name); if (!insn->opcode) { ORC_ERROR ("unknown opcode: %s", name); } insn->dest_args[0] = orc_program_find_var_by_name (program, arg1); insn->src_args[0] = orc_program_find_var_by_name (program, arg2); program->n_insns++; }
void orc_executor_set_array_str (OrcExecutor *ex, const char *name, void *ptr) { int var; var = orc_program_find_var_by_name (ex->program, name); if (var >= 0) ex->arrays[var] = ptr; }
void orc_executor_set_param_str (OrcExecutor *ex, const char *name, int value) { int var; var = orc_program_find_var_by_name (ex->program, name); if (var >= 0) ex->params[var] = value; }
int orc_executor_get_accumulator_str (OrcExecutor *ex, const char *name) { int var; var = orc_program_find_var_by_name (ex->program, name); if (var >= 0) return ex->accumulators[var]; return -1; }
void vips_vector_temporary( VipsVector *vector, char *name, int size ) { #ifdef HAVE_ORC g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 ); orc_program_add_temporary( vector->program, size, name ); vector->n_temp += 1; #endif /*HAVE_ORC*/ }
/** * orc_program_append_str_2: * @program: a pointer to an OrcProgram structure * @name: name of instruction * @flags: flags * @arg0: name of first variable * @arg1: name of second variable * @arg2: name of third variable * @arg3: name of fourth variable * * Appends an instruction to the program, with arguments @arg0, * @arg1, @arg2, and @arg3. */ void orc_program_append_str_2 (OrcProgram *program, const char *name, unsigned int flags, const char *arg1, const char *arg2, const char *arg3, const char *arg4) { OrcInstruction *insn; int args[4]; int i; insn = program->insns + program->n_insns; insn->line = program->current_line; insn->opcode = orc_opcode_find_by_name (name); if (!insn->opcode) { ORC_ERROR ("unknown opcode: %s at line %d", name, insn->line); } args[0] = orc_program_find_var_by_name (program, arg1); args[1] = orc_program_find_var_by_name (program, arg2); args[2] = orc_program_find_var_by_name (program, arg3); args[3] = orc_program_find_var_by_name (program, arg4); insn->flags = flags; i = 0; insn->dest_args[0] = args[i++]; if (insn->opcode) { if (insn->opcode->dest_size[1] != 0) { insn->dest_args[1] = args[i++]; } if (insn->opcode->src_size[0] != 0) { insn->src_args[0] = args[i++]; } if (insn->opcode->src_size[1] != 0) { insn->src_args[1] = args[i++]; } if (insn->opcode->src_size[2] != 0) { insn->src_args[2] = args[i++]; } } program->n_insns++; }
/** * orc_program_append_str_2: * @program: a pointer to an OrcProgram structure * @name: name of instruction * @flags: flags * @arg0: name of first variable * @arg1: name of second variable * @arg2: name of third variable * @arg3: name of fourth variable * * Appends an instruction to the program, with arguments @arg0, * @arg1, @arg2, and @arg3. */ void orc_program_append_str_2 (OrcProgram *program, const char *name, unsigned int flags, const char *arg1, const char *arg2, const char *arg3, const char *arg4) { OrcInstruction *insn; int args[4]; insn = program->insns + program->n_insns; insn->line = program->current_line; insn->opcode = orc_opcode_find_by_name (name); if (!insn->opcode) { ORC_ERROR ("unknown opcode: %s at line %d", name, insn->line); } args[0] = orc_program_find_var_by_name (program, arg1); args[1] = orc_program_find_var_by_name (program, arg2); args[2] = orc_program_find_var_by_name (program, arg3); args[3] = orc_program_find_var_by_name (program, arg4); insn->flags = flags; orc_program_dispatch_operands (insn, args); program->n_insns++; }
/** * orc_program_append_str: * @program: a pointer to an OrcProgram structure * @name: name of instruction * @arg0: name of first variable * @arg1: name of second variable * @arg2: name of third variable * * Appends an instruction to the program, with arguments @arg0, * @arg1, and @arg2. The instruction must take 3 operands. */ void orc_program_append_str (OrcProgram *program, const char *name, const char *arg1, const char *arg2, const char *arg3) { OrcInstruction *insn; insn = program->insns + program->n_insns; insn->opcode = orc_opcode_find_by_name (name); if (!insn->opcode) { ORC_ERROR ("unknown opcode: %s", name); return; } insn->dest_args[0] = orc_program_find_var_by_name (program, arg1); if (insn->opcode->dest_size[1] != 0) { insn->dest_args[1] = orc_program_find_var_by_name (program, arg2); insn->src_args[0] = orc_program_find_var_by_name (program, arg3); } else { insn->src_args[0] = orc_program_find_var_by_name (program, arg2); insn->src_args[1] = orc_program_find_var_by_name (program, arg3); } program->n_insns++; }
void vips_vector_temporary( VipsVector *vector, const char *name, int size ) { #ifdef HAVE_ORC g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 ); if( !orc_program_add_temporary( vector->program, size, name ) ) vips_vector_error( vector ); #ifdef DEBUG_TRACE printf( "orc_program_add_temporary( %s, %d, \"%s\" );\n", vector->unique_name, size, name ); #endif /*DEBUG_TRACE*/ vector->n_temp += 1; #endif /*HAVE_ORC*/ }
void vips_vector_source_scanline( VipsVector *vector, char *name, int line, int size ) { #ifdef HAVE_ORC vips_snprintf( name, 256, "sl%d", line ); if( orc_program_find_var_by_name( vector->program, name ) == -1 ) { int var; var = orc_program_add_source( vector->program, size, name ); vector->sl[vector->n_scanline] = var; vector->line[vector->n_scanline] = line; vector->n_scanline += 1; } #endif /*HAVE_ORC*/ }
int vips_vector_source_name( VipsVector *vector, char *name, int size ) { int var; #ifdef HAVE_ORC g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 ); vector->s[vector->n_source] = var = orc_program_add_source( vector->program, size, name ); vector->n_source += 1; #else /*!HAVE_ORC*/ var = -1; #endif /*HAVE_ORC*/ return( var ); }
int vips_vector_destination( VipsVector *vector, const char *name, int size ) { int var; #ifdef HAVE_ORC g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 ); var = orc_program_add_destination( vector->program, size, name ); #ifdef DEBUG_TRACE printf( "orc_program_add_destination( %d, \"%s\" );\n", size, name ); #endif /*DEBUG_TRACE*/ vector->n_destination += 1; #else /*!HAVE_ORC*/ var = -1; #endif /*HAVE_ORC*/ return( var ); }
int vips_vector_source_name( VipsVector *vector, const char *name, int size ) { int var; #ifdef HAVE_ORC g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 ); if( !(var = orc_program_add_source( vector->program, size, name )) ) vips_vector_error( vector ); vector->s[vector->n_source] = var; #ifdef DEBUG_TRACE printf( "orc_program_add_source( %s, %d, \"%s\" );\n", vector->unique_name, size, name ); #endif /*DEBUG_TRACE*/ vector->n_source += 1; #else /*!HAVE_ORC*/ var = -1; #endif /*HAVE_ORC*/ return( var ); }
void vips_vector_source_scanline( VipsVector *vector, char *name, int line, int size ) { #ifdef HAVE_ORC vips_snprintf( name, 256, "sl%d", line ); if( orc_program_find_var_by_name( vector->program, name ) == -1 ) { int var; if( !(var = orc_program_add_source( vector->program, size, name )) ) vips_vector_error( vector ); #ifdef DEBUG_TRACE printf( "orc_program_add_source( %s, %d, \"%s\" );\n", vector->unique_name, size, name ); #endif /*DEBUG_TRACE*/ vector->sl[vector->n_scanline] = var; vector->line[vector->n_scanline] = line; vector->n_scanline += 1; } #endif /*HAVE_ORC*/ }
/** * orc_program_append_str_n: * @program: a pointer to an OrcProgram structure * @name: name of instruction * @flags: flags * @argc: number of variableds * @argv: array of variables * * Appends an instruction to the program, with any number of * arguments. Only o <= number <= 4 is supported. * * Returns: status code. * 0: succesfull * <0: malformed opcode (unknown or bad arguments) * >0: unknown argument. Then the return value equals to the nth * argument. Beware: this is index, not offset (the first is 1). */ int orc_program_append_str_n (OrcProgram *program, const char *name, unsigned int flags, int argc, const char **argv) { OrcInstruction *insn; int args[4]; int i; int n = (argc < 4) ?argc :4; insn = program->insns + program->n_insns; insn->line = program->current_line; insn->opcode = orc_opcode_find_by_name (name); if (!insn->opcode) { return -1; } if (n < 0) { return -1; } for (i=0;i<n;i++){ args[i] = orc_program_find_var_by_name (program, argv[i]); if (args[i] == -1) { /* ORC_ERROR ("bad operand \"%s\" in position %d for opcode: %s at line %d", argv[i], i+1, name, insn->line); */ return i+1; } } insn->flags = flags; orc_program_dispatch_operands (insn, args); program->n_insns++; return 0; }