<commit_before>/*
This file is part of Bohrium and copyright (c) 2012 the Bohrium
team <http://www.bh107.org>.

Bohrium is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.

Bohrium is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the
GNU Lesser General Public License along with Bohrium.

If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include <boost/serialization/is_bitwise_serializable.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/vector.hpp>
#include <vector>
#include <set>

#include "bh_opcode.h"
#include <bh_view.hpp>

// Forward declaration of class boost::serialization::access
namespace boost {namespace serialization {class access;}}

// Maximum number of operands in a instruction.
#define BH_MAX_NO_OPERANDS (3)

//Memory layout of the Bohrium instruction
struct bh_instruction
{
    // Opcode: Identifies the operation
    bh_opcode  opcode;
    // Id of each operand
    std::vector<bh_view> operand;
    // Constant included in the instruction (Used if one of the operands == NULL)
    bh_constant constant;
    // Flag that indicates whether this instruction construct the output array (i.e. is the first operation on that array)
    // For now, this flag is only used by the code generators.
    bool constructor;
    // An identifier to track the original source of instruction transformations thus transformations such as
    // copy, transpose, and reshape does not change the 'origin_id'.
    // For now, this flag is only used by the code generators.
    int64_t origin_id = -1; // -1 indicates: unset

    // Constructors
    bh_instruction(){}
    bh_instruction(bh_opcode opcode, const std::vector<bh_view> &operands) : opcode(opcode), operand(operands) {}
    bh_instruction(const bh_instruction& instr)
    {
        opcode      = instr.opcode;
        constant    = instr.constant;
        constructor = instr.constructor;
        origin_id   = instr.origin_id;
        operand     = instr.operand;
    }

    // Return a set of all bases used by the instruction<commit_msg>bh_instruction(): now uses std::move()<commit_after>/*
This file is part of Bohrium and copyright (c) 2012 the Bohrium
team <http://www.bh107.org>.

Bohrium is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.

Bohrium is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the
GNU Lesser General Public License along with Bohrium.

If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include <boost/serialization/is_bitwise_serializable.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/vector.hpp>
#include <vector>
#include <set>

#include "bh_opcode.h"
#include <bh_view.hpp>

// Forward declaration of class boost::serialization::access
namespace boost {namespace serialization {class access;}}

// Maximum number of operands in a instruction.
#define BH_MAX_NO_OPERANDS (3)

//Memory layout of the Bohrium instruction
struct bh_instruction
{
    // Opcode: Identifies the operation
    bh_opcode  opcode;
    // Id of each operand
    std::vector<bh_view> operand;
    // Constant included in the instruction (Used if one of the operands == NULL)
    bh_constant constant;
    // Flag that indicates whether this instruction construct the output array (i.e. is the first operation on that array)
    // For now, this flag is only used by the code generators.
    bool constructor;
    // An identifier to track the original source of instruction transformations thus transformations such as
    // copy, transpose, and reshape does not change the 'origin_id'.
    // For now, this flag is only used by the code generators.
    int64_t origin_id = -1; // -1 indicates: unset

    // Constructors
    bh_instruction(){}
    bh_instruction(bh_opcode opcode, std::vector<bh_view> operands) : opcode(opcode), operand(std::move(operands)) {}
    bh_instruction(const bh_instruction& instr)
    {
        opcode      = instr.opcode;
        constant    = instr.constant;
        constructor = instr.constructor;
        origin_id   = instr.origin_id;
        operand     = instr.operand;
    }

    // Return a set of all bases used by the instruction
{'fraction_non_alphanumeric': 0.07781625585658994, 'fraction_numerical': 0.005296394377673661, 'mean_word_length': 3.619002822201317, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6508760', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1335, 'n_words': 575}