[m-dev.] for review: add floating point support to .NET backend.

Tyson Dowd trd at cs.mu.OZ.AU
Fri Jan 19 16:52:57 AEDT 2001


Hi,

Another one I plan to commit to both branches.

===================================================================


Estimated hours taken: 1

Get floating point working in the .NET backend.

compiler/mlds_to_il.m:
	Implement the floating point operations.

runtime/mercury_il.il:
runtime/mercury_mcpp.cpp:
	Add code for boxing and unboxing floats.
	


Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.9
diff -u -r1.9 mlds_to_il.m
--- compiler/mlds_to_il.m	2001/01/17 00:52:28	1.9
+++ compiler/mlds_to_il.m	2001/01/19 00:06:36
@@ -1463,17 +1463,26 @@
 binaryop_to_il((>=), node([clt(signed), ldc(int32, i(0)), ceq])) --> [].
 
 	% Floating pointer operations.
-binaryop_to_il(float_plus, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_minus, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_times, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_divide, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_eq, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_ne, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_lt, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_gt, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_le, throw_unimplemented("floating point")) --> [].
-binaryop_to_il(float_ge, throw_unimplemented("floating point")) --> [].
-
+binaryop_to_il(float_plus, instr_node(I)) -->
+	{ I = add(nocheckoverflow, signed) }.
+binaryop_to_il(float_minus, instr_node(I)) -->
+	{ I = sub(nocheckoverflow, signed) }.
+binaryop_to_il(float_times, instr_node(I)) -->
+	{ I = mul(nocheckoverflow, signed) }.
+binaryop_to_il(float_divide, instr_node(I)) -->
+	{ I = div(signed) }.
+binaryop_to_il(float_eq, instr_node(I)) -->
+	{ I = ceq }.
+binaryop_to_il(float_ne, node(Instrs)) --> 
+	{ Instrs = [
+		ceq, 
+		ldc(int32, i(0)),
+		ceq
+	] }.
+binaryop_to_il(float_lt, node([clt(signed)])) --> [].
+binaryop_to_il(float_gt, node([cgt(signed)])) --> [].
+binaryop_to_il(float_le, node([cgt(signed), ldc(int32, i(0)), ceq])) --> [].
+binaryop_to_il(float_ge, node([clt(signed), ldc(int32, i(0)), ceq])) --> [].
 
 %-----------------------------------------------------------------------------%
 %
Index: runtime/mercury_il.il
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_il.il,v
retrieving revision 1.2
diff -u -r1.2 mercury_il.il
--- runtime/mercury_il.il	2001/01/01 15:05:40	1.2
+++ runtime/mercury_il.il	2001/01/19 05:46:15
@@ -346,6 +346,13 @@
 	ret
 }
 
+.method static default class System.Object ToObject(float64 fval)
+{
+	ldarg fval
+	newobj instance void mercury.runtime.BoxedFloat::.ctor(float64)
+	ret
+}
+
 .method static default int32 ToInt32(class System.Object obj)
 {
 	ldarg obj
Index: runtime/mercury_mcpp.cpp
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_mcpp.cpp,v
retrieving revision 1.3
diff -u -r1.3 mercury_mcpp.cpp
--- runtime/mercury_mcpp.cpp	2001/01/09 23:30:21	1.3
+++ runtime/mercury_mcpp.cpp	2001/01/19 05:46:15
@@ -53,6 +53,10 @@
     {
         return x;
     }
+    static MR_Box ToObject(MR_Float x)
+    {
+        return ConvertImpl::ToObject(x);
+    }
 
 
     static MR_Char ToChar(MR_Box x)


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list