From ba0849c87cc27429d2f41e4dfeab4462b82e66b0 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 14 Sep 2018 11:30:15 +0200 Subject: [PATCH] Remove la; turns out that the assembler gets upset if you ask it to generate more than one fixup per instruction (I think). --- mach/mips/as/mach2.c | 1 - mach/mips/as/mach3.c | 1 - mach/mips/as/mach4.c | 15 +-------------- mach/mips/mcg/table | 6 ++++-- util/led/relocate.c | 4 ++++ 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/mach/mips/as/mach2.c b/mach/mips/as/mach2.c index 9b11f1f1c..3c1ee89dc 100644 --- a/mach/mips/as/mach2.c +++ b/mach/mips/as/mach2.c @@ -3,7 +3,6 @@ %token FCOND %token OP_LI -%token OP_LA %token HI16 %token HA16 diff --git a/mach/mips/as/mach3.c b/mach/mips/as/mach3.c index 008759d9d..d3cb812c5 100644 --- a/mach/mips/as/mach3.c +++ b/mach/mips/as/mach3.c @@ -75,7 +75,6 @@ 0, FPR, 31, "f31", 0, OP_LI, 0, "li", -0, OP_LA, 0, "la", 0, HI16, 0, "hi16", 0, HA16, 0, "ha16", 0, LO16, 0, "lo16", diff --git a/mach/mips/as/mach4.c b/mach/mips/as/mach4.c index 0befb2dc1..9e8dab51f 100644 --- a/mach/mips/as/mach4.c +++ b/mach/mips/as/mach4.c @@ -14,19 +14,6 @@ emit4(0x34000000 | (reg<<16) | (reg<<21) | (val & 0xffff)); /* ori reg, reg, value */ } } - | OP_LA GPR ',' expr - { - word_t reg = $2; - word_t type = $4.typ & S_TYP; - uint32_t val = $4.val; - - if (type != S_ABS) - newrelo($4.typ, RELO2HI | FIXUPFLAGS); - emit4(0x3c000000 | (reg<<16) | (val>>16)); /* lui reg, value */ - if (type != S_ABS) - newrelo($4.typ, RELO2 | FIXUPFLAGS); - emit4(0x34000000 | (reg<<16) | (reg<<21) | (val & 0xffff)); /* ori reg, reg, value */ - } extabsexp : absexp @@ -194,4 +181,4 @@ insmsblsb int size = $3; $$ = ((pos+size-1) << 5) | pos; } - ; \ No newline at end of file + ; diff --git a/mach/mips/mcg/table b/mach/mips/mcg/table index 43051cb4e..dbda9c84a 100644 --- a/mach/mips/mcg/table +++ b/mach/mips/mcg/table @@ -635,11 +635,13 @@ PATTERNS ALUCC(EOR.I, "xori") out:(int)reg = value:LABEL.I - emit "la %out, $value" + emit "lui %out, hi16[$value]" + emit "ori %out, %out, lo16[$value]" cost 4; out:(int)reg = value:BLOCK.I - emit "la %out, $value" + emit "lui %out, hi16[$value]" + emit "ori %out, %out, lo16[$value]" cost 4; out:(int)reg = value:CONST.I diff --git a/util/led/relocate.c b/util/led/relocate.c index 02af6666a..9fac60e52 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -556,11 +556,14 @@ long off; long valu; int sectindex = relo->or_sect - S_MIN; extern struct outhead outhead; + uint32_t realaddress = outsect[sectindex].os_base + relo->or_addr + + relorig[sectindex].org_size; /* * Pick up previous value at location to be relocated. */ valu = getvalu(emit + (relo->or_addr - off), relo->or_type); + debug("read relocation from 0x%08x type 0x%x value 0x%08x symbol %d\n", realaddress, relo->or_type, valu, relo->or_nami); /* * Or_nami is an index in the name table of the considered module. @@ -595,6 +598,7 @@ long off; /* * Now put the value back. */ + debug("written fixed up relocation to 0x%08x type 0x%x value 0x%08x\n", realaddress, relo->or_type, valu, 0); putvalu(valu, emit + (relo->or_addr - off), relo->or_type); /*