From 2d52b1fdaac288c40ff8c7be07198a3454d6caad Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 22 Oct 2016 12:13:57 +0200 Subject: [PATCH] Remove GETRET; values are now returned directly by CALL. Fix a bug in convertstackops which was resulting in duplicate IR groups. --- mach/powerpc/mcg/table | 38 ++++++++++++++++++--------- mach/proto/mcg/pass_convertstackops.c | 3 ++- mach/proto/mcg/treebuilder.c | 28 ++++++++------------ util/mcgg/ir.dat | 3 +-- 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/mach/powerpc/mcg/table b/mach/powerpc/mcg/table index fe29607c5..240086b0c 100644 --- a/mach/powerpc/mcg/table +++ b/mach/powerpc/mcg/table @@ -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" diff --git a/mach/proto/mcg/pass_convertstackops.c b/mach/proto/mcg/pass_convertstackops.c index 692a11a62..a8968c22f 100644 --- a/mach/proto/mcg/pass_convertstackops.c +++ b/mach/proto/mcg/pass_convertstackops.c @@ -88,7 +88,8 @@ static void convert_block(struct basicblock* bb) for (i=0; ileft; + ir->opcode = IR_NOP; + ir->size = 0; } for (i=0; isize = 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) diff --git a/util/mcgg/ir.dat b/util/mcgg/ir.dat index 2a6fec02d..6b3c3755e 100644 --- a/util/mcgg/ir.dat +++ b/util/mcgg/ir.dat @@ -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 -- 2.34.1