This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


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

[RFA] Patch to sim/common/cgen-ops.h


I'd like to submit this patch for comments/review before committing
it.  In particular, I am of two minds about:

     * the way to handle out-of-range arguments to the SUBWORD
       functions.  Perhaps it's okay to use assert(), since we're
       wasting a few cycles already by doing the test.

     * whether it makes sense to join two SFs into a DF.

Thoughts?


2000-11-16  Ben Elliston  <bje@redhat.com>

	* cgen-ops.h (SUBBI): New macro.
	(SUBWORDSIQI, SUBWORDSIHI, SUBWORDDIHI, SUBWORDDFSF): New functions.
	(SUBWORDSIUQI, SUBWORDDIUQI): Likewise.
	(JOINSFDF): Likewise.

--- cgen-ops.h	2000/06/06 04:06:55	1.16
+++ cgen-ops.h	2000/11/16 05:59:29
@@ -39,6 +39,7 @@
 #define ANDIF(x, y) ((x) && (y))
 #define ORIF(x, y) ((x) || (y))
 
+#define SUBBI(x, y) ((x) - (y))
 #define ANDBI(x, y) ((x) & (y))
 #define ORBI(x, y) ((x) | (y))
 #define XORBI(x, y) ((x) ^ (y))
@@ -308,6 +309,42 @@
   return x.out;
 }
 
+SEMOPS_INLINE QI
+SUBWORDSIQI (SI in, int byte)
+{
+  if (byte < 0 || byte > 3)
+    return -1;
+  else
+    return (UQI) (in >> (8 * (3 - byte)));
+}
+
+SEMOPS_INLINE UQI
+SUBWORDSIUQI (SI in, int byte)
+{
+  if (byte < 0 || byte > 3)
+    return -1;
+  else
+    return (UQI) (in >> (8 * (3 - byte)));
+}
+
+SEMOPS_INLINE HI
+SUBWORDDIHI (DI in, int word)
+{
+  if (word < 0 || word > 3)
+    return -1;
+  else
+    return (UHI) (in >> (16 * (3 - word)));
+}
+
+SEMOPS_INLINE HI
+SUBWORDSIHI (SI in, int word)
+{
+  if (word == 0)
+    return (USI) in >> 16;
+  else
+    return in;
+}
+
 SEMOPS_INLINE SI
 SUBWORDSFSI (SF in)
 {
@@ -316,6 +353,15 @@
   return x.out;
 }
 
+SEMOPS_INLINE UQI
+SUBWORDDIUQI (DI in, int byte)
+{
+  if (byte < 0 || byte > 7)
+    return -1;
+  else
+    return (UQI) (in >> (8 * (7 - byte)));
+}
+
 SEMOPS_INLINE SI
 SUBWORDDISI (DI in, int word)
 {
@@ -325,6 +371,16 @@
     return in;
 }
 
+SEMOPS_INLINE SF
+SUBWORDDFSF (DF in, int word)
+{
+  /* Note: typedef UDI DF; */
+  if (word == 0)
+    return (UDI) in >> 32;
+  else
+    return in;
+}
+
 SEMOPS_INLINE SI
 SUBWORDDFSI (DF in, int word)
 {
@@ -363,6 +419,17 @@
 }
 
 SEMOPS_INLINE DF
+JOINSFDF (SF x0, SF x1)
+{
+  union { SF in[2]; DF out; } x;
+  if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+    x.in[0] = x0, x.in[1] = x1;
+  else
+    x.in[1] = x0, x.in[0] = x1;
+  return x.out;
+}
+
+SEMOPS_INLINE DF
 JOINSIDF (SI x0, SI x1)
 {
   union { SI in[2]; DF out; } x;
@@ -397,17 +464,25 @@
 
 #else
 
-SF SUBWORDSISF (SI);
+QI SUBWORDSIQI (SI);
+HI SUBWORDSIHI (HI);
 SI SUBWORDSFSI (SF);
+SF SUBWORDSISF (SI);
+HI SUBWORDDIHI (DI, int);
 SI SUBWORDDISI (DI, int);
+SF SUBWORDDFSF (DF, int);
 SI SUBWORDDFSI (DF, int);
 SI SUBWORDXFSI (XF, int);
 SI SUBWORDTFSI (TF, int);
 
+UQI SUBWORDSIUQI (SI);
+UQI SUBWORDDIUQI (DI);
+
 DI JOINSIDI (SI, SI);
 DF JOINSIDF (SI, SI);
 XF JOINSIXF (SI, SI, SI);
 TF JOINSITF (SI, SI, SI, SI);
+DF JOINSFDF (SF, SF);
 
 #endif /* SUBWORD,JOIN */
 

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