From 26c0228b14992f0088e708599f867e9dce660314 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 4 Sep 2018 23:55:28 +0200 Subject: [PATCH] The examples all compile now (probably incorrectly, and the libc doesn't compile yet). --- mach/mips/as/instructions.dat | 2 ++ mach/mips/mcg/platform.c | 29 ++++++++++++++++++----------- mach/mips/mcg/table | 15 ++++++++++++++- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/mach/mips/as/instructions.dat b/mach/mips/as/instructions.dat index 0d6b90909..b1084675b 100644 --- a/mach/mips/as/instructions.dat +++ b/mach/mips/as/instructions.dat @@ -233,6 +233,8 @@ 01001100000001101 "suxc1" FD=fpr ',' RT=gpr '(' RS=gpr ')' 111001 "swc1" FT=fpr ',' IMM=e16 '(' RS=gpr ')' 01001100000001000 "swxc1" FD=fpr ',' RT=gpr '(' RS=gpr ')' +01000100000001001 "trunc" ".l" F=fmt FS=fpr ',' FD=fpr +01000100000001101 "trunc" ".w" F=fmt FS=fpr ',' FD=fpr # Generic coprocessor instructions. diff --git a/mach/mips/mcg/platform.c b/mach/mips/mcg/platform.c index 0f6881c59..ab0032664 100644 --- a/mach/mips/mcg/platform.c +++ b/mach/mips/mcg/platform.c @@ -208,20 +208,20 @@ struct hop* platform_move(struct basicblock* bb, struct hreg* src, struct hreg* switch (type) { case burm_int_ATTR: - hop_add_insel(hop, "stw %H, %S(fp) ! %H", src, dest, dest); - break; - - case burm_float_ATTR: - hop_add_insel(hop, "stfs %H, %S(fp) ! %H", src, dest, dest); + hop_add_insel(hop, "sw %H, %S(fp) ! %H", src, dest, dest); break; case burm_long_ATTR: - hop_add_insel(hop, "stw %0H, 4+%S(fp) ! %H", src, dest, dest); - hop_add_insel(hop, "stw %1H, 0+%S(fp) ! %H", src, dest, dest); + hop_add_insel(hop, "sw %0H, 0+%S(fp) ! %H", src, dest, dest); + hop_add_insel(hop, "sw %1H, 4+%S(fp) ! %H", src, dest, dest); + break; + + case burm_float_ATTR: + hop_add_insel(hop, "swc1 %H, %S(fp) ! %H", src, dest, dest); break; case burm_double_ATTR: - hop_add_insel(hop, "stfd %H, %S(fp) ! %H", src, dest, dest); + hop_add_insel(hop, "sdc1 %H, %S(fp) ! %H", src, dest, dest); break; default: @@ -233,15 +233,22 @@ struct hop* platform_move(struct basicblock* bb, struct hreg* src, struct hreg* switch (type) { case burm_int_ATTR: - hop_add_insel(hop, "lwz %H, %S(fp) ! %H", dest, src, src); + hop_add_insel(hop, "lw %H, %S(fp) ! %H", dest, src, src); + break; + + case burm_long_ATTR: + /* Can't load straight into dest because it might overlap with src. */ + hop_add_insel(hop, "lw at, 0+%S(fp) ! %H", dest, src, src); + hop_add_insel(hop, "lw %1H, 4+%S(fp) ! %H", dest, src, src); + hop_add_insel(hop, "mov %0H, at", dest); break; case burm_float_ATTR: - hop_add_insel(hop, "lfs %H, %S(fp) ! %H", dest, src, src); + hop_add_insel(hop, "lwc1 %H, %S(fp) ! %H", dest, src, src); break; case burm_double_ATTR: - hop_add_insel(hop, "lfd %H, %S(fp) ! %H", dest, src, src); + hop_add_insel(hop, "ldc1 %H, %S(fp) ! %H", dest, src, src); break; default: diff --git a/mach/mips/mcg/table b/mach/mips/mcg/table index 054a39bdd..24c362d7b 100644 --- a/mach/mips/mcg/table +++ b/mach/mips/mcg/table @@ -679,7 +679,12 @@ PATTERNS out:(double)reg = COPYL.D(in:(long)reg) emit "mtc1 %in.0, %out" /* mtc1 has reversed parameters */ - emit "mthic1 %in.1, %out" /* mtc1 has reversed parameters */ + emit "mthc1 %in.1, %out" /* mtc1 has reversed parameters */ + cost 8; + + out:(long)reg = COPYD.L(in:(double)reg) + emit "mfc1 %out.0, %in" + emit "mfhc1 %out.1, %in" cost 8; /* Floats */ @@ -710,5 +715,13 @@ PATTERNS emit "mfc1 %out, f31" cost 8; + out:(double)reg = COPYI.F(in:(long)reg) + emit "mtc1 %in, %out" /* mtc1 has reversed parameters */ + cost 8; + + out:(long)reg = COPYF.I(in:(double)reg) + emit "mfc1 %out, %in" + cost 8; + /* vim: set sw=4 ts=4 expandtab : */