qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] tests/tcg/i386: Introduce and use reg_t consistently


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 1/2] tests/tcg/i386: Introduce and use reg_t consistently
Date: Mon, 16 Jan 2023 09:23:08 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1

On 15/1/23 00:05, Richard Henderson wrote:
Define reg_t based on the actual register width.
Define the inlines using that type.  This will allow
input registers to 32-bit insns to be set to 64-bit
values on x86-64, which allows testing various edge cases.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
  tests/tcg/i386/test-i386-bmi2.c | 182 ++++++++++++++++----------------
  1 file changed, 93 insertions(+), 89 deletions(-)

diff --git a/tests/tcg/i386/test-i386-bmi2.c b/tests/tcg/i386/test-i386-bmi2.c
index 5fadf47510..3c3ef85513 100644
--- a/tests/tcg/i386/test-i386-bmi2.c
+++ b/tests/tcg/i386/test-i386-bmi2.c
@@ -3,34 +3,40 @@
  #include <stdint.h>
  #include <stdio.h>
+#ifdef __x86_64
+typedef uint64_t reg_t;
+#else
+typedef uint32_t reg_t;
+#endif
+
  #define insn1q(name, arg0)                                                    
       \
-static inline uint64_t name##q(uint64_t arg0)                                  
      \
+static inline reg_t name##q(reg_t arg0)                                        
      \
  {                                                                             
       \
-    uint64_t result64;                                                         
      \
+    reg_t result64;                                                            
      \
      asm volatile (#name "q   %1, %0" : "=r"(result64) : "rm"(arg0));          
       \
      return result64;                                                          
       \
  }
#define insn1l(name, arg0) \
-static inline uint32_t name##l(uint32_t arg0)                                  
      \
+static inline reg_t name##l(reg_t arg0)                                        
      \
  {                                                                             
       \
-    uint32_t result32;                                                         
      \
+    reg_t result32;                                                            
      \
      asm volatile (#name "l   %k1, %k0" : "=r"(result32) : "rm"(arg0));        
       \
      return result32;                                                          
       \
  }

Are the names 'result64/result32' still appropriate?

Otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]