void Visit(IRControlStmt* stmt, unsigned int indent) { // Note: multi-level break/continue statements don't print correctly. // We would have to count loop depth to do so. const char* name = OpcodeName(stmt->GetOpcode()); assert(name[0] == '_' && "Expected underscore in control opcode name"); Indent(indent) << ++name << ";\n"; }
// Get a persistent name for the specified instruction. If it's a known // instruction, the name is a static string constant. Otherwise it's // owned by this object. const char* OpcodeNames::GetName(Opcode opcode, const char* name) { if (opcode == kOpcode_Unknown) return mTokens.Get(name).Get(); else return OpcodeName(opcode); }
// Construct map from instruction name to opcode. OpcodeNames::OpcodeNames() { // Don't include the unknown instruction opcode in the map. assert(kOpcode_Unknown == 0 && "Opcode enum invariant botched"); for (unsigned int i = 1; i < kOpcode_NumInsts; ++i) { Opcode opcode = static_cast<Opcode>(i); mOpcodeMap[OpcodeName(opcode)] = opcode; } }
static void notImplemented(Cpu* cpu, OPCODE op) { cpuInfo(cpu); ERROR("Opcode %s has not been implemented jet.", OpcodeName(op)); \ }