mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-13 15:38:00 -05:00
62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
|
|
#include "Processor/Program.h"
|
|
#include "Processor/Data_Files.h"
|
|
#include "Processor/Processor.h"
|
|
|
|
#include "Processor/Instruction.hpp"
|
|
|
|
void Program::compute_constants()
|
|
{
|
|
for (int reg_type = 0; reg_type < MAX_REG_TYPE; reg_type++)
|
|
{
|
|
max_reg[reg_type] = 0;
|
|
max_mem[reg_type] = 0;
|
|
}
|
|
for (unsigned int i=0; i<p.size(); i++)
|
|
{
|
|
if (!p[i].get_offline_data_usage(offline_data_used))
|
|
unknown_usage = true;
|
|
for (int reg_type = 0; reg_type < MAX_REG_TYPE; reg_type++)
|
|
{
|
|
max_reg[reg_type] = max(max_reg[reg_type],
|
|
p[i].get_max_reg(reg_type));
|
|
max_mem[reg_type] = max(max_mem[reg_type],
|
|
p[i].get_mem(RegType(reg_type)));
|
|
}
|
|
}
|
|
}
|
|
|
|
void Program::parse(istream& s)
|
|
{
|
|
p.resize(0);
|
|
Instruction instr;
|
|
s.peek();
|
|
while (!s.eof())
|
|
{ instr.parse(s, p.size());
|
|
p.push_back(instr);
|
|
//cerr << "\t" << instr << endl;
|
|
s.peek();
|
|
}
|
|
compute_constants();
|
|
}
|
|
|
|
void Program::print_offline_cost() const
|
|
{
|
|
if (unknown_usage)
|
|
{
|
|
cerr << "Tape has unknown usage" << endl;
|
|
return;
|
|
}
|
|
|
|
cerr << "Cost of first tape:" << endl;
|
|
offline_data_used.print_cost();
|
|
}
|
|
|
|
|
|
ostream& operator<<(ostream& s,const Program& P)
|
|
{
|
|
for (unsigned int i=0; i<P.p.size(); i++)
|
|
{ s << i << " :: " << P.p[i] << endl; }
|
|
return s;
|
|
}
|