more conversion to orc int types
authorDavid Schleef <ds@schleef.org>
Thu, 10 Jun 2010 02:14:08 +0000 (19:14 -0700)
committerDavid Schleef <ds@schleef.org>
Thu, 10 Jun 2010 02:14:08 +0000 (19:14 -0700)
orc/orcprogram-c.c
orc/orcprogram.h
tools/orcc.c

index dcb4ec2..0a7bcf2 100644 (file)
@@ -27,10 +27,9 @@ orc_compiler_c_init (OrcCompiler *compiler)
 }
 
 const char *
-orc_target_c_get_asm_preamble (void)
+orc_target_c_get_typedefs (void)
 {
-  return "\n"
-    "/* begin Orc C target preamble */\n"
+  return
     "#ifndef _ORC_INTEGER_TYPEDEFS_\n"
     "#define _ORC_INTEGER_TYPEDEFS_\n"
     "#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n"
@@ -70,7 +69,14 @@ orc_target_c_get_asm_preamble (void)
     "#endif\n"
     "typedef union { orc_int32 i; float f; } orc_union32;\n"
     "typedef union { orc_int64 i; double f; } orc_union64;\n"
-    "#endif\n"
+    "#endif\n";
+}
+
+const char *
+orc_target_c_get_asm_preamble (void)
+{
+  return "\n"
+    "/* begin Orc C target preamble */\n"
     "#define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))\n"
     "#define ORC_ABS(a) ((a)<0 ? -(a) : (a))\n"
     "#define ORC_MIN(a,b) ((a)<(b) ? (a) : (b))\n"
index 6050b91..c2220b7 100644 (file)
@@ -577,6 +577,7 @@ int orc_compiler_get_constant (OrcCompiler *compiler, int size, int value);
 const char *orc_program_get_asm_code (OrcProgram *program);
 const char *orc_target_get_asm_preamble (const char *target);
 const char * orc_target_get_preamble (OrcTarget *target);
+const char * orc_target_c_get_typedefs (void);
 
 void orc_compiler_append_code (OrcCompiler *p, const char *fmt, ...)
   ORC_GNU_PRINTF(2,3);
index 081dab7..753b7ad 100644 (file)
@@ -176,6 +176,7 @@ main (int argc, char *argv[])
       output_code_header (programs[i], output);
     }
     fprintf(output, "\n");
+    fprintf(output, "%s", orc_target_c_get_typedefs ());
     fprintf(output, "%s", orc_target_get_asm_preamble ("c"));
     fprintf(output, "\n");
     for(i=0;i<n;i++){
@@ -196,6 +197,8 @@ main (int argc, char *argv[])
     fprintf(output, "extern \"C\" {\n");
     fprintf(output, "#endif\n");
     fprintf(output, "\n");
+    fprintf(output, "%s", orc_target_c_get_typedefs ());
+    fprintf(output, "\n");
     for(i=0;i<n;i++){
       output_code_header (programs[i], output);
     }
@@ -216,6 +219,7 @@ main (int argc, char *argv[])
       fprintf(output, "#include <%s>\n", include_file);
     }
     fprintf(output, "\n");
+    fprintf(output, "%s", orc_target_c_get_typedefs ());
     fprintf(output, "%s", orc_target_get_asm_preamble ("c"));
     fprintf(output, "\n");
     for(i=0;i<n;i++){
@@ -359,7 +363,7 @@ output_prototype (OrcProgram *p, FILE *output)
         fprintf(output, "%s * %s", var->type_name,
             varnames[ORC_VAR_D1 + i]);
       } else {
-        fprintf(output, "uint%d_t * %s", var->size*8,
+        fprintf(output, "orc_uint%d * %s", var->size*8,
             varnames[ORC_VAR_D1 + i]);
       }
       if (p->is_2d) {
@@ -376,7 +380,7 @@ output_prototype (OrcProgram *p, FILE *output)
         fprintf(output, "%s * %s", var->type_name,
             varnames[ORC_VAR_A1 + i]);
       } else {
-        fprintf(output, "uint%d_t * %s", var->size*8,
+        fprintf(output, "orc_uint%d * %s", var->size*8,
             varnames[ORC_VAR_A1 + i]);
       }
       need_comma = TRUE;
@@ -390,7 +394,7 @@ output_prototype (OrcProgram *p, FILE *output)
         fprintf(output, "const %s * %s", var->type_name,
             varnames[ORC_VAR_S1 + i]);
       } else {
-        fprintf(output, "const uint%d_t * %s", var->size*8,
+        fprintf(output, "const orc_uint%d * %s", var->size*8,
             varnames[ORC_VAR_S1 + i]);
       }
       if (p->is_2d) {