IRInstruction::IRInstruction(Arena& arena, const IRInstruction* inst, Id id) : m_typeParam(inst->m_typeParam) , m_op(inst->m_op) , m_numSrcs(inst->m_numSrcs) , m_numDsts(inst->m_numDsts) , m_marker(inst->m_marker) , m_id(id) , m_srcs(m_numSrcs ? new (arena) SSATmp*[m_numSrcs] : nullptr) , m_dst(nullptr) , m_block(nullptr) , m_extra(inst->m_extra ? cloneExtra(op(), inst->m_extra, arena) : nullptr) { assert(!isTransient()); std::copy(inst->m_srcs, inst->m_srcs + inst->m_numSrcs, m_srcs); if (hasEdges()) { m_edges = new (arena) Edge[2]; m_edges[0].setInst(this); m_edges[0].setTo(inst->next()); m_edges[1].setInst(this); m_edges[1].setTo(inst->taken()); } else { m_edges = nullptr; } }
void IRInstruction::become(IRFactory& factory, IRInstruction* other) { assert(other->isTransient() || m_numDsts == other->m_numDsts); auto& arena = factory.arena(); // Copy all but m_id, m_taken.from, m_listNode, m_marker, and don't clone // dests---the whole point of become() is things still point to us. m_op = other->m_op; m_typeParam = other->m_typeParam; m_numSrcs = other->m_numSrcs; m_extra = other->m_extra ? cloneExtra(m_op, other->m_extra, arena) : nullptr; m_srcs = new (arena) SSATmp*[m_numSrcs]; std::copy(other->m_srcs, other->m_srcs + m_numSrcs, m_srcs); setTaken(other->taken()); }
IRInstruction::IRInstruction(Arena& arena, const IRInstruction* inst, Id id) : m_op(inst->m_op) , m_typeParam(inst->m_typeParam) , m_numSrcs(inst->m_numSrcs) , m_numDsts(inst->m_numDsts) , m_id(id) , m_srcs(m_numSrcs ? new (arena) SSATmp*[m_numSrcs] : nullptr) , m_dst(nullptr) , m_marker(inst->m_marker) , m_extra(inst->m_extra ? cloneExtra(op(), inst->m_extra, arena) : nullptr) { std::copy(inst->m_srcs, inst->m_srcs + inst->m_numSrcs, m_srcs); setTaken(inst->taken()); }
void IRInstruction::become(IRUnit& unit, IRInstruction* other) { assert(other->isTransient() || m_numDsts == other->m_numDsts); auto& arena = unit.arena(); // Copy all but m_id, m_edges[].from, m_listNode, m_marker, and don't clone // dests---the whole point of become() is things still point to us. if (hasEdges() && !other->hasEdges()) { clearEdges(); } else if (!hasEdges() && other->hasEdges()) { m_edges = new (arena) Edge[2]; setNext(other->next()); setTaken(other->taken()); } m_op = other->m_op; m_typeParam = other->m_typeParam; m_numSrcs = other->m_numSrcs; m_extra = other->m_extra ? cloneExtra(m_op, other->m_extra, arena) : nullptr; m_srcs = new (arena) SSATmp*[m_numSrcs]; std::copy(other->m_srcs, other->m_srcs + m_numSrcs, m_srcs); }