mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-27 06:10:06 +08:00
Add nan, snan and inf float constants
This commit is contained in:
parent
2220467fcf
commit
8eb86ab78d
25
tccgen.c
25
tccgen.c
@ -310,6 +310,16 @@ static void vpushll(long long v)
|
|||||||
vsetc(&ctype, VT_CONST, &cval);
|
vsetc(&ctype, VT_CONST, &cval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* push arbitrary 64bit constant */
|
||||||
|
void vpush64(int ty, unsigned long long v)
|
||||||
|
{
|
||||||
|
CValue cval;
|
||||||
|
CType ctype;
|
||||||
|
ctype.t = ty;
|
||||||
|
cval.ull = v;
|
||||||
|
vsetc(&ctype, VT_CONST, &cval);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return a static symbol pointing to a section */
|
/* Return a static symbol pointing to a section */
|
||||||
ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
|
ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
|
||||||
{
|
{
|
||||||
@ -3535,6 +3545,21 @@ ST_FUNC void unary(void)
|
|||||||
vtop->sym = s;
|
vtop->sym = s;
|
||||||
next();
|
next();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// special qnan , snan and infinity values
|
||||||
|
case TOK___NAN__:
|
||||||
|
vpush64(VT_DOUBLE, 0x7ff8000000000000);
|
||||||
|
next();
|
||||||
|
break;
|
||||||
|
case TOK___SNAN__:
|
||||||
|
vpush64(VT_DOUBLE, 0x7ff0000000000001);
|
||||||
|
next();
|
||||||
|
break;
|
||||||
|
case TOK___INF__:
|
||||||
|
vpush64(VT_DOUBLE, 0x7ff0000000000000);
|
||||||
|
next();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
tok_identifier:
|
tok_identifier:
|
||||||
t = tok;
|
t = tok;
|
||||||
|
9
tcctok.h
9
tcctok.h
@ -81,10 +81,15 @@
|
|||||||
DEF(TOK___TIME__, "__TIME__")
|
DEF(TOK___TIME__, "__TIME__")
|
||||||
DEF(TOK___FUNCTION__, "__FUNCTION__")
|
DEF(TOK___FUNCTION__, "__FUNCTION__")
|
||||||
DEF(TOK___VA_ARGS__, "__VA_ARGS__")
|
DEF(TOK___VA_ARGS__, "__VA_ARGS__")
|
||||||
|
|
||||||
/* special identifiers */
|
/* special identifiers */
|
||||||
DEF(TOK___FUNC__, "__func__")
|
DEF(TOK___FUNC__, "__func__")
|
||||||
|
|
||||||
|
/* special floating point values */
|
||||||
|
DEF(TOK___NAN__, "__nan__")
|
||||||
|
DEF(TOK___SNAN__, "__snan__")
|
||||||
|
DEF(TOK___INF__, "__inf__")
|
||||||
|
|
||||||
/* attribute identifiers */
|
/* attribute identifiers */
|
||||||
/* XXX: handle all tokens generically since speed is not critical */
|
/* XXX: handle all tokens generically since speed is not critical */
|
||||||
DEF(TOK_SECTION1, "section")
|
DEF(TOK_SECTION1, "section")
|
||||||
|
Loading…
Reference in New Issue
Block a user