This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc porting - machine description for realizing multiplication with a routine call
- From: Diego Bernini <diego dot bernini at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 7 Feb 2013 19:11:07 +0100
- Subject: gcc porting - machine description for realizing multiplication with a routine call
Hi to all,
I am porting GCC to a custom architecture.
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))
Any advice?
Best,
Diego