Skip to contentSkip to conversation

cpu-all.h: Remove unnecessary target-specific ifdef for CPU_QuadU

PATCH Applied Peter Maydell 4 participants 8 messages Apr 4, 2011 – Apr 6, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpu-all.h: Remove unnecessary target-specific ifdef for CPU_QuadU

CPU_QuadU isn't used on all targets, but there's no harm in defining the typedef anyway. It only needs to be guarded by CONFIG_SOFTFLOAT, because softfloat-native doesn't have a float128 type. This avoids the need for every new target which uses CPU_QuadU to add itself to an #ifdef in what ought to be target-agnostic code.

---
Noticed this one as a result of the s390 support patches; seems like a minor but worthwhile cleanup to me...

 cpu-all.h |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
cpu-all.h +2 -3
index 4cc445f..dc0f2f0 100644
@@ -138,11 +138,10 @@ typedef union {
     uint64_t ll;
 } CPU_DoubleU;
 
-#if defined(TARGET_SPARC) || defined(TARGET_S390X)
+#if defined(CONFIG_SOFTFLOAT)
 typedef union {
     float128 q;
-#if defined(HOST_WORDS_BIGENDIAN) \
-    || (defined(__arm__) && !defined(__VFP_FP__) && !defined(CONFIG_SOFTFLOAT))
+#if defined(HOST_WORDS_BIGENDIAN)
     struct {
         uint32_t upmost;
         uint32_t upper;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 7 lines · Peter Maydell

CPU_QuadU isn't used on all targets, but there's no harm in defining the typedef anyway. It only needs to be guarded by CONFIG_SOFTFLOAT, because softfloat-native doesn't have a float128 type. This avoids the need for every new target which uses CPU_QuadU to add itself to an #ifdef in what ought to be target-agnostic code.

I don't really know my way around FP, but from here it looks good :). Not sure about the arm part, but I trust Peter on that one ;).

Alex

#2 lore raw
Quoted 8 lines · Alexander Graf
Quoted 7 lines · Peter Maydell

CPU_QuadU isn't used on all targets, but there's no harm in defining the typedef anyway. It only needs to be guarded by CONFIG_SOFTFLOAT, because softfloat-native doesn't have a float128 type. This avoids the need for every new target which uses CPU_QuadU to add itself to an #ifdef in what ought to be target-agnostic code.

Quoted 4 lines
Quoted 1 line

I don't really know my way around FP, but from here it looks good :). Not sure about the arm part, but I trust Peter on that one ;).

The __arm__ part of the ifdef was a voodoo-copy from the CPU_DoubleU typedef, where it actually does matter if you're building a softfloat-native target on an ARM host which uses the ancient FPA floating point ABI (as the comment says, although ARM is generally little-endian doubles are stored in memory in big-endian order under FPA; the more modern VFP has them little-endian). This ifdef condition was meaningless for CPU_QuadU (because FPA didn't have a 128 bit native float type for the type to try to be compatible with) and could never have kicked in anyhow because we wouldn't have compiled unless CONFIG_SOFTFLOAT was defined.

-- PMM

#3 lore raw
In reply to Peter Maydell
Quoted 6 lines · Peter Maydell

CPU_QuadU isn't used on all targets, but there's no harm in defining the typedef anyway. It only needs to be guarded by CONFIG_SOFTFLOAT, because softfloat-native doesn't have a float128 type. This avoids the need for every new target which uses CPU_QuadU to add itself to an #ifdef in what ought to be target-agnostic code.

Quoted 7 lines

---
Noticed this one as a result of the s390 support patches; seems like a minor but worthwhile cleanup to me...

 cpu-all.h |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Thanks, applied.

Quoted 23 lines
cpu-all.h +2 -3
index 4cc445f..dc0f2f0 100644
@@ -138,11 +138,10 @@ typedef union {
     uint64_t ll;
 } CPU_DoubleU;
 
-#if defined(TARGET_SPARC) || defined(TARGET_S390X)
+#if defined(CONFIG_SOFTFLOAT)
 typedef union {
     float128 q;
-#if defined(HOST_WORDS_BIGENDIAN) \
-    || (defined(__arm__) && !defined(__VFP_FP__) && !defined(CONFIG_SOFTFLOAT))
+#if defined(HOST_WORDS_BIGENDIAN)
     struct {
         uint32_t upmost;
         uint32_t upper;
Signature · 1 line
1.7.1
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#4 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

CPU_QuadU isn't used on all targets, but there's no harm in defining the typedef anyway. It only needs to be guarded by CONFIG_SOFTFLOAT, because softfloat-native doesn't have a float128 type. This avoids the need for every new target which uses CPU_QuadU to add itself to an #ifdef in what ought to be target-agnostic code.

---
Noticed this one as a result of the s390 support patches; seems like a minor but worthwhile cleanup to me...

Sorry for the late comment, but I saw this rebasing my patchset on master...

cpu-all.h typedef union { · line 141

Quoted 13 lines
 cpu-all.h |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
cpu-all.h +1 -1
index 4cc445f..dc0f2f0 100644
@@ -138,11 +138,10 @@ typedef union {
     uint64_t ll;
 } CPU_DoubleU;
 
-#if defined(TARGET_SPARC) || defined(TARGET_S390X)
+#if defined(CONFIG_SOFTFLOAT)

Why don't you use "#if defined(FLOAT128)" ?

Quoted 8 lines
cpu-all.h +1 -2
 typedef union {
     float128 q;
-#if defined(HOST_WORDS_BIGENDIAN) \
-    || (defined(__arm__) && !defined(__VFP_FP__) && !defined(CONFIG_SOFTFLOAT))
+#if defined(HOST_WORDS_BIGENDIAN)
     struct {
         uint32_t upmost;
         uint32_t upper;
Signature · 3 lines
--------------------- [email protected] ----------------------
"Tout ce qui est impossible reste à accomplir"    Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard
#5 lore raw
Quoted 5 lines · Laurent Vivier

cpu-all.h typedef union { · line 141

Quoted 2 lines · Peter Maydell
cpu-all.h +1 -1
-#if defined(TARGET_SPARC) || defined(TARGET_S390X)
+#if defined(CONFIG_SOFTFLOAT)

Why don't you use "#if defined(FLOAT128)" ?

I did consider that, but I felt FLOAT128 was a softfloat-internal macro rather than part of the API softfloat provides to the rest of qemu.

-- PMM

#6 lore raw
Quoted 10 lines · Peter Maydell
Quoted 5 lines · Laurent Vivier

cpu-all.h typedef union { · line 141

Quoted 2 lines · Peter Maydell
cpu-all.h +1 -1
-#if defined(TARGET_SPARC) || defined(TARGET_S390X)
+#if defined(CONFIG_SOFTFLOAT)

Why don't you use "#if defined(FLOAT128)" ?

I did consider that, but I felt FLOAT128 was a softfloat-internal macro rather than part of the API softfloat provides to the rest of qemu.

But, for instance, "#ifdef FLOATX80" is used in target-i386/cpu.h and target-i386/op_helper.c.

Regards,
Laurent

Signature · 3 lines
--------------------- [email protected] ----------------------
"Tout ce qui est impossible reste à accomplir"    Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard
#7 lore raw
Quoted 8 lines · Laurent Vivier
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Laurent Vivier

cpu-all.h typedef union { · line 141

Quoted 2 lines · Peter Maydell
cpu-all.h +1 -1
-#if defined(TARGET_SPARC) || defined(TARGET_S390X)
+#if defined(CONFIG_SOFTFLOAT)

Why don't you use "#if defined(FLOAT128)" ?

Quoted 6 lines
Quoted 3 lines

I did consider that, but I felt FLOAT128 was a softfloat-internal macro rather than part of the API softfloat provides to the rest of qemu.

But, for instance, "#ifdef FLOATX80" is used in target-i386/cpu.h and target-i386/op_helper.c.

Those uses seem conceptually wrong to me: either a target needs 80 bit floats, or it doesn't. It shouldn't behave differently depending on what host it was compiled on. However this is really just legacy of the fact that target-i386 is still compiled with softfloat-native rather than proper softfloat.

Personally I would also delete the FLOAT128 ifdefs in target-ppc since we always compile with softfloat now.

However I don't feel very strongly about any of this; mostly I just wanted to get rid of the target and host specific ifdeffery.

-- PMM