Added __builtin function __builtin_memset_x
[fw/sdcc] / src / ds390 / main.c
index b905d3cee1e61b1c7042f96887cf471490b2dcf8..132d6fb30b21865b422134a7f4a9ebf8175ed056 100644 (file)
@@ -43,7 +43,12 @@ static char *_ds390_keywords[] =
   NULL
 };
 
-
+static builtins __ds390_builtins[] = {
+    { "__builtin_memcpy_x2x","v",3,{"cx*","cx*","i"}}, /* void __builtin_memcpy_x2x (xdata char *,xdata char *,int) */
+    { "__builtin_memcpy_c2x","v",3,{"cx*","cp*","i"}}, /* void __builtin_memcpy_c2x (xdata char *,code  char *,int) */
+    { "__builtin_memset_x","v",3,{"cx*","c","i"}},     /* void __builtin_memset     (xdata char *,char,int)        */
+    { NULL , NULL,0, {NULL}}                      /* mark end of table */
+};    
 void ds390_assignRegisters (eBBlock ** ebbs, int count);
 
 static int regParmFlg = 0;     /* determine if we can register a parameter */
@@ -105,9 +110,9 @@ _ds390_finaliseOptions (void)
     port->s.fptr_size = 3;
     port->s.gptr_size = 4;
 
-    port->stack.isr_overhead++;        /* Will save dpx on ISR entry. */
+    port->stack.isr_overhead += 2;     /* Will save dpx on ISR entry. */
 
-    port->stack.call_overhead++;       /* This acounts for the extra byte 
+    port->stack.call_overhead += 2;    /* This acounts for the extra byte 
                                 * of return addres on the stack.
                                 * but is ugly. There must be a 
                                 * better way.
@@ -120,6 +125,8 @@ _ds390_finaliseOptions (void)
     {
     fprintf (stderr,
             "*** error: ds390 port only supports the 10 bit stack mode.\n");
+    } else {
+       if (!options.stack_loc) options.stack_loc = 0x400000;
     }
     
     /* generate native code 16*16 mul/div */
@@ -169,6 +176,7 @@ _ds390_genAssemblerPreamble (FILE * of)
       fputs ("mb = 0xD4\t\t; mb register unknown to assembler\n", of);
       fputs ("mc = 0xD5\t\t; mc register unknown to assembler\n", of);
       fputs ("F1 = 0xD1\t\t; F1 user flag unknown to assembler\n", of);
+      fputs ("esp = 0x9B\t\t; ESP user flag unknown to assembler\n", of);
 }
 
 /* Generate interrupt vector table. */
@@ -205,11 +213,11 @@ _ds390_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
 static bool cseCostEstimation (iCode *ic, iCode *pdic)
 {
     operand *result = IC_RESULT(ic);
-    operand *right  = IC_RIGHT(ic);
-    operand *left   = IC_LEFT(ic);
+    //operand *right  = IC_RIGHT(ic);
+    //operand *left   = IC_LEFT(ic);
     sym_link *result_type = operandType(result);
-    sym_link *right_type  = (right ? operandType(right) : 0);
-    sym_link *left_type   = (left  ? operandType(left)  : 0);
+    //sym_link *right_type  = (right ? operandType(right) : 0);
+    //sym_link *left_type   = (left  ? operandType(left)  : 0);
     
     /* if it is a pointer then return ok for now */
     if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
@@ -322,5 +330,6 @@ PORT ds390_port =
   0,                           /* leave == */
   TRUE,                         /* we support array initializers. */
   cseCostEstimation,
+  __ds390_builtins,             /* table of builtin functions */
   PORT_MAGIC
 };