2009/1/9 Sean D'Epagnier <[email protected]>:
> Hi,
>
> I am currently working on adding native fixed-point support to the avr
> backend. A lot of stuff is working, but there are a few things left,
> one of them is conversions from fixed point to floating point.
>
> I have conversions between all integer and fixed point types working
> as well as SA to SF conversion.
>
> I want to convert the fixed point types smaller than SA to float by
> using define_split to convert to SA then to SF. I am first trying to
> get QQ->SF working, one of the things I tried is:
>
> (define_expand "fractqqsf2"
> [(set (match_operand:SF 0 "register_operand" "")
> (fract_convert:SF (match_operand:QQ 1 "register_operand" "")))
> (clobber (match_operand:SA 2 "register_operand" ""))]
> ""
> "")
Wrong expand.
- (clobber (match_operand:SA 2 "register_operand" ""))]
+ (clobber (match_scratch:SA 2 ""))]
>
> (define_split
> [(set (match_operand:SF 0 "register_operand" "")
> (fract_convert:SF (match_operand:QQ 1 "register_operand" "")))
> (clobber (match_operand:SA 2 "register_operand" ""))]
> ""
> [(set (match_dup 2) (fract_convert:SA (match_dup 1)))
> (set (match_dup 0) (fract_convert:SF (match_dup 2)))]
> "")
(define_split
[(set (match_operand:SF 0 "register_operand" "")
(fract_convert:SF (match_operand:QQ 1 "register_operand" "")))
(clobber (match_scratch:SA 2 "=r"))]]
"reload_completed"
[(set (match_dup 2) (fract_convert:SA (match_dup 1)))
(set (match_dup 0) (fract_convert:SF (match_dup 2)))]
"")
>
> This causes the compiler to crash with a segmentation fault. I have
> tried a bunch of other strategies, and usually the compiler complains
> about unrecognized instruction. I'm not sure what I'm doing wrong,
> but I don't have a good reference example for this. I can implement
> these routines in a library, that might end up being better in terms
> of space, but I would like to know what I am doing wrong and how to
> use define_split correctly.
May be better to define expand like this:
(define_expand "fractqqsf2"
[(set (match_dup 2) (fract_convert:SA (match_operand:QQ 1
"register_operand" "")))
(set (match_operand:SF 0 "register_operand" "") (fract_convert:SF
(match_dup 2)))]
""
"
operands[2] = gen_reg_rtx (SAmode);
")
Denis.