Single operation array index computation
View Patent ↗Embodiments are directed to a processor for adjusting an index, wherein the index identifies a location of an element within an array. The processor includes a shift circuit configured to perform a single operation that adjusts a first parameter of the index to match a parameter of an array address. The single operation further adjusts a second parameter of the index to match a parameter of an array element.
1. A method of adjusting an index, wherein the index identifies a location of an element within an array, the method comprising:
performing, by a barrel shift circuit of a processor, a single operation that:
performs, using a selection logic circuit of the barrel shift circuit, an adjustment of a first parameter of the index to match a parameter of an array address; and
performs an adjustment of a second parameter of the index to match a parameter of the array element.
2. The method of claim 1 , wherein:
said array address comprises a start location of the array;
said first parameter comprises a size of the index;
said second parameter comprises a value of the index;
said parameter of the array address comprises a size of the array address; and
said parameter of the array element corresponds to a size of the array element.
3. The method of claim 1 , wherein said adjustment of said first parameter comprises a sign extension of said first parameter.
4. The method of claim 1 , wherein said adjustment of said second parameter comprises shifting said second parameter by an amount corresponding to said parameter of the element.