improved structure assignments
authorceriel <none@none>
Mon, 26 Aug 1991 14:26:07 +0000 (14:26 +0000)
committerceriel <none@none>
Mon, 26 Aug 1991 14:26:07 +0000 (14:26 +0000)
lang/cem/cemcom.ansi/blocks.c
lang/cem/cemcom.ansi/eval.c

index 1ac3531..08583fc 100644 (file)
@@ -20,6 +20,7 @@
 #include "Lpars.h"
 extern arith NewLocal();
 #define LocalPtrVar()  NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
+#define LocalIntVar()  NewLocal(int_size, int_align, reg_any, REGISTER)
 #endif STB
 
 /*     Because EM does not support the loading and storing of
@@ -137,18 +138,48 @@ load_block(sz, al)
        }
 }
 
+copy_block(sz, al)
+       arith sz;
+       int al;
+{
+
+       if (suitable_sz(sz, al))
+               C_blm(sz);
+       else {
+#ifndef STB
+               arith src, dst;
+
+               /* allocate two pointer temporaries */
+               src = LocalPtrVar();
+               dst = LocalPtrVar();
+
+               StoreLocal(src, pointer_size);
+               StoreLocal(dst, pointer_size);
+               copy_loop(sz, src, dst);
+               FreeLocal(dst);
+               FreeLocal(src);
+#else STB
+               C_loc(sz);                      /* # bytes to copy      */
+               C_cal("__stb");                 /* library copy routine */
+               C_asp(int_size + pointer_size + pointer_size);
+#endif STB
+       }
+}
+
 #ifndef STB
 copy_loop(sz, src, dst)
        arith sz, src, dst;
 {
        /* generate inline byte-copy loop */
        label l_cont = text_label(), l_stop = text_label();
+       arith tmp_sz = LocalIntVar();
 
        C_loc(sz);              /* amount of bytes */
+       StoreLocal(tmp_sz, int_size);
        C_df_ilb(l_cont);
-       C_dup(word_size);
+       LoadLocal(tmp_sz, int_size);
        C_zle(l_stop);
-       C_dec();
+       C_del(tmp_sz);
        LoadLocal(src, pointer_size);
        C_dup(pointer_size);
        C_adp((arith)1);
@@ -161,7 +192,7 @@ copy_loop(sz, src, dst)
        C_sti((arith)1);
        C_bra(l_cont);
        C_df_ilb(l_stop);
-       C_asp(word_size);
+       FreeLocal(tmp_sz);
 }
 #endif STB
 
index 08b8f81..574e442 100644 (file)
@@ -348,6 +348,12 @@ EVAL(expr, val, code, true_label, false_label)
                                break;
                        }
 #endif NOBITFIELD
+                       if (is_struct_or_union(tp->tp_fund) && ! gencode) {
+                               EVAL(right, LVAL, TRUE, NO_LABEL, NO_LABEL);
+                               EVAL(left, LVAL, TRUE, NO_LABEL, NO_LABEL);
+                               copy_block(tp->tp_size, tp->tp_align);
+                               break;
+                       }
                        EVAL(right, RVAL, TRUE, NO_LABEL, NO_LABEL);
                        if (gencode && val == RVAL)
                                C_dup(ATW(tp->tp_size));