[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3] pkl, testsuite: add support for printing/formatting floating-
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH v3] pkl, testsuite: add support for printing/formatting floating-points |
Date: |
Tue, 10 Jan 2023 23:05:55 +0100 |
2022-01-10 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pkl-insn.def (formatf32): Add new instruction.
(formatf64): Likewise.
* libpoke/pvm.jitter (FORMATF): New macro for formatting
floating-point numbers.
(formatf32): New instruction for formatting floating-point
numbers.
(formatf64): Likewise.
* libpoke/pkl-ast.h (PKL_AST_FORMAT_ARG_FLOATING_POINT_P): New macro.
(PKL_AST_FORMAT_ARG_FLOATING_POINT_STYLE): Likewise.
(PKL_AST_FORMAT_ARG_FLOATING_POINT_PREC): Likewise.
(PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH): Likewise.
(PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_SINGLE): Likewise.
(PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_DOUBLE): Likewise.
(struct pkl_ast_format_arg): Add new fields for floating-points.
* libpoke/pkl-trans.c (pkl_trans1_ps_format): Handle new specifiers
for floating-point numbers (f, e, g).
* libpoke/pkl-gen.c (pkl_gen_pr_format): Add support for formatting
and printing floating-point numbers.
* doc/poke.texi (Printing): Add new format specifiers to the table.
* testsuite/poke.pkl/format-43.pk: New test.
* testsuite/poke.pkl/format-44.pk: Likewise.
* testsuite/poke.pkl/format-45.pk: Likewise.
* testsuite/poke.pkl/format-46.pk: Likewise.
* testsuite/poke.pkl/format-47.pk: Likewise.
* testsuite/poke.pkl/format-48.pk: Likewise.
* testsuite/poke.pkl/format-49.pk: Likewise.
* testsuite/poke.pkl/format-50.pk: Likewise.
* testsuite/poke.pkl/format-51.pk: Likewise.
* testsuite/poke.pkl/format-52.pk: Likewise.
* testsuite/poke.pkl/format-53.pk: Likewise.
* testsuite/poke.pkl/format-54.pk: Likewise.
* testsuite/poke.pkl/format-55.pk: Likewise.
* testsuite/poke.pkl/format-56.pk: Likewise.
* testsuite/poke.pkl/format-57.pk: Likewise.
* testsuite/poke.pkl/format-58.pk: Likewise.
* testsuite/poke.pkl/format-59.pk: Likewise.
* testsuite/poke.pkl/format-60.pk: Likewise.
* testsuite/poke.pkl/format-61.pk: Likewise.
* testsuite/poke.pkl/format-62.pk: Likewise.
* testsuite/poke.pkl/format-63.pk: Likewise.
* testsuite/poke.pkl/format-64.pk: Likewise.
* testsuite/poke.pkl/format-65.pk: Likewise.
* testsuite/poke.pkl/format-66.pk: Likewise.
* testsuite/poke.pkl/format-67.pk: Likewise.
* testsuite/poke.pkl/format-68.pk: Likewise.
* testsuite/poke.pkl/format-69.pk: Likewise.
* testsuite/poke.pkl/format-70.pk: Likewise.
* testsuite/poke.pkl/format-71.pk: Likewise.
* testsuite/poke.pkl/format-72.pk: Likewise.
* testsuite/poke.pkl/format-73.pk: Likewise.
* testsuite/poke.pkl/format-diag-2.pk: Likewise.
* testsuite/poke.pkl/format-diag-3.pk: Likewise.
* testsuite/poke.pkl/format-diag-4.pk: Likewise.
* testsuite/poke.pkl/format-diag-5.pk: Likewise.
* testsuite/poke.pkl/format-diag-6.pk: Likewise.
* testsuite/poke.pkl/format-diag-7.pk: Likewise.
* testsuite/poke.pkl/format-diag-8.pk: Likewise.
* testsuite/poke.pkl/format-diag-9.pk: Likewise.
* testsuite/poke.pkl/printf-41.pk: Likewise.
* testsuite/poke.pkl/printf-42.pk: Likewise.
* testsuite/poke.pkl/printf-43.pk: Likewise.
* testsuite/poke.pkl/printf-44.pk: Likewise.
* testsuite/poke.pkl/printf-45.pk: Likewise.
* testsuite/poke.pkl/printf-46.pk: Likewise.
* testsuite/poke.pkl/printf-47.pk: Likewise.
* testsuite/poke.pkl/printf-48.pk: Likewise.
* testsuite/poke.pkl/printf-49.pk: Likewise.
* testsuite/poke.pkl/printf-50.pk: Likewise.
* testsuite/poke.pkl/printf-51.pk: Likewise.
* testsuite/poke.pkl/printf-52.pk: Likewise.
* testsuite/poke.pkl/printf-53.pk: Likewise.
* testsuite/poke.pkl/printf-54.pk: Likewise.
* testsuite/poke.pkl/printf-55.pk: Likewise.
* testsuite/poke.pkl/printf-56.pk: Likewise.
* testsuite/poke.pkl/printf-57.pk: Likewise.
* testsuite/poke.pkl/printf-58.pk: Likewise.
* testsuite/poke.pkl/printf-59.pk: Likewise.
* testsuite/poke.pkl/printf-60.pk: Likewise.
* testsuite/poke.pkl/printf-61.pk: Likewise.
* testsuite/poke.pkl/printf-62.pk: Likewise.
* testsuite/poke.pkl/printf-63.pk: Likewise.
* testsuite/poke.pkl/printf-64.pk: Likewise.
* testsuite/poke.pkl/printf-65.pk: Likewise.
* testsuite/poke.pkl/printf-66.pk: Likewise.
* testsuite/poke.pkl/printf-67.pk: Likewise.
* testsuite/poke.pkl/printf-68.pk: Likewise.
* testsuite/poke.pkl/printf-69.pk: Likewise.
* testsuite/poke.pkl/printf-70.pk: Likewise.
* testsuite/poke.pkl/printf-71.pk: Likewise.
* testsuite/poke.pkl/printf-diag-19.pk: Likewise.
* testsuite/poke.pkl/printf-diag-20.pk: Likewise.
* testsuite/poke.pkl/printf-diag-21.pk: Likewise.
* testsuite/poke.pkl/printf-diag-22.pk: Likewise.
* testsuite/poke.pkl/printf-diag-23.pk: Likewise.
* testsuite/poke.pkl/printf-diag-24.pk: Likewise.
* testsuite/poke.pkl/printf-diag-25.pk: Likewise.
* testsuite/poke.pkl/printf-diag-26.pk: Likewise.
* testsuite/Makefile.am (EXTRA_DIST): Update.
---
Hello Jose.
I fixed the problems you've mentioned, please review this version :)
For this patch, I changed the diff algorithm to patience to create
more human-readable diffs for the codegen. The problem in format codegen
was that I've used `if (!...) goto ...` pattern instead of
`if () {} else {}` to keep the indentation at a tolerable level for myself.
But with floating-point, I changed the format codegen to be like the printf
one hence a lot of noise in the patch.
Regards,
Mohammad-Reza
ChangeLog | 101 +++++++++++++++++++
doc/poke.texi | 35 +++++++
libpoke/pkl-ast.h | 39 +++++++
libpoke/pkl-gen.c | 145 ++++++++++++++++++++-------
libpoke/pkl-insn.def | 2 +
libpoke/pkl-trans.c | 107 +++++++++++++++++++-
libpoke/pvm.jitter | 90 +++++++++++++++++
testsuite/Makefile.am | 78 ++++++++++++++
testsuite/poke.pkl/format-43.pk | 4 +
testsuite/poke.pkl/format-44.pk | 4 +
testsuite/poke.pkl/format-45.pk | 4 +
testsuite/poke.pkl/format-46.pk | 4 +
testsuite/poke.pkl/format-47.pk | 4 +
testsuite/poke.pkl/format-48.pk | 4 +
testsuite/poke.pkl/format-49.pk | 4 +
testsuite/poke.pkl/format-50.pk | 4 +
testsuite/poke.pkl/format-51.pk | 4 +
testsuite/poke.pkl/format-52.pk | 4 +
testsuite/poke.pkl/format-53.pk | 4 +
testsuite/poke.pkl/format-54.pk | 4 +
testsuite/poke.pkl/format-55.pk | 4 +
testsuite/poke.pkl/format-56.pk | 4 +
testsuite/poke.pkl/format-57.pk | 4 +
testsuite/poke.pkl/format-58.pk | 4 +
testsuite/poke.pkl/format-59.pk | 4 +
testsuite/poke.pkl/format-60.pk | 4 +
testsuite/poke.pkl/format-61.pk | 4 +
testsuite/poke.pkl/format-62.pk | 4 +
testsuite/poke.pkl/format-63.pk | 4 +
testsuite/poke.pkl/format-64.pk | 4 +
testsuite/poke.pkl/format-65.pk | 4 +
testsuite/poke.pkl/format-66.pk | 4 +
testsuite/poke.pkl/format-67.pk | 4 +
testsuite/poke.pkl/format-68.pk | 4 +
testsuite/poke.pkl/format-69.pk | 4 +
testsuite/poke.pkl/format-70.pk | 4 +
testsuite/poke.pkl/format-71.pk | 4 +
testsuite/poke.pkl/format-72.pk | 4 +
testsuite/poke.pkl/format-73.pk | 4 +
testsuite/poke.pkl/format-diag-2.pk | 3 +
testsuite/poke.pkl/format-diag-3.pk | 3 +
testsuite/poke.pkl/format-diag-4.pk | 3 +
testsuite/poke.pkl/format-diag-5.pk | 3 +
testsuite/poke.pkl/format-diag-6.pk | 3 +
testsuite/poke.pkl/format-diag-7.pk | 3 +
testsuite/poke.pkl/format-diag-8.pk | 3 +
testsuite/poke.pkl/format-diag-9.pk | 3 +
testsuite/poke.pkl/printf-41.pk | 3 +
testsuite/poke.pkl/printf-42.pk | 3 +
testsuite/poke.pkl/printf-43.pk | 3 +
testsuite/poke.pkl/printf-44.pk | 3 +
testsuite/poke.pkl/printf-45.pk | 3 +
testsuite/poke.pkl/printf-46.pk | 3 +
testsuite/poke.pkl/printf-47.pk | 3 +
testsuite/poke.pkl/printf-48.pk | 3 +
testsuite/poke.pkl/printf-49.pk | 3 +
testsuite/poke.pkl/printf-50.pk | 3 +
testsuite/poke.pkl/printf-51.pk | 3 +
testsuite/poke.pkl/printf-52.pk | 3 +
testsuite/poke.pkl/printf-53.pk | 3 +
testsuite/poke.pkl/printf-54.pk | 3 +
testsuite/poke.pkl/printf-55.pk | 3 +
testsuite/poke.pkl/printf-56.pk | 3 +
testsuite/poke.pkl/printf-57.pk | 3 +
testsuite/poke.pkl/printf-58.pk | 3 +
testsuite/poke.pkl/printf-59.pk | 3 +
testsuite/poke.pkl/printf-60.pk | 3 +
testsuite/poke.pkl/printf-61.pk | 3 +
testsuite/poke.pkl/printf-62.pk | 3 +
testsuite/poke.pkl/printf-63.pk | 3 +
testsuite/poke.pkl/printf-64.pk | 3 +
testsuite/poke.pkl/printf-65.pk | 3 +
testsuite/poke.pkl/printf-66.pk | 3 +
testsuite/poke.pkl/printf-67.pk | 3 +
testsuite/poke.pkl/printf-68.pk | 3 +
testsuite/poke.pkl/printf-69.pk | 3 +
testsuite/poke.pkl/printf-70.pk | 3 +
testsuite/poke.pkl/printf-71.pk | 3 +
testsuite/poke.pkl/printf-diag-19.pk | 3 +
testsuite/poke.pkl/printf-diag-20.pk | 3 +
testsuite/poke.pkl/printf-diag-21.pk | 3 +
testsuite/poke.pkl/printf-diag-22.pk | 3 +
testsuite/poke.pkl/printf-diag-23.pk | 3 +
testsuite/poke.pkl/printf-diag-24.pk | 3 +
testsuite/poke.pkl/printf-diag-25.pk | 3 +
testsuite/poke.pkl/printf-diag-26.pk | 3 +
86 files changed, 823 insertions(+), 39 deletions(-)
create mode 100644 testsuite/poke.pkl/format-43.pk
create mode 100644 testsuite/poke.pkl/format-44.pk
create mode 100644 testsuite/poke.pkl/format-45.pk
create mode 100644 testsuite/poke.pkl/format-46.pk
create mode 100644 testsuite/poke.pkl/format-47.pk
create mode 100644 testsuite/poke.pkl/format-48.pk
create mode 100644 testsuite/poke.pkl/format-49.pk
create mode 100644 testsuite/poke.pkl/format-50.pk
create mode 100644 testsuite/poke.pkl/format-51.pk
create mode 100644 testsuite/poke.pkl/format-52.pk
create mode 100644 testsuite/poke.pkl/format-53.pk
create mode 100644 testsuite/poke.pkl/format-54.pk
create mode 100644 testsuite/poke.pkl/format-55.pk
create mode 100644 testsuite/poke.pkl/format-56.pk
create mode 100644 testsuite/poke.pkl/format-57.pk
create mode 100644 testsuite/poke.pkl/format-58.pk
create mode 100644 testsuite/poke.pkl/format-59.pk
create mode 100644 testsuite/poke.pkl/format-60.pk
create mode 100644 testsuite/poke.pkl/format-61.pk
create mode 100644 testsuite/poke.pkl/format-62.pk
create mode 100644 testsuite/poke.pkl/format-63.pk
create mode 100644 testsuite/poke.pkl/format-64.pk
create mode 100644 testsuite/poke.pkl/format-65.pk
create mode 100644 testsuite/poke.pkl/format-66.pk
create mode 100644 testsuite/poke.pkl/format-67.pk
create mode 100644 testsuite/poke.pkl/format-68.pk
create mode 100644 testsuite/poke.pkl/format-69.pk
create mode 100644 testsuite/poke.pkl/format-70.pk
create mode 100644 testsuite/poke.pkl/format-71.pk
create mode 100644 testsuite/poke.pkl/format-72.pk
create mode 100644 testsuite/poke.pkl/format-73.pk
create mode 100644 testsuite/poke.pkl/format-diag-2.pk
create mode 100644 testsuite/poke.pkl/format-diag-3.pk
create mode 100644 testsuite/poke.pkl/format-diag-4.pk
create mode 100644 testsuite/poke.pkl/format-diag-5.pk
create mode 100644 testsuite/poke.pkl/format-diag-6.pk
create mode 100644 testsuite/poke.pkl/format-diag-7.pk
create mode 100644 testsuite/poke.pkl/format-diag-8.pk
create mode 100644 testsuite/poke.pkl/format-diag-9.pk
create mode 100644 testsuite/poke.pkl/printf-41.pk
create mode 100644 testsuite/poke.pkl/printf-42.pk
create mode 100644 testsuite/poke.pkl/printf-43.pk
create mode 100644 testsuite/poke.pkl/printf-44.pk
create mode 100644 testsuite/poke.pkl/printf-45.pk
create mode 100644 testsuite/poke.pkl/printf-46.pk
create mode 100644 testsuite/poke.pkl/printf-47.pk
create mode 100644 testsuite/poke.pkl/printf-48.pk
create mode 100644 testsuite/poke.pkl/printf-49.pk
create mode 100644 testsuite/poke.pkl/printf-50.pk
create mode 100644 testsuite/poke.pkl/printf-51.pk
create mode 100644 testsuite/poke.pkl/printf-52.pk
create mode 100644 testsuite/poke.pkl/printf-53.pk
create mode 100644 testsuite/poke.pkl/printf-54.pk
create mode 100644 testsuite/poke.pkl/printf-55.pk
create mode 100644 testsuite/poke.pkl/printf-56.pk
create mode 100644 testsuite/poke.pkl/printf-57.pk
create mode 100644 testsuite/poke.pkl/printf-58.pk
create mode 100644 testsuite/poke.pkl/printf-59.pk
create mode 100644 testsuite/poke.pkl/printf-60.pk
create mode 100644 testsuite/poke.pkl/printf-61.pk
create mode 100644 testsuite/poke.pkl/printf-62.pk
create mode 100644 testsuite/poke.pkl/printf-63.pk
create mode 100644 testsuite/poke.pkl/printf-64.pk
create mode 100644 testsuite/poke.pkl/printf-65.pk
create mode 100644 testsuite/poke.pkl/printf-66.pk
create mode 100644 testsuite/poke.pkl/printf-67.pk
create mode 100644 testsuite/poke.pkl/printf-68.pk
create mode 100644 testsuite/poke.pkl/printf-69.pk
create mode 100644 testsuite/poke.pkl/printf-70.pk
create mode 100644 testsuite/poke.pkl/printf-71.pk
create mode 100644 testsuite/poke.pkl/printf-diag-19.pk
create mode 100644 testsuite/poke.pkl/printf-diag-20.pk
create mode 100644 testsuite/poke.pkl/printf-diag-21.pk
create mode 100644 testsuite/poke.pkl/printf-diag-22.pk
create mode 100644 testsuite/poke.pkl/printf-diag-23.pk
create mode 100644 testsuite/poke.pkl/printf-diag-24.pk
create mode 100644 testsuite/poke.pkl/printf-diag-25.pk
create mode 100644 testsuite/poke.pkl/printf-diag-26.pk
diff --git a/ChangeLog b/ChangeLog
index a4add249..3dcf2939 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,104 @@
+2022-01-10 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * libpoke/pkl-insn.def (formatf32): Add new instruction.
+ (formatf64): Likewise.
+ * libpoke/pvm.jitter (FORMATF): New macro for formatting
+ floating-point numbers.
+ (formatf32): New instruction for formatting floating-point
+ numbers.
+ (formatf64): Likewise.
+ * libpoke/pkl-ast.h (PKL_AST_FORMAT_ARG_FLOATING_POINT_P): New macro.
+ (PKL_AST_FORMAT_ARG_FLOATING_POINT_STYLE): Likewise.
+ (PKL_AST_FORMAT_ARG_FLOATING_POINT_PREC): Likewise.
+ (PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH): Likewise.
+ (PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_SINGLE): Likewise.
+ (PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_DOUBLE): Likewise.
+ (struct pkl_ast_format_arg): Add new fields for floating-points.
+ * libpoke/pkl-trans.c (pkl_trans1_ps_format): Handle new specifiers
+ for floating-point numbers (f, e, g).
+ * libpoke/pkl-gen.c (pkl_gen_pr_format): Add support for formatting
+ and printing floating-point numbers.
+ * doc/poke.texi (Printing): Add new format specifiers to the table.
+ * testsuite/poke.pkl/format-43.pk: New test.
+ * testsuite/poke.pkl/format-44.pk: Likewise.
+ * testsuite/poke.pkl/format-45.pk: Likewise.
+ * testsuite/poke.pkl/format-46.pk: Likewise.
+ * testsuite/poke.pkl/format-47.pk: Likewise.
+ * testsuite/poke.pkl/format-48.pk: Likewise.
+ * testsuite/poke.pkl/format-49.pk: Likewise.
+ * testsuite/poke.pkl/format-50.pk: Likewise.
+ * testsuite/poke.pkl/format-51.pk: Likewise.
+ * testsuite/poke.pkl/format-52.pk: Likewise.
+ * testsuite/poke.pkl/format-53.pk: Likewise.
+ * testsuite/poke.pkl/format-54.pk: Likewise.
+ * testsuite/poke.pkl/format-55.pk: Likewise.
+ * testsuite/poke.pkl/format-56.pk: Likewise.
+ * testsuite/poke.pkl/format-57.pk: Likewise.
+ * testsuite/poke.pkl/format-58.pk: Likewise.
+ * testsuite/poke.pkl/format-59.pk: Likewise.
+ * testsuite/poke.pkl/format-60.pk: Likewise.
+ * testsuite/poke.pkl/format-61.pk: Likewise.
+ * testsuite/poke.pkl/format-62.pk: Likewise.
+ * testsuite/poke.pkl/format-63.pk: Likewise.
+ * testsuite/poke.pkl/format-64.pk: Likewise.
+ * testsuite/poke.pkl/format-65.pk: Likewise.
+ * testsuite/poke.pkl/format-66.pk: Likewise.
+ * testsuite/poke.pkl/format-67.pk: Likewise.
+ * testsuite/poke.pkl/format-68.pk: Likewise.
+ * testsuite/poke.pkl/format-69.pk: Likewise.
+ * testsuite/poke.pkl/format-70.pk: Likewise.
+ * testsuite/poke.pkl/format-71.pk: Likewise.
+ * testsuite/poke.pkl/format-72.pk: Likewise.
+ * testsuite/poke.pkl/format-73.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-2.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-3.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-4.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-5.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-6.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-7.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-8.pk: Likewise.
+ * testsuite/poke.pkl/format-diag-9.pk: Likewise.
+ * testsuite/poke.pkl/printf-41.pk: Likewise.
+ * testsuite/poke.pkl/printf-42.pk: Likewise.
+ * testsuite/poke.pkl/printf-43.pk: Likewise.
+ * testsuite/poke.pkl/printf-44.pk: Likewise.
+ * testsuite/poke.pkl/printf-45.pk: Likewise.
+ * testsuite/poke.pkl/printf-46.pk: Likewise.
+ * testsuite/poke.pkl/printf-47.pk: Likewise.
+ * testsuite/poke.pkl/printf-48.pk: Likewise.
+ * testsuite/poke.pkl/printf-49.pk: Likewise.
+ * testsuite/poke.pkl/printf-50.pk: Likewise.
+ * testsuite/poke.pkl/printf-51.pk: Likewise.
+ * testsuite/poke.pkl/printf-52.pk: Likewise.
+ * testsuite/poke.pkl/printf-53.pk: Likewise.
+ * testsuite/poke.pkl/printf-54.pk: Likewise.
+ * testsuite/poke.pkl/printf-55.pk: Likewise.
+ * testsuite/poke.pkl/printf-56.pk: Likewise.
+ * testsuite/poke.pkl/printf-57.pk: Likewise.
+ * testsuite/poke.pkl/printf-58.pk: Likewise.
+ * testsuite/poke.pkl/printf-59.pk: Likewise.
+ * testsuite/poke.pkl/printf-60.pk: Likewise.
+ * testsuite/poke.pkl/printf-61.pk: Likewise.
+ * testsuite/poke.pkl/printf-62.pk: Likewise.
+ * testsuite/poke.pkl/printf-63.pk: Likewise.
+ * testsuite/poke.pkl/printf-64.pk: Likewise.
+ * testsuite/poke.pkl/printf-65.pk: Likewise.
+ * testsuite/poke.pkl/printf-66.pk: Likewise.
+ * testsuite/poke.pkl/printf-67.pk: Likewise.
+ * testsuite/poke.pkl/printf-68.pk: Likewise.
+ * testsuite/poke.pkl/printf-69.pk: Likewise.
+ * testsuite/poke.pkl/printf-70.pk: Likewise.
+ * testsuite/poke.pkl/printf-71.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-19.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-20.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-21.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-22.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-23.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-24.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-25.pk: Likewise.
+ * testsuite/poke.pkl/printf-diag-26.pk: Likewise.
+ * testsuite/Makefile.am (EXTRA_DIST): Update.
+
2023-01-08 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-rt.pk (getenv): Avoid calling the `gettenv'
diff --git a/doc/poke.texi b/doc/poke.texi
index ab0ba0c7..9ca92915 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -14485,6 +14485,41 @@ integers.
Same as @code{%i}, but for unsigned integers.
@item %c
A shorter way to write @code{%u8c}.
+@item %f@var{bits}[.@var{precision}]d
+@itemx %e@var{bits}[.@var{precision}]d
+@itemx %g@var{bits}[.@var{precision}]d
+These tags accept integral values, that are cast to an integral value
+of width @var{bits} and then interpreted as an IEEE 754 floating-point
+number. Currently, valid values for @var{bits} are 32 and 64.
+
+When using @code{%f} tag, the number will be printed in decimal
+notation in the style @code{[-]ddd.ddd}, where the number of digits
+after the decimal-point character is equal to the @var{precision}
+specification. The default @var{precision} for @code{%f32} tag
+is 7 and for @code{%f64} is 15.
+
+The @code{%e} tag will print the number in the style
+@code{[-]d.ddde+-dd} where there is one digit (which is non-zero
+if the floating-point number is non-zero) before the decimal-point
+character and the number of digits after it is equal the
+@var{precision}. The exponent always contains at least two digits;
+if the value is zero, the exponent is 00.
+
+And @code{%g} tag will print the number in style @code{%f} or
+@code{%e}. The @var{precision} specifies the number of the
+significant digits. Style @code{%e} is used if the exponent from its
+conversion is less than -4 or greater than or equal to the
+@var{precision}. Trailing zeros are removed from the fractional
+part of the result; a decimal point appears only if it is followed
+by at least one digit.
+
+@example
+(poke) printf ("%f64d\n", 0x40091eb851eb851fUL);
+3.140000000000000
+(poke) printf ("pi:%e32d\n", 0x4048f5c3U)
+pi:3.1400001e+00
+@end example
+
@item %v
Print the value printed representation of the argument, which can be
of any type including complex types like arrays and structs. This is
diff --git a/libpoke/pkl-ast.h b/libpoke/pkl-ast.h
index 3b56175d..1f27e738 100644
--- a/libpoke/pkl-ast.h
+++ b/libpoke/pkl-ast.h
@@ -1416,6 +1416,30 @@ pkl_ast_node pkl_ast_make_format (pkl_ast ast,
pkl_ast_node fmt,
VALUE_P indicates whether the argument shall be printed as a PVM
value or not (whether this argument corresponds to a %v or not).
+ FLOATING_POINT_P indicates whether the argument shall be interpreted
+ as a floating-point number. The argument should be an integral
+ value. The argument will be casted to UINT<32> for 32-bit
+ floating-point numbers and will be casted to UINT<64> for 64-bit
+ floating-point numbers.
+
+ FLOATING_POINT_STYLE specify the floating-point style; the valid
+ values are 'f', 'e' and 'g' ASCII characters. 'f' corresponds to
+ %f-tag which print the number in the style [-]ddd.ddd where
+ the number of digits after the decimal-point character is equal to
+ the precision. 'e' corresponds to %e-tag which print the number in
+ the style [-]d.ddde+-dd (so called scientific notation). And finally
+ 'g' which corresponds to %g-tag will choose either %f or %e based on
+ length of the representation.
+
+ FLOATING_POINT_PREC specify the precision in string representation
+ of the floating-point number. For %f- and %g-tags it specify the
+ number of digits after the decimal-point character, and for %g-tag
+ it specify the number of significant digits.
+
+ FLOATING_POINT_WIDTH specify the width of the floating-point number
+ which can be one the PKL_AST_FLOATING_POINT_WIDTH_* constants defined
+ below.
+
FORMAT_MODE and FORMAT_DEPTH specify how the argument shall be
printed if VALUE_P is true. FORMAT_MODE can be one of the
PKL_AST_FORMAT_MODE_* constants defined below, while FORMAT_DEPTH can
@@ -1427,12 +1451,23 @@ pkl_ast_node pkl_ast_make_format (pkl_ast ast,
pkl_ast_node fmt,
#define PKL_AST_FORMAT_ARG_BEGIN_SC(AST) ((AST)->format_arg.begin_sc)
#define PKL_AST_FORMAT_ARG_END_SC(AST) ((AST)->format_arg.end_sc)
#define PKL_AST_FORMAT_ARG_VALUE_P(AST) ((AST)->format_arg.value_p)
+#define PKL_AST_FORMAT_ARG_FLOATING_POINT_P(AST) \
+ ((AST)->format_arg.floating_point_p)
+#define PKL_AST_FORMAT_ARG_FLOATING_POINT_STYLE(AST) \
+ ((AST)->format_arg.floating_point_style)
+#define PKL_AST_FORMAT_ARG_FLOATING_POINT_PREC(AST) \
+ ((AST)->format_arg.floating_point_prec)
+#define PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH(AST) \
+ ((AST)->format_arg.floating_point_width)
#define PKL_AST_FORMAT_ARG_FORMAT_MODE(AST) ((AST)->format_arg.format_mode)
#define PKL_AST_FORMAT_ARG_FORMAT_DEPTH(AST) ((AST)->format_arg.format_depth)
#define PKL_AST_FORMAT_MODE_FLAT 0
#define PKL_AST_FORMAT_MODE_TREE 1
+#define PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_SINGLE 0
+#define PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_DOUBLE 1
+
struct pkl_ast_format_arg
{
struct pkl_ast_common common;
@@ -1441,6 +1476,10 @@ struct pkl_ast_format_arg
char *end_sc;
int base;
int value_p;
+ int floating_point_p;
+ int floating_point_style;
+ unsigned floating_point_prec;
+ int floating_point_width;
int format_mode;
int format_depth;
char *suffix;
diff --git a/libpoke/pkl-gen.c b/libpoke/pkl-gen.c
index 94b33dd7..5b1e1775 100644
--- a/libpoke/pkl-gen.c
+++ b/libpoke/pkl-gen.c
@@ -1462,49 +1462,83 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_format)
/* Generate code to put the value on the stack. */
PKL_PASS_SUBPASS (exp);
- /* Everything except %v. */
- if (!PKL_AST_FORMAT_ARG_VALUE_P (arg))
+ if (PKL_AST_FORMAT_ARG_VALUE_P (arg))
+ {
+ /* Generate code to format the literal value (%v). */
+ exp_type = PKL_AST_TYPE (exp);
+ arg_omode = PKL_AST_FORMAT_ARG_FORMAT_MODE (arg);
+ arg_odepth = PKL_AST_FORMAT_ARG_FORMAT_DEPTH (arg);
+
+ /* Set the argument's own omode and odepth, saving
+ the VM's own. */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHOM); /* OMODE */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
+ pvm_make_int (arg_omode, 32)); /* OMODE NOMODE */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOM); /* OMODE */
+
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHOD); /* OMODE ODEPTH */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
+ pvm_make_int (arg_odepth, 32)); /* OMODE ODEPTH
NODEPTH */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOD); /* OMODE ODEPTH */
+
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_ROT); /* OMODE ODEPTH EXP */
+
+ /* Format the value. */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
+ pvm_make_int (0, 32)); /* OMODE ODEPTH EXP DEPTH */
+ PKL_GEN_PUSH_SET_CONTEXT (PKL_GEN_CTX_IN_FORMATER);
+ PKL_PASS_SUBPASS (exp_type); /* OMODE ODEPTH STR */
+ PKL_GEN_POP_CONTEXT;
+
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NROT); /* STR OMODE ODEPTH */
+
+ /* Restore the current omode and odepth in the VM. */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOD); /* ARR STR OMODE */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOM); /* ARR STR */
+ }
+ else if (PKL_AST_FORMAT_ARG_FLOATING_POINT_P (arg))
+ {
+ enum pkl_asm_insn insn;
+ pvm_val prec
+ = pvm_make_uint (PKL_AST_FORMAT_ARG_FLOATING_POINT_PREC (arg),
+ 32);
+
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, prec); /* ARR EXP PREC */
+
+ switch (PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH (arg))
+ {
+ case PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_SINGLE:
+ insn = PKL_INSN_FORMATF32;
+ break;
+ case PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_DOUBLE:
+ insn = PKL_INSN_FORMATF64;
+ break;
+ default:
+ assert (0 && "unreachable reached");
+ }
+ switch (PKL_AST_FORMAT_ARG_FLOATING_POINT_STYLE (arg))
+ {
+ case 'f':
+ pkl_asm_insn (PKL_GEN_ASM, insn, 0); /* ARR STR */
+ break;
+ case 'e':
+ pkl_asm_insn (PKL_GEN_ASM, insn, 1); /* ARR STR */
+ break;
+ case 'g':
+ pkl_asm_insn (PKL_GEN_ASM, insn, 2); /* ARR STR */
+ break;
+ default:
+ assert (0 && "unreachable reached");
+ }
+ }
+ else
{
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
base ? pvm_make_int (base, 32) : PVM_NULL);
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_FORMAT, PKL_AST_TYPE (exp));
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, pvm_make_ulong (nstr++,
64));
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_SWAP);
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_AINS);
- goto fmt_suffix;
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_FORMAT,
+ PKL_AST_TYPE (exp)); /* ARR STR */
}
- /* Generate code to format the literal value (%v). */
- exp_type = PKL_AST_TYPE (exp);
- arg_omode = PKL_AST_FORMAT_ARG_FORMAT_MODE (arg);
- arg_odepth = PKL_AST_FORMAT_ARG_FORMAT_DEPTH (arg);
-
- /* Set the argument's own omode and odepth, saving
- the VM's own. */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHOM); /* OMODE */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
- pvm_make_int (arg_omode, 32)); /* OMODE NOMODE */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOM); /* OMODE */
-
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHOD); /* OMODE ODEPTH */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
- pvm_make_int (arg_odepth, 32)); /* OMODE ODEPTH NODEPTH */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOD); /* OMODE ODEPTH */
-
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_ROT); /* OMODE ODEPTH EXP */
-
- /* Format the value. */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
- pvm_make_int (0, 32)); /* OMODE ODEPTH EXP DEPTH */
- PKL_GEN_PUSH_SET_CONTEXT (PKL_GEN_CTX_IN_FORMATER);
- PKL_PASS_SUBPASS (exp_type); /* OMODE ODEPTH STR */
- PKL_GEN_POP_CONTEXT;
-
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NROT); /* STR OMODE ODEPTH */
-
- /* Restore the current omode and odepth in the VM. */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOD); /* ARR STR OMODE */
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOM); /* ARR STR */
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
pvm_make_ulong (nstr++, 64)); /* ARR STR IDX */
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_SWAP); /* ARR IDX STR */
@@ -1642,6 +1676,41 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_print_stmt)
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOD); /* OMODE */
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPOM); /* _ */
}
+ else if (PKL_AST_FORMAT_ARG_FLOATING_POINT_P (arg))
+ {
+ enum pkl_asm_insn insn;
+ pvm_val prec = pvm_make_uint (
+ PKL_AST_FORMAT_ARG_FLOATING_POINT_PREC (arg), 32);
+
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, prec); /* EXP PREC
*/
+
+ switch (PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH (arg))
+ {
+ case PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_SINGLE:
+ insn = PKL_INSN_FORMATF32;
+ break;
+ case PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_DOUBLE:
+ insn = PKL_INSN_FORMATF64;
+ break;
+ default:
+ assert (0 && "unreachable reached");
+ }
+ switch (PKL_AST_FORMAT_ARG_FLOATING_POINT_STYLE (arg))
+ {
+ case 'f':
+ pkl_asm_insn (PKL_GEN_ASM, insn, 0); /* STR */
+ break;
+ case 'e':
+ pkl_asm_insn (PKL_GEN_ASM, insn, 1); /* STR */
+ break;
+ case 'g':
+ pkl_asm_insn (PKL_GEN_ASM, insn, 2); /* STR */
+ break;
+ default:
+ assert (0 && "unreachable reached");
+ }
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PRINTS);
+ }
else
{
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
diff --git a/libpoke/pkl-insn.def b/libpoke/pkl-insn.def
index cb4d1973..bd764348 100644
--- a/libpoke/pkl-insn.def
+++ b/libpoke/pkl-insn.def
@@ -252,6 +252,8 @@ PKL_DEF_INSN(PKL_INSN_FORMATI,"n","formati")
PKL_DEF_INSN(PKL_INSN_FORMATIU,"n","formatiu")
PKL_DEF_INSN(PKL_INSN_FORMATL,"n","formatl")
PKL_DEF_INSN(PKL_INSN_FORMATLU,"n","formatlu")
+PKL_DEF_INSN(PKL_INSN_FORMATF32,"n","formatf32")
+PKL_DEF_INSN(PKL_INSN_FORMATF64,"n","formatf64")
/* Offset instructions. */
diff --git a/libpoke/pkl-trans.c b/libpoke/pkl-trans.c
index 355c0d49..09711b20 100644
--- a/libpoke/pkl-trans.c
+++ b/libpoke/pkl-trans.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <xalloc.h>
#include <stdlib.h>
+#include <errno.h>
#include "pk-utils.h"
@@ -684,7 +685,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_format)
pkl_ast_node format_fmt = PKL_AST_FORMAT_FMT (format);
char *fmt, *p;
pkl_ast_node t, arg;
- int ntag, nargs = 0;
+ int ntag, nargs = PKL_AST_FORMAT_NARGS (format);
pkl_ast_node types = NULL, prev_arg = NULL;
const char *msg = NULL;
/* XXX this hard limit should go away. */
@@ -878,6 +879,110 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_format)
ntag++;
break;
}
+ case 'f':
+ case 'e':
+ case 'g':
+ {
+ unsigned int bits;
+
+ PKL_AST_FORMAT_ARG_FLOATING_POINT_P (arg) = 1;
+ PKL_AST_FORMAT_ARG_FLOATING_POINT_STYLE (arg) = p[1];
+
+ if (p[2] >= '0' && p[2] <= '9')
+ {
+ int next_idx;
+
+ if (p[3] >= '0' && p[3] <= '9')
+ {
+ bits = (p[2] - '0') * 10 + (p[3] - '0');
+ next_idx = 4;
+ }
+ else
+ {
+ bits = p[2] - '0';
+ next_idx = 3;
+ }
+
+ if (bits == 0 || !(/*bits == 16 ||*/ bits == 32 || bits == 64))
+ {
+ msg = _("invalid bit-width for a floating-point number");
+ goto invalid_tag;
+ }
+ PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH (arg)
+ = bits == 32
+ ? PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_SINGLE
+ : PKL_AST_FORMAT_ARG_FLOATING_POINT_WIDTH_DOUBLE;
+
+ if (p[next_idx] == '.')
+ {
+ int prec_begin_idx;
+ char tmp;
+ long prec;
+
+ prec_begin_idx = ++next_idx;
+ while (p[next_idx] >= '0' && p[next_idx] <= '9')
+ ++next_idx;
+ if (next_idx == prec_begin_idx)
+ {
+ msg = _("expected a precision number after dot");
+ goto invalid_tag;
+ }
+ tmp = p[next_idx];
+ p[next_idx] = '\0';
+ errno = 0;
+ prec = strtol (&p[prec_begin_idx], NULL, 10);
+ if (errno != 0)
+ {
+ msg = _("invalid precision");
+ goto invalid_tag;
+ }
+ PKL_AST_FORMAT_ARG_FLOATING_POINT_PREC (arg)
+ = (unsigned)prec;
+ p[next_idx] = tmp;
+ }
+ else
+ {
+ PKL_AST_FORMAT_ARG_FLOATING_POINT_PREC (arg)
+ = bits == 32 ? 7 : 15;
+ }
+
+ switch (p[next_idx])
+ {
+ case 'b': PKL_AST_FORMAT_ARG_BASE (arg) = 2; break;
+ case 'o': PKL_AST_FORMAT_ARG_BASE (arg) = 8; break;
+ case 'd': PKL_AST_FORMAT_ARG_BASE (arg) = 10; break;
+ case 'x': PKL_AST_FORMAT_ARG_BASE (arg) = 16; break;
+ default:
+ msg = _("invalid base");
+ goto invalid_tag;
+ }
+
+ if (PKL_AST_FORMAT_ARG_BASE (arg) != 10)
+ {
+ msg = _("only base 10 is supported for floating-point
numbers");
+ goto invalid_tag;
+ }
+
+ atype = pkl_ast_make_integral_type (PKL_PASS_AST,
+ bits, /*signed_p*/ 0);
+ types = pkl_ast_chainon (types, atype);
+
+ p += ++next_idx;
+ }
+ else
+ {
+ if (p[1] == 'f')
+ msg = _("expected decimal digit after %f");
+ else if (p[1] == 'e')
+ msg = _("expected decimal digit after %e");
+ else
+ msg = _("expected decimal digit after %g");
+
+ goto invalid_tag;
+ }
+ ntag++;
+ break;
+ }
case '<':
/* Fallthrough. */
case '>':
diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
index 35be8504..e52f653c 100644
--- a/libpoke/pvm.jitter
+++ b/libpoke/pvm.jitter
@@ -875,6 +875,27 @@ late-header-c
JITTER_PUSH_STACK (pvm_make_string ((OUT))); \
} while (0)
+#define FORMATF(RESULT,NUM,PREC,STYLE,TYPEF) \
+ do \
+ { \
+ static const char STYLES[] = { 'f', 'e', 'g' }; \
+ TYPEF x; \
+ int n; \
+ char fmt[16]; \
+ \
+ PVM_ASSERT (sizeof (x) == sizeof (NUM)); \
+ PVM_ASSERT ((STYLE) < 3); \
+ \
+ memcpy (&x, &(NUM), sizeof (NUM)); \
+ n = snprintf (fmt, sizeof (fmt), "%%.%u%c", (unsigned)(PREC), \
+ STYLES[(STYLE) % 3]); \
+ if (n == -1) \
+ PVM_RAISE_DFL (PVM_E_CONV); \
+ n = asprintf (&(RESULT), fmt, x); \
+ if (n == -1) \
+ PVM_RAISE_DFL (PVM_E_CONV); \
+ } \
+ while (0)
end
end
@@ -2399,6 +2420,75 @@ instruction formatlu (?n)
end
end
+# Instruction: formatf32
+#
+# Given a UINT (that should be interpreted as a 32-bit floating-point
+# number), and a UINT (as the conversion precision), push the string
+# representation of the floating-point number with specified precision.
+#
+# The formatting style is given by a literal parameters.
+# Style 0 corresponds to %f-tag which converts the number in the style
+# [-]ddd.ddd where the number of digits after the decimal-point character
+# is the equal to the precision.
+# Style 1 corresponds to %e-tag which converts the number in the style
+# [-]d.ddde+-dd (so called scientific notation). Precision for this
+# style also means the number of digits after the decimal-point character.
+# Style 2 corresponds to %g-tag which choose either %f style or %e based
+# on the length of the repsentation. For this style, precision specify
+# the number of significant numbers.
+#
+# Stack: ( UINT UINT -- STR )
+
+instruction formatf32 (?n 0 1 2)
+ branching # because of PVM_RAISE_DIRECT
+ code
+ char *result = NULL;
+ uint32_t num = PVM_VAL_UINT (JITTER_UNDER_TOP_STACK ());
+ unsigned style = (unsigned)JITTER_ARGN0;
+ uint32_t precision = PVM_VAL_UINT (JITTER_TOP_STACK ());
+
+ JITTER_DROP_STACK ();
+ FORMATF (result, num, precision, style, float);
+ JITTER_TOP_STACK () = pvm_make_string (result);
+ free (result);
+ end
+end
+
+# Instruction: formatf64
+#
+# Given a ULONG (that should be interpreted as a 64-bit floating-point
+# number), and a UINT (as the conversion precision), push the string
+# representation of the floating-point number with specified precision.
+# The formatting style is given by a literal parameters.
+#
+# The formatting style is given by a literal parameters.
+# Style 0 corresponds to %f-tag which converts the number in the style
+# [-]ddd.ddd where the number of digits after the decimal-point character
+# is the equal to the precision.
+# Style 1 corresponds to %e-tag which converts the number in the style
+# [-]d.ddde+-dd (so called scientific notation). Precision for this
+# style also means the number of digits after the decimal-point character.
+# Style 2 corresponds to %g-tag which choose either %f style or %e based
+# on the length of the repsentation. For this style, precision specify
+# the number of significant numbers.
+#
+# Stack: ( ULONG UINT -- STR )
+
+instruction formatf64 (?n 0 1 2)
+ branching # because of PVM_RAISE_DIRECT
+ code
+ char *result = NULL;
+ uint64_t num = PVM_VAL_ULONG (JITTER_UNDER_TOP_STACK ());
+ unsigned style = (unsigned)JITTER_ARGN0;
+ uint32_t precision = PVM_VAL_UINT (JITTER_TOP_STACK ());
+
+ JITTER_DROP_STACK ();
+ FORMATF (result, num, precision, style, double);
+ JITTER_TOP_STACK () = pvm_make_string (result);
+ free (result);
+ end
+end
+
## Main stack manipulation instructions
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index adf82877..3de991c2 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1390,7 +1390,46 @@ EXTRA_DIST = \
poke.pkl/format-40.pk \
poke.pkl/format-41.pk \
poke.pkl/format-42.pk \
+ poke.pkl/format-43.pk \
+ poke.pkl/format-44.pk \
+ poke.pkl/format-45.pk \
+ poke.pkl/format-46.pk \
+ poke.pkl/format-47.pk \
+ poke.pkl/format-48.pk \
+ poke.pkl/format-49.pk \
+ poke.pkl/format-50.pk \
+ poke.pkl/format-51.pk \
+ poke.pkl/format-52.pk \
+ poke.pkl/format-53.pk \
+ poke.pkl/format-54.pk \
+ poke.pkl/format-55.pk \
+ poke.pkl/format-56.pk \
+ poke.pkl/format-57.pk \
+ poke.pkl/format-58.pk \
+ poke.pkl/format-59.pk \
+ poke.pkl/format-60.pk \
+ poke.pkl/format-61.pk \
+ poke.pkl/format-62.pk \
+ poke.pkl/format-63.pk \
+ poke.pkl/format-64.pk \
+ poke.pkl/format-65.pk \
+ poke.pkl/format-66.pk \
+ poke.pkl/format-67.pk \
+ poke.pkl/format-68.pk \
+ poke.pkl/format-69.pk \
+ poke.pkl/format-70.pk \
+ poke.pkl/format-71.pk \
+ poke.pkl/format-72.pk \
+ poke.pkl/format-73.pk \
poke.pkl/format-diag-1.pk \
+ poke.pkl/format-diag-2.pk \
+ poke.pkl/format-diag-3.pk \
+ poke.pkl/format-diag-4.pk \
+ poke.pkl/format-diag-5.pk \
+ poke.pkl/format-diag-6.pk \
+ poke.pkl/format-diag-7.pk \
+ poke.pkl/format-diag-8.pk \
+ poke.pkl/format-diag-9.pk \
poke.pkl/format-optcond-1.pk \
poke.pkl/format-optcond-2.pk \
poke.pkl/format-optcond-3.pk \
@@ -1979,6 +2018,37 @@ EXTRA_DIST = \
poke.pkl/printf-38.pk \
poke.pkl/printf-39.pk \
poke.pkl/printf-40.pk \
+ poke.pkl/printf-41.pk \
+ poke.pkl/printf-42.pk \
+ poke.pkl/printf-43.pk \
+ poke.pkl/printf-44.pk \
+ poke.pkl/printf-45.pk \
+ poke.pkl/printf-46.pk \
+ poke.pkl/printf-47.pk \
+ poke.pkl/printf-48.pk \
+ poke.pkl/printf-49.pk \
+ poke.pkl/printf-50.pk \
+ poke.pkl/printf-51.pk \
+ poke.pkl/printf-52.pk \
+ poke.pkl/printf-53.pk \
+ poke.pkl/printf-54.pk \
+ poke.pkl/printf-55.pk \
+ poke.pkl/printf-56.pk \
+ poke.pkl/printf-57.pk \
+ poke.pkl/printf-58.pk \
+ poke.pkl/printf-59.pk \
+ poke.pkl/printf-60.pk \
+ poke.pkl/printf-61.pk \
+ poke.pkl/printf-62.pk \
+ poke.pkl/printf-63.pk \
+ poke.pkl/printf-64.pk \
+ poke.pkl/printf-65.pk \
+ poke.pkl/printf-66.pk \
+ poke.pkl/printf-67.pk \
+ poke.pkl/printf-68.pk \
+ poke.pkl/printf-69.pk \
+ poke.pkl/printf-70.pk \
+ poke.pkl/printf-71.pk \
poke.pkl/printf-binary-1.pk \
poke.pkl/printf-binary-2.pk \
poke.pkl/printf-binary-3.pk \
@@ -2008,6 +2078,14 @@ EXTRA_DIST = \
poke.pkl/printf-diag-15.pk \
poke.pkl/printf-diag-16.pk \
poke.pkl/printf-diag-18.pk \
+ poke.pkl/printf-diag-19.pk \
+ poke.pkl/printf-diag-20.pk \
+ poke.pkl/printf-diag-21.pk \
+ poke.pkl/printf-diag-22.pk \
+ poke.pkl/printf-diag-23.pk \
+ poke.pkl/printf-diag-24.pk \
+ poke.pkl/printf-diag-25.pk \
+ poke.pkl/printf-diag-26.pk \
poke.pkl/printf-value-1.pk \
poke.pkl/printf-value-2.pk \
poke.pkl/printf-value-3.pk \
diff --git a/testsuite/poke.pkl/format-43.pk b/testsuite/poke.pkl/format-43.pk
new file mode 100644
index 00000000..a326625f
--- /dev/null
+++ b/testsuite/poke.pkl/format-43.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f32d", 0x4048f5c3U);} } */
+/* { dg-output {"3.1400001"} } */
diff --git a/testsuite/poke.pkl/format-44.pk b/testsuite/poke.pkl/format-44.pk
new file mode 100644
index 00000000..3e236580
--- /dev/null
+++ b/testsuite/poke.pkl/format-44.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f32d", 0x4048f5c3U);} } */
+/* { dg-output {"Xx3.1400001"} } */
diff --git a/testsuite/poke.pkl/format-45.pk b/testsuite/poke.pkl/format-45.pk
new file mode 100644
index 00000000..52ab1fd6
--- /dev/null
+++ b/testsuite/poke.pkl/format-45.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f32dxX", 0x4048f5c3U);} } */
+/* { dg-output {"3.1400001xX"} } */
diff --git a/testsuite/poke.pkl/format-46.pk b/testsuite/poke.pkl/format-46.pk
new file mode 100644
index 00000000..1f667c19
--- /dev/null
+++ b/testsuite/poke.pkl/format-46.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f32dxX", 0x4048f5c3U);} } */
+/* { dg-output {"Xx3.1400001xX"} } */
diff --git a/testsuite/poke.pkl/format-47.pk b/testsuite/poke.pkl/format-47.pk
new file mode 100644
index 00000000..965d7d60
--- /dev/null
+++ b/testsuite/poke.pkl/format-47.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%s%f32d%u32x", "FP!", 0x4048f5c3U, 0x4048f5c3U);} }
*/
+/* { dg-output {"FP!3.14000014048f5c3"} } */
diff --git a/testsuite/poke.pkl/format-48.pk b/testsuite/poke.pkl/format-48.pk
new file mode 100644
index 00000000..3cf4032b
--- /dev/null
+++ b/testsuite/poke.pkl/format-48.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f32.7d", 0x4048f5c3U);} } */
+/* { dg-output {"3.1400001"} } */
diff --git a/testsuite/poke.pkl/format-49.pk b/testsuite/poke.pkl/format-49.pk
new file mode 100644
index 00000000..32dd5d93
--- /dev/null
+++ b/testsuite/poke.pkl/format-49.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f32.7d", 0x4048f5c3U);} } */
+/* { dg-output {"Xx3.1400001"} } */
diff --git a/testsuite/poke.pkl/format-50.pk b/testsuite/poke.pkl/format-50.pk
new file mode 100644
index 00000000..a3c411d9
--- /dev/null
+++ b/testsuite/poke.pkl/format-50.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f32.7dxX", 0x4048f5c3U);} } */
+/* { dg-output {"3.1400001xX"} } */
diff --git a/testsuite/poke.pkl/format-51.pk b/testsuite/poke.pkl/format-51.pk
new file mode 100644
index 00000000..36f953cd
--- /dev/null
+++ b/testsuite/poke.pkl/format-51.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f32.7dxX", 0x4048f5c3U);} } */
+/* { dg-output {"Xx3.1400001xX"} } */
diff --git a/testsuite/poke.pkl/format-52.pk b/testsuite/poke.pkl/format-52.pk
new file mode 100644
index 00000000..0c7bca42
--- /dev/null
+++ b/testsuite/poke.pkl/format-52.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%s%f32.7d%u32x", "FP!", 0x4048f5c3U, 0x4048f5c3U);}
} */
+/* { dg-output {"FP!3.14000014048f5c3"} } */
diff --git a/testsuite/poke.pkl/format-53.pk b/testsuite/poke.pkl/format-53.pk
new file mode 100644
index 00000000..e379c0f3
--- /dev/null
+++ b/testsuite/poke.pkl/format-53.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f32.9d%s", 0x4048f5c3U, "XxX");} } */
+/* { dg-output {"3.140000105XxX"} } */
diff --git a/testsuite/poke.pkl/format-54.pk b/testsuite/poke.pkl/format-54.pk
new file mode 100644
index 00000000..1e92b1de
--- /dev/null
+++ b/testsuite/poke.pkl/format-54.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format (" %f32.22d %s ", 0x4048f5c3U, "!");} } */
+/* { dg-output {" 3.1400001049041748046875 ! "} } */
diff --git a/testsuite/poke.pkl/format-55.pk b/testsuite/poke.pkl/format-55.pk
new file mode 100644
index 00000000..336e0d8b
--- /dev/null
+++ b/testsuite/poke.pkl/format-55.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%e32.22d", 0x4048f5c3U);} } */
+/* { dg-output {"3.1400001049041748046875e\+00"} } */
diff --git a/testsuite/poke.pkl/format-56.pk b/testsuite/poke.pkl/format-56.pk
new file mode 100644
index 00000000..8549cc8c
--- /dev/null
+++ b/testsuite/poke.pkl/format-56.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%g32.8d", 0x4048f5c3U);} } */
+/* { dg-output {"3.1400001"} } */
diff --git a/testsuite/poke.pkl/format-57.pk b/testsuite/poke.pkl/format-57.pk
new file mode 100644
index 00000000..8549cc8c
--- /dev/null
+++ b/testsuite/poke.pkl/format-57.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%g32.8d", 0x4048f5c3U);} } */
+/* { dg-output {"3.1400001"} } */
diff --git a/testsuite/poke.pkl/format-58.pk b/testsuite/poke.pkl/format-58.pk
new file mode 100644
index 00000000..b27a06cf
--- /dev/null
+++ b/testsuite/poke.pkl/format-58.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f64d", 0x40091eb851eb851fU);} } */
+/* { dg-output {"3.140000000000000"} } */
diff --git a/testsuite/poke.pkl/format-59.pk b/testsuite/poke.pkl/format-59.pk
new file mode 100644
index 00000000..8070eeab
--- /dev/null
+++ b/testsuite/poke.pkl/format-59.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f64d", 0x40091eb851eb851fU);} } */
+/* { dg-output {"Xx3.140000000000000"} } */
diff --git a/testsuite/poke.pkl/format-60.pk b/testsuite/poke.pkl/format-60.pk
new file mode 100644
index 00000000..8fc9de65
--- /dev/null
+++ b/testsuite/poke.pkl/format-60.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f64dxX", 0x40091eb851eb851fU);} } */
+/* { dg-output {"3.140000000000000xX"} } */
diff --git a/testsuite/poke.pkl/format-61.pk b/testsuite/poke.pkl/format-61.pk
new file mode 100644
index 00000000..1c2029d7
--- /dev/null
+++ b/testsuite/poke.pkl/format-61.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f64dxX", 0x40091eb851eb851fU);} } */
+/* { dg-output {"Xx3.140000000000000xX"} } */
diff --git a/testsuite/poke.pkl/format-62.pk b/testsuite/poke.pkl/format-62.pk
new file mode 100644
index 00000000..59df0b4b
--- /dev/null
+++ b/testsuite/poke.pkl/format-62.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%s%f64d%u64x", "FP!", 0x40091eb851eb851fU,
0x40091eb851eb851fU);} } */
+/* { dg-output {"FP!3.14000000000000040091eb851eb851f"} } */
diff --git a/testsuite/poke.pkl/format-63.pk b/testsuite/poke.pkl/format-63.pk
new file mode 100644
index 00000000..17cc8d9a
--- /dev/null
+++ b/testsuite/poke.pkl/format-63.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f64.15d", 0x40091eb851eb851fU);} } */
+/* { dg-output {"3.140000000000000"} } */
diff --git a/testsuite/poke.pkl/format-64.pk b/testsuite/poke.pkl/format-64.pk
new file mode 100644
index 00000000..f3d71448
--- /dev/null
+++ b/testsuite/poke.pkl/format-64.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f64.15d", 0x40091eb851eb851fU);} } */
+/* { dg-output {"Xx3.140000000000000"} } */
diff --git a/testsuite/poke.pkl/format-65.pk b/testsuite/poke.pkl/format-65.pk
new file mode 100644
index 00000000..3432de92
--- /dev/null
+++ b/testsuite/poke.pkl/format-65.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f64.15dxX", 0x40091eb851eb851fU);} } */
+/* { dg-output {"3.140000000000000xX"} } */
diff --git a/testsuite/poke.pkl/format-66.pk b/testsuite/poke.pkl/format-66.pk
new file mode 100644
index 00000000..9a5b5c14
--- /dev/null
+++ b/testsuite/poke.pkl/format-66.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("Xx%f64.15dxX", 0x40091eb851eb851fU);} } */
+/* { dg-output {"Xx3.140000000000000xX"} } */
diff --git a/testsuite/poke.pkl/format-67.pk b/testsuite/poke.pkl/format-67.pk
new file mode 100644
index 00000000..36a822f5
--- /dev/null
+++ b/testsuite/poke.pkl/format-67.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%s%f64.15d%u64x", "FP!", 0x40091eb851eb851fU,
0x40091eb851eb851fU);} } */
+/* { dg-output {"FP!3.14000000000000040091eb851eb851f"} } */
diff --git a/testsuite/poke.pkl/format-68.pk b/testsuite/poke.pkl/format-68.pk
new file mode 100644
index 00000000..80156b2d
--- /dev/null
+++ b/testsuite/poke.pkl/format-68.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f64.7d%s", 0x40091eb851eb851fU, "XxX");} } */
+/* { dg-output {"3.1400000XxX"} } */
diff --git a/testsuite/poke.pkl/format-69.pk b/testsuite/poke.pkl/format-69.pk
new file mode 100644
index 00000000..272db154
--- /dev/null
+++ b/testsuite/poke.pkl/format-69.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%s%f64.14d%s", "!", 0x40091eb851eb851fU, "XxX");} }
*/
+/* { dg-output {"!3.14000000000000XxX"} } */
diff --git a/testsuite/poke.pkl/format-70.pk b/testsuite/poke.pkl/format-70.pk
new file mode 100644
index 00000000..66f770bf
--- /dev/null
+++ b/testsuite/poke.pkl/format-70.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format (" %f64.22d %s ", 0x40091eb851eb851fU, "!");} } */
+/* { dg-output {" 3.1400000000000001243450 ! "} } */
diff --git a/testsuite/poke.pkl/format-71.pk b/testsuite/poke.pkl/format-71.pk
new file mode 100644
index 00000000..158fb98c
--- /dev/null
+++ b/testsuite/poke.pkl/format-71.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%f64.51d", 0x40091eb851eb851fU);} } */
+/* { dg-output {"3.140000000000000124344978758017532527446746826171875"} } */
diff --git a/testsuite/poke.pkl/format-72.pk b/testsuite/poke.pkl/format-72.pk
new file mode 100644
index 00000000..7c592d74
--- /dev/null
+++ b/testsuite/poke.pkl/format-72.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%e64.15d", 0x40091eb851eb851fU);} } */
+/* { dg-output {"3.140000000000000e\+00"} } */
diff --git a/testsuite/poke.pkl/format-73.pk b/testsuite/poke.pkl/format-73.pk
new file mode 100644
index 00000000..a2a6799d
--- /dev/null
+++ b/testsuite/poke.pkl/format-73.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {format ("%g64.15d", 0x40091eb851eb851fU);} } */
+/* { dg-output {"3.14"} } */
diff --git a/testsuite/poke.pkl/format-diag-2.pk
b/testsuite/poke.pkl/format-diag-2.pk
new file mode 100644
index 00000000..5de99f65
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-2.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format ("%f1d", 1UH); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/format-diag-3.pk
b/testsuite/poke.pkl/format-diag-3.pk
new file mode 100644
index 00000000..9bd748fa
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-3.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format ("x%f16d", 1UH); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/format-diag-4.pk
b/testsuite/poke.pkl/format-diag-4.pk
new file mode 100644
index 00000000..0d901f44
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-4.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format ("%f32bAB", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/format-diag-5.pk
b/testsuite/poke.pkl/format-diag-5.pk
new file mode 100644
index 00000000..cb01cbec
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-5.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format ("AB%f32oCD", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/format-diag-6.pk
b/testsuite/poke.pkl/format-diag-6.pk
new file mode 100644
index 00000000..02b1ed2f
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-6.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format ("%f32x", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/format-diag-7.pk
b/testsuite/poke.pkl/format-diag-7.pk
new file mode 100644
index 00000000..8012f8d6
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-7.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format (" %f64b %s", 1U, "Hi"); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/format-diag-8.pk
b/testsuite/poke.pkl/format-diag-8.pk
new file mode 100644
index 00000000..97456e0c
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-8.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format ("%f64o", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/format-diag-9.pk
b/testsuite/poke.pkl/format-diag-9.pk
new file mode 100644
index 00000000..b1910845
--- /dev/null
+++ b/testsuite/poke.pkl/format-diag-9.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+format ("%f64x", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-41.pk b/testsuite/poke.pkl/printf-41.pk
new file mode 100644
index 00000000..bae954d9
--- /dev/null
+++ b/testsuite/poke.pkl/printf-41.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f32d", 0x4048f5c3U); /* { dg-output {3.1400001} } */
diff --git a/testsuite/poke.pkl/printf-42.pk b/testsuite/poke.pkl/printf-42.pk
new file mode 100644
index 00000000..8facaa7c
--- /dev/null
+++ b/testsuite/poke.pkl/printf-42.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f32d", 0x4048f5c3U); /* { dg-output {Xx3.1400001} } */
diff --git a/testsuite/poke.pkl/printf-43.pk b/testsuite/poke.pkl/printf-43.pk
new file mode 100644
index 00000000..5023336c
--- /dev/null
+++ b/testsuite/poke.pkl/printf-43.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f32dxX", 0x4048f5c3U); /* { dg-output {3.1400001xX} } */
diff --git a/testsuite/poke.pkl/printf-44.pk b/testsuite/poke.pkl/printf-44.pk
new file mode 100644
index 00000000..ea6e7a97
--- /dev/null
+++ b/testsuite/poke.pkl/printf-44.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f32dxX", 0x4048f5c3U); /* { dg-output {Xx3.1400001xX} } */
diff --git a/testsuite/poke.pkl/printf-45.pk b/testsuite/poke.pkl/printf-45.pk
new file mode 100644
index 00000000..a3dde7c8
--- /dev/null
+++ b/testsuite/poke.pkl/printf-45.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%s%f32d%u32x", "FP!", 0x4048f5c3U, 0x4048f5c3U); /* { dg-output
{FP!3.14000014048f5c3} } */
diff --git a/testsuite/poke.pkl/printf-46.pk b/testsuite/poke.pkl/printf-46.pk
new file mode 100644
index 00000000..75e2c803
--- /dev/null
+++ b/testsuite/poke.pkl/printf-46.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f32.7d", 0x4048f5c3U); /* { dg-output {3.1400001} } */
diff --git a/testsuite/poke.pkl/printf-47.pk b/testsuite/poke.pkl/printf-47.pk
new file mode 100644
index 00000000..4d4c7349
--- /dev/null
+++ b/testsuite/poke.pkl/printf-47.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f32.7d", 0x4048f5c3U); /* { dg-output {Xx3.1400001} } */
diff --git a/testsuite/poke.pkl/printf-48.pk b/testsuite/poke.pkl/printf-48.pk
new file mode 100644
index 00000000..35a13390
--- /dev/null
+++ b/testsuite/poke.pkl/printf-48.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f32.7dxX", 0x4048f5c3U); /* { dg-output {3.1400001xX} } */
diff --git a/testsuite/poke.pkl/printf-49.pk b/testsuite/poke.pkl/printf-49.pk
new file mode 100644
index 00000000..9e9a1890
--- /dev/null
+++ b/testsuite/poke.pkl/printf-49.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f32.7dxX", 0x4048f5c3U); /* { dg-output {Xx3.1400001xX} } */
diff --git a/testsuite/poke.pkl/printf-50.pk b/testsuite/poke.pkl/printf-50.pk
new file mode 100644
index 00000000..bb4ee360
--- /dev/null
+++ b/testsuite/poke.pkl/printf-50.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%s%f32.7d%u32x", "FP!", 0x4048f5c3U, 0x4048f5c3U); /* { dg-output
{FP!3.14000014048f5c3} } */
diff --git a/testsuite/poke.pkl/printf-51.pk b/testsuite/poke.pkl/printf-51.pk
new file mode 100644
index 00000000..c58178bd
--- /dev/null
+++ b/testsuite/poke.pkl/printf-51.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f32.9d%s", 0x4048f5c3U, "XxX"); /* { dg-output {3.140000105XxX} } */
diff --git a/testsuite/poke.pkl/printf-52.pk b/testsuite/poke.pkl/printf-52.pk
new file mode 100644
index 00000000..d191b711
--- /dev/null
+++ b/testsuite/poke.pkl/printf-52.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf (" %f32.22d %s ", 0x4048f5c3U, "!"); /* { dg-output {
3.1400001049041748046875 ! } } */
diff --git a/testsuite/poke.pkl/printf-53.pk b/testsuite/poke.pkl/printf-53.pk
new file mode 100644
index 00000000..a451ab1a
--- /dev/null
+++ b/testsuite/poke.pkl/printf-53.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%e32.22d", 0x4048f5c3U); /* { dg-output
{3.1400001049041748046875e\+00} } */
diff --git a/testsuite/poke.pkl/printf-54.pk b/testsuite/poke.pkl/printf-54.pk
new file mode 100644
index 00000000..62ce87af
--- /dev/null
+++ b/testsuite/poke.pkl/printf-54.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%g32.8d", 0x4048f5c3U); /* { dg-output {3.1400001} } */
diff --git a/testsuite/poke.pkl/printf-55.pk b/testsuite/poke.pkl/printf-55.pk
new file mode 100644
index 00000000..62ce87af
--- /dev/null
+++ b/testsuite/poke.pkl/printf-55.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%g32.8d", 0x4048f5c3U); /* { dg-output {3.1400001} } */
diff --git a/testsuite/poke.pkl/printf-56.pk b/testsuite/poke.pkl/printf-56.pk
new file mode 100644
index 00000000..66db325c
--- /dev/null
+++ b/testsuite/poke.pkl/printf-56.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f64d", 0x40091eb851eb851fU); /* { dg-output {3.140000000000000} } */
diff --git a/testsuite/poke.pkl/printf-57.pk b/testsuite/poke.pkl/printf-57.pk
new file mode 100644
index 00000000..8510be86
--- /dev/null
+++ b/testsuite/poke.pkl/printf-57.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f64d", 0x40091eb851eb851fU); /* { dg-output {Xx3.140000000000000}
} */
diff --git a/testsuite/poke.pkl/printf-58.pk b/testsuite/poke.pkl/printf-58.pk
new file mode 100644
index 00000000..6117ec85
--- /dev/null
+++ b/testsuite/poke.pkl/printf-58.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f64dxX", 0x40091eb851eb851fU); /* { dg-output {3.140000000000000xX}
} */
diff --git a/testsuite/poke.pkl/printf-59.pk b/testsuite/poke.pkl/printf-59.pk
new file mode 100644
index 00000000..848c3d51
--- /dev/null
+++ b/testsuite/poke.pkl/printf-59.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f64dxX", 0x40091eb851eb851fU); /* { dg-output
{Xx3.140000000000000xX} } */
diff --git a/testsuite/poke.pkl/printf-60.pk b/testsuite/poke.pkl/printf-60.pk
new file mode 100644
index 00000000..0a6fdba8
--- /dev/null
+++ b/testsuite/poke.pkl/printf-60.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%s%f64d%u64x", "FP!", 0x40091eb851eb851fU, 0x40091eb851eb851fU); /* {
dg-output {FP!3.14000000000000040091eb851eb851f} } */
diff --git a/testsuite/poke.pkl/printf-61.pk b/testsuite/poke.pkl/printf-61.pk
new file mode 100644
index 00000000..b4a33dbb
--- /dev/null
+++ b/testsuite/poke.pkl/printf-61.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f64.15d", 0x40091eb851eb851fU); /* { dg-output {3.140000000000000} }
*/
diff --git a/testsuite/poke.pkl/printf-62.pk b/testsuite/poke.pkl/printf-62.pk
new file mode 100644
index 00000000..09082f95
--- /dev/null
+++ b/testsuite/poke.pkl/printf-62.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f64.15d", 0x40091eb851eb851fU); /* { dg-output
{Xx3.140000000000000} } */
diff --git a/testsuite/poke.pkl/printf-63.pk b/testsuite/poke.pkl/printf-63.pk
new file mode 100644
index 00000000..9c64170e
--- /dev/null
+++ b/testsuite/poke.pkl/printf-63.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f64.15dxX", 0x40091eb851eb851fU); /* { dg-output
{3.140000000000000xX} } */
diff --git a/testsuite/poke.pkl/printf-64.pk b/testsuite/poke.pkl/printf-64.pk
new file mode 100644
index 00000000..8a049eb6
--- /dev/null
+++ b/testsuite/poke.pkl/printf-64.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("Xx%f64.15dxX", 0x40091eb851eb851fU); /* { dg-output
{Xx3.140000000000000xX} } */
diff --git a/testsuite/poke.pkl/printf-65.pk b/testsuite/poke.pkl/printf-65.pk
new file mode 100644
index 00000000..129bb3a1
--- /dev/null
+++ b/testsuite/poke.pkl/printf-65.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%s%f64.15d%u64x", "FP!", 0x40091eb851eb851fU, 0x40091eb851eb851fU);
/* { dg-output {FP!3.14000000000000040091eb851eb851f} } */
diff --git a/testsuite/poke.pkl/printf-66.pk b/testsuite/poke.pkl/printf-66.pk
new file mode 100644
index 00000000..6adf2e21
--- /dev/null
+++ b/testsuite/poke.pkl/printf-66.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f64.7d%s", 0x40091eb851eb851fU, "XxX"); /* { dg-output
{3.1400000XxX} } */
diff --git a/testsuite/poke.pkl/printf-67.pk b/testsuite/poke.pkl/printf-67.pk
new file mode 100644
index 00000000..94ef9d77
--- /dev/null
+++ b/testsuite/poke.pkl/printf-67.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%s%f64.14d%s", "!", 0x40091eb851eb851fU, "XxX"); /* { dg-output
{!3.14000000000000XxX} } */
diff --git a/testsuite/poke.pkl/printf-68.pk b/testsuite/poke.pkl/printf-68.pk
new file mode 100644
index 00000000..acb9b115
--- /dev/null
+++ b/testsuite/poke.pkl/printf-68.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf (" %f64.22d %s ", 0x40091eb851eb851fU, "!"); /* { dg-output {
3.1400000000000001243450 ! } } */
diff --git a/testsuite/poke.pkl/printf-69.pk b/testsuite/poke.pkl/printf-69.pk
new file mode 100644
index 00000000..fd7ab551
--- /dev/null
+++ b/testsuite/poke.pkl/printf-69.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%f64.51d", 0x40091eb851eb851fU); /* { dg-output
{3.140000000000000124344978758017532527446746826171875} } */
diff --git a/testsuite/poke.pkl/printf-70.pk b/testsuite/poke.pkl/printf-70.pk
new file mode 100644
index 00000000..ea2b4021
--- /dev/null
+++ b/testsuite/poke.pkl/printf-70.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%e64.15d", 0x40091eb851eb851fU); /* { dg-output
{3.140000000000000e\+00} } */
diff --git a/testsuite/poke.pkl/printf-71.pk b/testsuite/poke.pkl/printf-71.pk
new file mode 100644
index 00000000..27461660
--- /dev/null
+++ b/testsuite/poke.pkl/printf-71.pk
@@ -0,0 +1,3 @@
+/* { dg-do run } */
+
+printf ("%g64.15d", 0x40091eb851eb851fU); /* { dg-output {3.14} } */
diff --git a/testsuite/poke.pkl/printf-diag-19.pk
b/testsuite/poke.pkl/printf-diag-19.pk
new file mode 100644
index 00000000..7b489d29
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-19.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf ("%f1d", 1UH); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-diag-20.pk
b/testsuite/poke.pkl/printf-diag-20.pk
new file mode 100644
index 00000000..1a0bc1bc
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-20.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf ("x%f16d", 1UH); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-diag-21.pk
b/testsuite/poke.pkl/printf-diag-21.pk
new file mode 100644
index 00000000..c9eef385
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-21.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf ("%f32bAB", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-diag-22.pk
b/testsuite/poke.pkl/printf-diag-22.pk
new file mode 100644
index 00000000..76b59ecb
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-22.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf ("AB%f32oCD", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-diag-23.pk
b/testsuite/poke.pkl/printf-diag-23.pk
new file mode 100644
index 00000000..8a34ead6
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-23.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf ("%f32x", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-diag-24.pk
b/testsuite/poke.pkl/printf-diag-24.pk
new file mode 100644
index 00000000..d7bc5a21
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-24.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf (" %f64b %s", 1U, "Hi"); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-diag-25.pk
b/testsuite/poke.pkl/printf-diag-25.pk
new file mode 100644
index 00000000..d7f00eaf
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-25.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf ("%f64o", 1U); /* { dg-error "" } */
diff --git a/testsuite/poke.pkl/printf-diag-26.pk
b/testsuite/poke.pkl/printf-diag-26.pk
new file mode 100644
index 00000000..54ca8460
--- /dev/null
+++ b/testsuite/poke.pkl/printf-diag-26.pk
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+
+printf ("%f64x", 1U); /* { dg-error "" } */
--
2.39.0
- [PATCH] pkl,std: add `format_f32' and `format_f64' std functions, Mohammad-Reza Nabipoor, 2023/01/07
- Re: [PATCH] pkl,std: add `format_f32' and `format_f64' std functions, Jose E. Marchesi, 2023/01/07
- Re: [PATCH] pkl,std: add `format_f32' and `format_f64' std functions, Mohammad-Reza Nabipoor, 2023/01/08
- Re: [PATCH] pkl,std: add `format_f32' and `format_f64' std functions, Jose E. Marchesi, 2023/01/08
- [PATCH v2 1/2] pkl, testsuite: add support for printing/formatting floating-points, Mohammad-Reza Nabipoor, 2023/01/08
- [PATCH v2 2/2] pickles: add new pickle for floating-point numbers, Mohammad-Reza Nabipoor, 2023/01/08
- Re: [PATCH v2 2/2] pickles: add new pickle for floating-point numbers, Jose E. Marchesi, 2023/01/08
- Re: [PATCH v2 1/2] pkl,testsuite: add support for printing/formatting floating-points, Jose E. Marchesi, 2023/01/08
- [PATCH v3] pkl, testsuite: add support for printing/formatting floating-points,
Mohammad-Reza Nabipoor <=
- Re: [PATCH v3] pkl,testsuite: add support for printing/formatting floating-points, Jose E. Marchesi, 2023/01/10
- Re: [PATCH v3] pkl,testsuite: add support for printing/formatting floating-points, Mohammad-Reza Nabipoor, 2023/01/11