/** * instrNumPops() returns the number of values consumed from the stack * for a given push/pop instruction. For peek/poke instructions, this * function returns 0. */ int instrNumPops(PC pc) { static const int32_t numberOfPops[] = { #define NOV 0 #define ONE(...) 1 #define TWO(...) 2 #define THREE(...) 3 #define FOUR(...) 4 #define MMANY -1 #define C_MMANY -2 #define V_MMANY -2 #define R_MMANY -2 #define MFINAL -3 #define FMANY -3 #define CVMANY -3 #define CVUMANY -3 #define CMANY -3 #define SMANY -1 #define IDX_A -4 #define O(name, imm, pop, push, flags) pop, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef MMANY #undef C_MMANY #undef V_MMANY #undef R_MMANY #undef MFINAL #undef FMANY #undef CVMANY #undef CVUMANY #undef CMANY #undef SMANY #undef IDX_A #undef O }; int n = numberOfPops[size_t(peek_op(pc))]; // For most instructions, we know how many values are popped based // solely on the opcode if (n >= 0) return n; // BaseSC and BaseSL remove an A that may be on the top of the stack or one // element below the top, depending on the second immediate. if (n == -4) return getImm(pc, 1).u_IVA + 1; // FCall, NewPackedArray, and final member operations specify how many values // are popped in their first immediate if (n == -3) return getImm(pc, 0).u_IVA; // For instructions with vector immediates, we have to scan the // contents of the vector immediate to determine how many values // are popped assert(n == -1 || n == -2); ImmVector iv = getImmVector(pc); // Count the number of values on the stack accounted for by the // ImmVector's location and members int k = iv.numStackValues(); // If this instruction also takes a RHS, count that too if (n == -2) ++k; return k; }
/** * instrNumPops() returns the number of values consumed from the stack * for a given push/pop instruction. For peek/poke instructions, this * function returns 0. */ int instrNumPops(PC pc) { static const int32_t numberOfPops[] = { #define NOV 0 #define ONE(...) 1 #define TWO(...) 2 #define THREE(...) 3 #define FOUR(...) 4 #define MFINAL -3 #define F_MFINAL -6 #define C_MFINAL -5 #define V_MFINAL C_MFINAL #define FMANY -3 #define CVUMANY -3 #define CMANY -3 #define SMANY -1 #define IDX_A -4 #define O(name, imm, pop, push, flags) pop, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef MFINAL #undef F_MFINAL #undef C_MFINAL #undef V_MFINAL #undef FMANY #undef CVUMANY #undef CMANY #undef SMANY #undef IDX_A #undef O }; auto const op = peek_op(pc); int n = numberOfPops[size_t(op)]; // For most instructions, we know how many values are popped based // solely on the opcode if (n >= 0) return n; // BaseSC and BaseSL remove an A that may be on the top of the stack or one // element below the top, depending on the second immediate. if (n == -4) return getImm(pc, 1).u_IVA + 1; // FCall, NewPackedArray, and some final member operations specify how many // values are popped in their first immediate if (n == -3) return getImm(pc, 0).u_IVA; // FPassM final operations have paramId as imm 0 and stackCount as imm1 if (n == -6) return getImm(pc, 1).u_IVA; // Other final member operations pop their first immediate + 1 if (n == -5) return getImm(pc, 0).u_IVA + 1; // For instructions with vector immediates, we have to scan the contents of // the vector immediate to determine how many values are popped assert(n == -1); ImmVector iv = getImmVector(pc); int k = iv.numStackValues(); return k; }
/** * instrNumPops() returns the number of values consumed from the stack * for a given push/pop instruction. For peek/poke instructions, this * function returns 0. */ int instrNumPops(PC pc) { static const int32_t numberOfPops[] = { #define NOV 0 #define ONE(...) 1 #define TWO(...) 2 #define THREE(...) 3 #define FOUR(...) 4 #define MFINAL -3 #define F_MFINAL -6 #define C_MFINAL -5 #define V_MFINAL C_MFINAL #define FMANY -3 #define UFMANY -4 #define CVUMANY -3 #define CMANY -3 #define SMANY -1 #define O(name, imm, pop, push, flags) pop, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef MFINAL #undef F_MFINAL #undef C_MFINAL #undef V_MFINAL #undef FMANY #undef UFMANY #undef CVUMANY #undef CMANY #undef SMANY #undef O }; auto const op = peek_op(pc); int n = numberOfPops[size_t(op)]; // For most instructions, we know how many values are popped based // solely on the opcode if (n >= 0) return n; // FCall, NewPackedArray, and some final member operations specify how many // values are popped in their first immediate if (n == -3) return getImm(pc, 0).u_IVA; // FCallM, FCallDM, and FCallUnpackM pop uninit values from the stack and // push multiple returned values. if (n == -4) return getImm(pc, 0).u_IVA + getImm(pc, 1).u_IVA - 1; // FPassM final operations have paramId as imm 0 and stackCount as imm1 if (n == -6) return getImm(pc, 1).u_IVA; // Other final member operations pop their first immediate + 1 if (n == -5) return getImm(pc, 0).u_IVA + 1; // For instructions with vector immediates, we have to scan the contents of // the vector immediate to determine how many values are popped assertx(n == -1); ImmVector iv = getImmVector(pc); int k = iv.numStackValues(); return k; }
/** * instrNumPops() returns the number of values consumed from the stack * for a given push/pop instruction. For peek/poke instructions, this * function returns 0. */ int instrNumPops(PC pc) { static const int32_t numberOfPops[] = { #define NOV 0 #define ONE(...) 1 #define TWO(...) 2 #define THREE(...) 3 #define FOUR(...) 4 #define FIVE(...) 5 #define MFINAL -3 #define C_MFINAL -5 #define V_MFINAL C_MFINAL #define CVMANY -3 #define CVUMANY -3 #define FCALL -4 #define CMANY -3 #define SMANY -1 #define O(name, imm, pop, push, flags) pop, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef FIVE #undef MFINAL #undef C_MFINAL #undef V_MFINAL #undef CVMANY #undef CVUMANY #undef FCALL #undef CMANY #undef SMANY #undef O }; auto const op = peek_op(pc); int n = numberOfPops[size_t(op)]; // For most instructions, we know how many values are popped based // solely on the opcode if (n >= 0) return n; // FCallAwait, NewPackedArray, and some final member operations specify how // many values are popped in their first immediate if (n == -3) return getImm(pc, 0).u_IVA; // FCall pops numArgs, unpack and (numRets - 1) uninit values if (n == -4) { auto const fca = getImm(pc, 0).u_FCA; return fca.numArgs + (fca.hasUnpack ? 1 : 0) + fca.numRets - 1; } // Other final member operations pop their first immediate + 1 if (n == -5) return getImm(pc, 0).u_IVA + 1; // For instructions with vector immediates, we have to scan the contents of // the vector immediate to determine how many values are popped assertx(n == -1); ImmVector iv = getImmVector(pc); int k = iv.numStackValues(); return k; }
/** * instrNumPops() returns the number of values consumed from the stack * for a given push/pop instruction. For peek/poke instructions, this * function returns 0. */ int instrNumPops(const Op* opcode) { static const int8_t numberOfPops[] = { #define NOV 0 #define ONE(...) 1 #define TWO(...) 2 #define THREE(...) 3 #define FOUR(...) 4 #define MMANY -1 #define C_MMANY -2 #define V_MMANY -2 #define R_MMANY -2 #define FMANY -3 #define CVMANY -3 #define CVUMANY -3 #define CMANY -3 #define SMANY -1 #define O(name, imm, pop, push, flags) pop, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef FOUR #undef MMANY #undef C_MMANY #undef V_MMANY #undef R_MMANY #undef FMANY #undef CVMANY #undef CVUMANY #undef CMANY #undef SMANY #undef O }; int n = numberOfPops[uint8_t(*opcode)]; // For most instructions, we know how many values are popped based // solely on the opcode if (n >= 0) return n; // FCall and NewPackedArray specify how many values are popped in their // first immediate if (n == -3) return getImm(opcode, 0).u_IVA; // For instructions with vector immediates, we have to scan the // contents of the vector immediate to determine how many values // are popped assert(n == -1 || n == -2); ImmVector iv = getImmVector(opcode); // Count the number of values on the stack accounted for by the // ImmVector's location and members int k = iv.numStackValues(); // If this instruction also takes a RHS, count that too if (n == -2) ++k; return k; }
/** * instrNumPops() returns the number of values consumed from the stack * for a given push/pop instruction. For peek/poke instructions, this * function returns 0. */ int instrNumPops(const Opcode* opcode) { static const int8_t numberOfPops[] = { #define NOV 0 #define ONE(...) 1 #define TWO(...) 2 #define THREE(...) 3 #define LMANY(...) -1 #define C_LMANY(...) -2 #define V_LMANY(...) -2 #define FMANY -3 #define O(name, imm, pop, push, flags) pop, OPCODES #undef NOV #undef ONE #undef TWO #undef THREE #undef LMANY #undef C_LMANY #undef V_LMANY #undef FMANY #undef O }; int n = numberOfPops[*opcode]; // For most instructions, we know how many values are popped based // solely on the opcode if (n >= 0) return n; // FCall specifies how many values are popped in its first immediate if (n == -3) return getImm(opcode, 0).u_IVA; // For instructions with vector immediates, we have to scan the // contents of the vector immediate to determine how many values // are popped ASSERT(n == -1 || n == -2); ImmVector iv = getImmVector(opcode); // Count the number of values on the stack accounted for by the // ImmVector's location and members int k = iv.numStackValues(); // If this instruction also takes a RHS, count that too if (n == -2) ++k; return k; }