Floating point stack and exchange instruction
AssigneeAdvanced Micro Devices, Inc.
InventorsMichael D. Goddard, Scott A. White
Life of this patent
Estimating the term…
Abstract
In a processor (110) that performs multiple instructions in a single cycle, predicts outcomes of branch conditions and speculatively executes instructions based on the branch predictions, a method and apparatus for operating a data stack utilize a remap array (674) to support a stack exchange capability. The remap array is used to correlate a stack pointer (672) to data elements (700) within the stack. A lookahead stack pointer (502) and remap array (504) are updated to preserve the processor's state of operation while speculative instructions are executed.
Claims15
A processor that speculatively performs a plurality of operations concurrently of an instruction set including calculation instructions and stack instructions further including a stack exchange instruction and instructions that push or pop the stack, the processor comprising:
- an instruction decoder;
- a speculative execution unit coupled to the instruction decoder and controlling speculative execution of selected instructions in the instruction set including speculative execution of the stack exchange instruction;
- a calculation execution unit coupled to the instruction decoder, the calculation execution unit executing calculation operations;
- and
- a stack coupled to the speculative execution unit and coupled to the calculation execution unit including:
- a stack array storing calculation results received from the calculation execution unit;
- a stack pointer coupled to the stack array and specifying array elements for storing the calculation results;
- and
- a stack remap array coupling the stack pointer to the stack array and reordering stack array elements addressed by the stack pointer.
A method of controlling a stack in a processor that executes an instruction set including conditional branch instructions, a stack exchange instruction, instructions that push or pop the stack and instructions that access the stack, the method comprising:
- speculatively executing a plurality of instructions of the instruction set concurrently;
- exchanging elements of a stack remap array during execution of a stack exchange instruction;
- adjusting a stack pointer in a first direction during execution of a stack push instruction;
- adjusting the stack pointer in a second direction opposite the first direction during execution of a stack pop operation;
- and
- accessing a stack array element designated by the stack pointer and reordered by the stack remap array during a stack access instruction.
A method of controlling a stack in a processor that executes an instruction set including a stack exchange instruction, instructions that push or pop the stack, instructions that access the stack and conditional branch instructions, the method comprising:
- speculatively executing a plurality of instructions of the instruction set concurrently;
- exchanging elements of a lookahead stack remap array during execution of a stack exchange instruction;
- adjusting a lookahead stack pointer during execution of an instruction that pushes or pops the stack;
- accessing a stack array element designated by the lookahead stack pointer and reordered by the lookahead stack remap array during execution of an instruction that accesses the stack;
- responding to a conditional branch instruction including:
- saving the lookahead remap array,
- predicting whether the branch is taken or not taken,
- determining whether the branch is predicted correctly or mispredicted and restoring the lookahead remap array to the saved value when the branch instruction is mispredicted;
- and
- retiring the instruction in program order determined by a reorder buffer retirement logic,
- including:
- replacing the stack remap array with the lookahead remap array during retirement of a stack exchange instruction, and
- adjusting the stack pointer during retirement of a instruction that pushes or pops the stack.
A stack in a processor which executes an instruction set including conditional branch instructions, a stack exchange instruction, and instructions that push or pop the stack, the stack comprising:
- a speculative execution unit which speculatively executes conditional branch instructions and the stack exchange instruction;
- a stack memory array coupled to the speculative execution unit;
- a stack pointer coupled to the stack memory array, the stack pointer designating a stack memory array element and adjusting the stack pointer during execution of instructions that push or pop the stack;
- and
- a stack remap array of pointers coupled to the stack pointer and coupled to the stack memory array, the stack remap array reordering stack array elements as the stack array elements are addressed by the stack pointer, the pointers being exchanged in response to a stack exchange instruction.
A processor that concurrently executes a plurality of instructions from an instruction set including branch instructions, stack element exchange instructions and instructions that push and pop the stack, the stack comprising:
- a register file including a stack memory array;
- a reorder buffer coupled to the register file including:
- a stack pointer specifying a stack memory array element;
- and
- a stack remap array coupling the stack pointer to the stack memory array and reordering stack memory elements addressed by the stack pointer;
- an instruction decoder coupled to the register file and the reorder buffer including:
- a lookahead stack pointer;
- a lookahead remap array coupled to the lookahead stack pointer;
- a decoding circuit coupled to the lookahead stack pointer and the lookahead remap array;
- an exchange circuit activated by decoding of a stack element exchange instruction and exchanging lookahead remap array elements;
- a stack controller activated by decoding of an instruction that pushes or pops the stack and adjusting the lookahead stack pointer;
- a branch unit, coupled to the instruction decoder and receiving copies of the lookahead remap array and the lookahead stack pointer, the branch unit including:
- a storage saving copies of the lookahead remap array and the lookahead stack pointer during execution of a branch instruction;
- a branch predictor responsive to a conditional branch instruction and predicting whether a branch is taken or not taken;
- a branch tester coupled to the branch predictor and subsequently determining whether the conditional branch is predicted or mispredicted;
- a misprediction replacement circuit replacing the lookahead remap array with the saved lookahead remap array and replacing the lookahead stack pointer with the saved lookahead stack pointer during execution of a mispredicted branch;
- and
- an exchange replacement circuit replacing the stack remap array with the saved lookahead remap array upon completion of execution of a stack element exchange instruction.
Dependencies are inferred from the claim text.