Remove GETRET; values are now returned directly by CALL. Fix a bug in
authorDavid Given <dg@cowlark.com>
Sat, 22 Oct 2016 10:13:57 +0000 (12:13 +0200)
committerDavid Given <dg@cowlark.com>
Sat, 22 Oct 2016 10:13:57 +0000 (12:13 +0200)
convertstackops which was resulting in duplicate IR groups.

mach/powerpc/mcg/table
mach/proto/mcg/pass_convertstackops.c
mach/proto/mcg/treebuilder.c
util/mcgg/ir.dat

index fe29607..240086b 100644 (file)
@@ -130,9 +130,9 @@ DECLARATIONS
 
        cr;
     ubyteX;   /* bottom 8 bits valid, the rest undefined */
-    ubyte0;  /* bottom 8 bits valid, the rest 0 */
+    ubyte0;   /* bottom 8 bits valid, the rest 0 */
     ushortX;  /* bottom 16 bits valid, the rest undefined */
-    ushort0; /* bottom 16 bits valid, the rest 0 */
+    ushort0;  /* bottom 16 bits valid, the rest 0 */
 
        address fragment;
 
@@ -181,14 +181,6 @@ PATTERNS
         emit "! setret8"
         cost 1;
 
-    (ret)reg = GETRET4
-        emit "! getret4"
-        cost 1;
-
-    (pret)reg = GETRET8
-        emit "! getret8"
-        cost 1;
-
        STACKADJUST4(delta:CONST4)
         when signed_constant(%delta, 16)
                emit "addi sp, sp, $delta"
@@ -401,12 +393,34 @@ PATTERNS
         emit "b $false"
                cost 8;
 
-       CALL(dest:LABEL4)
+       CALL1(dest:LABEL4)
+        with corrupted(volatile)
+               emit "bl $dest"
+               cost 4;
+
+       out:(ret)reg = CALL4(dest:LABEL4)
+        with corrupted(volatile)
+               emit "bl $dest"
+               cost 4;
+
+       out:(pret)reg = CALL8(dest:LABEL4)
         with corrupted(volatile)
                emit "bl $dest"
                cost 4;
 
-    CALL(dest:(int)reg)
+    CALL1(dest:(int)reg)
+        with corrupted(volatile)
+        emit "mtspr ctr, %dest"
+        emit "bcctrl 20, 0, 0"
+        cost 8;
+
+    out:(ret)reg = CALL4(dest:(int)reg)
+        with corrupted(volatile)
+        emit "mtspr ctr, %dest"
+        emit "bcctrl 20, 0, 0"
+        cost 8;
+
+    out:(pret)reg = CALL8(dest:(int)reg)
         with corrupted(volatile)
         emit "mtspr ctr, %dest"
         emit "bcctrl 20, 0, 0"
index 692a11a..a8968c2 100644 (file)
@@ -88,7 +88,8 @@ static void convert_block(struct basicblock* bb)
         for (i=0; i<pushes.count; i++)
         {
             struct ir* ir = pushes.item[i].right;
-            *ir = *ir->left;
+            ir->opcode = IR_NOP;
+            ir->size = 0;
         }
 
         for (i=0; i<pops.count; i++)
index 7d2b0b1..91a0826 100644 (file)
@@ -4,6 +4,7 @@ static struct basicblock* current_bb;
 
 static int stackptr;
 static struct ir* stack[64];
+static struct ir* lastcall;
 
 static struct ir* convert(struct ir* src, int destsize, int opcodebase);
 static struct ir* appendir(struct ir* ir);
@@ -237,7 +238,7 @@ static void insn_simple(int opcode)
             struct ir* dest = pop(EM_pointersize);
 
             materialise_stack();
-            appendir(
+            lastcall = appendir(
                 new_ir1(
                     IR_CALL, 0,
                     dest
@@ -867,13 +868,9 @@ static void insn_ivalue(int opcode, arith value)
                     
         case op_lfr:
         {
-            push(
-                appendir(
-                    new_ir0(
-                        IR_GETRET, value
-                    )
-                )
-            );
+            assert(lastcall != NULL);
+            lastcall->size = value;
+            push(lastcall);
             break;
         }
 
@@ -918,15 +915,12 @@ static void insn_ivalue(int opcode, arith value)
             }
 
             materialise_stack();
-            appendir(
-                new_ir1(
-                    IR_CALL, 0,
-                    new_labelir(helper)
-                )
-            );
             push(
-                new_ir0(
-                    IR_GETRET, EM_wordsize
+                appendir(
+                    new_ir1(
+                        IR_CALL, EM_wordsize,
+                        new_labelir(helper)
+                    )
                 )
             );
             break;
@@ -1198,7 +1192,7 @@ static void insn_lvalue(int opcode, const char* label, arith offset)
         case op_cal:
             assert(offset == 0);
             materialise_stack();
-            appendir(
+            lastcall = appendir(
                 new_ir1(
                     IR_CALL, 0,
                     new_labelir(label)
index 2a6fec0..6b3c375 100644 (file)
@@ -102,7 +102,7 @@ S IFLT
 S IFLE
 
 # Procedures
-V CALL
+S CALL
 
 # Flow control --- these never return
 V JUMP
@@ -113,7 +113,6 @@ V RET
  
 # Special
 S STACKADJUST
-S GETRET
 S SETRET
 S GETFP
 S GETSP