mulhisi3 problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
I am trying to write back end port for our school 16bit processor (called ADOP).

I've read GCC internals and start programming. I have a few basic patterns (like movhi, movsi, addhi, addsi, call, prologue, epilogue ...) defined and if I try to compile some simple program, everything seems ok.

I'd like to add this "mulhisi3" pattern now:
(define_insn "mulhisi3"
        [(set (match_operand:SI 0 "register_operand" "=r")
	      (mult:SI (match_operand:HI 1 "register_operand" "%r")
		       (match_operand:HI 2 "register_operand"  "r")))]
        ""
        "mul\\t%0, %1, %2"
	[(set_attr "cc" "clobber")]
)

When I compile (with -O0, GCC 4.3.2), for example, this:
void foo()
{
  int a,b;    /* int size is 16bit */
  long int c; /* long int size is 32bit - bits, bytes and word are big endian */

  a = 6535;
  b = 535;
  c = a * b;
}

*.expand file in rtl dump then contains:
...
(insn 9 8 10 3 /// (set (reg:HI 25)
        (mem/c/i:HI (plus:HI (reg/f:HI 17 virtual-stack-vars)
                (const_int -8 [0xfffffff8])) [0 a+0 S2 A16])) -1 (nil))

(insn 10 9 11 3 /// (set (reg:HI 26)
        (mem/c/i:HI (plus:HI (reg/f:HI 17 virtual-stack-vars)
                (const_int -6 [0xfffffffa])) [0 b+0 S2 A16])) -1 (nil))

(insn 11 10 12 3 /// (set (reg:SI 24)
        (mult:SI (reg:HI 25)
            (reg:HI 26))) -1 (nil))

(insn 12 11 13 3 /// (set (reg:HI 21 [ D.1176 ])
        (subreg:HI (reg:SI 24) 2)) -1 (nil))

(insn 13 12 14 3 /// (set (mem/c/i:HI (plus:HI (reg/f:HI 17 virtual-stack-vars)
                (const_int -2 [0xfffffffe])) [0 c+2 S2 A16])
        (reg:HI 21 [ D.1176 ])) -1 (nil))

(insn 14 13 15 3 /// (set (reg:HI 27)
        (ashiftrt:HI (reg:HI 21 [ D.1176 ])
            (const_int 15 [0xf]))) -1 (nil))

(insn 15 14 20 3 /// (set (mem/c/i:HI (plus:HI (reg/f:HI 17 virtual-stack-vars)
                (const_int -4 [0xfffffffc])) [0 c+0 S2 A16])
        (reg:HI 27)) -1 (nil))
...

The problem is I don't know why the ashiftrt is used instead of direct storing the 32bit mult result into mem (it seems that GCC consider the mult result to be only 16bit and performs the sign extension on lower part of it).

I have no idea where should be the problem (what I've done wrong would probably be more precise expression). I appreciate any help. Thanks in advance.

Vit Zizka
v.zizka at seznam dot cz

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux