diff options
author | Bor Grošelj Simić <bor.groseljsimic@telemach.net> | 2022-01-28 02:06:18 +0100 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2022-01-28 09:24:15 +0100 |
commit | 3964574a8325ab802f98856195b8214dcce3124c (patch) | |
tree | 0ac6128a201088b186d642b990a02c6e78cf715a /test | |
parent | 74d022f975f22fda20c0d1fe09a3f6fc7680f64f (diff) | |
download | roux-3964574a8325ab802f98856195b8214dcce3124c.tar.gz |
implement float -> unsigned casts
amd64 lacks instruction for this so it has to be implemented with float -> signed casts. The approach is borrowed from llvm.
Diffstat (limited to 'test')
-rw-r--r-- | test/fpcnv.ssa | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/fpcnv.ssa b/test/fpcnv.ssa index 4dac489..3036168 100644 --- a/test/fpcnv.ssa +++ b/test/fpcnv.ssa @@ -43,7 +43,37 @@ function d $ltod(l %l) { ret %rt } +export +function w $stow(s %f) { +@start + %rt =w stoui %f + ret %rt +} +export +function w $dtow(d %f) { +@start + %rt =w dtoui %f + ret %rt +} + +export +function l $stol(s %f) { +@start + %rt =l stoui %f + ret %rt +} +export +function l $dtol(d %f) { +@start + %rt =l dtoui %f + ret %rt +} + + + # >>> driver +# #include<limits.h> +# # extern float fneg(float); # extern double ftrunc(double); # @@ -52,10 +82,19 @@ function d $ltod(l %l) { # extern float ltos(long long unsigned int); # extern double ltod(long long unsigned int); # +# extern unsigned int stow(float); +# extern unsigned int dtow(double); +# extern unsigned long long stol(float); +# extern unsigned long long dtol(double); +# # unsigned long long iin[] = { 0, 1, 16, 234987, 427386245, 0x7fff0000, # 0xffff0000, 23602938196141, 72259248152500195, 9589010795705032704ull, # 0xdcf5fbe299d0148aull, 0xffffffff00000000ull, -1 }; # +# double fin[] = { 0.17346516197824458, 442.0760005466251, 4342856.879893436, +# 98547543006.49626, 236003043787688.3, 9.499222733527032e+18, +# 1.1936266170755652e+19 }; +# # int main() { # int i; # @@ -72,6 +111,18 @@ function d $ltod(l %l) { # return 6; # if (ltod(iin[i]) != (double)iin[i]) # return 7; +# } +# for (i=0; i<sizeof(fin)/sizeof(fin[0]); i++) { +# if (stol((float)fin[i]) != (unsigned long long)(float)fin[i]) +# return 8; +# if (dtol(fin[i]) != (unsigned long long)fin[i]) +# return 9; +# if((unsigned long long)fin[i] > UINT_MAX) +# continue; +# if (stow((float)fin[i]) != (unsigned int)(float)fin[i]) +# return 10; +# if (dtow(fin[i]) != (unsigned int)fin[i]) +# return 11; # } # return 0; # } |