<commit_before>/*
 * Copyright 2010 2011 2012 2013 2014 <NAME> <<EMAIL>>
 * Copyright 2011 2012 2014 2015 <NAME> <<EMAIL>>
 * See COPYING for terms of redistribution.
 */

#ifndef JIVE_ARCH_INSTRUCTION_H
#define JIVE_ARCH_INSTRUCTION_H

#include <algorithm>
#include <string.h>

#include <jive/arch/immediate.h>
#include <jive/arch/instruction-class.h>
#include <jive/arch/linker-symbol.h>
#include <jive/arch/registers.h>
#include <jive/rvsdg/label.h>
#include <jive/rvsdg/nullary.h>
#include <jive/rvsdg/simple-node.h>
#include <jive/types/bitstring/type.h>
#include <jive/util/ptr-collection.h>

namespace jive {

class instruction_op final : public simple_op {
public:
	virtual
	~instruction_op() noexcept;

	inline
	instruction_op(
		const jive::instruction * i,
		const std::vector<jive::port> & iports,
		const std::vector<jive::port> & oports)
	: simple_op(create_operands(i, iports), create_results(i, oports))
	, icls_(i)
	{}

	virtual bool
	operator==(const operation & other) const noexcept override;

	virtual std::string
	debug_string() const override;

	inline const jive::instruction *
	icls() const noexcept
	{
		return icls_;
	}

	virtual std::unique_ptr<jive::operation>
	copy() const override;

private:
	static std::vector<jive::port>
	create_operands(
		const jive::instruction * icls,
		const std::vector<jive::port> & iports);

	static std::vector<jive::port>
	create_results(
		const jive::instruction * icls,
		const std::vector<jive::port> & oprts);

	const jive::instruction * icls_;
};

static inline jive::node *<commit_msg>arch: add is_instruction_op and is_instruction_node functions<commit_after>/*
 * Copyright 2010 2011 2012 2013 2014 <NAME> <<EMAIL>>
 * Copyright 2011 2012 2014 2015 <NAME> <<EMAIL>>
 * See COPYING for terms of redistribution.
 */

#ifndef JIVE_ARCH_INSTRUCTION_H
#define JIVE_ARCH_INSTRUCTION_H

#include <algorithm>
#include <string.h>

#include <jive/arch/immediate.h>
#include <jive/arch/instruction-class.h>
#include <jive/arch/linker-symbol.h>
#include <jive/arch/registers.h>
#include <jive/rvsdg/label.h>
#include <jive/rvsdg/nullary.h>
#include <jive/rvsdg/simple-node.h>
#include <jive/types/bitstring/type.h>
#include <jive/util/ptr-collection.h>

namespace jive {

class instruction_op final : public simple_op {
public:
	virtual
	~instruction_op() noexcept;

	inline
	instruction_op(
		const jive::instruction * i,
		const std::vector<jive::port> & iports,
		const std::vector<jive::port> & oports)
	: simple_op(create_operands(i, iports), create_results(i, oports))
	, icls_(i)
	{}

	virtual bool
	operator==(const operation & other) const noexcept override;

	virtual std::string
	debug_string() const override;

	inline const jive::instruction *
	icls() const noexcept
	{
		return icls_;
	}

	virtual std::unique_ptr<jive::operation>
	copy() const override;

private:
	static std::vector<jive::port>
	create_operands(
		const jive::instruction * icls,
		const std::vector<jive::port> & iports);

	static std::vector<jive::port>
	create_results(
		const jive::instruction * icls,
		const std::vector<jive::port> & oprts);

	const jive::instruction * icls_;
};

static inline bool
is_instruction_op(const jive::operation & op) noexcept
{
	return dynamic_cast<const instruction_op*>(&op);
}

static inline bool
is_instruction_node(const jive::node * node) noexcept
{
	return is_opnode<instruction_op>(node);
}

static inline jive::node *
{'fraction_non_alphanumeric': 0.13307873090481787, 'fraction_numerical': 0.021151586368977675, 'mean_word_length': 5.586073500967118, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1760787', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1207, 'n_words': 276}