[M3devel] IR init_int with out of range values?
Jay K
jay.krell at cornell.edu
Wed Jun 1 13:17:43 CEST 2016
Is this reasonable?
m3-libs/m3core/src/float/IEEE-be/LongRealRep.i3
INTERFACE LongRealRep;
(* This interface describes the layout of IEEE double precision reals
on big endian machines *)
TYPE
T = RECORD
sign : BITS 1 FOR [0..1] := 0;
exponent : BITS 11 FOR [0..16_7FF] := 0;
significand0 : BITS 20 FOR [0..16_FFFFF] := 0;
significand1 : BITS 32 FOR [-16_7fffffff-1 .. 16_7fffffff] := 0;
END;
CONST
NegInf = T { sign := 1, exponent := 16_7FF };
PosInf = T { sign := 0, exponent := 16_7FF };
Nan = T { sign := 0, exponent := 16_7FF, significand0 := 1 };
END LongRealRep.
begin_init v.1
# constant NegInf
# constant PosInf
init_int 0 18442240474082181120 Int.64
# constant Nan
init_int 8 9218868437227405312 Int.64
My C backend doesn't like 18442240474082181120 Int.64, since
18442240474082181120 does not fit in a signed 64bit integer.
Should the frontend be obligated to make it Word.64?
I guess I can make it work.
jair:python jay$ cat 1.c
#include <stdio.h>
int main()
{
long long a = 18442240474082181120ll;
printf("%llu %llx %lld %llx\n", a, a, a, a);
return 0;
}
jair:python jay$ edit 1.c
jair:python jay$ cat 1.c
#include <stdio.h>
int main()
{
long long a = 18442240474082181120ll;
printf("%llu %llx %lld %llx\n", a, a, a, a);
return 0;
}
jair:python jay$ cc 1.c
1.c:5:15: warning: integer literal is too large to be represented in a signed integer type, interpreting as unsigned
[-Wimplicitly-unsigned-literal]
long long a = 18442240474082181120ll;
^
1 warning generated.
jair:python jay$ ./a.out
18442240474082181120 fff0000000000000 -4503599627370496 fff0000000000000
Thank you,
- Jay
More information about the M3devel
mailing list