This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
Re: Is there a function in cgen for parsing short integers?
- From: Dave Brolley <brolley at redhat dot com>
- To: Mehak Mahajan <mehak dot mahajan at gmail dot com>
- Cc: cgen at sources dot redhat dot com
- Date: Fri, 18 Apr 2008 11:23:43 -0400
- Subject: Re: Is there a function in cgen for parsing short integers?
- References: <4807D8CD.20703@gmail.com>
You need to define your own parse handler for this operand. Take a look
at the operand 'hi16' in cgen/cpu/openrisc.cpu and its parse handler
'parse_hi16' in cgen/cpu/openrisc.opc. At the end, this particular
handler chooses to extend the sign from bit 16. You could issue your
error/warning at this point in the case of overflow.
I hope this helps,
Dave
Mehak Mahajan wrote:
Hi,
I am porting cgen to a 16 bit architecture. The immediates are 16 bits
long. I am also parsing all hex numbers as signed numbers. Hence
0xFFFF will be -1.
When I parse -1, I get 0xFFFFFFFF, since cgen_parse_signed_integer
accepts a long.
My problem is that since the max size of immediate can only be 16
bits, I want to flag an error if the user enters an immediate like
0xFFFFFFFF. However, since -1 is parsed as a long, there is no way for
me to restrict the length of the immediates to 16 bits.
Is there an equivalent function for parsing short integers as well?
Cheers,
Mehak