move patterns, emit_move_insn
Florent DEFAY
spira.inhabitant@gmail.com
Mon Mar 2 13:25:00 GMT 2009
Hi,
I am porting GCC on a new arch. I have just been trying to do the
"prologue" pattern.
I do it this way :
______________________________________________
(define_expand "prologue"
[(clobber (const_int 0))]
""
{
function_prologue();
DONE;
}
)
______________________________________________
where function_prologue is defined (and not finished) in target.c like this :
______________________________________________
function_prologue()
{
emit_move_insn (gen_rtx_REG (HImode, FRAME_POINTER_REGNUM),
gen_rtx_REG (HImode, STACK_POINTER_REGNUM));
}
_____________________________________________
And move in HImode is defined by these patterns in the md :
_____________________________________________
;; move word expand
(define_expand "movhi"
[(set (match_operand:HI 0 "nonimmediate_operand" "=r, m")
(match_operand:HI 1 "general_operand" "rmi,r")
)]
""
""
)
;; move word r -> r
(define_insn "movhi_r_r"
[(set (match_operand:HI 0 "register_operand" "=r")
(match_operand:HI 1 "register_operand" "r")
)]
""
"movew\t%1,%0"
)
;; move word i -> r
(define_insn "movhi_i_r"
[(set (match_operand:HI 0 "register_operand" "=r")
(match_operand:HI 1 "immediate_operand" "i")
)]
""
"movew\t%1,%0"
)
;; move word (r) -> r
(define_insn "movhi_m1_r"
[(set (match_operand:HI 0 "general_operand" "=r")
(mem:HI (match_operand:HI 1 "register_operand" "r"))
)]
""
"movew\t(%1),%0"
)
;; move word r -> (r)
(define_insn "movhi_r_m1"
[(set (mem:HI (match_operand:HI 0 "register_operand" "r"))
(match_operand:HI 1 "general_operand" "r")
)]
""
"movew\t%1,(%0)"
)
_______________________________________
I suppose my patterns for move are not well implemented.
When I run GCC I have this error :
[guest1]$ target-gcc e.c -S
e.c: In function ‘nothing’:
e.c:7: error: insn does not satisfy its constraints:
(insn 21 3 22 e.c:3 (set (reg/f:HI 5 r5)
(reg/f:HI 6 r6)) 7 {movhi_r_r} (nil))
e.c
__________________________
void nothing (void)
{
int i = 3;
i = 4 + 2;
}
__________________________
The error appeared since I added the "emit_move_insn" in the
function_prologue. Before that, GCC compiled e.c well.
I tried to redo patterns and especially constraints and predicates. I
did not success to avoid the error.
GCC already succeeded in compiling a register to register move with
source code like
int i = 3;
(I mean the pattern movhi_r_r has served successfully).
I would like to know if the error is due to patterns and what is the
link with emit_move_insn ?
Looking for any explaination or advice.
Thank you for your help.
Regards.
Florent
More information about the Gcc-help
mailing list