OrcProgram
Functions
orc_program_add_accumulator
int orc_program_add_accumulator (OrcProgram * program, int size, const char * name)
Creates a new variable representing an accumulator.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data value
name
–
name of variable
the index of the new variable
orc_program_add_constant
int orc_program_add_constant (OrcProgram * program, int size, int value, const char * name)
Creates a new variable representing a constant value.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data value
value
–
the value
name
–
name of variable
the index of the new variable
orc_program_add_constant_double
int orc_program_add_constant_double (OrcProgram * program, int size, double value, const char * name)
Parameters:
program
–
size
–
value
–
name
–
orc_program_add_constant_float
int orc_program_add_constant_float (OrcProgram * program, int size, float value, const char * name)
Parameters:
program
–
size
–
value
–
name
–
orc_program_add_constant_int64
int orc_program_add_constant_int64 (OrcProgram * program, int size, orc_int64 value, const char * name)
Parameters:
program
–
size
–
value
–
name
–
orc_program_add_constant_str
int orc_program_add_constant_str (OrcProgram * program, int size, const char * value, const char * name)
Parameters:
program
–
size
–
value
–
name
–
orc_program_add_destination
int orc_program_add_destination (OrcProgram * program, int size, const char * name)
Creates a new variable representing a destination array.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data values
name
–
name of variable
the index of the new variable
orc_program_add_destination_full
int orc_program_add_destination_full (OrcProgram * program, int size, const char * name, const char * type_name, int alignment)
Creates a new variable representing a destination array.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data values
name
–
name of variable
type_name
–
alignment
–
the index of the new variable
orc_program_add_parameter
int orc_program_add_parameter (OrcProgram * program, int size, const char * name)
Creates a new variable representing a scalar parameter.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data value
name
–
name of variable
the index of the new variable
orc_program_add_parameter_double
int orc_program_add_parameter_double (OrcProgram * program, int size, const char * name)
Parameters:
program
–
size
–
name
–
orc_program_add_parameter_float
int orc_program_add_parameter_float (OrcProgram * program, int size, const char * name)
Creates a new variable representing a scalar parameter.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data value
name
–
name of variable
the index of the new variable
orc_program_add_parameter_int64
int orc_program_add_parameter_int64 (OrcProgram * program, int size, const char * name)
Parameters:
program
–
size
–
name
–
orc_program_add_source
int orc_program_add_source (OrcProgram * program, int size, const char * name)
Creates a new variable representing a source array.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data values
name
–
name of variable
the index of the new variable
orc_program_add_source_full
int orc_program_add_source_full (OrcProgram * program, int size, const char * name, const char * type_name, int alignment)
Creates a new variable representing a source array.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data values
name
–
name of variable
type_name
–
name of type, or NULL
alignment
–
alignment in bytes, or 0
the index of the new variable
orc_program_add_temporary
int orc_program_add_temporary (OrcProgram * program, int size, const char * name)
Creates a new variable holding temporary values.
Parameters:
program
–
a pointer to an OrcProgram structure
size
–
size of data values
name
–
name of variable
the index of the new variable
orc_program_allocate_register
int orc_program_allocate_register (OrcProgram * program, int is_data)
Parameters:
program
–
is_data
–
orc_program_append
void orc_program_append (OrcProgram * p, const char * opcode, int arg0, int arg1, int arg2)
Parameters:
p
–
opcode
–
arg0
–
arg1
–
arg2
–
orc_program_append_2
void orc_program_append_2 (OrcProgram * program, const char * name, unsigned int flags, int arg0, int arg1, int arg2, int arg3)
Parameters:
program
–
name
–
flags
–
arg0
–
arg1
–
arg2
–
arg3
–
orc_program_append_dds_str
void orc_program_append_dds_str (OrcProgram * program, const char * name, const char * arg1, const char * arg2, const char * arg3)
Parameters:
program
–
name
–
arg1
–
arg2
–
arg3
–
orc_program_append_ds
void orc_program_append_ds (OrcProgram * program, const char * opcode, int arg0, int arg1)
Appends an instruction to the program, with arguments arg0, arg1, and arg2. The instruction must take 3 operands.
Parameters:
program
–
a pointer to an OrcProgram structure
opcode
–
arg0
–
index of first variable
arg1
–
index of second variable
orc_program_append_ds_str
void orc_program_append_ds_str (OrcProgram * p, const char * opcode, const char * arg0, const char * arg1)
Appends an instruction to the program, with arguments arg0 and arg2. The instruction must take 2 operands.
Parameters:
p
–
opcode
–
arg0
–
name of first variable
arg1
–
name of second variable
orc_program_append_str
void orc_program_append_str (OrcProgram * p, const char * opcode, const char * arg0, const char * arg1, const char * arg2)
Appends an instruction to the program, with arguments arg0, arg1, and arg2. The instruction must take 3 operands.
Parameters:
p
–
opcode
–
arg0
–
name of first variable
arg1
–
name of second variable
arg2
–
name of third variable
orc_program_append_str_2
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)
Appends an instruction to the program, with arguments arg0, arg1, arg2, and arg3.
Parameters:
program
–
a pointer to an OrcProgram structure
name
–
name of instruction
flags
–
flags
arg1
–
name of second variable
arg2
–
name of third variable
arg3
–
name of fourth variable
arg4
–
orc_program_append_str_n
int orc_program_append_str_n (OrcProgram * program, const char * name, unsigned int flags, int argc, const char ** argv)
Appends an instruction to the program, with any number of arguments. Only 1 <= number <= 6 is supported.
Parameters:
program
–
a pointer to an OrcProgram structure
name
–
name of instruction
flags
–
flags
argc
–
number of variableds
argv
–
array of variables
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).
orc_program_compile
OrcCompileResult orc_program_compile (OrcProgram * p)
Compiles an Orc program for the current CPU. If successful, executable code for the program was generated and can be executed.
The return value indicates various levels of success or failure. Success can be determined by checking for a true value of the macro ORC_COMPILE_RESULT_IS_SUCCESSFUL on the return value. This indicates that executable code was generated. If the macro ORC_COMPILE_RESULT_IS_FATAL on the return value evaluates to true, then there was a syntactical error in the program. If the result is neither successful nor fatal, the program can still be emulated.
Parameters:
p
–
an OrcCompileResult
orc_program_compile_for_target
OrcCompileResult orc_program_compile_for_target (OrcProgram * p, OrcTarget* target)
Compiles an Orc program for the given target, using the default target flags for that target.
Parameters:
p
–
target
–
an OrcCompileResult
orc_program_compile_full
OrcCompileResult orc_program_compile_full (OrcProgram * p, OrcTarget* target, unsigned int flags)
Compiles an Orc program for the given target, using the given target flags.
Parameters:
p
–
target
–
flags
–
an OrcCompileResult
orc_program_dup_temporary
int orc_program_dup_temporary (OrcProgram * program, int i, int j)
Internal function.
Parameters:
program
–
a pointer to an OrcProgram structure
i
–
j
–
index
the index of the new variable
orc_program_find_var_by_name
int orc_program_find_var_by_name (OrcProgram * program, const char * name)
Finds the variable with the name name. If no variable with the given name exists in the program, -1 is returned.
Parameters:
program
–
a pointer to an OrcProgram structure
name
–
name of instruction
the index of the variable
orc_program_free
void orc_program_free (OrcProgram * program)
Frees an OrcProgram.
Parameters:
program
–
a pointer to an OrcProgram structure
orc_program_get_asm_code
const char * orc_program_get_asm_code (OrcProgram * program)
Returns a character string containing the assembly code created by compiling the program. This string is valid until the program is compiled again or the program is freed.
Parameters:
program
–
a pointer to an OrcProgram structure
a character string
orc_program_get_error
const char * orc_program_get_error (OrcProgram * program)
Returns a character string containing the error message from compilation. This string is valid until the program is compiled again, the program is freed, or another error is set.
Parameters:
program
–
a pointer to an OrcProgram structure
a character string
orc_program_get_max_accumulator_size
int orc_program_get_max_accumulator_size (OrcProgram * program)
Returns the size of the largest array used in the program.
Parameters:
program
–
a pointer to an OrcProgram structure
the number of bytes
orc_program_get_max_array_size
int orc_program_get_max_array_size (OrcProgram * program)
Returns the size of the largest array used in the program.
Parameters:
program
–
a pointer to an OrcProgram structure
the number of bytes
orc_program_get_name
const char * orc_program_get_name (OrcProgram * program)
Gets the name of the program. The string is valid until the name is changed or the program is freed.
Parameters:
program
–
a pointer to an OrcProgram structure
a character string
orc_program_new
OrcProgram * orc_program_new ()
Create a new OrcProgram. The program should be freed using orc_program_free().
a pointer to an OrcProgram structure
orc_program_new_as
OrcProgram * orc_program_new_as (int size1, int size2)
Create a new OrcProgram, with an accumulator named "a1" and one source named "s1".
Parameters:
size1
–
size of destination array members
size2
–
size of source array members
a pointer to an OrcProgram structure
orc_program_new_ass
OrcProgram * orc_program_new_ass (int size1, int size2, int size3)
Create a new OrcProgram, with an accumulator named "a1" and two source named "s1" and "s2".
Parameters:
size1
–
size of destination array members
size2
–
size of first source array members
size3
–
size of second source array members
a pointer to an OrcProgram structure
orc_program_new_ds
OrcProgram * orc_program_new_ds (int size1, int size2)
Create a new OrcProgram, with a destination named "d1" and one source named "s1".
Parameters:
size1
–
size of destination array members
size2
–
size of source array members
a pointer to an OrcProgram structure
orc_program_new_dss
OrcProgram * orc_program_new_dss (int size1, int size2, int size3)
Create a new OrcProgram, with a destination named "d1" and two sources named "s1" and "s2".
Parameters:
size1
–
size of destination array members
size2
–
size of first source array members
size3
–
size of second source array members
a pointer to an OrcProgram structure
orc_program_new_from_static_bytecode
OrcProgram * orc_program_new_from_static_bytecode (orc_uint8 * bytecode)
Parameters:
bytecode
–
orc_program_reset
void orc_program_reset (OrcProgram * program)
Parameters:
program
–
orc_program_set_2d
void orc_program_set_2d (OrcProgram * program)
Sets a flag on the program indicating that arrays are two dimensional. This causes the compiler to generate code for an OrcExec2D executor.
Parameters:
program
–
a pointer to an OrcProgram structure
orc_program_set_backup_function
void orc_program_set_backup_function (OrcProgram * p, OrcExecutorFunc func)
Normally, if a program cannot be compiled for a particular CPU, Orc will emulate the function, which is typically very slow. This function allows the developer to provide a function that is called instead of resorting to emulation.
Parameters:
p
–
func
–
a function that performs the operations in the program
orc_program_set_backup_name
void orc_program_set_backup_name (OrcProgram * p, const char * name)
Parameters:
p
–
name
–
a function name that performs the operations in the program
orc_program_set_constant_m
void orc_program_set_constant_m (OrcProgram * program, int m)
Parameters:
program
–
m
–
orc_program_set_constant_n
void orc_program_set_constant_n (OrcProgram * program, int n)
Parameters:
program
–
n
–
orc_program_set_error
void orc_program_set_error (OrcProgram * program, const char * error)
Stores the error in the program. This string is duplicated. If an error has already been set, this new error is ignored. An error will stay till the next call to _reset, if any.
Parameters:
program
–
a pointer to an OrcProgram structure
error
–
an error string
orc_program_set_line
void orc_program_set_line (OrcProgram * program, unsigned int line)
Sets the current line of the program.
Parameters:
program
–
a pointer to an OrcProgram structure
line
–
orc_program_set_n_maximum
void orc_program_set_n_maximum (OrcProgram * ex, int n)
Parameters:
ex
–
n
–
orc_program_set_n_minimum
void orc_program_set_n_minimum (OrcProgram * ex, int n)
Parameters:
ex
–
n
–
orc_program_set_n_multiple
void orc_program_set_n_multiple (OrcProgram * ex, int n)
Parameters:
ex
–
n
–
orc_program_set_name
void orc_program_set_name (OrcProgram * program, const char * name)
Sets the name of the program. The string is copied.
Parameters:
program
–
a pointer to an OrcProgram structure
name
–
string to set the name to
orc_program_set_sampling_type
void orc_program_set_sampling_type (OrcProgram * program, int var, int sampling_type)
Parameters:
program
–
var
–
sampling_type
–
orc_program_set_type_name
void orc_program_set_type_name (OrcProgram * program, int var, const char * type_name)
Parameters:
program
–
var
–
type_name
–
orc_program_set_var_alignment
void orc_program_set_var_alignment (OrcProgram * program, int var, int alignment)
Parameters:
program
–
var
–
alignment
–
orc_program_take_code
OrcCode * orc_program_take_code (OrcProgram * program)
Parameters:
program
–
Structures
OrcProgram
The OrcProgram structure has no public members
struct (unnamed at /builds/gstreamer/orc/orc/orcprogram.h:28:3)
struct {
OrcStaticOpcode *opcode;
int dest_args[ORC_STATIC_OPCODE_N_DEST];
int src_args[ORC_STATIC_OPCODE_N_SRC];
OrcRule *rule;
} _unused[ORC_N_INSNS]; /* needed for ABI compatibility */
Fields
opcode
(OrcStaticOpcode *)
–
dest_args
(int[2] )
–
src_args
(int[4] )
–
rule
(OrcRule *)
–
struct (unnamed at /builds/gstreamer/orc/orc/orcprogram.h:37:3)
struct {
char *name;
char *type_name;
int size;
OrcVarType vartype;
int used;
int first_use;
int last_use;
int replaced;
int replacement;
int alloc;
int is_chained;
int is_aligned;
int is_uncached;
int value;
int ptr_register;
int ptr_offset;
int mask_alloc;
int aligned_data;
int param_type;
int load_dest;
} _unused3[ORC_N_VARIABLES]; /* needed for ABI compatibility */
Fields
name
(char *)
–
type_name
(char *)
–
size
(int )
–
vartype
(OrcVarType)
–
used
(int )
–
first_use
(int )
–
last_use
(int )
–
replaced
(int )
–
replacement
(int )
–
alloc
(int )
–
is_chained
(int )
–
is_aligned
(int )
–
is_uncached
(int )
–
value
(int )
–
ptr_register
(int )
–
ptr_offset
(int )
–
mask_alloc
(int )
–
aligned_data
(int )
–
param_type
(int )
–
load_dest
(int )
–
The results of the search are