]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Introduce libcc1 version 1.
authorKeith Seitz <keiths@redhat.com>
Tue, 21 Feb 2017 21:32:57 +0000 (13:32 -0800)
committerKeith Seitz <keiths@redhat.com>
Tue, 21 Feb 2017 21:32:57 +0000 (13:32 -0800)
gdb/compile/compile-c-types.c
include/gcc-c-fe.def
include/gcc-c-interface.h
include/gcc-interface.h

index 22aee78deea010df131020e30622cdad0cfd675d..5ce4cdef06a9611b259c71dfcfc55593891b3280 100644 (file)
@@ -206,9 +206,15 @@ convert_enum (struct compile_c_instance *context, struct type *type)
   int i;
   struct gcc_c_context *ctx = C_CTX (context);
 
-  int_type = ctx->c_ops->int_type (ctx,
-                                  TYPE_UNSIGNED (type),
-                                  TYPE_LENGTH (type));
+  if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+    int_type = ctx->c_ops->int_type (ctx,
+                                    TYPE_UNSIGNED (type),
+                                    TYPE_LENGTH (type),
+                                    NULL);
+  else
+    int_type = ctx->c_ops->int_type_v0 (ctx,
+                                       TYPE_UNSIGNED (type),
+                                       TYPE_LENGTH (type));
 
   result = ctx->c_ops->build_enum_type (ctx, int_type);
   for (i = 0; i < TYPE_NFIELDS (type); ++i)
@@ -256,9 +262,22 @@ convert_func (struct compile_c_instance *context, struct type *type)
 static gcc_type
 convert_int (struct compile_c_instance *context, struct type *type)
 {
-  return C_CTX (context)->c_ops->int_type (C_CTX (context),
-                                          TYPE_UNSIGNED (type),
-                                          TYPE_LENGTH (type));
+  if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+    {
+      if (TYPE_NOSIGN (type))
+       {
+         gdb_assert (TYPE_LENGTH (type) == 1);
+         return C_CTX (context)->c_ops->char_type (C_CTX (context));
+       }
+      return C_CTX (context)->c_ops->int_type (C_CTX (context),
+                                              TYPE_UNSIGNED (type),
+                                              TYPE_LENGTH (type),
+                                              TYPE_NAME (type));
+    }
+  else
+    return C_CTX (context)->c_ops->int_type_v0 (C_CTX (context),
+                                               TYPE_UNSIGNED (type),
+                                               TYPE_LENGTH (type));
 }
 
 /* Convert a floating-point type to its gcc representation.  */
@@ -266,8 +285,13 @@ convert_int (struct compile_c_instance *context, struct type *type)
 static gcc_type
 convert_float (struct compile_c_instance *context, struct type *type)
 {
-  return C_CTX (context)->c_ops->float_type (C_CTX (context),
-                                            TYPE_LENGTH (type));
+  if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+    return C_CTX (context)->c_ops->float_type (C_CTX (context),
+                                              TYPE_LENGTH (type),
+                                              TYPE_NAME (type));
+  else
+    return C_CTX (context)->c_ops->float_type_v0 (C_CTX (context),
+                                                 TYPE_LENGTH (type));
 }
 
 /* Convert the 'void' type to its gcc representation.  */
index 09998ba67e75cdad8c08f3aa15d6837e2f73d748..acf1940c0122fbc3579bdc1dcedd23bb745365c9 100644 (file)
@@ -125,16 +125,18 @@ GCC_METHOD3 (gcc_type, build_function_type,
             const struct gcc_type_array *, /* Argument ARGUMENT_TYPES.  */
             int /* bool */)               /* Argument IS_VARARGS.  */
 
-/* Return an integer type with the given properties.  */
+/* Return an integer type with the given properties.
+   Deprecated in v1, use int_type instead.  */
 
-GCC_METHOD2 (gcc_type, int_type,
+GCC_METHOD2 (gcc_type, int_type_v0,
             int /* bool */,               /* Argument IS_UNSIGNED.  */
             unsigned long)                /* Argument SIZE_IN_BYTES.  */
 
-/* Return a floating point type with the given properties.  */
+/* Return a floating point type with the given properties.
+   Deprecated in v1, use float_type instead.  */
 
-GCC_METHOD1 (gcc_type, float_type,
-            unsigned long)                     /* Argument SIZE_IN_BYTES.  */
+GCC_METHOD1 (gcc_type, float_type_v0,
+            unsigned long)                /* Argument SIZE_IN_BYTES.  */
 
 /* Return the 'void' type.  */
 
@@ -195,3 +197,26 @@ GCC_METHOD5 (int /* bool */, build_constant,
 
 GCC_METHOD1 (gcc_type, error,
             const char *)               /* Argument MESSAGE.  */
+
+/* Return an integer type with the given properties.  If BUILTIN_NAME
+   is non-NULL, it must name a builtin integral type with the given
+   signedness and size, and that is the type that will be returned.  */
+
+GCC_METHOD3 (gcc_type, int_type,
+            int /* bool */,               /* Argument IS_UNSIGNED.  */
+            unsigned long,                /* Argument SIZE_IN_BYTES.  */
+            const char *)                 /* Argument BUILTIN_NAME.  */
+
+/* Return the 'char' type, a distinct type from both 'signed char' and
+   'unsigned char' returned by int_type.  */
+
+GCC_METHOD0 (gcc_type, char_type)
+
+/* Return a floating point type with the given properties.  If BUILTIN_NAME
+   is non-NULL, it must name a builtin integral type with the given
+   signedness and size, and that is the type that will be returned.  */
+
+GCC_METHOD2 (gcc_type, float_type,
+            unsigned long,                /* Argument SIZE_IN_BYTES.  */
+            const char *)                 /* Argument BUILTIN_NAME.  */
+
index 00ccbfb2a75e82f14cc864eb3b31303cedc7f477..e048c863070d6c90cc547a47b6f9e80f7b4a8f33 100644 (file)
@@ -41,7 +41,11 @@ struct gcc_c_context;
 
 enum gcc_c_api_version
 {
-  GCC_C_FE_VERSION_0 = 0
+  GCC_C_FE_VERSION_0 = 0,
+
+  /* Added char_type.  Added new version of int_type and float_type,
+     deprecated int_type_v0 and float_type_v0.  */
+  GCC_C_FE_VERSION_1 = 1
 };
 
 /* Qualifiers.  */
@@ -111,19 +115,6 @@ typedef gcc_address gcc_c_symbol_address_function (void *datum,
                                                   struct gcc_c_context *ctxt,
                                                   const char *identifier);
 
-/* An array of types used for creating a function type.  */
-
-struct gcc_type_array
-{
-  /* Number of elements.  */
-
-  int n_elements;
-
-  /* The elements.  */
-
-  gcc_type *elements;
-};
-
 /* The vtable used by the C front end.  */
 
 struct gcc_c_fe_vtable
@@ -146,7 +137,7 @@ struct gcc_c_fe_vtable
      provides the declaration.
 
      DATUM is an arbitrary piece of data that is passed back verbatim
-     to the callbakcs in requests.  */
+     to the callbacks in requests.  */
 
   void (*set_callbacks) (struct gcc_c_context *self,
                         gcc_c_oracle_function *binding_oracle,
index e3ffd18a75d78472554703b91362fb32184bff61..1dc3498e877b765e9e94862ce6bc14e407d81b99 100644 (file)
@@ -169,6 +169,20 @@ struct gcc_base_context
   const struct gcc_base_vtable *ops;
 };
 
+/* An array of types used for creating function types in multiple
+   languages.  */
+
+struct gcc_type_array
+{
+  /* Number of elements.  */
+
+  int n_elements;
+
+  /* The elements.  */
+
+  gcc_type *elements;
+};
+
 /* The name of the dummy wrapper function generated by gdb.  */
 
 #define GCC_FE_WRAPPER_FUNCTION "_gdb_expr"