* Is there a function in cgen for parsing short integers?
@ 2008-04-18 20:42 Mehak Mahajan
2008-04-19 0:09 ` Dave Brolley
0 siblings, 1 reply; 5+ messages in thread
From: Mehak Mahajan @ 2008-04-18 20:42 UTC (permalink / raw)
To: brolley, cgen
Hi,
Thanks for your reply. :)
I am doing precisely what you have decribed.
However, I need to differentiate between -1 which is represented as a 16
bit number (0xFFFF) and -1 which is represented as a 32 bit number
(0xFFFFFFFF).
Is there a way to do that?
Cheers,
Mehak
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is there a function in cgen for parsing short integers?
2008-04-18 20:42 Is there a function in cgen for parsing short integers? Mehak Mahajan
@ 2008-04-19 0:09 ` Dave Brolley
2008-04-19 17:24 ` Dave Brolley
0 siblings, 1 reply; 5+ messages in thread
From: Dave Brolley @ 2008-04-19 0:09 UTC (permalink / raw)
To: Mehak Mahajan; +Cc: cgen
Why would you want to issue a diagnostic for -1? It's not out of range
for a 16 bit literal. I would think you would be more interested in
cases like 65536 or -65535. As for the user specifying 0xffffffff, I'm
wondering if cgen_parse_signed_integer will indicate an error since (in
C at least) that's out range of a signed 32 bit integer.
Mehak Mahajan wrote:
> Hi,
>
> Thanks for your reply. :)
> I am doing precisely what you have decribed.
> However, I need to differentiate between -1 which is represented as a
> 16 bit number (0xFFFF) and -1 which is represented as a 32 bit number
> (0xFFFFFFFF).
> Is there a way to do that?
>
> Cheers,
> Mehak
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is there a function in cgen for parsing short integers?
2008-04-19 0:09 ` Dave Brolley
@ 2008-04-19 17:24 ` Dave Brolley
0 siblings, 0 replies; 5+ messages in thread
From: Dave Brolley @ 2008-04-19 17:24 UTC (permalink / raw)
To: Mehak Mahajan; +Cc: cgen
Why would you want to issue a diagnostic for -1? It's not out of range
for a 16 bit literal. I would think you would be more interested in
cases like 65536 or -65535. As for the user specifying 0xffffffff, I'm
wondering if cgen_parse_signed_integer will indicate an error since (in
C at least) that's out range of a signed 32 bit integer.
Mehak Mahajan wrote:
> Hi,
>
> Thanks for your reply. :)
> I am doing precisely what you have decribed.
> However, I need to differentiate between -1 which is represented as a
> 16 bit number (0xFFFF) and -1 which is represented as a 32 bit number
> (0xFFFFFFFF).
> Is there a way to do that?
>
> Cheers,
> Mehak
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is there a function in cgen for parsing short integers?
2008-04-17 23:10 Mehak Mahajan
@ 2008-04-18 15:24 ` Dave Brolley
0 siblings, 0 replies; 5+ messages in thread
From: Dave Brolley @ 2008-04-18 15:24 UTC (permalink / raw)
To: Mehak Mahajan; +Cc: cgen
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Is there a function in cgen for parsing short integers?
@ 2008-04-17 23:10 Mehak Mahajan
2008-04-18 15:24 ` Dave Brolley
0 siblings, 1 reply; 5+ messages in thread
From: Mehak Mahajan @ 2008-04-17 23:10 UTC (permalink / raw)
To: cgen
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-04-19 0:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-18 20:42 Is there a function in cgen for parsing short integers? Mehak Mahajan
2008-04-19 0:09 ` Dave Brolley
2008-04-19 17:24 ` Dave Brolley
-- strict thread matches above, loose matches on Subject: below --
2008-04-17 23:10 Mehak Mahajan
2008-04-18 15:24 ` Dave Brolley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).