}
}
} else if (strcmp (token[0], ".n") == 0) {
- int size = strtol (token[1], NULL, 0);
- orc_program_set_constant_n (parser->program, size);
+ int i;
+ for(i=1;i<n_tokens;i++){
+ if (strcmp (token[i], "mult") == 0) {
+ if (i == n_tokens - 1) {
+ orc_parse_log (parser, "error: line %d: .n mult requires multiple value\n",
+ parser->line_number);
+ } else {
+ orc_program_set_n_multiple (parser->program,
+ strtol (token[1], NULL, 0));
+ i++;
+ }
+ } else if (strcmp (token[i], "min") == 0) {
+ if (i == n_tokens - 1) {
+ orc_parse_log (parser, "error: line %d: .n mult requires multiple value\n",
+ parser->line_number);
+ } else {
+ orc_program_set_n_minimum (parser->program,
+ strtol (token[1], NULL, 0));
+ i++;
+ }
+ } else if (strcmp (token[i], "max") == 0) {
+ if (i == n_tokens - 1) {
+ orc_parse_log (parser, "error: line %d: .n mult requires multiple value\n",
+ parser->line_number);
+ } else {
+ orc_program_set_n_maximum (parser->program,
+ strtol (token[1], NULL, 0));
+ i++;
+ }
+ } else {
+ orc_program_set_constant_n (parser->program,
+ strtol (token[1], NULL, 0));
+ }
+ }
} else if (strcmp (token[0], ".m") == 0) {
int size = strtol (token[1], NULL, 0);
orc_program_set_constant_m (parser->program, size);
program->constant_n = n;
}
+void orc_program_set_n_multiple (OrcProgram *program, int n)
+{
+ program->n_multiple = n;
+}
+
+void orc_program_set_n_minimum (OrcProgram *program, int n)
+{
+ program->n_minimum = n;
+}
+
+void orc_program_set_n_maximum (OrcProgram *program, int n)
+{
+ program->n_maximum = n;
+}
+
void orc_program_set_constant_m (OrcProgram *program, int m)
{
program->constant_m = m;
}
/**
- * orc_program_add_source:
+ * orc_program_add_source_full:
* @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
*
* Creates a new variable representing a source array.
*
* Returns: the index of the new variable
*/
int
-orc_program_add_source (OrcProgram *program, int size, const char *name)
+orc_program_add_source_full (OrcProgram *program, int size, const char *name,
+ const char *type_name, int alignment)
{
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].alignment = size;
+ if (alignment == 0) alignment = size;
+ program->vars[i].alignment = alignment;
program->vars[i].name = strdup(name);
+ if (type_name) {
+ program->vars[i].type_name = strdup(type_name);
+ }
program->n_src_vars++;
return i;
}
/**
- * orc_program_add_destination:
+ * orc_program_add_source:
+ * @program: a pointer to an OrcProgram structure
+ * @size: size of data values
+ * @name: name of variable
+ *
+ * Creates a new variable representing a source array.
+ *
+ * Returns: the index of the new variable
+ */
+int
+orc_program_add_source (OrcProgram *program, int size, const char *name)
+{
+ return orc_program_add_source_full (program, size, name, NULL, 0);
+}
+
+/**
+ * orc_program_add_destination_full:
* @program: a pointer to an OrcProgram structure
* @size: size of data values
* @name: name of variable
* Returns: the index of the new variable
*/
int
-orc_program_add_destination (OrcProgram *program, int size, const char *name)
+orc_program_add_destination_full (OrcProgram *program, int size, const char *name,
+ const char *type_name, int alignment)
{
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].alignment = size;
+ if (alignment == 0) alignment = size;
+ program->vars[i].alignment = alignment;
program->vars[i].name = strdup(name);
+ if (type_name) {
+ program->vars[i].type_name = strdup(type_name);
+ }
program->n_dest_vars++;
return i;
}
/**
+ * orc_program_add_destination:
+ * @program: a pointer to an OrcProgram structure
+ * @size: size of data values
+ * @name: name of variable
+ *
+ * Creates a new variable representing a destination array.
+ *
+ * Returns: the index of the new variable
+ */
+int
+orc_program_add_destination (OrcProgram *program, int size, const char *name)
+{
+ return orc_program_add_destination_full (program, size, name, NULL, 0);
+}
+
+/**
* orc_program_add_constant:
* @program: a pointer to an OrcProgram structure
* @size: size of data value
void *backup_func;
int is_2d;
int constant_n;
+ int n_multiple;
+ int n_minimum;
+ int n_maximum;
int constant_m;
OrcCode *orccode;
void orc_program_set_name (OrcProgram *program, const char *name);
void orc_program_set_2d (OrcProgram *program);
void orc_program_set_constant_n (OrcProgram *program, int n);
+void orc_program_set_n_multiple (OrcProgram *ex, int n);
+void orc_program_set_n_minimum (OrcProgram *ex, int n);
+void orc_program_set_n_maximum (OrcProgram *ex, int n);
void orc_program_set_constant_m (OrcProgram *program, int m);
void orc_program_append (OrcProgram *p, const char *opcode, int arg0, int arg1, int arg2);
int orc_program_add_temporary (OrcProgram *program, int size, const char *name);
int orc_program_dup_temporary (OrcProgram *program, int i, int j);
int orc_program_add_source (OrcProgram *program, int size, const char *name);
+int orc_program_add_source_full (OrcProgram *program, int size, const char *name,
+ const char *type_name, int alignment);
int orc_program_add_destination (OrcProgram *program, int size, const char *name);
+int orc_program_add_destination_full (OrcProgram *program, int size, const char *name,
+ const char *type_name, int alignment);
int orc_program_add_constant (OrcProgram *program, int size, int value, const char *name);
int orc_program_add_constant_int64 (OrcProgram *program, int size, orc_int64 value, const char *name);
int orc_program_add_constant_float (OrcProgram *program, int size, float value, const char *name);
fprintf(output, " orc_program_set_constant_n (p, %d);\n",
p->constant_n);
}
+ if (p->n_multiple != 0) {
+ REQUIRE(0,4,14,1);
+ fprintf(output, " orc_program_set_n_multiple (p, %d);\n",
+ p->constant_n);
+ }
+ if (p->n_minimum != 0) {
+ REQUIRE(0,4,14,1);
+ fprintf(output, " orc_program_set_n_minimum (p, %d);\n",
+ p->constant_n);
+ }
+ if (p->n_maximum != 0) {
+ REQUIRE(0,4,14,1);
+ fprintf(output, " orc_program_set_n_maximum (p, %d);\n",
+ p->constant_n);
+ }
if (p->is_2d) {
fprintf(output, " orc_program_set_2d (p);\n");
if (p->constant_m != 0) {
for(i=0;i<4;i++){
var = &p->vars[ORC_VAR_D1 + i];
if (var->size) {
- fprintf(output, " orc_program_add_destination (p, %d, \"%s\");\n",
- var->size, varnames[ORC_VAR_D1 + i]);
+ if (var->alignment != var->size) {
+ REQUIRE(0,4,14,1);
+ fprintf(output, " orc_program_add_destination_full (p, %d, \"%s\", NULL, %d);\n",
+ var->size, varnames[ORC_VAR_D1 + i], var->alignment);
+ } else {
+ fprintf(output, " orc_program_add_destination (p, %d, \"%s\");\n",
+ var->size, varnames[ORC_VAR_D1 + i]);
+ }
}
}
for(i=0;i<8;i++){
var = &p->vars[ORC_VAR_S1 + i];
if (var->size) {
- fprintf(output, " orc_program_add_source (p, %d, \"%s\");\n",
- var->size, varnames[ORC_VAR_S1 + i]);
+ if (var->alignment != var->size) {
+ REQUIRE(0,4,14,1);
+ fprintf(output, " orc_program_add_source_full (p, %d, \"%s\", NULL, %d);\n",
+ var->size, varnames[ORC_VAR_S1 + i],
+ var->alignment);
+ } else {
+ fprintf(output, " orc_program_add_source (p, %d, \"%s\");\n",
+ var->size, varnames[ORC_VAR_S1 + i]);
+ }
}
}
for(i=0;i<4;i++){