Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
Be illustrated in figure 1 as the structural representation of a kind of typical data table items in the existing processor; This data table items is 32 a data table items; Wherein the marker bit in the tag field is respectively F1-F8; Be respectively Field_1-Field_8 with the corresponding data field of marker bit, when certain marker bit enabled in the tag field, processor will go corresponding data field to obtain data to carry out code process; Such as when F1 and F3 enable, processor can go Field_1 and Field_3 to obtain data to carry out code process.
Be illustrated in figure 2 as the schematic flow sheet of the method for searching processing of a kind of data table items that the embodiment of the invention provides, this method comprises:
S201: search the enable flag position in the said tag field;
Need not carry out the pairing processing code of all marker bits in the tag field in the present embodiment, but directly find the enable flag position in this tag field, and then carry out this pairing processing code in enable flag position.The mode of directly searching the enable flag position in the present embodiment can have multiple, does not limit at this.
S202: jump to the pairing data field in said enable flag position and carry out code process.
It is to be noted; In embodiments of the present invention; Be after finding an enable flag position through S201, to jump to this pairing data field in enable flag position at once and carry out code process, after finishing dealing with; Continue to search next enable flag position again, till all pairing processing code in enable flag position all obtain handling in tag field.
The embodiment of the invention is through directly searching the enable flag position in the tag field and carry out this pairing processing code in enable flag position, and the embodiment of the invention only need utilize a hardware instruction to realize.Make the embodiment of the invention need not carry out the pairing processing code of all marker bits in the data table items, effectively improved the work efficiency of processor.
Be illustrated in figure 3 as the schematic flow sheet of the method for searching processing of the another kind of data table items that the embodiment of the invention provides, come the embodiment of the invention is described below in conjunction with Fig. 1 and Fig. 3, this method comprises:
S301: the tag field in the data table items is carried out the value that shifting function influences carry flag carry-flag;
Data table items generally is stored in the internal memory, when system need operate this data table items, can it be read in the register, and then operate.The embodiment of the invention is carried out associative operation after promptly can data table items shown in Figure 1 being read in one 32 registers that perhaps capacity is bigger again.
On concrete the realization, S301 can realize through processor, such as; Data table items is stored in the internal memory of processor, when needs carried out shifting function, processor read this data table items in one register; Then through arithmetic logical unti in the processor (Arithmetic Logic Unit, the shift unit (Shift) in ALU) is accomplished shifting function, when ALU accomplishes a shifting function; Last position that is moved out of will be kept among the Carry-flag of flag register; With data table items shown in Figure 1 is example, and a shifting function described in the embodiment of the invention is meant the single job of the some marker bits in the tag field being shifted out data table items; Such as 9bit that F1 is moved to left, or with the F2 10bit etc. that moves to left.Because the embodiment of the invention needs in the judgment data list item value of each marker bit on the tag field; Therefore can utilize the shifting function of tag field to influence the value of Carry-flag, and then judge the value on certain marker bit in this tag field according to the value of Carry-flag.
In addition, it is pointed out that among the S301 that the value that the shifting function to tag field is actually whole data table items moves to left or right-shift operation; With data table items shown in Figure 1 is example; If move to left, the 9bit position just can make tag field have influence on the value of Carry-flag because F1 in the 23bit position, therefore need move to left one 32 data at least; And since F8 in the 16bit position, the scope that therefore moves to left should be between 9bit-16bit; If move to right, because F8 is in the 16bit position, 17 the bit positions that therefore need move to right at least just can make F8 begin to have influence on the value of Carry-flag, and since F1 in the 23bit position, the scope that therefore moves to right should be between 17bit-24bit.It is pointed out that also that in order not change the structure of raw data list item do not have write back operations after each shifting function, each shifting function all is on the basis of raw data list item, to carry out.
S302: the value according to carry-flag finds the enable flag position on direction of displacement in the tag field.
Can know by S301 since can influence after the displacement value of Carry-flag, be example therefore with moving to left of data table items among Fig. 1, if the scope that moves to left between 9bit-16bit the time, the value that the interior value of Carry-flag just is followed successively by on the F1-F8 marker bit is replaced.Therefore only need to judge the value of Carry-flag, promptly know the value on the respective markers position in the tag field.
Specifically, be when tag field shifts out said data table items by turn, judge the state of carry-flag, if be 1, the then current marker bit that shifts out said data table items is the enable flag position, gets into S303 and carries out code process; If be 0, then continue the marker bit that does not shift out in the said tag field is carried out the state that shifting function influences carry-flag.
In order to carry out the skip operation of follow-up shifting function and S303 on the basis of realizing to be shifted in front; When tag field shifts out said data table items by turn, can and note the current position number of marker bit in said tag field that shifts out said data table items in the present embodiment with current PC pointer pop down.This position number is the number that shows that marker bit puts in order in tag field, is respectively 1-8 such as the position number of the marker bit F1-F8 among Fig. 1.
Moving to left with tag field shown in Figure 1 is example, when F1 moves to left nine displacements when going out said data table items, is about to current PC pointer pop down, and notes position number 1, and then judge the value of carry-flag:
If be 0, then jump to call stack PC place, the marker bit that does not shift out on the basis of the current marker bit that shifts out data table items, continuing data table items carries out the value that shifting function influences carry-flag;
If be 1, then jump to the PC+1 place and carry out this processing code, promptly carry out S303.
S303: jump to the pairing data field in enable flag position and carry out code process.
It is to be noted; After executing this S303; Can move the return instruction and return S301; Owing to, therefore can begin to continue to seek next enable flag position through PC pointer pop down aforementioned, all dispose up to all pairing processing code in enable flag position from above-mentioned enable flag position.
The embodiment of the invention utilizes shifting function to come whole marker bits are judged; And then only carry out the processing code at enable flag position place; Avoided carrying out the processing code of all marker bits; And the shifting function of the embodiment of the invention only need take a hardware instruction in realization and can realize, has therefore improved the efficient of the actual execution of processor.
Come the foregoing description is further described through a concrete instruction flow below, be illustrated in figure 4 as the embodiment of the invention a kind of data table items search the processed instruction schematic flow sheet, this instruction flow can comprise
S401: judge whether this cue mark f equals false, if then get into S402; If, then do not get into S405;
It is to be noted that the initial value of mark f is false when carrying out this instruction for the first time.
S402: tagging f equals ture;
S403: the initial data (a) of initialization tag field shifting scope and end data (b); With data table items shown in Figure 1 is example, a=9 after the initialization, b=16;
S404: the current position number c that shifts out data table items of initialization makes c=0;
S405: be pressed into the current PC pointer in the function call stack;
S406: whether judge a greater than b, if greater than would get into S407; If less than, then get into S408;
S407: remove the operation mark, make f equal false, and entering S411 finishes whole instruction;
S408: the shift unit that uses ALU is with the register data a position that moves to left;
S409: a and c are added 1 on the original basis;
S410: judge that whether the carry-flag position is true, if be true, then gets into S411; If, then get into S412 for not;
S411: jump to instruction place of call stack PC+c position, execute instruction back operation return instruction and return S401; If through S407 and get into S411 and since this moment c the position of last instruction inlet of this instruction group of value more than 1, just equal to have jumped out whole instruction group so carry out S411 at this moment, this instruction is through with.
S412: jump to call stack PC, promptly move the return instruction and return S401.
The embodiment of the invention utilizes shifting function to come whole marker bits are judged; And then only carry out the processing code at enable flag position place; Avoided carrying out the processing code of all marker bits; And the shifting function of the embodiment of the invention only need take a hardware instruction in realization and can realize, has therefore improved the efficient of the actual execution of processor.
Be illustrated in figure 5 as the schematic flow sheet of the method for searching processing of the another kind of data table items that the embodiment of the invention provides, this method comprises:
S501: it is the individual sub-tag field of n that said tag field is divided equally, and n is the integer more than or equal to 1;
In the present embodiment; Can do whole tag field as a whole; Also can it be divided equally and be a plurality of sub-tag fields; With Fig. 1 is example, and such as can tag field being divided into 2 sub-tag field: F1-F4 and F5-F8, each sub-tag field all comprises 4 marker bits in the present embodiment.
S502: each sub-tag field is carried out many bits relatively obtain an output valve A;
Many bits in the present embodiment are meant relatively according to a plurality of marker bits in the sub-tag field and obtain an output valve A that this output valve A can represent residing position in this sub-tag field, first enable flag position.In concrete the realization; Can in the inner process chip of processor, realize a hardware logic; Such as being called MCMP (Multi Compare) logic; The input of this MCMP logic is the binary coding of a certain width, and output valve A is a numeral, represents first non-0 position in this input binary coding.See also table 1, it is for being 4 when being binary coding when input coding, the output result of this MCMP logic:
The input of MCMP logic |
The output of MCMP logic |
0000 |
0 |
0001 |
4 |
0010 |
3 |
0011 |
3 |
0100 |
2 |
0101 |
2 |
0110 |
2 |
0111 |
2 |
1000 |
1 |
1001 |
1 |
1010 |
1 |
1011 |
1 |
1100 |
1 |
1101 |
1 |
1110 |
1 |
1111 |
1 |
Table 1
S503: obtain the enable flag position in said each sub-tag field according to output valve A.
S504: jump to the pairing data field in enable flag position and carry out code process.
It is to be noted; In embodiments of the present invention; Be after finding an enable flag position through S503, to jump to this pairing data field in enable flag position at once and carry out code process, after finishing dealing with; Continue again to search the next enable flag position in the above-mentioned tag field, till all pairing processing code in enable flag position all obtain handling in each sub-tag field.
For realize above-mentioned redirect and enable flag position continue search, also can carry out many bits relatively before current PC pointer pop down just.
Below in conjunction with Fig. 1 above-mentioned S502-S504 is done further detailed description:
Tag field among Fig. 1 is divided into: the first sub-tag field (F1-F4), the second sub-tag field F5-F8, suppose that F2, F3 and F7 are the enable flag position.
Then at first the first sub-tag field (0110) is carried out many bits relatively,, can obtain output valve A=2 according to table 1; Thereby confirm that F2 is the enable flag position, corresponding processing code is carried out in the position that then jumps to PC+X+2, and (X is an accumulator register, and its initial value is 0; Whenever change a sub-tag field, X can add the figure place of this sub-tag field, is 4 in the present embodiment); Simultaneously, with the F2 zero clearing; After executing above-mentioned processing code, operation return instruction continues the first sub-tag field (0010) is carried out many bits relatively; According to table 1; Can obtain output valve A=3 this moment, thereby confirm that F3 is the enable flag position, corresponding processing code is carried out in the position that then jumps to PC+0+3; Simultaneously, with the F3 zero clearing; Move the return instruction then, continue the first sub-tag field (0000) is carried out many bits relatively, according to table 1; Obtain output valve A=0; Then begin the second sub-tag field (0010) is carried out many bits relatively, obtain output valve A=3, thereby confirm that F7 is the enable flag position; Corresponding processing code is carried out in the position that then jumps to PC+4+3 (PC+7), then with the F7 zero clearing; Move return instruction once more, again the second sub-tag field (0000) is carried out many bits relatively, obtain output valve A=0,, then finish the processing of searching of this data table items because all sub-tag fields were all judged and finished this moment.
It is thus clear that; Among the pairing embodiment of Fig. 3; No matter employing moves to left or right-shift operation, all need carry out 8 times, and only need just can find out above-mentioned 3 enable flag positions 5 times in the embodiment of the invention; Become 8 if MCMP is imported width, then the embodiment of the invention only need be carried out and just can find above-mentioned 3 enable flag positions for 4 times.Many bits of embodiment of the invention comparative approach also only need take a hardware instruction in addition; Therefore the embodiment of the invention not only can only be carried out the processing code at place, enable flag position; Execution command is simplified, has further improved the efficient of the actual execution of processor.
Be illustrated in figure 6 as the structural representation of searching treating apparatus of a kind of data table items that the embodiment of the invention provides, state in the present embodiment data table items comprise tag field and with said tag field in the corresponding data field of marker bit.This device comprises: search unit 610 and redirect performance element 620, wherein:
Search unit 610 and be used for searching the enable flag position of tag field.
Need not carry out the pairing processing code of all marker bits in the tag field in the present embodiment; But directly find the enable flag position in this tag field, and then carry out this pairing processing code in enable flag position through redirect processing unit 620 through searching unit 610.The mode of directly searching the enable flag position in the present embodiment can have multiple, does not limit at this.
Redirect processing unit 620 is used to jump to the pairing data field in enable flag position and carries out code process.
It is to be noted; In embodiments of the present invention; Be that redirect processing unit 620 jumps to this pairing data field in enable flag position at once and carries out code process, after finishing dealing with after searching unit 610 and finding an enable flag position; Search unit 610 and continue to search next enable flag position again, till all pairing processing code in enable flag position all obtain handling in tag field.
The embodiment of the invention is through directly searching the enable flag position in the tag field and carry out this pairing processing code in enable flag position, and the embodiment of the invention only need utilize a hardware instruction to realize.Make the embodiment of the invention need not carry out the pairing processing code of all marker bits in the data table items, effectively improved the work efficiency of processor.
Be illustrated in figure 7 as the structural representation of searching treating apparatus of the another kind of data table items that the embodiment of the invention provides; This device comprises: search unit 710 and redirect performance element 720, wherein search unit 710 and comprise that again shift module 711 and enable flag search module 712.
Shift module 711 is used for tag field is carried out the value that shifting function influences carry flag carry-flag.
The value that the shifting function of 711 pairs of tag fields of shift module is actually whole data table items in the embodiment of the invention moves to left or right-shift operation; With data table items shown in Figure 1 is example; If move to left, the 9bit position just can make tag field have influence on the value of Carry-flag because F 1 in the 23bit position, therefore need move to left one 32 data at least; And since F8 in the 16bit position, the scope that therefore moves to left should be between 9bit-16bit; If move to right, because F8 is in the 16bit position, 17 the bit positions that therefore need move to right at least just can make F8 begin to have influence on the value of Carry-flag, and since F1 in the 23bit position, the scope that therefore moves to right should be between 17bit-24bit.It is pointed out that also that in order not change the structure of raw data list item do not have write back operations after each shifting function, each shifting function all is on the basis of raw data list item, to carry out.
Enable flag is searched module 712 and is used for finding the enable flag position of said tag field on direction of displacement according to the value of carry-flag.
Since can influence after the displacement value of Carry-flag, be example therefore with moving to left of data table items among Fig. 1, if the scope that moves to left between 9bit-16bit the time, the value that the interior value of Carry-flag just is followed successively by on the F1-F8 marker bit is replaced.Therefore only need to judge the value of Carry-flag, promptly know the value on the respective markers position in the tag field.
Specifically; Enable flag is searched module 712 and specifically can be used for: when shift module 711 shifts out said data table items by turn with tag field; Judge the state of carry-flag; If be 1, confirm that then the current marker bit that shifts out said data table items is the enable flag position, makes redirect performance element 720 to carry out relevant treatment according to this enable flag position; If be 0, then notify shift module 711 that the marker bit that does not shift out in the said tag field is carried out the value that shifting function influences carry-flag.
Similar among the embodiment of redirect performance element 720 and Fig. 6 correspondence, repeat no more once more.
It is to be noted; Redirect performance element 720 is after executing a pairing processing code in enable flag position; Search module 712 and can begin from above-mentioned enable flag position to continue to seek next enable flag position, all dispose up to all pairing processing code in enable flag position.
The embodiment of the invention utilizes shifting function to come whole marker bits are judged; And then only carry out the processing code at enable flag position place; Avoided carrying out the processing code of all marker bits; And the shifting function of the embodiment of the invention only need take a hardware instruction in realization and can realize, has therefore improved the efficient of the actual execution of processor.
Be illustrated in figure 8 as the structural representation of searching treating apparatus of the another kind of data table items that the embodiment of the invention provides; This device comprises: search unit 810 and redirect performance element 820, wherein search unit 810 and comprise segmentation module 811, many bits comparison module 812 and enable flag acquisition module 813 again.
Segmentation module 811 is used for tag field is divided into n sub-tag field, and n is the integer more than or equal to 1.
In the present embodiment; Can be with whole tag field as 1 integral body, also can it be divided equally and be a plurality of sub-tag fields, be example with Fig. 1; Such as can tag field being divided into 2 sub-tag field: F1-F4 and F5-F8, each word mark field all comprises 4 marker bits in the present embodiment.
Many bits comparison module 812 is used for that each sub-tag field is carried out many bits and relatively obtains an output valve A.Many bits in the present embodiment are meant relatively according to a plurality of marker bits in the sub-tag field and obtain an output valve A that this output valve A can represent residing position in this sub-tag field, first enable flag position.
Enable flag acquisition module 813 is used for obtaining the enable flag position in each sub-tag field according to output valve A.
Such as, many bits comparison module 812 specifically is used for: t sub-tag field carried out many bits relatively obtain an output valve A;
Enable flag acquisition module 813 specifically is used for: judge whether output valve A is 0, if be 0, then notify 812 couples of t+1 of many bits comparison module sub-tag fields to carry out many bits relatively; If be not 0; Confirm that then said t the A position in the sub-tag field is the enable flag position; Carry out handled with reinforming redirect performance element 820 after this position zero clearing, notify many bits comparison module 812 to continue t sub-tag field carried out many bits relatively after redirect performance element 820 is finished dealing with.The detailed process of searching processing about the comparison of many bits can repeat no more at this referring to the pairing embodiment of Fig. 5.
Many bits comparative approach of the embodiment of the invention also only need take a hardware instruction; And the embodiment of the invention not only can only be carried out the processing code at place, enable flag position; Execution command is simplified, has further improved the efficient of the actual execution of processor.
Be illustrated in figure 9 as the structural representation of a kind of processor that the embodiment of the invention provides; This processor 900 comprises searches treating apparatus 910; This is searched treating apparatus and can comprise like any one device among Fig. 6, Fig. 7 or the corresponding embodiment of Fig. 8, just no longer this processor has been given unnecessary details at this.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in the foregoing description method; Can instruct relevant hardware to accomplish through computer program; Described program can be stored in the computer read/write memory medium; This program can comprise the flow process like the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only storage memory body (Read-OnlyMemory, ROM) or at random store memory body (Random Access Memory, RAM) etc.
Above-described specific embodiment; The object of the invention, technical scheme and beneficial effect have been carried out further explain, and institute it should be understood that the above is merely specific embodiment of the present invention; And be not used in qualification protection scope of the present invention; All within spirit of the present invention and principle, any modification of being made, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.