true. If we don't match, return error_mark_node and leave
UNSUPPORTED_BUILTIN alone. */
-tree
-find_instance (bool *unsupported_builtin, ovlddata **instance,
+static tree
+find_instance (bool *unsupported_builtin, int *instance,
rs6000_gen_builtins instance_code,
rs6000_gen_builtins fcode,
tree *types, tree *args, int nargs)
{
- while (*instance && (*instance)->bifid != instance_code)
- *instance = (*instance)->next;
+ while (*instance != -1
+ && rs6000_instance_info[*instance].bifid != instance_code)
+ *instance = rs6000_instance_info[*instance].next;
- ovlddata *inst = *instance;
- gcc_assert (inst != NULL);
+ int inst = *instance;
+ gcc_assert (inst != -1);
/* It is possible for an instance to require a data type that isn't
- defined on this target, in which case inst->fntype will be NULL. */
- if (!inst->fntype)
+ defined on this target, in which case rs6000_instance_info_fntype[inst]
+ will be NULL. */
+ if (!rs6000_instance_info_fntype[inst])
return error_mark_node;
- tree fntype = rs6000_builtin_info[inst->bifid].fntype;
+ rs6000_gen_builtins bifid = rs6000_instance_info[inst].bifid;
+ tree fntype = rs6000_builtin_info_fntype[bifid];
tree argtype = TYPE_ARG_TYPES (fntype);
bool args_compatible = true;
if (args_compatible)
{
- if (rs6000_builtin_decl (inst->bifid, false) != error_mark_node
- && rs6000_builtin_is_supported (inst->bifid))
+ if (rs6000_builtin_decl (bifid, false) != error_mark_node
+ && rs6000_builtin_is_supported (bifid))
{
- tree ret_type = TREE_TYPE (inst->fntype);
+ tree ret_type = TREE_TYPE (rs6000_instance_info_fntype[inst]);
return altivec_build_resolved_builtin (args, nargs, fntype, ret_type,
- inst->bifid, fcode);
+ bifid, fcode);
}
else
*unsupported_builtin = true;
bool unsupported_builtin = false;
rs6000_gen_builtins instance_code;
bool supported = false;
- ovlddata *instance = rs6000_overload_info[adj_fcode].first_instance;
- gcc_assert (instance != NULL);
+ int instance = rs6000_overload_info[adj_fcode].first_instance;
+ gcc_assert (instance != -1);
/* Functions with no arguments can have only one overloaded instance. */
- gcc_assert (nargs > 0 || !instance->next);
+ gcc_assert (nargs > 0 || rs6000_instance_info[instance].next == -1);
/* Standard overload processing involves determining whether an instance
exists that is type-compatible with the overloaded function call. In
/* Standard overload processing. Look for an instance with compatible
parameter types. If it is supported in the current context, resolve
the overloaded call to that instance. */
- for (; instance != NULL; instance = instance->next)
+ for (; instance != -1; instance = rs6000_instance_info[instance].next)
{
+ tree fntype = rs6000_instance_info_fntype[instance];
+ rs6000_gen_builtins bifid = rs6000_instance_info[instance].bifid;
/* It is possible for an instance to require a data type that isn't
- defined on this target, in which case instance->fntype will be
+ defined on this target, in which case fntype will be
NULL. */
- if (!instance->fntype)
+ if (!fntype)
continue;
bool mismatch = false;
- tree nextparm = TYPE_ARG_TYPES (instance->fntype);
+ tree nextparm = TYPE_ARG_TYPES (fntype);
for (unsigned int arg_i = 0;
arg_i < nargs && nextparm != NULL;
if (mismatch)
continue;
- supported = rs6000_builtin_is_supported (instance->bifid);
- if (rs6000_builtin_decl (instance->bifid, false) != error_mark_node
+ supported = rs6000_builtin_is_supported (bifid);
+ if (rs6000_builtin_decl (bifid, false) != error_mark_node
&& supported)
{
- tree fntype = rs6000_builtin_info[instance->bifid].fntype;
- tree ret_type = TREE_TYPE (instance->fntype);
+ tree ret_type = TREE_TYPE (fntype);
+ fntype = rs6000_builtin_info_fntype[bifid];
return altivec_build_resolved_builtin (args, nargs, fntype,
- ret_type, instance->bifid,
- fcode);
+ ret_type, bifid, fcode);
}
else
{
{
/* Indicate that the instantiation of the overloaded builtin
name is not available with the target flags in effect. */
- rs6000_gen_builtins fcode = (rs6000_gen_builtins) instance->bifid;
+ rs6000_gen_builtins bifid = rs6000_instance_info[instance].bifid;
+ rs6000_gen_builtins fcode = (rs6000_gen_builtins) bifid;
rs6000_invalid_builtin (fcode);
/* Provide clarity of the relationship between the overload
and the instantiation. */
- const char *internal_name
- = rs6000_builtin_info[instance->bifid].bifname;
+ const char *internal_name = rs6000_builtin_info[bifid].bifname;
rich_location richloc (line_table, input_location);
inform (&richloc,
"overloaded builtin %qs is implemented by builtin %qs",
fprintf (header_file, "};\n\n");
fprintf (header_file, "#define PPC_MAXRESTROPNDS 3\n");
- fprintf (header_file, "struct GTY(()) bifdata\n");
+ fprintf (header_file, "struct bifdata\n");
fprintf (header_file, "{\n");
- fprintf (header_file, " const char *GTY((skip(\"\"))) bifname;\n");
- fprintf (header_file, " bif_enable GTY((skip(\"\"))) enable;\n");
- fprintf (header_file, " tree fntype;\n");
- fprintf (header_file, " insn_code GTY((skip(\"\"))) icode;\n");
- fprintf (header_file, " int nargs;\n");
- fprintf (header_file, " int bifattrs;\n");
- fprintf (header_file, " int restr_opnd[PPC_MAXRESTROPNDS];\n");
- fprintf (header_file, " restriction GTY((skip(\"\"))) restr[PPC_MAXRESTROPNDS];\n");
- fprintf (header_file, " int restr_val1[PPC_MAXRESTROPNDS];\n");
- fprintf (header_file, " int restr_val2[PPC_MAXRESTROPNDS];\n");
- fprintf (header_file, " const char *GTY((skip(\"\"))) attr_string;\n");
- fprintf (header_file, " rs6000_gen_builtins GTY((skip(\"\"))) assoc_bif;\n");
+ fprintf (header_file, " const char *bifname;\n");
+ fprintf (header_file, " bif_enable enable;\n");
+ fprintf (header_file, " insn_code icode;\n");
+ fprintf (header_file, " int nargs;\n");
+ fprintf (header_file, " int bifattrs;\n");
+ fprintf (header_file, " int restr_opnd[PPC_MAXRESTROPNDS];\n");
+ fprintf (header_file, " restriction restr[PPC_MAXRESTROPNDS];\n");
+ fprintf (header_file, " int restr_val1[PPC_MAXRESTROPNDS];\n");
+ fprintf (header_file, " int restr_val2[PPC_MAXRESTROPNDS];\n");
+ fprintf (header_file, " const char *attr_string;\n");
+ fprintf (header_file, " rs6000_gen_builtins assoc_bif;\n");
fprintf (header_file, "};\n\n");
fprintf (header_file, "#define bif_init_bit\t\t(0x00000001)\n");
fprintf (header_file, "\n");
fprintf (header_file,
- "extern GTY(()) bifdata rs6000_builtin_info[RS6000_BIF_MAX];\n\n");
+ "extern bifdata rs6000_builtin_info[RS6000_BIF_MAX];\n\n");
- fprintf (header_file, "struct GTY(()) ovlddata\n");
+ fprintf (header_file,
+ "extern GTY(()) tree rs6000_builtin_info_fntype[RS6000_BIF_MAX];\n\n");
+
+ fprintf (header_file, "struct ovlddata\n");
fprintf (header_file, "{\n");
- fprintf (header_file, " const char *GTY((skip(\"\"))) bifname;\n");
- fprintf (header_file, " rs6000_gen_builtins GTY((skip(\"\"))) bifid;\n");
- fprintf (header_file, " tree fntype;\n");
- fprintf (header_file, " ovlddata *GTY((skip(\"\"))) next;\n");
+ fprintf (header_file, " const char *bifname;\n");
+ fprintf (header_file, " rs6000_gen_builtins bifid;\n");
+ fprintf (header_file, " int next;\n");
fprintf (header_file, "};\n\n");
fprintf (header_file, "struct ovldrecord\n");
fprintf (header_file, "{\n");
fprintf (header_file, " const char *ovld_name;\n");
- fprintf (header_file, " ovlddata *first_instance;\n");
+ fprintf (header_file, " int first_instance;\n");
fprintf (header_file, "};\n\n");
fprintf (header_file,
- "extern GTY(()) ovlddata rs6000_instance_info[RS6000_INST_MAX];\n");
+ "extern ovlddata rs6000_instance_info[RS6000_INST_MAX];\n");
+ fprintf (header_file, "extern GTY(()) tree "
+ "rs6000_instance_info_fntype[RS6000_INST_MAX];\n");
fprintf (header_file, "extern ovldrecord rs6000_overload_info[];\n\n");
fprintf (header_file, "extern void rs6000_init_generated_builtins ();\n\n");
fprintf (init_file, "bifdata rs6000_builtin_info[RS6000_BIF_MAX] =\n");
fprintf (init_file, " {\n");
fprintf (init_file, " { /* RS6000_BIF_NONE: */\n");
- fprintf (init_file, " \"\", ENB_ALWAYS, 0, CODE_FOR_nothing, 0,\n");
+ fprintf (init_file, " \"\", ENB_ALWAYS, CODE_FOR_nothing, 0,\n");
fprintf (init_file, " 0, {0, 0, 0}, {RES_NONE, RES_NONE, RES_NONE},\n");
fprintf (init_file, " {0, 0, 0}, {0, 0, 0}, \"\", RS6000_BIF_NONE\n");
fprintf (init_file, " },\n");
bifp->proto.bifname);
fprintf (init_file, " /* enable*/\t%s,\n",
enable_string[bifp->stanza]);
- /* Type must be instantiated at run time. */
- fprintf (init_file, " /* fntype */\t0,\n");
fprintf (init_file, " /* icode */\tCODE_FOR_%s,\n",
bifp->patname);
fprintf (init_file, " /* nargs */\t%d,\n",
fprintf (init_file, " },\n");
}
fprintf (init_file, " };\n\n");
+
+ fprintf (init_file, "tree rs6000_builtin_info_fntype[RS6000_BIF_MAX];\n\n");
}
/* Write the decls and initializers for rs6000_overload_info[] and
"- RS6000_OVLD_NONE] =\n");
fprintf (init_file, " {\n");
fprintf (init_file, " { /* RS6000_OVLD_NONE: */\n");
- fprintf (init_file, " \"\", NULL\n");
+ fprintf (init_file, " \"\", -1\n");
fprintf (init_file, " },\n");
for (int i = 0; i <= curr_ovld_stanza; i++)
{
fprintf (init_file, " /* ovld_name */\t\"%s\",\n",
ovld_stanzas[i].intern_name);
/* First-instance must currently be instantiated at run time. */
- fprintf (init_file, " /* first_instance */\tNULL\n");
+ fprintf (init_file, " /* first_instance */\t-1\n");
fprintf (init_file, " },\n");
}
fprintf (init_file, " };\n\n");
fprintf (init_file, "ovlddata rs6000_instance_info[RS6000_INST_MAX] =\n");
fprintf (init_file, " {\n");
fprintf (init_file, " { /* RS6000_INST_NONE: */\n");
- fprintf (init_file, " \"\", RS6000_BIF_NONE, NULL_TREE, NULL\n");
+ fprintf (init_file, " \"\", RS6000_BIF_NONE, -1\n");
fprintf (init_file, " },\n");
for (int i = 0; i <= curr_ovld; i++)
{
ovlds[i].proto.bifname);
fprintf (init_file, " /* bifid */\tRS6000_BIF_%s,\n",
ovlds[i].bif_id_name);
- /* Type must be instantiated at run time. */
- fprintf (init_file, " /* fntype */\t0,\n");
fprintf (init_file, " /* next */\t");
if (i < curr_ovld
&& !strcmp (ovlds[i+1].proto.bifname, ovlds[i].proto.bifname))
fprintf (init_file,
- "&rs6000_instance_info[RS6000_INST_%s]\n",
+ "RS6000_INST_%s\n",
ovlds[i+1].ovld_id_name);
else
- fprintf (init_file, "NULL\n");
+ fprintf (init_file, "-1\n");
fprintf (init_file, " },\n");
}
fprintf (init_file, " };\n\n");
+
+ fprintf (init_file,
+ "tree rs6000_instance_info_fntype[RS6000_INST_MAX];\n\n");
}
/* Write code to initialize the built-in function table. */
for (int i = 0; i <= curr_bif; i++)
{
fprintf (init_file,
- " rs6000_builtin_info[RS6000_BIF_%s].fntype"
+ " rs6000_builtin_info_fntype[RS6000_BIF_%s]"
"\n = %s;\n",
bifs[i].idname, bifs[i].fndecl);
for (int i = 0; i <= curr_ovld; i++)
{
fprintf (init_file,
- " rs6000_instance_info[RS6000_INST_%s].fntype"
+ " rs6000_instance_info_fntype[RS6000_INST_%s]"
"\n = %s;\n",
ovlds[i].ovld_id_name, ovlds[i].fndecl);
".first_instance\n",
stanza->stanza_id);
fprintf (init_file,
- " = &rs6000_instance_info[RS6000_INST_%s];\n\n",
+ " = RS6000_INST_%s;\n\n",
ovlds[i].ovld_id_name);
}
}