StackTransInfo instrStackTransInfo(PC opcode) { static const StackTransInfo::Kind transKind[] = { #define NOV StackTransInfo::Kind::PushPop #define ONE(...) StackTransInfo::Kind::PushPop #define TWO(...) StackTransInfo::Kind::PushPop #define THREE(...) StackTransInfo::Kind::PushPop #define FOUR(...) StackTransInfo::Kind::PushPop #define IDX_A StackTransInfo::Kind::PushPop #define INS_1(...) StackTransInfo::Kind::InsertMid #define INS_2(...) StackTransInfo::Kind::InsertMid #define O(name, imm, pop, push, flags) push, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef INS_1 #undef INS_2 #undef IDX_A #undef O }; static const int8_t peekPokeType[] = { #define NOV -1 #define ONE(...) -1 #define TWO(...) -1 #define THREE(...) -1 #define FOUR(...) -1 #define INS_1(...) 0 #define INS_2(...) 1 #define IDX_A 0 #define O(name, imm, pop, push, flags) push, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef INS_2 #undef INS_1 #undef IDX_A #undef O }; StackTransInfo ret; auto const op = peek_op(opcode); ret.kind = transKind[size_t(op)]; switch (ret.kind) { case StackTransInfo::Kind::PushPop: ret.pos = 0; ret.numPushes = instrNumPushes(opcode); ret.numPops = instrNumPops(opcode); return ret; case StackTransInfo::Kind::InsertMid: ret.numPops = 0; ret.numPushes = 0; ret.pos = peekPokeType[size_t(op)]; return ret; } not_reached(); }
StackTransInfo instrStackTransInfo(const Opcode* opcode) { static const StackTransInfo::Kind transKind[] = { #define NOV StackTransInfo::PushPop #define ONE(...) StackTransInfo::PushPop #define TWO(...) StackTransInfo::PushPop #define THREE(...) StackTransInfo::PushPop #define FOUR(...) StackTransInfo::PushPop #define INS_1(...) StackTransInfo::InsertMid #define INS_2(...) StackTransInfo::InsertMid #define O(name, imm, pop, push, flags) push, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef INS_1 #undef INS_2 #undef O }; static const int8_t peekPokeType[] = { #define NOV -1 #define ONE(...) -1 #define TWO(...) -1 #define THREE(...) -1 #define FOUR(...) -1 #define INS_1(...) 0 #define INS_2(...) 1 #define O(name, imm, pop, push, flags) push, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef INS_2 #undef INS_1 #undef O }; StackTransInfo ret; ret.kind = transKind[*opcode]; switch (ret.kind) { case StackTransInfo::PushPop: ret.pos = 0; ret.numPushes = instrNumPushes(opcode); ret.numPops = instrNumPops(opcode); return ret; case StackTransInfo::InsertMid: ret.numPops = 0; ret.numPushes = 0; ret.pos = peekPokeType[*opcode]; return ret; default: NOT_REACHED(); } }