<commit_before>/*
 * rf.h - register file
 * @author <NAME> <EMAIL>
 * Copyright 2015-2018 MIPT-MIPS
 */

#ifndef RF_H
#define RF_H

#include <array>

template<typename ISA>
class RF
{
    using FuncInstr = typename ISA::FuncInstr;
    using Register = typename ISA::Register;
public:
    struct Reg {
        uint32 value = 0;
    };
    std::array<Reg, Register::MAX_REG> array = {};

    Reg& get_entry( Register num) { return array.at( num.to_size_t()); }
    const Reg& get_entry( Register num) const { return array.at( num.to_size_t()); }

    uint32 read( Register num) const
    {
        assert( !num.is_mips_hi_lo());
        return get_entry( num).value;
    }

    void write( Register num, uint64 val)
    {
        if ( num.is_zero())
            return;
        if ( num.is_mips_hi_lo()) {
            write( Register::mips_hi, val >> 32);
            write( Register::mips_lo, val);
            return;
        }            

        auto& entry = get_entry(num);
        entry.value = val;
    }

public:<commit_msg>Fix visibility scope in RF class (#346)<commit_after>/*
 * rf.h - register file
 * @author <NAME> <EMAIL>
 * Copyright 2015-2018 MIPT-MIPS
 */

#ifndef RF_H
#define RF_H

#include <array>

template<typename ISA>
class RF
{
    using FuncInstr = typename ISA::FuncInstr;
    using Register = typename ISA::Register;

    struct Reg {
        uint32 value = 0;
    };
    std::array<Reg, Register::MAX_REG> array = {};

    Reg& get_entry( Register num) { return array.at( num.to_size_t()); }
    const Reg& get_entry( Register num) const { return array.at( num.to_size_t()); }

protected:
    uint32 read( Register num) const
    {
        assert( !num.is_mips_hi_lo());
        return get_entry( num).value;
    }

    void write( Register num, uint64 val)
    {
        if ( num.is_zero())
            return;
        if ( num.is_mips_hi_lo()) {
            write( Register::mips_hi, val >> 32);
            write( Register::mips_lo, val);
            return;
        }            

        auto& entry = get_entry(num);
        entry.value = val;
    }

public:
{'fraction_non_alphanumeric': 0.12833969465648856, 'fraction_numerical': 0.017652671755725192, 'mean_word_length': 2.2562111801242235, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '3675730', 'n_tokens_mistral': 739, 'n_tokens_neox': 690, 'n_words': 181}