diff mbox

[v4,1/4] target-tilegx: Add floating point shared functions

Message ID 1450907315-10135-2-git-send-email-chengang@emindsoft.com.cn
State New
Headers show

Commit Message

Chen Gang Dec. 23, 2015, 9:48 p.m. UTC
From: Chen Gang <chengang@emindsoft.com.cn>

They are used by fsingle and fdouble helpers.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 target-tilegx/helper-fshared.c | 22 +++++++++++++++++
 target-tilegx/helper-fshared.h | 55 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 target-tilegx/helper-fshared.c
 create mode 100644 target-tilegx/helper-fshared.h

Comments

Richard Henderson Dec. 23, 2015, 10:51 p.m. UTC | #1
On 12/23/2015 01:48 PM, chengang@emindsoft.com.cn wrote:
> +extern float_status fp_status;

No.  Locally declared in e.g. main_calc.


r~
Chen Gang Dec. 24, 2015, 3:38 p.m. UTC | #2
On 12/24/15 06:51, Richard Henderson wrote:
> On 12/23/2015 01:48 PM, chengang@emindsoft.com.cn wrote:
>> +extern float_status fp_status;
> 
> No.  Locally declared in e.g. main_calc.
> 

OK, thanks. Since fp_status need to be initialized to be 0, so I will
declared it statically, too (need we consider about thread safe for it?
I guess not).


Thanks.
Richard Henderson Dec. 24, 2015, 8:01 p.m. UTC | #3
On 12/24/2015 07:38 AM, Chen Gang wrote:
>
> On 12/24/15 06:51, Richard Henderson wrote:
>> On 12/23/2015 01:48 PM, chengang@emindsoft.com.cn wrote:
>>> +extern float_status fp_status;
>>
>> No.  Locally declared in e.g. main_calc.
>>
>
> OK, thanks. Since fp_status need to be initialized to be 0, so I will
> declared it statically, too (need we consider about thread safe for it?
> I guess not).

While qemu is not currently thread-safe, there's work going on to make that 
happen.  There is no need to exacerbate the problem.

Also, I think using an on-stack automatic variable, initialized each time, 
emphasizes the fact there there is no state that is preserved across operations.

This should really be as simple as

   float_status fp_status = {
     .float_rounding_mode = float_round_nearest_even
   };

(I realize float_round_nearest_even is *also* zero, but humor me.  At least the 
other members are either flags or booleans.)


r~
Chen Gang Dec. 25, 2015, 1:05 p.m. UTC | #4
On 12/25/15 04:01, Richard Henderson wrote:
> On 12/24/2015 07:38 AM, Chen Gang wrote:
>>
>> OK, thanks. Since fp_status need to be initialized to be 0, so I will
>> declared it statically, too (need we consider about thread safe for it?
>> I guess not).
> 
> While qemu is not currently thread-safe, there's work going on to make that happen.  There is no need to exacerbate the problem.
> 

OK, thanks.

> Also, I think using an on-stack automatic variable, initialized each time, emphasizes the fact there there is no state that is preserved across operations.
> 
> This should really be as simple as
> 
>   float_status fp_status = {
>     .float_rounding_mode = float_round_nearest_even
>   };
> 
> (I realize float_round_nearest_even is *also* zero, but humor me.  At least the other members are either flags or booleans.)
> 

OK, thanks.
diff mbox

Patch

diff --git a/target-tilegx/helper-fshared.c b/target-tilegx/helper-fshared.c
new file mode 100644
index 0000000..bad1c9a
--- /dev/null
+++ b/target-tilegx/helper-fshared.c
@@ -0,0 +1,22 @@ 
+/*
+ *  TILE-Gx virtual Floating point shared functions
+ *
+ *  Copyright (c) 2015 Chen Gang
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "fpu/softfloat.h"
+
+float_status fp_status;
diff --git a/target-tilegx/helper-fshared.h b/target-tilegx/helper-fshared.h
new file mode 100644
index 0000000..5f4926e
--- /dev/null
+++ b/target-tilegx/helper-fshared.h
@@ -0,0 +1,55 @@ 
+/*
+ *  TILE-Gx virtual Floating point shared functions
+ *
+ *  Copyright (c) 2015 Chen Gang
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+static inline uint64_t create_fsfd_flag_un(void)
+{
+    return 1 << 25;
+}
+
+static inline uint64_t create_fsfd_flag_lt(void)
+{
+    return 1 << 26;
+}
+
+static inline uint64_t create_fsfd_flag_le(void)
+{
+    return 1 << 27;
+}
+
+static inline uint64_t create_fsfd_flag_gt(void)
+{
+    return 1 << 28;
+}
+
+static inline uint64_t create_fsfd_flag_ge(void)
+{
+    return 1 << 29;
+}
+
+static inline uint64_t create_fsfd_flag_eq(void)
+{
+    return 1 << 30;
+}
+
+static inline uint64_t create_fsfd_flag_ne(void)
+{
+    return 1ULL << 31;
+}
+
+extern float_status fp_status;