writing md rules for fixed-point conversion

Chao-Ying Fu fu@mips.com
Sun Jan 4 05:48:00 GMT 2009


Sean D'Epagnier wrote:
>I am working toward efficient support of some of the sfixed point
> types on avr architecture.
>
> I started out by writing an assembly library to handle all of the
> conversions to and from various fixed point, integer, and floating
> point types.  In many cases the functions are only 1 or 2
> instructions, so I would like to implement them in the machine
> descriptor language so there isn't a function call needed, and the
> registers can be used more efficiently.
>
> I was able to get addition of fixed point rules working, eg:
>
> (define_insn "addqq3"
>  [(set (match_operand:QQ 0 "register_operand" "=r")
>        (plus:QQ (match_operand:QQ 1 "register_operand" "%0")
>                 (match_operand:QQ 2 "register_operand" "r")))]
>  ""
>  "add %0,%2"
>  [(set_attr "length" "1")
>   (set_attr "cc" "set_czn")])
>
> This rule works correctly and adds numbers.  The problem is I can't
> get conversions to work, and I'm wondering if something is missing in
> the compiler elsewhere.  Here is what I tried:
>
> (define_insn "fractqiqq"
>  [(set (match_operand:QQ 0 "register_operand" "=r")
>        (fract_convert:QQ (match_operand:QI 1 "register_operand"
> "0")))]
>  ""
>  "clr %0"
>  [(set_attr "length" "1")
>   (set_attr "cc" "set_czn")])
>
> However, it always generates "rcall __fractqiqq" so it isn't using my
> rule.  I also found that the fixed point conversions specified at
> "http://gcc.gnu.org/onlinedocs/gccint/Conversions.html" are not used
> by any backend currently, so I don't have any examples to work with.
>
> Has anyone used any of the following in machine description?
> fract_convert
> sat_fract
> unsigned_fract_convert
> unsigned_sat_fract
>
>
> I would like some examples.
>
> Thanks,
> Sean
>

Here is one example I made up in 2007 for MIPS backend.  The md file 
contains all possible instruction patterns that GCC may utilize.

Regards,
Chao-ying 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fake-mips-fixed.md
Type: application/octet-stream
Size: 9223 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20090104/c7bbcd90/attachment.obj>


More information about the Gcc mailing list