Blame kpatch-build/gcc-plugins/gcc-generate-rtl-pass.h

Packit Service ac8aad
/* SPDX-License-Identifier: GPL-2.0 */
Packit Service ac8aad
/*
Packit Service ac8aad
 * Generator for RTL pass related boilerplate code/data
Packit Service ac8aad
 *
Packit Service ac8aad
 * Supports gcc 4.5-6
Packit Service ac8aad
 *
Packit Service ac8aad
 * Usage:
Packit Service ac8aad
 *
Packit Service ac8aad
 * 1. before inclusion define PASS_NAME
Packit Service ac8aad
 * 2. before inclusion define NO_* for unimplemented callbacks
Packit Service ac8aad
 *    NO_GATE
Packit Service ac8aad
 *    NO_EXECUTE
Packit Service ac8aad
 * 3. before inclusion define PROPERTIES_* and TODO_FLAGS_* to override
Packit Service ac8aad
 *    the default 0 values
Packit Service ac8aad
 * 4. for convenience, all the above will be undefined after inclusion!
Packit Service ac8aad
 * 5. the only exported name is make_PASS_NAME_pass() to register with gcc
Packit Service ac8aad
 */
Packit Service ac8aad
Packit Service ac8aad
#ifndef PASS_NAME
Packit Service ac8aad
#error at least PASS_NAME must be defined
Packit Service ac8aad
#else
Packit Service ac8aad
#define __GCC_PLUGIN_STRINGIFY(n)	#n
Packit Service ac8aad
#define _GCC_PLUGIN_STRINGIFY(n)	__GCC_PLUGIN_STRINGIFY(n)
Packit Service ac8aad
#define _GCC_PLUGIN_CONCAT2(x, y)	x ## y
Packit Service ac8aad
#define _GCC_PLUGIN_CONCAT3(x, y, z)	x ## y ## z
Packit Service ac8aad
Packit Service ac8aad
#define __PASS_NAME_PASS_DATA(n)	_GCC_PLUGIN_CONCAT2(n, _pass_data)
Packit Service ac8aad
#define _PASS_NAME_PASS_DATA		__PASS_NAME_PASS_DATA(PASS_NAME)
Packit Service ac8aad
Packit Service ac8aad
#define __PASS_NAME_PASS(n)		_GCC_PLUGIN_CONCAT2(n, _pass)
Packit Service ac8aad
#define _PASS_NAME_PASS			__PASS_NAME_PASS(PASS_NAME)
Packit Service ac8aad
Packit Service ac8aad
#define _PASS_NAME_NAME			_GCC_PLUGIN_STRINGIFY(PASS_NAME)
Packit Service ac8aad
Packit Service ac8aad
#define __MAKE_PASS_NAME_PASS(n)	_GCC_PLUGIN_CONCAT3(make_, n, _pass)
Packit Service ac8aad
#define _MAKE_PASS_NAME_PASS		__MAKE_PASS_NAME_PASS(PASS_NAME)
Packit Service ac8aad
Packit Service ac8aad
#ifdef NO_GATE
Packit Service ac8aad
#define _GATE NULL
Packit Service ac8aad
#define _HAS_GATE false
Packit Service ac8aad
#else
Packit Service ac8aad
#define __GATE(n)			_GCC_PLUGIN_CONCAT2(n, _gate)
Packit Service ac8aad
#define _GATE				__GATE(PASS_NAME)
Packit Service ac8aad
#define _HAS_GATE true
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
#ifdef NO_EXECUTE
Packit Service ac8aad
#define _EXECUTE NULL
Packit Service ac8aad
#define _HAS_EXECUTE false
Packit Service ac8aad
#else
Packit Service ac8aad
#define __EXECUTE(n)			_GCC_PLUGIN_CONCAT2(n, _execute)
Packit Service ac8aad
#define _EXECUTE			__EXECUTE(PASS_NAME)
Packit Service ac8aad
#define _HAS_EXECUTE true
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
#ifndef PROPERTIES_REQUIRED
Packit Service ac8aad
#define PROPERTIES_REQUIRED 0
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
#ifndef PROPERTIES_PROVIDED
Packit Service ac8aad
#define PROPERTIES_PROVIDED 0
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
#ifndef PROPERTIES_DESTROYED
Packit Service ac8aad
#define PROPERTIES_DESTROYED 0
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
#ifndef TODO_FLAGS_START
Packit Service ac8aad
#define TODO_FLAGS_START 0
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
#ifndef TODO_FLAGS_FINISH
Packit Service ac8aad
#define TODO_FLAGS_FINISH 0
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
#if BUILDING_GCC_VERSION >= 4009
Packit Service ac8aad
namespace {
Packit Service ac8aad
static const pass_data _PASS_NAME_PASS_DATA = {
Packit Service ac8aad
#else
Packit Service ac8aad
static struct rtl_opt_pass _PASS_NAME_PASS = {
Packit Service ac8aad
	.pass = {
Packit Service ac8aad
#endif
Packit Service ac8aad
		.type			= RTL_PASS,
Packit Service ac8aad
		.name			= _PASS_NAME_NAME,
Packit Service ac8aad
#if BUILDING_GCC_VERSION >= 4008
Packit Service ac8aad
		.optinfo_flags		= OPTGROUP_NONE,
Packit Service ac8aad
#endif
Packit Service ac8aad
#if BUILDING_GCC_VERSION >= 5000
Packit Service ac8aad
#elif BUILDING_GCC_VERSION == 4009
Packit Service ac8aad
		.has_gate		= _HAS_GATE,
Packit Service ac8aad
		.has_execute		= _HAS_EXECUTE,
Packit Service ac8aad
#else
Packit Service ac8aad
		.gate			= _GATE,
Packit Service ac8aad
		.execute		= _EXECUTE,
Packit Service ac8aad
		.sub			= NULL,
Packit Service ac8aad
		.next			= NULL,
Packit Service ac8aad
		.static_pass_number	= 0,
Packit Service ac8aad
#endif
Packit Service ac8aad
		.tv_id			= TV_NONE,
Packit Service ac8aad
		.properties_required	= PROPERTIES_REQUIRED,
Packit Service ac8aad
		.properties_provided	= PROPERTIES_PROVIDED,
Packit Service ac8aad
		.properties_destroyed	= PROPERTIES_DESTROYED,
Packit Service ac8aad
		.todo_flags_start	= TODO_FLAGS_START,
Packit Service ac8aad
		.todo_flags_finish	= TODO_FLAGS_FINISH,
Packit Service ac8aad
#if BUILDING_GCC_VERSION < 4009
Packit Service ac8aad
	}
Packit Service ac8aad
#endif
Packit Service ac8aad
};
Packit Service ac8aad
Packit Service ac8aad
#if BUILDING_GCC_VERSION >= 4009
Packit Service ac8aad
class _PASS_NAME_PASS : public rtl_opt_pass {
Packit Service ac8aad
public:
Packit Service ac8aad
	_PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {}
Packit Service ac8aad
Packit Service ac8aad
#ifndef NO_GATE
Packit Service ac8aad
#if BUILDING_GCC_VERSION >= 5000
Packit Service ac8aad
	virtual bool gate(function *) { return _GATE(); }
Packit Service ac8aad
#else
Packit Service ac8aad
	virtual bool gate(void) { return _GATE(); }
Packit Service ac8aad
#endif
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
	virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }
Packit Service ac8aad
Packit Service ac8aad
#ifndef NO_EXECUTE
Packit Service ac8aad
#if BUILDING_GCC_VERSION >= 5000
Packit Service ac8aad
	virtual unsigned int execute(function *) { return _EXECUTE(); }
Packit Service ac8aad
#else
Packit Service ac8aad
	virtual unsigned int execute(void) { return _EXECUTE(); }
Packit Service ac8aad
#endif
Packit Service ac8aad
#endif
Packit Service ac8aad
};
Packit Service ac8aad
}
Packit Service ac8aad
Packit Service ac8aad
opt_pass *_MAKE_PASS_NAME_PASS(void)
Packit Service ac8aad
{
Packit Service ac8aad
	return new _PASS_NAME_PASS();
Packit Service ac8aad
}
Packit Service ac8aad
#else
Packit Service ac8aad
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
Packit Service ac8aad
{
Packit Service ac8aad
	return &_PASS_NAME_PASS.pass;
Packit Service ac8aad
}
Packit Service ac8aad
#endif
Packit Service ac8aad
Packit Service ac8aad
/* clean up user provided defines */
Packit Service ac8aad
#undef PASS_NAME
Packit Service ac8aad
#undef NO_GATE
Packit Service ac8aad
#undef NO_EXECUTE
Packit Service ac8aad
Packit Service ac8aad
#undef PROPERTIES_DESTROYED
Packit Service ac8aad
#undef PROPERTIES_PROVIDED
Packit Service ac8aad
#undef PROPERTIES_REQUIRED
Packit Service ac8aad
#undef TODO_FLAGS_FINISH
Packit Service ac8aad
#undef TODO_FLAGS_START
Packit Service ac8aad
Packit Service ac8aad
/* clean up generated defines */
Packit Service ac8aad
#undef _EXECUTE
Packit Service ac8aad
#undef __EXECUTE
Packit Service ac8aad
#undef _GATE
Packit Service ac8aad
#undef __GATE
Packit Service ac8aad
#undef _GCC_PLUGIN_CONCAT2
Packit Service ac8aad
#undef _GCC_PLUGIN_CONCAT3
Packit Service ac8aad
#undef _GCC_PLUGIN_STRINGIFY
Packit Service ac8aad
#undef __GCC_PLUGIN_STRINGIFY
Packit Service ac8aad
#undef _HAS_EXECUTE
Packit Service ac8aad
#undef _HAS_GATE
Packit Service ac8aad
#undef _MAKE_PASS_NAME_PASS
Packit Service ac8aad
#undef __MAKE_PASS_NAME_PASS
Packit Service ac8aad
#undef _PASS_NAME_NAME
Packit Service ac8aad
#undef _PASS_NAME_PASS
Packit Service ac8aad
#undef __PASS_NAME_PASS
Packit Service ac8aad
#undef _PASS_NAME_PASS_DATA
Packit Service ac8aad
#undef __PASS_NAME_PASS_DATA
Packit Service ac8aad
Packit Service ac8aad
#endif /* PASS_NAME */