diff mbox series

[08/57] rs6000: Add functions for matching types, part 2 of 3

Message ID eaa651085191c2c955b8a2aedf3b7f0ad303e652.1619537141.git.wschmidt@linux.ibm.com
State New
Headers show
Series Replace the Power target-specific built-in machinery | expand

Commit Message

Bill Schmidt April 27, 2021, 3:32 p.m. UTC
2021-04-02  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-gen-builtins.c (match_basetype): Implement.
---
 gcc/config/rs6000/rs6000-gen-builtins.c | 64 +++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

Comments

Segher Boessenkool May 21, 2021, 9:36 p.m. UTC | #1
On Tue, Apr 27, 2021 at 10:32:43AM -0500, Bill Schmidt via Gcc-patches wrote:

Oh, hrm, I deleted it all?  I guess there was nothing to complain about
^W^Wcomment on then!  Okay for trunk.  Thanks!


Segher
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index ac061d092e7..96e74e6048a 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -393,6 +393,70 @@  handle_pointer (typeinfo *typedata)
 static int
 match_basetype (typeinfo *typedata)
 {
+  consume_whitespace ();
+  int oldpos = pos;
+  char *token = match_identifier ();
+  if (!token)
+    {
+      (*diag) ("missing base type in return type at column %d\n", pos + 1);
+      return 0;
+    }
+
+  if (!strcmp (token, "char"))
+    typedata->base = BT_CHAR;
+  else if (!strcmp (token, "short"))
+    typedata->base = BT_SHORT;
+  else if (!strcmp (token, "int"))
+    typedata->base = BT_INT;
+  else if (!strcmp (token, "long"))
+    {
+      consume_whitespace ();
+      oldpos = pos;
+      char *mustbelongordbl = match_identifier ();
+      if (!mustbelongordbl)
+	typedata->base = BT_LONG;
+      else if (!strcmp (mustbelongordbl, "long"))
+	typedata->base = BT_LONGLONG;
+      else if (!strcmp (mustbelongordbl, "double"))
+	typedata->base = BT_LONGDOUBLE;
+      else
+	/* Speculatively accept "long" here and push back the token.
+	   This occurs when "long" is a return type and the next token
+	   is the function name.  */
+	{
+	  typedata->base = BT_LONG;
+	  pos = oldpos;
+	}
+    }
+  else if (!strcmp (token, "float"))
+    typedata->base = BT_FLOAT;
+  else if (!strcmp (token, "double"))
+    typedata->base = BT_DOUBLE;
+  else if (!strcmp (token, "__int128"))
+    typedata->base = BT_INT128;
+  else if (!strcmp (token, "_Float128"))
+    typedata->base = BT_FLOAT128;
+  else if (!strcmp (token, "bool"))
+    typedata->base = BT_BOOL;
+  /* A "string" is a special "const char *" -- we need it because it
+     cannot match either signed or unsigned char *.  */
+  else if (!strcmp (token, "string"))
+    typedata->base = BT_STRING;
+  else if (!strcmp (token, "_Decimal32"))
+    typedata->base = BT_DECIMAL32;
+  else if (!strcmp (token, "_Decimal64"))
+    typedata->base = BT_DECIMAL64;
+  else if (!strcmp (token, "_Decimal128"))
+    typedata->base = BT_DECIMAL128;
+  else if (!strcmp (token, "__ibm128"))
+    typedata->base = BT_IBM128;
+  else
+    {
+      (*diag) ("unrecognized base type at column %d\n", oldpos + 1);
+      return 0;
+    }
+
+  handle_pointer (typedata);
   return 1;
 }