Remove la; turns out that the assembler gets upset if you ask it to
authorDavid Given <dg@cowlark.com>
Fri, 14 Sep 2018 09:30:15 +0000 (11:30 +0200)
committerDavid Given <dg@cowlark.com>
Fri, 14 Sep 2018 09:30:15 +0000 (11:30 +0200)
generate more than one fixup per instruction (I think).

mach/mips/as/mach2.c
mach/mips/as/mach3.c
mach/mips/as/mach4.c
mach/mips/mcg/table
util/led/relocate.c

index 9b11f1f..3c1ee89 100644 (file)
@@ -3,7 +3,6 @@
 %token <y_word> FCOND
 
 %token <y_word> OP_LI
-%token <y_word> OP_LA
 
 %token <y_word> HI16
 %token <y_word> HA16
index 008759d..d3cb812 100644 (file)
@@ -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",
index 0befb2d..9e8dab5 100644 (file)
                        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
+       ;
index 43051cb..dbda9c8 100644 (file)
@@ -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
index 02af666..9fac60e 100644 (file)
@@ -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);
 
        /*