This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc porting - machine description for realizing multiplication with a routine call


On Thu, Feb 7, 2013 at 10:11 AM, Diego Bernini <diego.bernini@gmail.com> wrote:
>
> The custom architecture has not a "mul" instruction. Hence I am
> working to generate a proper routine call. The external routine ("
> __mulqi3") expect to have the first parameter inside the reg #0, the
> second parameter inside the reg #1 and then it puts the result inside
> the reg #0.
>
> Starting from the porting for AVR, I tried to add the following
> machine description definitions:
>
> define_expand "mulqi3"
>   [(set (match_operand:QI 0 "register_operand" "")
> (mult:QI (match_operand:QI 1 "register_operand" "")
>  (match_operand:QI 2 "register_operand" "")))]
>   ""
>   "
>       emit_insn (gen_mulqi3_call (operands[0], operands[1], operands[2]));
>       DONE;
>   ")
>
> (define_expand "mulqi3_call"
>   [(set (reg:QI 0) (match_operand:QI 1 "register_operand" ""))
>    (set (reg:QI 1) (match_operand:QI 2 "register_operand" ""))
>    (parallel [(set (reg:QI 0) (mult:QI (reg:QI 0) (reg:QI 1)))
>       (clobber (reg:QI 1))
>   ])
>    (set (match_operand:QI 0 "register_operand" "") (reg:QI 0))]
>   ""
>   "")
>
> (define_insn "*mulqi3_call"
>   [(set (reg:QI 0) (mult:QI (reg:QI 0) (reg:QI 1)))
>    (clobber (reg:QI 1))
>    ]
>   ""
>   "call __mulqi3"
> )
>
> There is something wrong with these definitions, because trying to
> compile a simple multiplication I obtain
>
> error: insn does not satisfy its constraints:
> (insn 51 25 26 (set (reg:QI 0 A0 [orig:51 a ] [51])
>         (reg:QI 2 A2)) 5 {*move_regs} (nil)
>     (nil))

You didn't show us your movqi instruction, so we don't know why that
insn doesn't satisfy its constraints.  That said, my guess is that
here:

(define_expand "mulqi3_call"
  [(set (reg:QI 0) (match_operand:QI 1 "register_operand" ""))
   (set (reg:QI 1) (match_operand:QI 2 "register_operand" ""))
   (parallel [(set (reg:QI 0) (mult:QI (reg:QI 0) (reg:QI 1)))
      (clobber (reg:QI 1))
  ])
   (set (match_operand:QI 0 "register_operand" "") (reg:QI 0))]
  ""
  "")

It looks like you want to generate something that the mulqi3_call
pattern will match, but you are not doing that.  The mulqi3_call
pattern expects a mult:QI.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]