Hi everybody,
I decided to split the modification in two parts:
- add an __asm__ () statement to control the value of
  the segment registers from an high level language;
  This __asm__ () statement is then used as follow:
   register short a __asm__ ("es");

   int main(int argc, char **argv)
    {
        short b;

        b = a;
        a = 0x2a;
        printf("old value: %x new value: %x\n", b, a);
        return (0);
    }

- add an __attribute__ ((__far__())) to allow pointers to
  choose their data segment.
  This __attribute__(()) statement is then used as follow:
        int     *gs_p __attribute__ ((__far__("gs"))) = 0x2a;

  int main(int argc, char **argv)
   {
        int     *fs_p __attribute__((__far__("fs"))) = 0x0;

        fs_p[1] = 10;
        gs_p[0] = fs_p[0];
        return (0);
   }

Presently I have a problem with the first part.
I have added the the entries for es,fs and gs at the end of
FIXED_REGISTERS under the value 1,1,1 and in
CALL_USED_REGISTERS with the value 1,1,1
I also add the entries at the end of REG_ALLOC_ORDER and in
both HI_REGISER_NAMES and ADDITIONAL_REGISTER_NAMES.
Because those registers are different, I have created a new
register class at the end of the reg_class enum and added
the relevant REG_CLASS_NAMES and REG_CLASS_CONTENTS entries.
At least, I added the 's' id in REG_CLASS_FROM_LETTER.

To manage the manipulation of the register class, I added entries in
the i386.md file.

;; get a value from a segment register.
(define_insn "store_seg"
 [(set (match_operand:SI 0 "nonimmediate_operand" "")
       (match_operand:SI 1 "general_operand" "s"))]
       ""
       "movl\t%1,%0")

;; set a value in a segment register.
(define_insn "load_seg"
 [(set (match_operand:SI 0 "general_operand" "=s")
       (match_operand:SI 1 "register_operand" ""))]
       ""
       "movl\t%1,%0")

I think I did everything needed to make it working but when I compile
gcc I get the following error:
../.././gcc/crtstuff.c:301: error: unable to generate reloads for:
(insn:HI 17 15 18 1 (set (reg:SI 0 ax [orig:62 p.25 ] [62])
       (mem/f/c/i:SI (symbol_ref:SI ("p.5512") [flags 0x2] <var_decl
0x3b01dc60 p>) [7 p+0 S4 A32])) 28 {store_seg} (nil)
   (nil))
../.././gcc/crtstuff.c:301: internal compiler error: in find_reloads,
at reload.c:3734
Please submit a full bug report,
[...]

This is the 4.1.0 version of the compiler.
If somebody can light me... Thanks.


--
Rémy Saissy            JabberID: [EMAIL PROTECTED]
                               Web:     http://remysaissy.free.fr
"L'homme qui a le plus vécu n'est pas celui qui a compté le plus d'années,
mais celui qui a le plus senti la vie."
J.-J. Rousseau, Emile.

Reply via email to