public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* [commit] fix nan handling
@ 2010-09-01 14:14 Doug Evans
  0 siblings, 0 replies; only message in thread
From: Doug Evans @ 2010-09-01 14:14 UTC (permalink / raw)
  To: cgen

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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-30 16:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-01 14:14 [commit] fix nan handling Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).