summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2019-03-13 20:33:52 -0700
committerThiago Macieira <thiago.macieira@intel.com>2019-06-03 10:42:44 -0700
commit26e5aa45e1f4bd980f894a5e0621ecde03464d33 (patch)
tree2cb6e9bcb087e229063e94e5a87556f0fbbf6b67 /src/tools
parent6492541df306e20d16e3a64d9df174c99c847945 (diff)
De-bootstrap the qfloat16 generator tool
It doesn't really need Qt. So remove the dependency. I've confirmed that the output is identical to what used to be generated. This ought to be replaced by a script. Or just committed to Git, since the generated output is not really supposed to change, ever. Change-Id: I46363e5b8944459e8c48fffd158bb5d74fb6184c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/qfloat16-tables/gen_qfloat16_tables.cpp96
-rw-r--r--src/tools/qfloat16-tables/qfloat16-tables.pro2
2 files changed, 43 insertions, 55 deletions
diff --git a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp
index 17fc978039..5aca0235e3 100644
--- a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp
+++ b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 by Southwest Research Institute (R)
+** Copyright (C) 2019 Intel Corporation.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -37,13 +38,13 @@
**
****************************************************************************/
-#include <qfile.h>
-#include <qdebug.h>
+#include <stdint.h>
+#include <stdio.h>
-quint32 convertmantissa(qint32 i)
+uint32_t convertmantissa(int32_t i)
{
- quint32 m = i << 13; // Zero pad mantissa bits
- quint32 e = 0; // Zero exponent
+ uint32_t m = i << 13; // Zero pad mantissa bits
+ uint32_t e = 0; // Zero exponent
while (!(m & 0x00800000)) { // While not normalized
e -= 0x00800000; // Decrement exponent (1<<23)
@@ -56,60 +57,48 @@ quint32 convertmantissa(qint32 i)
// we first build these tables up and then print them out as a separate step in order
// to more closely map the implementation given in the paper.
-quint32 basetable[512];
-quint32 shifttable[512];
+uint32_t basetable[512];
+uint32_t shifttable[512];
-#define PRINTHEX(a) "0x" + QByteArray::number(a,16).toUpper() + "U,\n"
-
-qint32 main(qint32 argc, char **argv)
+int main()
{
- if (argc < 2) {
- qWarning() << "Must provide output filename as argument.";
- return -1;
- }
-
- QFile fid(QFile::decodeName(argv[1]));
- if (!fid.open(QIODevice::WriteOnly | QIODevice::Text)) {
- qWarning() << "Abort: Failed to open/create file" << fid.fileName();
- return -1;
- }
- quint32 i;
+ uint32_t i;
- fid.write("/* This file was generated by gen_qfloat16_tables.cpp */\n\n");
- fid.write("#include <QtCore/qfloat16.h>\n\n");
+ printf("/* This file was generated by gen_qfloat16_tables.cpp */\n\n");
+ printf("#include <QtCore/qfloat16.h>\n\n");
- fid.write("QT_BEGIN_NAMESPACE\n\n");
- fid.write("#if !defined(__F16C__) && !defined(__ARM_FP16_FORMAT_IEEE)\n\n");
+ printf("QT_BEGIN_NAMESPACE\n\n");
+ printf("#if !defined(__F16C__) && !defined(__ARM_FP16_FORMAT_IEEE)\n\n");
- fid.write("const quint32 qfloat16::mantissatable[2048] = {\n");
- fid.write("0,\n");
+ printf("const quint32 qfloat16::mantissatable[2048] = {\n");
+ printf("0,\n");
for (i = 1; i < 1024; i++)
- fid.write(PRINTHEX(convertmantissa(i)));
+ printf("0x%XU,\n", convertmantissa(i));
for (i = 1024; i < 2048; i++)
- fid.write(PRINTHEX(0x38000000U + ((i - 1024) << 13)));
- fid.write("};\n\n");
+ printf("0x%XU,\n", 0x38000000U + ((i - 1024) << 13));
+ printf("};\n\n");
- fid.write("const quint32 qfloat16::exponenttable[64] = {\n");
- fid.write("0,\n");
+ printf("const quint32 qfloat16::exponenttable[64] = {\n");
+ printf("0,\n");
for (i = 1; i < 31; i++)
- fid.write(PRINTHEX(i << 23));
- fid.write("0x47800000U,\n"); // 31
- fid.write("0x80000000U,\n"); // 32
+ printf("0x%XU,\n", i << 23);
+ printf("0x47800000U,\n"); // 31
+ printf("0x80000000U,\n"); // 32
for (i = 33; i < 63; i++)
- fid.write(PRINTHEX(0x80000000U + ((i - 32) << 23)));
- fid.write("0xC7800000U,\n"); // 63
- fid.write("};\n\n");
+ printf("0x%XU,\n", 0x80000000U + ((i - 32) << 23));
+ printf("0xC7800000U,\n"); // 63
+ printf("};\n\n");
- fid.write("const quint32 qfloat16::offsettable[64] = {\n");
- fid.write("0,\n");
+ printf("const quint32 qfloat16::offsettable[64] = {\n");
+ printf("0,\n");
for (i = 1; i < 32; i++)
- fid.write("1024U,\n");
- fid.write("0,\n");
+ printf("1024U,\n");
+ printf("0,\n");
for (i = 33; i < 64; i++)
- fid.write("1024U,\n");
- fid.write("};\n\n");
+ printf("1024U,\n");
+ printf("};\n\n");
- qint32 e;
+ int32_t e;
for (i = 0; i < 256; ++i) {
e = i - 127;
if (e < -24) { // Very small numbers map to zero
@@ -144,20 +133,19 @@ qint32 main(qint32 argc, char **argv)
}
}
- fid.write("const quint32 qfloat16::basetable[512] = {\n");
+ printf("const quint32 qfloat16::basetable[512] = {\n");
for (i = 0; i < 512; i++)
- fid.write(PRINTHEX(basetable[i]));
+ printf("0x%XU,\n", basetable[i]);
- fid.write("};\n\n");
+ printf("};\n\n");
- fid.write("const quint32 qfloat16::shifttable[512] = {\n");
+ printf("const quint32 qfloat16::shifttable[512] = {\n");
for (i = 0; i < 512; i++)
- fid.write(PRINTHEX(shifttable[i]));
+ printf("0x%XU,\n", shifttable[i]);
- fid.write("};\n\n");
+ printf("};\n\n");
- fid.write("#endif // !__F16C__ && !__ARM_FP16_FORMAT_IEEE\n\n");
- fid.write("QT_END_NAMESPACE\n");
- fid.close();
+ printf("#endif // !__F16C__ && !__ARM_FP16_FORMAT_IEEE\n\n");
+ printf("QT_END_NAMESPACE\n");
return 0;
}
diff --git a/src/tools/qfloat16-tables/qfloat16-tables.pro b/src/tools/qfloat16-tables/qfloat16-tables.pro
index a7d10ac197..12878ce6c7 100644
--- a/src/tools/qfloat16-tables/qfloat16-tables.pro
+++ b/src/tools/qfloat16-tables/qfloat16-tables.pro
@@ -1,6 +1,6 @@
option(host_build)
-CONFIG += force_bootstrap
+CONFIG -= qt
SOURCES += gen_qfloat16_tables.cpp
load(qt_tool)