mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Update QP for Makefile that works on Ubuntu and RHEL - adds API call to quadmath instead of RHEL printf of %Q. This will allow the examples to compile for both OSes
This commit is contained in:
parent
c62ddc234a
commit
f267c20601
@ -6,7 +6,7 @@ LFLAGS = -L.
|
||||
# Link against the riscv-isa-sim version of SoftFloat rather than
|
||||
# the regular version to get RISC-V NaN behavior
|
||||
#IFLAGS = -I$(RISCV)/riscv-isa-sim/softfloat
|
||||
#LIBS = $(RISCV)/riscv-isa-sim/build/libsoftfloat.a
|
||||
#LIBS = $(RISCV)/riscv-isa-sim/build/libsoftfloat.a -lm -lquadmath
|
||||
IFLAGS = -I../../../addins/SoftFloat-3e/source/include/
|
||||
LIBS = ../../../addins/SoftFloat-3e/build/Linux-x86_64-GCC/softfloat.a -lm -lquadmath
|
||||
SRCS = $(wildcard *.c)
|
||||
|
@ -38,16 +38,19 @@ void printF64 (char *msg, float64_t d) {
|
||||
int i, j;
|
||||
conv.v = d.v; // use union to convert between hexadecimal and floating-point views
|
||||
printf("%s: ", msg); // print out nicely
|
||||
printf("0x%08x_%08x = %g\n", (conv.v >> 32),(conv.v & 0xFFFFFFFF), conv.d);
|
||||
printf("0x%08lx_%08lx = %g\n", (conv.v >> 32),(conv.v & 0xFFFFFFFF), conv.d);
|
||||
}
|
||||
|
||||
void printF128 (char *msg, float128_t q) {
|
||||
qp conv;
|
||||
int i, j;
|
||||
char buf[64];
|
||||
conv.v[0] = q.v[0]; // use union to convert between hexadecimal and floating-point views
|
||||
conv.v[1] = q.v[1]; // use union to convert between hexadecimal and floating-point views
|
||||
printf("%s: ", msg); // print out nicely
|
||||
printf("0x%016" PRIx64 "_%016" PRIx64 " = %1.15Qe\n", q.v[1], q.v[0], conv.q);
|
||||
//printf("0x%016" PRIx64 "_%016" PRIx64 " = %1.15Qe\n", q.v[1], q.v[0], conv.q);
|
||||
quadmath_snprintf (buf, sizeof buf, "%1.15Qe", conv.q);
|
||||
printf("0x%016" PRIx64 "_%016" PRIx64 " = %s\n", q.v[1], q.v[0], buf);
|
||||
}
|
||||
|
||||
void printFlags(void) {
|
||||
|
@ -38,16 +38,23 @@ void printF64 (char *msg, float64_t d) {
|
||||
int i, j;
|
||||
conv.v = d.v; // use union to convert between hexadecimal and floating-point views
|
||||
printf("%s: ", msg); // print out nicely
|
||||
printf("0x%08x_%08x = %g\n", (conv.v >> 32),(conv.v & 0xFFFFFFFF), conv.d);
|
||||
printf("0x%08lx_%08lx = %g\n", (conv.v >> 32),(conv.v & 0xFFFFFFFF), conv.d);
|
||||
}
|
||||
|
||||
void printF128 (char *msg, float128_t q) {
|
||||
qp conv;
|
||||
int i, j;
|
||||
char buf[64];
|
||||
conv.v[0] = q.v[0]; // use union to convert between hexadecimal and floating-point views
|
||||
conv.v[1] = q.v[1]; // use union to convert between hexadecimal and floating-point views
|
||||
printf("%s: ", msg); // print out nicely
|
||||
printf("0x%016" PRIx64 "_%016" PRIx64 " = %1.15Qe\n", q.v[1], q.v[0], conv.q);
|
||||
|
||||
// Some compilers can understand %Q for printf on quad precision instead of the
|
||||
// API call of quadmath_snprintf
|
||||
// printf("0x%016" PRIx64 "_%016" PRIx64 " = %1.15Qe\n", q.v[1], q.v[0], conv.q);
|
||||
quadmath_snprintf (buf, sizeof buf, "%1.15Qe", conv.q);
|
||||
printf("0x%016" PRIx64 "_%016" PRIx64 " = %s\n", q.v[1], q.v[0], buf);
|
||||
|
||||
}
|
||||
|
||||
void printFlags(void) {
|
||||
@ -74,6 +81,8 @@ int main() {
|
||||
|
||||
float128_t x, y, z;
|
||||
float128_t r;
|
||||
uint32_t u, v, w;
|
||||
int32_t a, b, c;
|
||||
|
||||
x.v[1] = 0xBFFF988ECE97DFEB;
|
||||
x.v[0] = 0xC3BBA082445B4836;
|
||||
|
@ -38,16 +38,19 @@ void printF64 (char *msg, float64_t d) {
|
||||
int i, j;
|
||||
conv.v = d.v; // use union to convert between hexadecimal and floating-point views
|
||||
printf("%s: ", msg); // print out nicely
|
||||
printf("0x%08x_%08x = %g\n", (conv.v >> 32),(conv.v & 0xFFFFFFFF), conv.d);
|
||||
printf("0x%08lx_%08lx = %g\n", (conv.v >> 32),(conv.v & 0xFFFFFFFF), conv.d);
|
||||
}
|
||||
|
||||
void printF128 (char *msg, float128_t q) {
|
||||
qp conv;
|
||||
int i, j;
|
||||
char buf[64];
|
||||
conv.v[0] = q.v[0]; // use union to convert between hexadecimal and floating-point views
|
||||
conv.v[1] = q.v[1]; // use union to convert between hexadecimal and floating-point views
|
||||
printf("%s: ", msg); // print out nicely
|
||||
printf("0x%016" PRIx64 "_%016" PRIx64 " = %1.15Qe\n", q.v[1], q.v[0], conv.q);
|
||||
//printf("0x%016" PRIx64 "_%016" PRIx64 " = %1.15Qe\n", q.v[1], q.v[0], conv.q);
|
||||
quadmath_snprintf (buf, sizeof buf, "%1.15Qe", conv.q);
|
||||
printf("0x%016" PRIx64 "_%016" PRIx64 " = %s\n", q.v[1], q.v[0], buf);
|
||||
}
|
||||
|
||||
void printFlags(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user