From ceb938fb3c5b535ddd4e30f34180e6c25ea84511 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 22 Oct 2016 11:26:28 +0200 Subject: [PATCH] More opcodes. --- mach/powerpc/mcg/table | 12 ++++++ mach/proto/mcg/treebuilder.c | 75 ++++++++++++++++++++++++++++++++++++ util/mcgg/ir.dat | 2 + 3 files changed, 89 insertions(+) diff --git a/mach/powerpc/mcg/table b/mach/powerpc/mcg/table index 15a278e16..fe29607c5 100644 --- a/mach/powerpc/mcg/table +++ b/mach/powerpc/mcg/table @@ -194,6 +194,10 @@ PATTERNS emit "addi sp, sp, $delta" cost 4; + STACKADJUST4(in:(int)reg) + emit "add sp, sp, %in" + cost 4; + out:(int)reg = GETFP4 emit "mr %out, fp" cost 4; @@ -206,6 +210,14 @@ PATTERNS emit "addi %out, %in, 8" cost 4; + out:(int)reg = GETSP4 + emit "mr %out, sp" + cost 4; + + SETSP4(in:(int)reg) + emit "mr sp, %in" + cost 4; + /* Memory operations */ diff --git a/mach/proto/mcg/treebuilder.c b/mach/proto/mcg/treebuilder.c index 4ee49ebba..7d2b0b11f 100644 --- a/mach/proto/mcg/treebuilder.c +++ b/mach/proto/mcg/treebuilder.c @@ -817,6 +817,15 @@ static void insn_ivalue(int opcode, arith value) break; } + case op_ass: + appendir( + new_ir1( + IR_STACKADJUST, EM_pointersize, + pop(value) + ) + ); + break; + case op_ret: { if (value > 0) @@ -1015,6 +1024,72 @@ static void insn_ivalue(int opcode, arith value) break; } + case op_lor: + { + switch (value) + { + case 1: + appendir( + new_ir0( + IR_GETSP, EM_pointersize + ) + ); + break; + + default: + fatal("'lor %d' not supported", value); + } + + break; + } + + case op_str: + { + switch (value) + { + case 1: + appendir( + new_ir1( + IR_SETSP, EM_pointersize, + pop(EM_pointersize) + ) + ); + break; + + default: + fatal("'str %d' not supported", value); + } + + break; + } + + case op_blm: + { + /* Input stack: ( src dest -- ) */ + /* Memmove stack: ( size src dest -- ) */ + struct ir* dest = pop(EM_pointersize); + struct ir* src = pop(EM_pointersize); + + push(new_wordir(value)); + push(src); + push(dest); + + materialise_stack(); + appendir( + new_ir1( + IR_CALL, 0, + new_labelir("memmove") + ) + ); + appendir( + new_ir1( + IR_STACKADJUST, EM_pointersize, + new_wordir(EM_pointersize*2 + EM_wordsize) + ) + ); + break; + } + case op_lin: { /* Set line number --- ignore. */ diff --git a/util/mcgg/ir.dat b/util/mcgg/ir.dat index 7fe51ed30..2a6fec02d 100644 --- a/util/mcgg/ir.dat +++ b/util/mcgg/ir.dat @@ -116,6 +116,8 @@ S STACKADJUST S GETRET S SETRET S GETFP +S GETSP +S SETSP S CHAINFP S FPTOARGS