This is the mail archive of the cgen@sourceware.org mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] fix nan handling


Hi.

I've committed this.

nan,qnan,snan return a BI mode value, thus using s-unop to generate
them is wrong.

2010-08-30  Doug Evans  <dje@sebabeach.org>

	* rtl-c.scm (s-float-predop): New function.
	(nan, qnan, snan): Call it.

Index: rtl-c.scm
===================================================================
RCS file: /cvs/src/src/cgen/rtl-c.scm,v
retrieving revision 1.31
diff -u -p -r1.31 rtl-c.scm
--- rtl-c.scm	25 Jan 2010 03:50:43 -0000	1.31
+++ rtl-c.scm	30 Aug 2010 16:47:24 -0000
@@ -828,6 +828,27 @@
 				"))"))))
 )
 
+;; Process fp predicates, e.g. nan, qnan, snan.
+;; SRC-MODE is the mode name of SRC.
+;; The result has mode BI.
+
+(define (s-float-predop estate name src-mode src)
+  (let* ((val (rtl-c-get estate src-mode src))
+	 (mode (cx:mode val))
+	 (sem-mode (rtx-sem-mode mode)))
+    ;; FIXME: Argument checking.
+
+    (if (not (mode-float? mode))
+	(estate-error estate "non floating-point mode" src-mode))
+
+    (cx:make (mode:lookup 'BI)
+	     (string-append "CGEN_CPU_FPU (current_cpu)->ops->"
+			    (string-downcase name)
+			    (string-downcase (obj:str-name sem-mode))
+			    " (CGEN_CPU_FPU (current_cpu), "
+			    (cx:c val) ")")))
+)
+
 ;; Integer mode conversions.
 ;; MODE is the mode name.
 
@@ -1749,13 +1770,13 @@
 )
 
 (define-fn nan (*estate* options mode s1)
-  (s-unop *estate* "NAN" #f mode s1)
+  (s-float-predop *estate* "NAN" mode s1)
 )
 (define-fn qnan (*estate* options mode s1)
-  (s-unop *estate* "QNAN" #f mode s1)
+  (s-float-predop *estate* "QNAN" mode s1)
 )
 (define-fn snan (*estate* options mode s1)
-  (s-unop *estate* "SNAN" #f mode s1)
+  (s-float-predop *estate* "SNAN" mode s1)
 )
 
 (define-fn min (*estate* options mode s1 s2)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]