Please see my reply below. > -----Original Message----- > From: Florent DEFAY [mailto:spira.inhabitant@xxxxxxxxx] > Sent: Tuesday, March 03, 2009 3:10 PM > To: gcc-help@xxxxxxxxxxx > Subject: Re: move patterns, emit_move_insn > > Thank you for your help. > > Regarding your advice, I tried this implementation: > > ___________________________________________________ > ;; movhi > (define_expand "movhi" > [(set (match_operand:HI 0 "nonimmediate_operand" "") > (match_operand:HI 1 "general_operand" "") > )] > "" > "" > ) > > (define_insn "movhi1" > [(set (match_operand:HI 0 "register_operand" "=r,r,m,r") > (match_operand:HI 1 "general_operand" "r,m,r,i") > )] > "" > "@ > movew\t%1,%0 > movew\t%1,%0 > movew\t%1,%0 > movew\t%1,%0" > ) > ____________________________________________________ > > But I get this error then: > > e.c:7: error: unrecognizable insn: > (insn 7 6 8 3 e.c:4 (set (mem/c/i:HI (reg/f:HI 14) [0 i+0 S2 A16]) > (const_int 3 [0x3])) -1 (nil)) > > I think GCC has to put immediate into memory. The arch can't do that > directly. GCC should put the immediate in register and then register > to memory. > It succeded with old implementation (with a lot of define_insn). What > should I change in the new implementation to get it right ? In your 'define_expand' try forcing the source operand in to a register. Then try to move it to destination. Please see whether 'mips_legitimize_move' function in 'mips.c' is useful. > > Another question, I wonder how to deal with access modes ? > For example, to obtain such an ASM instruction > movew r1,8(r2) > should it come from a define_insn like movhi1 and then treated by > print_operand ? > > Thank you. > Regards. > > Florent