diff options
author | Michael Forney <mforney@mforney.org> | 2019-05-29 16:37:49 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-05-29 17:04:17 -0700 |
commit | 31c2d5aa28eed34dc6949db828c1ae9a81203740 (patch) | |
tree | 07690174fe58041d9213daa330f0f02ad5a8346d | |
parent | c1d079fae39e20ea695f575a221e2251727d07aa (diff) |
Temporarily avoid %a when printing floating constants
This is C99, but is not supported by fscanf in OpenBSD, so floating
constants can't be read back in by QBE.
-rw-r--r-- | qbe.c | 5 | ||||
-rw-r--r-- | test/float-const-leading-dot.qbe | 2 | ||||
-rw-r--r-- | test/float-promote.qbe | 6 | ||||
-rw-r--r-- | test/float-to-uint64.qbe | 4 | ||||
-rw-r--r-- | test/union.qbe | 2 |
5 files changed, 10 insertions, 9 deletions
@@ -1,6 +1,7 @@ #include <assert.h> #include <ctype.h> #include <errno.h> +#include <float.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -1035,7 +1036,7 @@ emitvalue(struct value *v) switch (v->kind) { case VALCONST: if (v->repr->base == 's' || v->repr->base == 'd') - printf("%c_%a", v->repr->base, v->f); + printf("%c_%.*g", v->repr->base, DECIMAL_DIG, v->f); else printf("%" PRIu64, v->i); break; @@ -1243,7 +1244,7 @@ dataitem(struct expr *expr, uint64_t size) break; case EXPRCONST: if (expr->type->prop & PROPFLOAT) - printf("%c_%a", expr->type->size == 4 ? 's' : 'd', expr->constant.f); + printf("%c_%.*g", expr->type->size == 4 ? 's' : 'd', DECIMAL_DIG, expr->constant.f); else printf("%" PRIu64, expr->constant.i); break; diff --git a/test/float-const-leading-dot.qbe b/test/float-const-leading-dot.qbe index 12ae325..097f529 100644 --- a/test/float-const-leading-dot.qbe +++ b/test/float-const-leading-dot.qbe @@ -1 +1 @@ -export data $x = align 4 { s s_0x1p-1, } +export data $x = align 4 { s s_0.5, } diff --git a/test/float-promote.qbe b/test/float-promote.qbe index 052b1fa..5dad07c 100644 --- a/test/float-promote.qbe +++ b/test/float-promote.qbe @@ -2,10 +2,10 @@ export function $f() { @start.1 @body.2 - %.1 =d exts s_0x1p+0 + %.1 =d exts s_1 call $g1(d %.1) - %.2 =d exts s_0x1p+0 + %.2 =d exts s_1 call $g2(w 0, d %.2, ...) - call $g3(s s_0x1p+0) + call $g3(s s_1) ret } diff --git a/test/float-to-uint64.qbe b/test/float-to-uint64.qbe index 3c3aa01..b19ff32 100644 --- a/test/float-to-uint64.qbe +++ b/test/float-to-uint64.qbe @@ -3,13 +3,13 @@ function l $f() { @start.1 @body.2 %.1 =s call $g() - %.2 =w cges %.1, s_0x1p+63 + %.2 =w cges %.1, s_9223372036854775808 jnz %.2, @ftou_big.4, @ftou_small.3 @ftou_small.3 %.3 =l stosi %.1 jmp @ftou_join.5 @ftou_big.4 - %.4 =s sub %.1, s_0x1p+63 + %.4 =s sub %.1, s_9223372036854775808 %.5 =l stosi %.4 %.6 =l xor %.5, 9223372036854775808 @ftou_join.5 diff --git a/test/union.qbe b/test/union.qbe index adbda57..d0b9e23 100644 --- a/test/union.qbe +++ b/test/union.qbe @@ -1,2 +1,2 @@ export data $a = align 8 { w 5, z 4 } -export data $b = align 8 { d d_0x1.ep+2, } +export data $b = align 8 { d d_7.5, } |