octave-maintainers
[Top][All Lists]
Advanced

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

RE: MSVC compiler support [patch 22]: mx-op-defs additional macros


From: John W. Eaton
Subject: RE: MSVC compiler support [patch 22]: mx-op-defs additional macros
Date: Fri, 27 Oct 2006 20:13:59 -0400

On 27-Oct-2006, address@hidden wrote:

| > Maybe I've missed something, but I don't see any places in your
| > patches where these new macros are used.
|  
| You're right. Those macros are expected to be used in the generated
| mx-* files. This requires hacking mk-ops.awk and mx-ops, which I
| didn't do yet, such that those additional macros are used for the
| problematic files (those that make MSVC to crash). For the time being,
| I have a patch locally, which I apply after running mk-ops.awk. This
| patch replaces the regular macros with the new ones.
|  
| Maybe I could send you the patch, such that you see where the problems
| are. Not being a awk expert, I'd prefer not to hack mk-ops.awk and mx-ops
| myself.

OK, here are the changes I checked in.  I'm not sure it was necessary
to handle both the ND x scalar and scalar x ND cases, but I did both.

Thanks,

jwe


liboctave/ChangeLog:

2006-10-26  Michael Goffioul  <address@hidden>

        * mx-op-defs.h (NDS_CMP_OP1, NDS_CMP_OPS1, NDS_CMP_OP2,
        NDS_CMP_OPS2): New macros.

2006-10-26  John W. Eaton  <address@hidden>

        * mx-ops (core-type): New field for integer types.
        * mk-ops.awk: Handle core-type for integer comparison ops.


Index: liboctave/mk-ops.awk
===================================================================
RCS file: /cvs/octave/liboctave/mk-ops.awk,v
retrieving revision 1.6
diff -u -u -r1.6 mk-ops.awk
--- liboctave/mk-ops.awk        24 Sep 2004 03:22:23 -0000      1.6
+++ liboctave/mk-ops.awk        27 Oct 2006 22:23:18 -0000
@@ -26,8 +26,11 @@
     {
       ntypes++;
 
-      if (NF == 6)
+      if (NF == 6 || NF == 7)
         {
+         if (NF == 7)
+           core_type[ntypes] = $7;
+
           scalar_zero_val[ntypes] = $6;
           fwd_decl_ok[ntypes] = $5 == "YES";
           header[ntypes] = $4 == "NONE" ? "" : $4;
@@ -98,6 +101,9 @@
          lhs_type = type[lhs_num];
           rhs_type = type[rhs_num];
 
+         lhs_core_type = core_type[lhs_num];
+         rhs_core_type = core_type[rhs_num];
+
          result_scalar_zero_val = scalar_zero_val[result_num];
           lhs_scalar_zero_val = scalar_zero_val[lhs_num];
           rhs_scalar_zero_val = scalar_zero_val[rhs_num];
@@ -196,8 +202,38 @@
             }
 
           if (cmp_ops)
-            printf ("%s%s_CMP_OPS (%s, %s, %s, %s)\n", lhs_class, rhs_class,
-                   lhs_type, lhs_conv, rhs_type, rhs_conv) >> cc_file
+           {
+             if (lhs_class == "S" || rhs_class == "S")
+               {
+                 if (lhs_core_type)
+                   {
+                     if (rhs_core_type)
+                       printf ("%s%s_CMP_OPS2 (%s, %s, %s, %s, %s, %s)\n",
+                               lhs_class, rhs_class, lhs_type, lhs_conv,
+                               rhs_type, rhs_conv,
+                               lhs_core_type, rhs_core_type) >> cc_file
+                     else
+                       printf ("%s%s_CMP_OPS1 (%s, %s, %s, %s, %s)\n",
+                               lhs_class, rhs_class, lhs_type, lhs_conv,
+                               rhs_type, rhs_conv, lhs_core_type) >> cc_file
+                   }
+                 else
+                   {
+                     if (rhs_core_type)
+                       printf ("%s%s_CMP_OPS1 (%s, %s, %s, %s, %s)\n",
+                               lhs_class, rhs_class, lhs_type, lhs_conv,
+                               rhs_type, rhs_conv, rhs_core_type) >> cc_file
+                     else
+                       printf ("%s%s_CMP_OPS (%s, %s, %s, %s)\n",
+                               lhs_class, rhs_class, lhs_type, lhs_conv,
+                               rhs_type, rhs_conv) >> cc_file
+                   }
+               }
+             else
+               printf ("%s%s_CMP_OPS (%s, %s, %s, %s)\n",
+                       lhs_class, rhs_class, lhs_type, lhs_conv,
+                       rhs_type, rhs_conv) >> cc_file
+           }
 
           if (bool_ops)
             printf ("%s%s_BOOL_OPS2 (%s, %s, %s, %s)\n", lhs_class, rhs_class,
Index: liboctave/mx-op-defs.h
===================================================================
RCS file: /cvs/octave/liboctave/mx-op-defs.h,v
retrieving revision 1.13
diff -u -u -r1.13 mx-op-defs.h
--- liboctave/mx-op-defs.h      27 Oct 2006 01:45:56 -0000      1.13
+++ liboctave/mx-op-defs.h      27 Oct 2006 22:23:18 -0000
@@ -541,6 +541,54 @@
   NDS_CMP_OP (mx_el_eq, ==, ND,    , S,   ) \
   NDS_CMP_OP (mx_el_ne, !=, ND,    , S,   )
 
+#define NDS_CMP_OP1(F, OP, ND, NDC, S, SC, SPEC) \
+  boolNDArray \
+  F (const ND& m, const S& s) \
+  { \
+    boolNDArray r; \
+ \
+    int len = m.length (); \
+ \
+    r.resize (m.dims ()); \
+ \
+    for (int i = 0; i < len; i++) \
+      r.elem(i) = operator OP <SPEC> (NDC (m.elem(i)), SC (s)); \
+ \
+    return r; \
+  }
+
+#define NDS_CMP_OPS1(ND, NDC, S, SC, SPEC) \
+  NDS_CMP_OP1 (mx_el_lt, <,  ND, NDC, S, SC, SPEC) \
+  NDS_CMP_OP1 (mx_el_le, <=, ND, NDC, S, SC, SPEC) \
+  NDS_CMP_OP1 (mx_el_ge, >=, ND, NDC, S, SC, SPEC) \
+  NDS_CMP_OP1 (mx_el_gt, >,  ND, NDC, S, SC, SPEC) \
+  NDS_CMP_OP1 (mx_el_eq, ==, ND,    , S,   , SPEC) \
+  NDS_CMP_OP1 (mx_el_ne, !=, ND,    , S,   , SPEC)
+
+#define NDS_CMP_OP2(F, OP, ND, NDC, S, SC, SPEC1, SPEC2) \
+  boolNDArray \
+  F (const ND& m, const S& s) \
+  { \
+    boolNDArray r; \
+ \
+    int len = m.length (); \
+ \
+    r.resize (m.dims ()); \
+ \
+    for (int i = 0; i < len; i++) \
+      r.elem(i) = operator OP <SPEC1,SPEC2> (NDC (m.elem(i)), SC (s)); \
+ \
+    return r; \
+  }
+
+#define NDS_CMP_OPS2(ND, NDC, S, SC, SPEC1, SPEC2) \
+  NDS_CMP_OP2 (mx_el_lt, <,  ND, NDC, S, SC, SPEC1, SPEC2) \
+  NDS_CMP_OP2 (mx_el_le, <=, ND, NDC, S, SC, SPEC1, SPEC2) \
+  NDS_CMP_OP2 (mx_el_ge, >=, ND, NDC, S, SC, SPEC1, SPEC2) \
+  NDS_CMP_OP2 (mx_el_gt, >,  ND, NDC, S, SC, SPEC1, SPEC2) \
+  NDS_CMP_OP2 (mx_el_eq, ==, ND,    , S,   , SPEC1, SPEC2) \
+  NDS_CMP_OP2 (mx_el_ne, !=, ND,    , S,   , SPEC1, SPEC2)
+
 #define NDS_BOOL_OP_DECLS(ND, S) \
   NDBOOL_OP_DECL (mx_el_and, ND, S); \
   NDBOOL_OP_DECL (mx_el_or,  ND, S);
@@ -636,6 +684,54 @@
   SND_CMP_OP (mx_el_eq, ==, S,   , ND,    ) \
   SND_CMP_OP (mx_el_ne, !=, S,   , ND,    )
 
+#define SND_CMP_OP1(F, OP, S, SC, ND, NDC, SPEC) \
+  boolNDArray \
+  F (const S& s, const ND& m) \
+  { \
+    boolNDArray r; \
+ \
+    int len = m.length (); \
+ \
+    r.resize (m.dims ()); \
+ \
+    for (int i = 0; i < len; i++) \
+      r.elem(i) = operator OP <SPEC> (SC (s), NDC (m.elem(i))); \
+ \
+    return r; \
+  }
+
+#define SND_CMP_OPS1(S, CS, ND, CND, SPEC) \
+  SND_CMP_OP1 (mx_el_lt, <,  S, CS, ND, CND, SPEC) \
+  SND_CMP_OP1 (mx_el_le, <=, S, CS, ND, CND, SPEC) \
+  SND_CMP_OP1 (mx_el_ge, >=, S, CS, ND, CND, SPEC) \
+  SND_CMP_OP1 (mx_el_gt, >,  S, CS, ND, CND, SPEC) \
+  SND_CMP_OP1 (mx_el_eq, ==, S,   , ND,    , SPEC) \
+  SND_CMP_OP1 (mx_el_ne, !=, S,   , ND,    , SPEC)
+
+#define SND_CMP_OP2(F, OP, S, SC, ND, NDC, SPEC1, SPEC2) \
+  boolNDArray \
+  F (const S& s, const ND& m) \
+  { \
+    boolNDArray r; \
+ \
+    int len = m.length (); \
+ \
+    r.resize (m.dims ()); \
+ \
+    for (int i = 0; i < len; i++) \
+      r.elem(i) = operator OP <SPEC1, SPEC2> (SC (s), NDC (m.elem(i))); \
+ \
+    return r; \
+  }
+
+#define SND_CMP_OPS2(S, CS, ND, CND, SPEC1, SPEC2) \
+  SND_CMP_OP2 (mx_el_lt, <,  S, CS, ND, CND, SPEC1, SPEC2) \
+  SND_CMP_OP2 (mx_el_le, <=, S, CS, ND, CND, SPEC1, SPEC2) \
+  SND_CMP_OP2 (mx_el_ge, >=, S, CS, ND, CND, SPEC1, SPEC2) \
+  SND_CMP_OP2 (mx_el_gt, >,  S, CS, ND, CND, SPEC1, SPEC2) \
+  SND_CMP_OP2 (mx_el_eq, ==, S,   , ND,    , SPEC1, SPEC2) \
+  SND_CMP_OP2 (mx_el_ne, !=, S,   , ND,    , SPEC1, SPEC2)
+
 #define SND_BOOL_OP_DECLS(S, ND) \
   NDBOOL_OP_DECL (mx_el_and, S, ND); \
   NDBOOL_OP_DECL (mx_el_or,  S, ND);
Index: liboctave/mx-ops
===================================================================
RCS file: /cvs/octave/liboctave/mx-ops,v
retrieving revision 1.6
diff -u -u -r1.6 mx-ops
--- liboctave/mx-ops    24 Sep 2004 03:22:23 -0000      1.6
+++ liboctave/mx-ops    27 Oct 2006 22:23:18 -0000
@@ -1,6 +1,6 @@
 # types
 #
-# key typename object-type header fwd-decl-ok scalar-zero
+# key typename object-type header fwd-decl-ok scalar-zero core-type
 #
 # object-type is one of
 #
@@ -9,6 +9,9 @@
 #   DM: diagonal matrix
 #   ND: N-d array
 #
+# core-type is only used for the octave_int types, and is the template
+# parameter: octave_int8 is octave_int<int8_t>
+#
 x NONE NONE NONE NO 0
 b bool S NONE NO false
 bm boolMatrix ND boolMatrix.h YES false
@@ -21,22 +24,22 @@
 m Matrix M dMatrix.h YES 0.0
 nda NDArray ND dNDArray.h YES 0.0
 s double S NONE NO 0.0
-i8 octave_int8 S oct-inttypes.h YES octave_int8(0)
-ui8 octave_uint8 S oct-inttypes.h YES octave_uint8(0)
-i16 octave_int16 S oct-inttypes.h YES octave_int16(0)
-ui16 octave_uint16 S oct-inttypes.h YES octave_uint16(0)
-i32 octave_int32 S oct-inttypes.h YES octave_int32(0)
-ui32 octave_uint32 S oct-inttypes.h YES octave_uint32(0)
-i64 octave_int64 S oct-inttypes.h YES octave_int64(0)
-ui64 octave_uint64 S oct-inttypes.h YES octave_uint64(0)
-i8nda int8NDArray ND int8NDArray.h YES octave_int8(0)
-ui8nda uint8NDArray ND uint8NDArray.h YES octave_uint8(0)
-i16nda int16NDArray ND int16NDArray.h YES octave_int16(0)
-ui16nda uint16NDArray ND uint16NDArray.h YES octave_uint16(0)
-i32nda int32NDArray ND int32NDArray.h YES octave_int32(0)
-ui32nda uint32NDArray ND uint32NDArray.h YES octave_uint32(0)
-i64nda int64NDArray ND int64NDArray.h YES octave_int64(0)
-ui64nda uint64NDArray ND uint64NDArray.h YES octave_uint64(0)
+i8 octave_int8 S oct-inttypes.h YES octave_int8(0) int8_t
+ui8 octave_uint8 S oct-inttypes.h YES octave_uint8(0) uint8_t
+i16 octave_int16 S oct-inttypes.h YES octave_int16(0) int16_t
+ui16 octave_uint16 S oct-inttypes.h YES octave_uint16(0) uint16_t
+i32 octave_int32 S oct-inttypes.h YES octave_int32(0) int32_t
+ui32 octave_uint32 S oct-inttypes.h YES octave_uint32(0) uint32_t
+i64 octave_int64 S oct-inttypes.h YES octave_int64(0) int64_t
+ui64 octave_uint64 S oct-inttypes.h YES octave_uint64(0) uint64_t
+i8nda int8NDArray ND int8NDArray.h YES octave_int8(0) int8_t
+ui8nda uint8NDArray ND uint8NDArray.h YES octave_uint8(0) uint8_t
+i16nda int16NDArray ND int16NDArray.h YES octave_int16(0) int16_t
+ui16nda uint16NDArray ND uint16NDArray.h YES octave_uint16(0) uint16_t
+i32nda int32NDArray ND int32NDArray.h YES octave_int32(0) int32_t
+ui32nda uint32NDArray ND uint32NDArray.h YES octave_uint32(0) uint32_t
+i64nda int64NDArray ND int64NDArray.h YES octave_int64(0) int64_t
+ui64nda uint64NDArray ND uint64NDArray.h YES octave_uint64(0) uint64_t
 # ops
 # result_t lhs_t rhs_t op-type lhs_conv rhs_conv headers ...
 #

reply via email to

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