orc_executor_set_n (ex, n);
dest_index = -1;
- for(i=0;i<program->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (program->vars[i].name == NULL) continue;
+
if (program->vars[i].vartype == ORC_VAR_TYPE_SRC) {
uint8_t *data;
data = malloc(n*program->vars[i].size);
printf("%2d:", i);
- for(j=0;j<program->n_vars;j++){
+ for(j=0;j<ORC_N_VARIABLES;j++){
+ if (program->vars[j].name == NULL) continue;
if (program->vars[j].vartype == ORC_VAR_TYPE_SRC &&
program->vars[j].size > 0) {
print_array_val (ex->arrays[j], program->vars[j].size, i);
compiler->n_insns = program->n_insns;
memcpy (compiler->vars, program->vars,
- program->n_vars * sizeof(OrcVariable));
- compiler->n_vars = program->n_vars;
+ ORC_N_VARIABLES * sizeof(OrcVariable));
+ compiler->n_temp_vars = program->n_temp_vars;
for(i=0;i<32;i++) {
compiler->valid_regs[i] = 1;
OrcVariable *var;
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
var = compiler->vars + i;
+ if (var->name == NULL) continue;
switch (var->vartype) {
case ORC_VAR_TYPE_CONST:
var->first_use = -1;
}
}
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (compiler->vars[i].name == NULL) continue;
if (compiler->vars[i].first_use == j) {
if (compiler->vars[i].alloc) continue;
k = orc_compiler_allocate_register (compiler, TRUE);
compiler->vars[i].alloc = k;
}
}
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (compiler->vars[i].name == NULL) continue;
if (compiler->vars[i].last_use == j) {
compiler->alloc_regs[compiler->vars[i].alloc]--;
}
int
orc_compiler_dup_temporary (OrcCompiler *compiler, int var, int j)
{
- int i = compiler->n_vars;
+ int i = ORC_VAR_T1 + compiler->n_temp_vars;
compiler->vars[i].vartype = ORC_VAR_TYPE_TEMP;
compiler->vars[i].size = compiler->vars[var].size;
compiler->vars[i].name = malloc (strlen(compiler->vars[var].name) + 10);
sprintf(compiler->vars[i].name, "%s.dup%d", compiler->vars[var].name, j);
- compiler->n_vars++;
+ compiler->n_temp_vars++;
return i;
}
static void
convusswb (OrcOpcodeExecutor *ex, void *user)
{
- ex->dest_values[0] = ORC_CLAMP_SB((uint16_t)(ex->src_values[0]));
+ ex->dest_values[0] = ORC_CLAMP_SB((int)(uint16_t)(ex->src_values[0]));
}
static void
convuuswb (OrcOpcodeExecutor *ex, void *user)
{
- ex->dest_values[0] = ORC_CLAMP_UB((uint16_t)(ex->src_values[0]));
+ ex->dest_values[0] = ORC_CLAMP_UB((int)(uint16_t)(ex->src_values[0]));
}
static void
arm_load_constants (OrcCompiler *compiler)
{
int i;
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (compiler->vars[i].name == NULL) continue;
switch (compiler->vars[i].vartype) {
case ORC_VAR_TYPE_CONST:
//arm_emit_loadiw (compiler, compiler->vars[i].alloc,
}
}
- for(k=0;k<compiler->n_vars;k++){
+ for(k=0;k<ORC_N_VARIABLES;k++){
+ if (compiler->vars[k].name == NULL) continue;
if (compiler->vars[k].vartype == ORC_VAR_TYPE_SRC ||
compiler->vars[k].vartype == ORC_VAR_TYPE_DEST) {
if (compiler->vars[k].ptr_register) {
ORC_ASM_CODE(compiler,"{\n");
ORC_ASM_CODE(compiler," int i;\n");
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
OrcVariable *var = compiler->vars + i;
+ if (var->name == NULL) continue;
switch (var->vartype) {
case ORC_VAR_TYPE_CONST:
ORC_ASM_CODE(compiler," %s var%d = %d;\n",
mmx_load_constants (OrcCompiler *compiler)
{
int i;
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (compiler->vars[i].name == NULL) continue;
switch (compiler->vars[i].vartype) {
case ORC_VAR_TYPE_CONST:
mmx_emit_loadiw (compiler, compiler->vars[i].alloc,
}
}
- for(k=0;k<compiler->n_vars;k++){
+ for(k=0;k<ORC_N_VARIABLES;k++){
+ if (compiler->vars[k].name == NULL) continue;
if (compiler->vars[k].vartype == ORC_VAR_TYPE_SRC ||
compiler->vars[k].vartype == ORC_VAR_TYPE_DEST) {
if (compiler->vars[k].ptr_register) {
powerpc_load_constants (OrcCompiler *compiler)
{
int i;
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (compiler->vars[i].name == NULL) continue;
switch (compiler->vars[i].vartype) {
case ORC_VAR_TYPE_CONST:
ORC_ASM_CODE(compiler," vspltish %s, %d\n",
}
}
- for(k=0;k<compiler->n_vars;k++){
+ for(k=0;k<ORC_N_VARIABLES;k++){
+ if (compiler->vars[k].name == NULL) continue;
if (compiler->vars[k].vartype == ORC_VAR_TYPE_SRC ||
compiler->vars[k].vartype == ORC_VAR_TYPE_DEST) {
if (compiler->vars[k].ptr_register) {
break;
}
- compiler->long_jumps = TRUE;
+ //compiler->long_jumps = TRUE;
}
void
sse_load_constants (OrcCompiler *compiler)
{
int i;
- for(i=0;i<compiler->n_vars;i++){
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (compiler->vars[i].name == NULL) continue;
switch (compiler->vars[i].vartype) {
case ORC_VAR_TYPE_CONST:
if (compiler->vars[i].size == 1) {
}
}
- for(k=0;k<compiler->n_vars;k++){
+ for(k=0;k<ORC_N_VARIABLES;k++){
+ if (compiler->vars[k].name == NULL) continue;
if (compiler->vars[k].vartype == ORC_VAR_TYPE_SRC ||
compiler->vars[k].vartype == ORC_VAR_TYPE_DEST) {
if (compiler->vars[k].ptr_register) {
orc_program_free (OrcProgram *program)
{
int i;
- for(i=0;i<program->n_vars;i++){
- free (program->vars[i].name);
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (program->vars[i].name) free (program->vars[i].name);
}
if (program->name) {
free (program->name);
int
orc_program_add_temporary (OrcProgram *program, int size, const char *name)
{
- int i = program->n_vars;
+ int i = ORC_VAR_T1 + program->n_temp_vars;
program->vars[i].vartype = ORC_VAR_TYPE_TEMP;
program->vars[i].size = size;
program->vars[i].name = strdup(name);
- program->n_vars++;
+ program->n_temp_vars++;
return i;
}
int
orc_program_dup_temporary (OrcProgram *program, int var, int j)
{
- int i = program->n_vars;
+ int i = ORC_VAR_T1 + program->n_temp_vars;
program->vars[i].vartype = ORC_VAR_TYPE_TEMP;
program->vars[i].size = program->vars[var].size;
program->vars[i].name = malloc (strlen(program->vars[var].name) + 10);
sprintf(program->vars[i].name, "%s.dup%d", program->vars[var].name, j);
- program->n_vars++;
+ program->n_temp_vars++;
return i;
}
int
orc_program_add_source (OrcProgram *program, int size, const char *name)
{
- int i = program->n_vars;
+ int i = ORC_VAR_S1 + program->n_src_vars;
program->vars[i].vartype = ORC_VAR_TYPE_SRC;
program->vars[i].size = size;
program->vars[i].name = strdup(name);
- program->n_vars++;
+ program->n_src_vars++;
return i;
}
int
orc_program_add_destination (OrcProgram *program, int size, const char *name)
{
- int i = program->n_vars;
+ int i = ORC_VAR_D1 + program->n_dest_vars;
program->vars[i].vartype = ORC_VAR_TYPE_DEST;
program->vars[i].size = size;
program->vars[i].name = strdup(name);
- program->n_vars++;
+ program->n_dest_vars++;
return i;
}
int
orc_program_add_constant (OrcProgram *program, int size, int value, const char *name)
{
- int i = program->n_vars;
+ int i = ORC_VAR_C1 + program->n_const_vars;
program->vars[i].vartype = ORC_VAR_TYPE_CONST;
program->vars[i].size = size;
program->vars[i].value = value;
program->vars[i].name = strdup(name);
- program->n_vars++;
+ program->n_const_vars++;
return i;
}
int
orc_program_add_parameter (OrcProgram *program, int size, const char *name)
{
- int i = program->n_vars;
+ int i = ORC_VAR_P1 + program->n_param_vars;
program->vars[i].vartype = ORC_VAR_TYPE_PARAM;
program->vars[i].size = size;
program->vars[i].name = strdup(name);
- program->n_vars++;
+ program->n_param_vars++;
return i;
}
{
int i;
- for(i=0;i<program->n_vars;i++){
- if (strcmp (program->vars[i].name, name) == 0) {
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (program->vars[i].name && strcmp (program->vars[i].name, name) == 0) {
return i;
}
}
{
int k;
- for(k=0;k<compiler->n_vars;k++){
- if (compiler->vars[k].vartype == ORC_VAR_TYPE_DEST) {
+ for(k=0;k<ORC_N_VARIABLES;k++){
+ if (compiler->vars[k].name &&
+ compiler->vars[k].vartype == ORC_VAR_TYPE_DEST) {
return k;
}
}
int max;
max = 0;
- for(i=0;i<program->n_vars;i++){
- max = MAX(max, program->vars[i].size);
+ for(i=0;i<ORC_N_VARIABLES;i++){
+ if (program->vars[i].size) {
+ max = MAX(max, program->vars[i].size);
+ }
}
return max;
ORC_VAR_TYPE_PARAM
} OrcVarType;
+enum {
+ ORC_VAR_D1,
+ ORC_VAR_D2,
+ ORC_VAR_D3,
+ ORC_VAR_D4,
+ ORC_VAR_S1,
+ ORC_VAR_S2,
+ ORC_VAR_S3,
+ ORC_VAR_S4,
+ ORC_VAR_S5,
+ ORC_VAR_S6,
+ ORC_VAR_S7,
+ ORC_VAR_S8,
+ ORC_VAR_C1,
+ ORC_VAR_C2,
+ ORC_VAR_C3,
+ ORC_VAR_C4,
+ ORC_VAR_C5,
+ ORC_VAR_C6,
+ ORC_VAR_C7,
+ ORC_VAR_C8,
+ ORC_VAR_P1,
+ ORC_VAR_P2,
+ ORC_VAR_P3,
+ ORC_VAR_P4,
+ ORC_VAR_P5,
+ ORC_VAR_P6,
+ ORC_VAR_P7,
+ ORC_VAR_P8,
+ ORC_VAR_T1,
+ ORC_VAR_T2,
+ ORC_VAR_T3,
+ ORC_VAR_T4,
+ ORC_VAR_T5,
+ ORC_VAR_T6,
+ ORC_VAR_T7,
+ ORC_VAR_T8
+};
+
struct _OrcVariable {
char *name;
int n_insns;
OrcVariable vars[ORC_N_VARIABLES];
- int n_vars;
+ //int n_vars;
+ int n_src_vars;
+ int n_dest_vars;
+ int n_param_vars;
+ int n_const_vars;
+ int n_temp_vars;
char *name;
char *asm_code;
int n_insns;
OrcVariable vars[ORC_N_VARIABLES];
- int n_vars;
+ //int n_vars;
+ int n_temp_vars;
unsigned char *codeptr;