]> sourceware.org Git - cgen.git/commitdiff
* rtl-c.scm (s-sequence): Use gcc's statement expressions for
authorDoug Evans <xdje42@gmail.com>
Sat, 21 Nov 2009 17:39:14 +0000 (17:39 +0000)
committerDoug Evans <xdje42@gmail.com>
Sat, 21 Nov 2009 17:39:14 +0000 (17:39 +0000)
non-VOID-mode expressions with multiple statements.

ChangeLog
rtl-c.scm

index 10caab6d45a745987719cc6af79934fed02368fd..16a3333285cef56353c1d3d3b89148aa0a8c2207 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-11-21  Doug Evans  <dje@sebabeach.org>
 
+       * rtl-c.scm (s-sequence): Use gcc's statement expressions for
+       non-VOID-mode expressions with multiple statements.
+
        * sim.scm (/operand-number-elaboration-written?): New variable.
        (/op-gen-written-update op): New function.
        (/op-gen-set-trace, /op-gen-set-trace-parallel): Call it.
index a10d09f8656b9417911a4ca9788b15586f306f97..211e181154b37c18003eb8976168e611c9eaa332 100644 (file)
--- a/rtl-c.scm
+++ b/rtl-c.scm
                 ))))
 )
 
-; Return a <c-expr> node for a `sequence'.
-; MODE is the mode name.
+;; Return a <c-expr> node for a `sequence'.
+;; MODE is the mode name.
 
 (define (s-sequence estate mode env . exprs)
-  (let* ((env (rtx-env-make-locals env)) ; compile env
+  (let* ((env (rtx-env-make-locals env)) ;; compile env
         (estate (estate-push-env estate env)))
+
     (if (or (mode:eq? 'DFLT mode) ;; FIXME: DFLT can't appear anymore
            (mode:eq? 'VOID mode))
+
        (cx:make VOID
                 (string-append 
-                 ; ??? do {} while (0); doesn't get "optimized out"
-                 ; internally by gcc, meaning two labels and a loop are
-                 ; created for it to have to process.  We can generate pretty
-                 ; big files and can cause gcc to require *lots* of memory.
-                 ; So let's try just {} ...
+                 ;; ??? do {} while (0); doesn't get "optimized out"
+                 ;; internally by gcc, meaning two labels and a loop are
+                 ;; created for it to have to process.  We can generate pretty
+                 ;; big files and can cause gcc to require *lots* of memory.
+                 ;; So let's try just {} ...
                  "{\n"
                  (gen-temp-defs estate env)
                  (string-map (lambda (e)
                                (rtl-c-with-estate estate VOID e))
                              exprs)
                  "}\n"))
-       (cx:make mode
-                (string-append
-                 ; Don't use GCC extension unless necessary.
-                 (if (rtx-env-empty? env) "(" "({ ")
-                 (gen-temp-defs estate env)
-                 (string-drop 2
-                              (string-map
-                               (lambda (e)
-                                 (string-append
-                                  (if (rtx-env-empty? env) ", " "; ")
-                                  ; Strip off gratuitous ";\n" at end of expressions that
-                                  ; misguessed themselves to be in statement context.
-                                  ; See s-c-call, s-c-call-raw above.
-                                  (let ((substmt (rtl-c-with-estate estate DFLT e)))
-                                    (if (and (rtx-env-empty? env)
-                                             (string=? (string-take -2 substmt) ";\n"))
-                                        (string-drop -2 substmt)
-                                        substmt))))
-                               exprs))
-                 (if (rtx-env-empty? env) ")" "; })")))))
+
+       (let (
+             ;; Don't use GCC extension unless necessary.
+             (use-stmt-expr? (or (not (rtx-env-empty? env))
+                                 (> (length exprs) 1)))
+             )
+         (cx:make mode
+                  (string-append
+                   (if use-stmt-expr? "({ " "(")
+                   (gen-temp-defs estate env)
+                   (string-drop 2
+                                (string-map
+                                 (lambda (e)
+                                   (string-append
+                                    (if use-stmt-expr? "; " ", ")
+                                    ;; Strip off gratuitous ";\n" at end of expressions that
+                                    ;; misguessed themselves to be in statement context.
+                                    ;; See s-c-call, s-c-call-raw above.
+                                    (let ((substmt (rtl-c-with-estate estate DFLT e)))
+                                      (if (and (not use-stmt-expr?)
+                                               (string=? (string-take -2 substmt) ";\n"))
+                                          (string-drop -2 substmt)
+                                          substmt))))
+                                 exprs))
+                   (if use-stmt-expr? "; })" ")"))))))
 )
 
 ; Return a <c-expr> node for a `do-count'.
This page took 0.04555 seconds and 5 git commands to generate.