|
Packit Service |
ac8aad |
#include "gcc-common.h"
|
|
Packit Service |
ac8aad |
#include <error.h>
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
#define PLUGIN_NAME "ppc64le-plugin"
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
da4517 |
#if BUILDING_GCC_VERSION < 10000
|
|
Packit Service |
da4517 |
#define CALL_LOCAL "*call_local_aixdi"
|
|
Packit Service |
da4517 |
#define CALL_NONLOCAL "*call_nonlocal_aixdi"
|
|
Packit Service |
da4517 |
#define CALL_VALUE_LOCAL "*call_value_local_aixdi"
|
|
Packit Service |
da4517 |
#define CALL_VALUE_NONLOCAL "*call_value_nonlocal_aixdi"
|
|
Packit Service |
da4517 |
#else
|
|
Packit Service |
da4517 |
#define CALL_LOCAL "*call_localdi"
|
|
Packit Service |
da4517 |
#define CALL_NONLOCAL "*call_nonlocal_aixdi"
|
|
Packit Service |
da4517 |
#define CALL_VALUE_LOCAL "*call_value_localdi"
|
|
Packit Service |
da4517 |
#define CALL_VALUE_NONLOCAL "*call_value_nonlocal_aixdi"
|
|
Packit Service |
da4517 |
#endif
|
|
Packit Service |
da4517 |
|
|
Packit Service |
ac8aad |
int plugin_is_GPL_compatible;
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
struct plugin_info plugin_info = {
|
|
Packit Service |
ac8aad |
.version = "1",
|
|
Packit Service |
ac8aad |
.help = PLUGIN_NAME ": insert nops after local calls\n",
|
|
Packit Service |
ac8aad |
};
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
static unsigned int ppc64le_plugin_execute(void)
|
|
Packit Service |
ac8aad |
{
|
|
Packit Service |
ac8aad |
rtx_insn *insn;
|
|
Packit Service |
ac8aad |
int code;
|
|
Packit Service |
ac8aad |
const char *name;
|
|
Packit Service |
ac8aad |
static int nonlocal_code = -1, local_code = -1,
|
|
Packit Service |
ac8aad |
value_nonlocal_code = -1, value_local_code = -1;
|
|
Packit Service |
ac8aad |
static bool initialized = false;
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
if (initialized)
|
|
Packit Service |
ac8aad |
goto found;
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
/* Find the rs6000.md code numbers for local and non-local calls */
|
|
Packit Service |
ac8aad |
initialized = true;
|
|
Packit Service |
ac8aad |
for (code = 0; code < 1000; code++) {
|
|
Packit Service |
ac8aad |
name = get_insn_name(code);
|
|
Packit Service |
ac8aad |
if (!name)
|
|
Packit Service |
ac8aad |
continue;
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
da4517 |
if (!strcmp(name , CALL_LOCAL))
|
|
Packit Service |
ac8aad |
local_code = code;
|
|
Packit Service |
da4517 |
else if (!strcmp(name , CALL_NONLOCAL))
|
|
Packit Service |
ac8aad |
nonlocal_code = code;
|
|
Packit Service |
da4517 |
else if (!strcmp(name, CALL_VALUE_LOCAL))
|
|
Packit Service |
ac8aad |
value_local_code = code;
|
|
Packit Service |
da4517 |
else if (!strcmp(name, CALL_VALUE_NONLOCAL))
|
|
Packit Service |
ac8aad |
value_nonlocal_code = code;
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
if (nonlocal_code != -1 && local_code != -1 &&
|
|
Packit Service |
ac8aad |
value_nonlocal_code != -1 && value_local_code != -1)
|
|
Packit Service |
ac8aad |
goto found;
|
|
Packit Service |
ac8aad |
}
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
found:
|
|
Packit Service |
ac8aad |
if (nonlocal_code == -1 || local_code == -1 ||
|
|
Packit Service |
ac8aad |
value_nonlocal_code == -1 || value_local_code == -1) {
|
|
Packit Service |
da4517 |
error("%s: cannot find call instruction codes", PLUGIN_NAME);
|
|
Packit Service |
ac8aad |
}
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
/* Convert local calls to non-local */
|
|
Packit Service |
ac8aad |
for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
|
|
Packit Service |
ac8aad |
if (GET_CODE(insn) == CALL_INSN) {
|
|
Packit Service |
ac8aad |
if (INSN_CODE(insn) == local_code)
|
|
Packit Service |
ac8aad |
INSN_CODE(insn) = nonlocal_code;
|
|
Packit Service |
ac8aad |
else if (INSN_CODE(insn) == value_local_code)
|
|
Packit Service |
ac8aad |
INSN_CODE(insn) = value_nonlocal_code;
|
|
Packit Service |
ac8aad |
}
|
|
Packit Service |
ac8aad |
}
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
return 0;
|
|
Packit Service |
ac8aad |
}
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
#define PASS_NAME ppc64le_plugin
|
|
Packit Service |
ac8aad |
#define NO_GATE
|
|
Packit Service |
ac8aad |
#include "gcc-generate-rtl-pass.h"
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
int plugin_init(struct plugin_name_args *plugin_info,
|
|
Packit Service |
ac8aad |
struct plugin_gcc_version *version)
|
|
Packit Service |
ac8aad |
{
|
|
Packit Service |
ac8aad |
const char * const plugin_name = plugin_info->base_name;
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
PASS_INFO(ppc64le_plugin, "vregs", 1, PASS_POS_INSERT_AFTER);
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
if (!plugin_default_version_check(version, &gcc_version))
|
|
Packit Service |
ac8aad |
error(1, 0, PLUGIN_NAME ": incompatible gcc/plugin versions");
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
register_callback(plugin_name, PLUGIN_INFO, NULL, &plugin_info);
|
|
Packit Service |
ac8aad |
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL,
|
|
Packit Service |
ac8aad |
&ppc64le_plugin_pass_info);
|
|
Packit Service |
ac8aad |
|
|
Packit Service |
ac8aad |
return 0;
|
|
Packit Service |
ac8aad |
}
|
|
Packit Service |
ac8aad |
|