<commit_before>//=======================================================================
// Copyright <NAME> 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include <iostream>

#include "il/Move.hpp"
#include "il/Operand.hpp"

#include "AssemblyFileWriter.hpp"

using namespace eddic;

Move::Move(std::shared_ptr<Operand> lhs, std::shared_ptr<Operand> rhs) : m_lhs(lhs), m_rhs(rhs) {}

void Move::write(AssemblyFileWriter& writer){
    //We can always put an immediate value everywhere
    writer.stream() << "movl " << m_lhs->getValue() << ", " << m_rhs->getValue() << std::endl;

    //TODO Improve ?
}<commit_msg>Improve Move to have not several operands in memory<commit_after>//=======================================================================
// Copyright <NAME> 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include <iostream>

#include "il/Move.hpp"
#include "il/Operand.hpp"

#include "AssemblyFileWriter.hpp"

using namespace eddic;

Move::Move(std::shared_ptr<Operand> lhs, std::shared_ptr<Operand> rhs) : m_lhs(lhs), m_rhs(rhs) {}

void Move::write(AssemblyFileWriter& writer){
    //Cannot move stack to stack directly, must use a register
    if(m_lhs->isStack() && m_rhs->isStack()){
        //TODO Avoid using eax if not available
        writer.stream() << "movl " << m_lhs->getValue() << ", %eax" << std::endl;
        writer.stream() << "movl %eax, " << m_rhs->getValue() << std::endl;
    } else {
        //We can always put an immediate value everywhere
        writer.stream() << "movl " << m_lhs->getValue() << ", " << m_rhs->getValue() << std::endl;
    }

    //TODO Improve ?
}
{'fraction_non_alphanumeric': 0.28635907723169507, 'fraction_numerical': 0.010030090270812437, 'mean_word_length': 4.526315789473684, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7342581', 'n_tokens_mistral': 618, 'n_tokens_neox': 593, 'n_words': 149}