Remove GETRET; values are now returned directly by CALL. Fix a bug in

convertstackops which was resulting in duplicate IR groups.
This commit is contained in:
David Given 2016-10-22 12:13:57 +02:00
parent ceb938fb3c
commit 2d52b1fdaa
4 changed files with 40 additions and 32 deletions

View file

@ -130,9 +130,9 @@ DECLARATIONS
cr; cr;
ubyteX; /* bottom 8 bits valid, the rest undefined */ 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 */ 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; address fragment;
@ -181,14 +181,6 @@ PATTERNS
emit "! setret8" emit "! setret8"
cost 1; cost 1;
(ret)reg = GETRET4
emit "! getret4"
cost 1;
(pret)reg = GETRET8
emit "! getret8"
cost 1;
STACKADJUST4(delta:CONST4) STACKADJUST4(delta:CONST4)
when signed_constant(%delta, 16) when signed_constant(%delta, 16)
emit "addi sp, sp, $delta" emit "addi sp, sp, $delta"
@ -401,12 +393,34 @@ PATTERNS
emit "b $false" emit "b $false"
cost 8; cost 8;
CALL(dest:LABEL4) CALL1(dest:LABEL4)
with corrupted(volatile) with corrupted(volatile)
emit "bl $dest" emit "bl $dest"
cost 4; cost 4;
CALL(dest:(int)reg) 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;
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) with corrupted(volatile)
emit "mtspr ctr, %dest" emit "mtspr ctr, %dest"
emit "bcctrl 20, 0, 0" emit "bcctrl 20, 0, 0"

View file

@ -88,7 +88,8 @@ static void convert_block(struct basicblock* bb)
for (i=0; i<pushes.count; i++) for (i=0; i<pushes.count; i++)
{ {
struct ir* ir = pushes.item[i].right; struct ir* ir = pushes.item[i].right;
*ir = *ir->left; ir->opcode = IR_NOP;
ir->size = 0;
} }
for (i=0; i<pops.count; i++) for (i=0; i<pops.count; i++)

View file

@ -4,6 +4,7 @@ static struct basicblock* current_bb;
static int stackptr; static int stackptr;
static struct ir* stack[64]; static struct ir* stack[64];
static struct ir* lastcall;
static struct ir* convert(struct ir* src, int destsize, int opcodebase); static struct ir* convert(struct ir* src, int destsize, int opcodebase);
static struct ir* appendir(struct ir* ir); static struct ir* appendir(struct ir* ir);
@ -237,7 +238,7 @@ static void insn_simple(int opcode)
struct ir* dest = pop(EM_pointersize); struct ir* dest = pop(EM_pointersize);
materialise_stack(); materialise_stack();
appendir( lastcall = appendir(
new_ir1( new_ir1(
IR_CALL, 0, IR_CALL, 0,
dest dest
@ -867,13 +868,9 @@ static void insn_ivalue(int opcode, arith value)
case op_lfr: case op_lfr:
{ {
push( assert(lastcall != NULL);
appendir( lastcall->size = value;
new_ir0( push(lastcall);
IR_GETRET, value
)
)
);
break; break;
} }
@ -918,15 +915,12 @@ static void insn_ivalue(int opcode, arith value)
} }
materialise_stack(); materialise_stack();
appendir(
new_ir1(
IR_CALL, 0,
new_labelir(helper)
)
);
push( push(
new_ir0( appendir(
IR_GETRET, EM_wordsize new_ir1(
IR_CALL, EM_wordsize,
new_labelir(helper)
)
) )
); );
break; break;
@ -1198,7 +1192,7 @@ static void insn_lvalue(int opcode, const char* label, arith offset)
case op_cal: case op_cal:
assert(offset == 0); assert(offset == 0);
materialise_stack(); materialise_stack();
appendir( lastcall = appendir(
new_ir1( new_ir1(
IR_CALL, 0, IR_CALL, 0,
new_labelir(label) new_labelir(label)

View file

@ -102,7 +102,7 @@ S IFLT
S IFLE S IFLE
# Procedures # Procedures
V CALL S CALL
# Flow control --- these never return # Flow control --- these never return
V JUMP V JUMP
@ -113,7 +113,6 @@ V RET
# Special # Special
S STACKADJUST S STACKADJUST
S GETRET
S SETRET S SETRET
S GETFP S GETFP
S GETSP S GETSP