| 1 |
|
| 2 |
#ifndef _ORC_PROGRAM_H_ |
| 3 |
#define _ORC_PROGRAM_H_ |
| 4 |
|
| 5 |
#include <orc/orclimits.h> |
| 6 |
#include <orc/orcexecutor.h> |
| 7 |
#include <orc/orccode.h> |
| 8 |
#include <orc/orcbytecode.h> |
| 9 |
#include <orc/orccompiler.h> |
| 10 |
#include <orc/orctarget.h> |
| 11 |
#include <orc/orcrule.h> |
| 12 |
|
| 13 |
ORC_BEGIN_DECLS |
| 14 |
|
| 15 |
|
| 16 |
#define ORC_PROGRAM_ERROR(program, ...) do { \ |
| 17 |
program->error = TRUE; \ |
| 18 |
orc_debug_print(ORC_DEBUG_WARNING, __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \ |
| 19 |
} while (0) |
| 20 |
|
| 21 |
/** |
| 22 |
* OrcProgram: |
| 23 |
* |
| 24 |
* The OrcProgram structure has no public members |
| 25 |
*/ |
| 26 |
struct _OrcProgram { |
| 27 |
/*< private >*/ |
| 28 |
struct { |
| 29 |
OrcStaticOpcode *opcode; |
| 30 |
int dest_args[ORC_STATIC_OPCODE_N_DEST]; |
| 31 |
int src_args[ORC_STATIC_OPCODE_N_SRC]; |
| 32 |
|
| 33 |
OrcRule *rule; |
| 34 |
} _unused[ORC_N_INSNS]; /* needed for ABI compatibility */ |
| 35 |
int n_insns; |
| 36 |
|
| 37 |
struct { |
| 38 |
char *name; |
| 39 |
char *type_name; |
| 40 |
|
| 41 |
int size; |
| 42 |
OrcVarType vartype; |
| 43 |
|
| 44 |
int used; |
| 45 |
int first_use; |
| 46 |
int last_use; |
| 47 |
int replaced; |
| 48 |
int replacement; |
| 49 |
|
| 50 |
int alloc; |
| 51 |
int is_chained; |
| 52 |
int is_aligned; |
| 53 |
int is_uncached; |
| 54 |
|
| 55 |
int value; |
| 56 |
|
| 57 |
int ptr_register; |
| 58 |
int ptr_offset; |
| 59 |
int mask_alloc; |
| 60 |
int aligned_data; |
| 61 |
int param_type; |
| 62 |
int load_dest; |
| 63 |
} _unused3[ORC_N_VARIABLES]; /* needed for ABI compatibility */ |
| 64 |
|
| 65 |
int n_src_vars; |
| 66 |
int n_dest_vars; |
| 67 |
int n_param_vars; |
| 68 |
int n_const_vars; |
| 69 |
int n_temp_vars; |
| 70 |
int n_accum_vars; |
| 71 |
|
| 72 |
char *name; |
| 73 |
char *asm_code; |
| 74 |
|
| 75 |
unsigned char *_unused2; |
| 76 |
/* The offset of code_exec in this structure is part of the ABI */ |
| 77 |
void *code_exec; |
| 78 |
|
| 79 |
OrcInstruction insns[ORC_N_INSNS]; |
| 80 |
OrcVariable vars[ORC_N_VARIABLES]; |
| 81 |
|
| 82 |
void *backup_func; |
| 83 |
char *backup_name; |
| 84 |
int is_2d; |
| 85 |
int constant_n; |
| 86 |
int n_multiple; |
| 87 |
int n_minimum; |
| 88 |
int n_maximum; |
| 89 |
int constant_m; |
| 90 |
|
| 91 |
OrcCode *orccode; |
| 92 |
|
| 93 |
/* Hide this here. Belongs in a Parser object */ |
| 94 |
char *init_function; |
| 95 |
char *error_msg; |
| 96 |
unsigned int current_line; |
| 97 |
}; |
| 98 |
|
| 99 |
ORC_API OrcProgram * orc_program_new (void); |
| 100 |
ORC_API OrcProgram * orc_program_new_ds (int size1, int size2); |
| 101 |
ORC_API OrcProgram * orc_program_new_dss (int size1, int size2, int size3); |
| 102 |
ORC_API OrcProgram * orc_program_new_as (int size1, int size2); |
| 103 |
ORC_API OrcProgram * orc_program_new_ass (int size1, int size2, int size3); |
| 104 |
ORC_API OrcProgram * orc_program_new_from_static_bytecode (const orc_uint8 *bytecode); |
| 105 |
|
| 106 |
ORC_API const char * orc_program_get_name (OrcProgram *program); |
| 107 |
ORC_API void orc_program_set_name (OrcProgram *program, const char *name); |
| 108 |
ORC_API void orc_program_set_line (OrcProgram *program, unsigned int line); |
| 109 |
ORC_API void orc_program_set_2d (OrcProgram *program); |
| 110 |
ORC_API void orc_program_set_constant_n (OrcProgram *program, int n); |
| 111 |
ORC_API void orc_program_set_n_multiple (OrcProgram *ex, int n); |
| 112 |
ORC_API void orc_program_set_n_minimum (OrcProgram *ex, int n); |
| 113 |
ORC_API void orc_program_set_n_maximum (OrcProgram *ex, int n); |
| 114 |
ORC_API void orc_program_set_constant_m (OrcProgram *program, int m); |
| 115 |
|
| 116 |
ORC_API void orc_program_append (OrcProgram *p, const char *opcode, int arg0, int arg1, int arg2); |
| 117 |
ORC_API void orc_program_append_2 (OrcProgram *program, const char *name, |
| 118 |
unsigned int flags, int arg0, int arg1, int arg2, int arg3); |
| 119 |
ORC_API void orc_program_append_str (OrcProgram *p, const char *opcode, |
| 120 |
const char * arg0, const char * arg1, const char * arg2); |
| 121 |
ORC_API void orc_program_append_str_2 (OrcProgram *program, const char *name, |
| 122 |
unsigned int flags, const char *arg1, const char *arg2, const char *arg3, |
| 123 |
const char *arg4); |
| 124 |
ORC_API int orc_program_append_str_n (OrcProgram *program, const char *name, |
| 125 |
unsigned int flags, int argc, const char **argv); |
| 126 |
ORC_API void orc_program_append_ds (OrcProgram *program, const char *opcode, int arg0, |
| 127 |
int arg1); |
| 128 |
ORC_API void orc_program_append_ds_str (OrcProgram *p, const char *opcode, |
| 129 |
const char * arg0, const char * arg1); |
| 130 |
ORC_API void orc_program_append_dds_str (OrcProgram *program, const char *name, |
| 131 |
const char *arg1, const char *arg2, const char *arg3); |
| 132 |
|
| 133 |
ORC_API OrcCompileResult orc_program_compile (OrcProgram *p); |
| 134 |
ORC_API OrcCompileResult orc_program_compile_for_target (OrcProgram *p, OrcTarget *target); |
| 135 |
ORC_API OrcCompileResult orc_program_compile_full (OrcProgram *p, OrcTarget *target, |
| 136 |
unsigned int flags); |
| 137 |
ORC_API void orc_program_set_backup_function (OrcProgram *p, OrcExecutorFunc func); |
| 138 |
ORC_API void orc_program_set_backup_name (OrcProgram *p, const char *name); |
| 139 |
ORC_API void orc_program_free (OrcProgram *program); |
| 140 |
|
| 141 |
ORC_API int orc_program_find_var_by_name (OrcProgram *program, const char *name); |
| 142 |
|
| 143 |
ORC_API int orc_program_add_temporary (OrcProgram *program, int size, const char *name); |
| 144 |
ORC_API int orc_program_dup_temporary (OrcProgram *program, int i, int j); |
| 145 |
ORC_API int orc_program_add_source (OrcProgram *program, int size, const char *name); |
| 146 |
ORC_API int orc_program_add_source_full (OrcProgram *program, int size, const char *name, |
| 147 |
const char *type_name, int alignment); |
| 148 |
ORC_API int orc_program_add_destination (OrcProgram *program, int size, const char *name); |
| 149 |
ORC_API int orc_program_add_destination_full (OrcProgram *program, int size, const char *name, |
| 150 |
const char *type_name, int alignment); |
| 151 |
ORC_API int orc_program_add_constant (OrcProgram *program, int size, int value, const char *name); |
| 152 |
ORC_API int orc_program_add_constant_int64 (OrcProgram *program, int size, orc_int64 value, const char *name); |
| 153 |
ORC_API int orc_program_add_constant_float (OrcProgram *program, int size, float value, const char *name); |
| 154 |
ORC_API int orc_program_add_constant_double (OrcProgram *program, int size, double value, const char *name); |
| 155 |
ORC_API int orc_program_add_constant_str (OrcProgram *program, int size, const char *value, const char *name); |
| 156 |
ORC_API int orc_program_add_parameter (OrcProgram *program, int size, const char *name); |
| 157 |
ORC_API int orc_program_add_parameter_float (OrcProgram *program, int size, const char *name); |
| 158 |
ORC_API int orc_program_add_parameter_double (OrcProgram *program, int size, const char *name); |
| 159 |
ORC_API int orc_program_add_parameter_int64 (OrcProgram *program, int size, const char *name); |
| 160 |
ORC_API int orc_program_add_accumulator (OrcProgram *program, int size, const char *name); |
| 161 |
ORC_API void orc_program_set_type_name (OrcProgram *program, int var, const char *type_name); |
| 162 |
ORC_API void orc_program_set_var_alignment (OrcProgram *program, int var, int alignment); |
| 163 |
ORC_API void orc_program_set_sampling_type (OrcProgram *program, int var, int sampling_type); |
| 164 |
|
| 165 |
ORC_API int orc_program_allocate_register (OrcProgram *program, int is_data); |
| 166 |
|
| 167 |
ORC_API void orc_program_reset (OrcProgram *program); |
| 168 |
ORC_API OrcCode *orc_program_take_code (OrcProgram *program); |
| 169 |
|
| 170 |
ORC_API const char *orc_program_get_asm_code (OrcProgram *program); |
| 171 |
ORC_API const char * orc_program_get_error (OrcProgram *program); |
| 172 |
ORC_API void orc_program_set_error (OrcProgram *program, const char *error); |
| 173 |
|
| 174 |
ORC_API int orc_program_get_max_array_size (OrcProgram *program); |
| 175 |
ORC_API int orc_program_get_max_accumulator_size (OrcProgram *program); |
| 176 |
|
| 177 |
|
| 178 |
ORC_END_DECLS |
| 179 |
|
| 180 |
#endif |
| 181 |
|