[PATCH 06/28] rs6000: Add functions for matching types, part 2 of 3

Bill Schmidt wschmidt@linux.ibm.com
Wed Jun 17 19:46:29 GMT 2020


2020-06-17  Bill Schmidt  <wschmidt@linux.ibm.com>

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

diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c
index 56938de55f2..e38f3af9c7a 100644
--- a/gcc/config/rs6000/rs6000-gen-builtins.c
+++ b/gcc/config/rs6000/rs6000-gen-builtins.c
@@ -365,6 +365,55 @@ 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 ();
+      char *mustbelong = match_identifier ();
+      if (!mustbelong || strcmp (mustbelong, "long"))
+	{
+	  (*diag) ("incomplete 'long long' at column %d\n", oldpos + 1);
+	  return 0;
+	}
+      typedata->base = BT_LONGLONG;
+    }
+  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, "_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;
 }
 
-- 
2.17.1



More information about the Gcc-patches mailing list