orc_program_add_parameter (parser->program, size, token[2]);
} else if (strcmp (token[0], ".const") == 0) {
int size = strtol (token[1], NULL, 0);
- int value = strtoul (token[3], NULL, 0);
- orc_program_add_constant (parser->program, size, value, token[2]);
+ char *end, *endf;
+ int value;
+ double valuef;
+ value = strtol (token[3], &end, 0);
+ valuef = strtod (token[3], &endf);
+ if (endf > end) {
+ orc_program_add_constant_float (parser->program, size, valuef, token[2]);
+ } else {
+ orc_program_add_constant (parser->program, size, value, token[2]);
+ }
} else if (strcmp (token[0], ".floatparam") == 0) {
int size = strtol (token[1], NULL, 0);
orc_program_add_parameter_float (parser->program, size, token[2]);
if (o) {
int n_args = opcode_n_args (o);
+ char const_regs[10][10];
+ int i;
if (n_tokens != 1 + offset + n_args) {
orc_parse_log (parser, "error: line %d: too %s arguments for %s (expected %d)\n",
token[offset], n_args);
}
+ for(i=offset+1;i<n_tokens;i++){
+ char *end;
+ char *endf;
+ int imm;
+ double immf;
+ imm = strtol (token[i], &end, 0);
+ immf = strtod (token[i], &endf);
+ if ((end != token[i]) || (endf != token[i])) {
+ sprintf(const_regs[i], "c%d", parser->creg_index);
+ parser->creg_index++;
+ if (end >= endf) {
+ orc_program_add_constant (parser->program, 2, imm,
+ const_regs[i]);
+ } else {
+ orc_program_add_constant_float (parser->program, 2, immf,
+ const_regs[i]);
+ }
+ token[i] = const_regs[i];
+ }
+ }
+
if (n_tokens - offset == 5) {
orc_program_append_str_2 (parser->program, token[offset], flags,
token[offset+1], token[offset+2], token[offset+3], token[offset+4]);
} else if (n_tokens - offset == 4) {
- char *end;
- int imm = strtol (token[offset + 3], &end, 0);
- if (end != token[offset + 3]) {
- char creg[10];
- sprintf(creg, "c%d", parser->creg_index);
- parser->creg_index++;
- orc_program_add_constant (parser->program, 2, imm, creg);
- orc_program_append_str_2 (parser->program, token[offset], flags,
- token[offset+1], token[offset+2], creg, NULL);
- } else {
- orc_program_append_str_2 (parser->program, token[offset], flags,
- token[offset+1], token[offset+2], token[offset+3], NULL);
- }
+ orc_program_append_str_2 (parser->program, token[offset], flags,
+ token[offset+1], token[offset+2], token[offset+3], NULL);
} else {
orc_program_append_str_2 (parser->program, token[offset], flags,
token[offset+1], token[offset+2], NULL, NULL);
return i;
}
+int
+orc_program_add_constant_int64 (OrcProgram *program, int size,
+ orc_int64 value, const char *name)
+{
+ ORC_ASSERT(0);
+}
+
+int
+orc_program_add_constant_float (OrcProgram *program, int size,
+ float value, const char *name)
+{
+ orc_union32 u;
+ u.f = value;
+ return orc_program_add_constant (program, size, u.i, name);
+}
+
+int
+orc_program_add_constant_double (OrcProgram *program, int size,
+ double value, const char *name)
+{
+ orc_union64 u;
+ u.f = value;
+ return orc_program_add_constant_int64 (program, size, u.i, name);
+}
+
/**
* orc_program_add_parameter:
* @program: a pointer to an OrcProgram structure
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_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);
+int orc_program_add_constant_double (OrcProgram *program, int size, double value, const char *name);
int orc_program_add_parameter (OrcProgram *program, int size, const char *name);
int orc_program_add_parameter_float (OrcProgram *program, int size, const char *name);
int orc_program_add_parameter_double (OrcProgram *program, int size, const char *name);