# 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

Returns (int ) –

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

Returns (int ) –

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` –
No description available
`size` –
No description available
`value` –
No description available
`name` –
No description available
Returns (int ) –
No description available

### orc_program_add_constant_float

    int
    orc_program_add_constant_float (OrcProgram * program,
                                    int  size,
                                    float  value,
                                    const char * name)

Parameters:

`program` –
No description available
`size` –
No description available
`value` –
No description available
`name` –
No description available
Returns (int ) –
No description available

### orc_program_add_constant_int64

    int
    orc_program_add_constant_int64 (OrcProgram * program,
                                    int  size,
                                    orc_int64 value,
                                    const char * name)

Parameters:

`program` –
No description available
`size` –
No description available
`value` –
No description available
`name` –
No description available
Returns (int ) –
No description available

### orc_program_add_constant_str

    int
    orc_program_add_constant_str (OrcProgram * program,
                                  int  size,
                                  const char * value,
                                  const char * name)

Parameters:

`program` –
No description available
`size` –
No description available
`value` –
No description available
`name` –
No description available
Returns (int ) –
No description available

### 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

Returns (int ) –

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` –
No description available
`alignment` –
No description available
Returns (int ) –

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

Returns (int ) –

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` –
No description available
`size` –
No description available
`name` –
No description available
Returns (int ) –
No description available

### 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

Returns (int ) –

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` –
No description available
`size` –
No description available
`name` –
No description available
Returns (int ) –
No description available

### 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

Returns (int ) –

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

Returns (int ) –

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

Returns (int ) –

the index of the new variable

### orc_program_allocate_register

    int
    orc_program_allocate_register (OrcProgram * program,
                                   int  is_data)

Parameters:

`program` –
No description available
`is_data` –
No description available
Returns (int ) –
No description available

### orc_program_append

    void
    orc_program_append (OrcProgram * p,
                        const char * opcode,
                        int  arg0,
                        int  arg1,
                        int  arg2)

Parameters:

`p` –
No description available
`opcode` –
No description available
`arg0` –
No description available
`arg1` –
No description available
`arg2` –
No description available
Returns (void ) –
No description available

### 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` –
No description available
`name` –
No description available
`flags` –
No description available
`arg0` –
No description available
`arg1` –
No description available
`arg2` –
No description available
`arg3` –
No description available
Returns (void ) –
No description available

### 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` –
No description available
`name` –
No description available
`arg1` –
No description available
`arg2` –
No description available
`arg3` –
No description available
Returns (void ) –
No description available

### 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` –
No description available
`arg0` –

index of first variable

`arg1` –

index of second variable

Returns (void ) –
No description available

### 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` –
No description available
`opcode` –
No description available
`arg0` –

name of first variable

`arg1` –

name of second variable

Returns (void ) –
No description available

### 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` –
No description available
`opcode` –
No description available
`arg0` –

name of first variable

`arg1` –

name of second variable

`arg2` –

name of third variable

Returns (void ) –
No description available

### 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` –
No description available
Returns (void ) –
No description available

### 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

Returns (int ) –

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` –
No description available
Returns (OrcCompileResult) –

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` –
No description available
`target` –
No description available
Returns (OrcCompileResult) –

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` –
No description available
`target` –
No description available
`flags` –
No description available
Returns (OrcCompileResult) –

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` –
No description available
`j` –

index

Returns (int ) –

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

Returns (int ) –

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

Returns (void ) –
No description available

### 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

Returns (const char *) –

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

Returns (const char *) –

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

Returns (int ) –

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

Returns (int ) –

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

Returns (const char *) –

a character string

### orc_program_new

    OrcProgram *
    orc_program_new ()

Create a new OrcProgram. The program should be freed using orc_program_free().

Returns (OrcProgram *) –

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

Returns (OrcProgram *) –

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

Returns (OrcProgram *) –

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

Returns (OrcProgram *) –

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

Returns (OrcProgram *) –

a pointer to an OrcProgram structure

### orc_program_new_from_static_bytecode

    OrcProgram *
    orc_program_new_from_static_bytecode (orc_uint8 * bytecode)

Parameters:

`bytecode` –
No description available
Returns (OrcProgram *) –
No description available

### orc_program_reset

    void
    orc_program_reset (OrcProgram * program)

Parameters:

`program` –
No description available
Returns (void ) –
No description available

### 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

Returns (void ) –
No description available

### 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` –
No description available
`func` –

a function that performs the operations in the program

Returns (void ) –
No description available

### orc_program_set_backup_name

    void
    orc_program_set_backup_name (OrcProgram * p,
                                 const char * name)

Parameters:

`p` –
No description available
`name` –

a function name that performs the operations in the program

Returns (void ) –
No description available

### orc_program_set_constant_m

    void
    orc_program_set_constant_m (OrcProgram * program,
                                int  m)

Parameters:

`program` –
No description available
`m` –
No description available
Returns (void ) –
No description available

### orc_program_set_constant_n

    void
    orc_program_set_constant_n (OrcProgram * program,
                                int  n)

Parameters:

`program` –
No description available
`n` –
No description available
Returns (void ) –
No description available

### 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

Returns (void ) –
No description available

### 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` –
No description available
Returns (void ) –
No description available

### orc_program_set_n_maximum

    void
    orc_program_set_n_maximum (OrcProgram * ex,
                               int  n)

Parameters:

`ex` –
No description available
`n` –
No description available
Returns (void ) –
No description available

### orc_program_set_n_minimum

    void
    orc_program_set_n_minimum (OrcProgram * ex,
                               int  n)

Parameters:

`ex` –
No description available
`n` –
No description available
Returns (void ) –
No description available

### orc_program_set_n_multiple

    void
    orc_program_set_n_multiple (OrcProgram * ex,
                                int  n)

Parameters:

`ex` –
No description available
`n` –
No description available
Returns (void ) –
No description available

### 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

Returns (void ) –
No description available

### orc_program_set_sampling_type

    void
    orc_program_set_sampling_type (OrcProgram * program,
                                   int  var,
                                   int  sampling_type)

Parameters:

`program` –
No description available
`var` –
No description available
`sampling_type` –
No description available
Returns (void ) –
No description available

### orc_program_set_type_name

    void
    orc_program_set_type_name (OrcProgram * program,
                               int  var,
                               const char * type_name)

Parameters:

`program` –
No description available
`var` –
No description available
`type_name` –
No description available
Returns (void ) –
No description available

### orc_program_set_var_alignment

    void
    orc_program_set_var_alignment (OrcProgram * program,
                                   int  var,
                                   int  alignment)

Parameters:

`program` –
No description available
`var` –
No description available
`alignment` –
No description available
Returns (void ) –
No description available

### orc_program_take_code

    OrcCode *
    orc_program_take_code (OrcProgram * program)

Parameters:

`program` –
No description available
Returns (OrcCode *) –
No description available

## Structures

### OrcProgram

The OrcProgram structure has no public members

### struct (unnamed at /build/orc/src/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 *) –
No description available
`dest_args` (int[2] ) –
No description available
`src_args` (int[4] ) –
No description available
`rule` (OrcRule *) –
No description available

### struct (unnamed at /build/orc/src/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 *) –
No description available
`type_name` (char *) –
No description available
`size` (int ) –
No description available
`vartype` (OrcVarType) –
No description available
`used` (int ) –
No description available
`first_use` (int ) –
No description available
`last_use` (int ) –
No description available
`replaced` (int ) –
No description available
`replacement` (int ) –
No description available
`alloc` (int ) –
No description available
`is_chained` (int ) –
No description available
`is_aligned` (int ) –
No description available
`is_uncached` (int ) –
No description available
`value` (int ) –
No description available
`ptr_register` (int ) –
No description available
`ptr_offset` (int ) –
No description available
`mask_alloc` (int ) –
No description available
`aligned_data` (int ) –
No description available
`param_type` (int ) –
No description available
`load_dest` (int ) –
No description available

The results of the search are