![]() |
![]() |
![]() |
Orc Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
OrcProgram; #define ORC_N_CONSTANTS #define ORC_N_RULE_SETS #define ORC_N_TARGETS #define ORC_PROGRAM_ERROR (program, ...) OrcProgram * orc_program_new (void
); OrcProgram * orc_program_new_dss (int size1
,int size2
,int size3
); OrcProgram * orc_program_new_as (int size1
,int size2
); OrcProgram * orc_program_new_ass (int size1
,int size2
,int size3
); OrcProgram * orc_program_new_ds (int size1
,int size2
); void orc_program_free (OrcProgram *program
); const char * orc_program_get_name (OrcProgram *program
); void orc_program_set_name (OrcProgram *program
,const char *name
); int orc_program_add_temporary (OrcProgram *program
,int size
,const char *name
); int orc_program_add_source (OrcProgram *program
,int size
,const char *name
); int orc_program_add_destination (OrcProgram *program
,int size
,const char *name
); int orc_program_add_constant (OrcProgram *program
,int size
,int value
,const char *name
); int orc_program_add_accumulator (OrcProgram *program
,int size
,const char *name
); int orc_program_add_parameter (OrcProgram *program
,int size
,const char *name
); void orc_program_append (OrcProgram *p
,const char *opcode
,int arg0
,int arg1
,int arg2
); void orc_program_append_str (OrcProgram *p
,const char *opcode
,const char *arg0
,const char *arg1
,const char *arg2
); void orc_program_append_ds (OrcProgram *program
,const char *opcode
,int arg0
,int arg1
); void orc_program_append_ds_str (OrcProgram *p
,const char *opcode
,const char *arg0
,const char *arg1
); OrcCompileResult orc_program_compile (OrcProgram *p
); OrcCompileResult orc_program_compile_for_target (OrcProgram *p
,OrcTarget *target
); OrcCompileResult orc_program_compile_full (OrcProgram *p
,OrcTarget *target
,unsigned int flags
); const char * orc_program_get_asm_code (OrcProgram *program
); int orc_program_find_var_by_name (OrcProgram *program
,const char *name
); int orc_program_allocate_register (OrcProgram *program
,int is_data
); int orc_program_get_max_var_size (OrcProgram *program
); int orc_program_dup_temporary (OrcProgram *program
,int i
,int j
);
OrcProgram * orc_program_new (void
);
Create a new OrcProgram. The program should be freed using
@orc_program_free()
.
Returns : |
a pointer to an OrcProgram structure |
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".
|
size of destination array members |
|
size of first source array members |
|
size of second source array members |
Returns : |
a pointer to an OrcProgram structure |
OrcProgram * orc_program_new_as (int size1
,int size2
);
Create a new OrcProgram, with an accumulator named "a1" and one source named "s1".
|
size of destination array members |
|
size of source array members |
Returns : |
a pointer to an OrcProgram structure |
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".
|
size of destination array members |
|
size of first source array members |
|
size of second source array members |
Returns : |
a pointer to an OrcProgram structure |
OrcProgram * orc_program_new_ds (int size1
,int size2
);
Create a new OrcProgram, with a destination named "d1" and one source named "s1".
|
size of destination array members |
|
size of source array members |
Returns : |
a pointer to an OrcProgram structure |
void orc_program_free (OrcProgram *program
);
Frees an OrcProgram.
|
a pointer to an OrcProgram structure |
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.
|
a pointer to an OrcProgram structure |
Returns : |
a character string |
void orc_program_set_name (OrcProgram *program
,const char *name
);
Sets the name of the program. The string is copied.
|
a pointer to an OrcProgram structure |
|
string to set the name to |
int orc_program_add_temporary (OrcProgram *program
,int size
,const char *name
);
Creates a new variable holding temporary values.
|
a pointer to an OrcProgram structure |
|
size of data values |
|
name of variable |
Returns : |
the index of the new variable |
int orc_program_add_source (OrcProgram *program
,int size
,const char *name
);
Creates a new variable representing a source array.
|
a pointer to an OrcProgram structure |
|
size of data values |
|
name of variable |
Returns : |
the index of the new variable |
int orc_program_add_destination (OrcProgram *program
,int size
,const char *name
);
Creates a new variable representing a destination array.
|
a pointer to an OrcProgram structure |
|
size of data values |
|
name of variable |
Returns : |
the index of the new variable |
int orc_program_add_constant (OrcProgram *program
,int size
,int value
,const char *name
);
Creates a new variable representing a constant value.
|
a pointer to an OrcProgram structure |
|
size of data value |
|
the value |
|
name of variable |
Returns : |
the index of the new variable |
int orc_program_add_accumulator (OrcProgram *program
,int size
,const char *name
);
Creates a new variable representing an accumulator.
|
a pointer to an OrcProgram structure |
|
size of data value |
|
name of variable |
Returns : |
the index of the new variable |
int orc_program_add_parameter (OrcProgram *program
,int size
,const char *name
);
Creates a new variable representing a scalar parameter.
|
a pointer to an OrcProgram structure |
|
size of data value |
|
name of variable |
Returns : |
the index of the new variable |
void orc_program_append (OrcProgram *p
,const char *opcode
,int arg0
,int arg1
,int arg2
);
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
name of first variable |
|
name of second variable |
|
name of third variable |
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.
|
a pointer to an OrcProgram structure |
|
|
|
index of first variable |
|
index of second variable |
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.
|
|
|
|
|
name of first variable |
|
name of second variable |
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.
|
|
Returns : |
an OrcCompileResult |
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.
|
|
|
|
Returns : |
an OrcCompileResult |
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.
|
|
|
|
|
|
Returns : |
an OrcCompileResult |
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.
|
a pointer to an OrcProgram structure |
Returns : |
a character string |
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.
|
a pointer to an OrcProgram structure |
|
name of instruction |
Returns : |
the index of the variable |
int orc_program_allocate_register (OrcProgram *program
,int is_data
);
|
|
|
|
Returns : |
int orc_program_get_max_var_size (OrcProgram *program
);
Returns the size of the largest variable used in the program.
|
a pointer to an OrcProgram structure |
Returns : |
the number of bytes |
int orc_program_dup_temporary (OrcProgram *program
,int i
,int j
);
Internal function.
|
a pointer to an OrcProgram structure |
|
|
|
index |
Returns : |
the index of the new variable |