Ejemplo n.º 1
0
void Census::visit(const std::shared_ptr<Instruction> &instruction) {
	instructions_.push_back(instruction.get());
	unique_ = false;

	switch (instruction->mnemonic()) {
		case Instruction::READ: {
			Read *read = instruction->as<Read>();
			visit(read->reg());
			visit(read->address());
			spaces_.push_back(read->space());
			break;
		}
		case Instruction::WRITE: {
			Write *write = instruction->as<Write>();
			visit(write->value());
			visit(write->address());
			spaces_.push_back(write->space());
			break;
		}
		case Instruction::MFENCE: {
			break;
		}
		case Instruction::LOCAL: {
			Local *local = instruction->as<Local>();
			visit(local->reg());
			visit(local->value());
			break;
		}
		case Instruction::CONDITION: {
			Condition *condition = instruction->as<Condition>();
			visit(condition->expression());
			break;
		}
		case Instruction::ATOMIC: {
			Atomic *atomic = instruction->as<Atomic>();
			for (const auto &instr : atomic->instructions()) {
				visit(instr);
			}
			break;
		}
		case Instruction::NOOP: /* FALLTHROUGH */
		case Instruction::LOCK: /* FALLTHROUGH */
		case Instruction::UNLOCK:
			break;
		default: {
			assert(!"NEVER REACHED");
		}
	}
}