Download TriCore™ Compiler Writer`s Guide
Transcript
TriCore 32-bit Unified Processor Compiler Writer’s Guide conditional, the actual branch direction is resolved. If the branch direction is contrary to the prediction, then the correct target address is sent to the fetch unit at the end of the execute cycle. The decode cycle for the first instruction at the branch target address follows the execute cycle for the branch instruction. This is equivalent to a branch time of two cycles for a branch that is either unconditional, or correctly predicted as taken. If a branch is incorrectly predicted, the correct target address is sent to the instruction fetch unit at the end of the branch instruction's execute cycle, giving an effective branch time of three cycles. For a branch that is correctly predicted as not taken, the execution time is the same as for a regular instruction: one cycle. The branch timing numbers are summarized in Table 6, which follows. Table 6 TriCore 1.2/1.3 Branch Timings Actual Direction Predicted Direction Taken Not Taken Taken 2 3 Not Taken 3 1 2.1.3.3 TriCore 2.0 Branch Timings The TriCore 2.0 branch mechanism is compliant with TriCore 1.2/1.3, but is implemented differently. Branch instruction selection and hence block ordering should be performed in the same manner as for TriCore 1.2/1.3 to limit the differences in compiler implementations. 2.1.3.4 Block Ordering for TriCore 1.2/1.3 Compilers often have some knowledge of branch probabilities. That knowledge may be derived from heuristics applied to the source code, or from direct feedback of profiling information. In either case the compiler can use the information to reduce branch costs. The conditional branch instructions of the TriCore architecture do not include a static prediction bit as such, but the compiler can choose to order code blocks in such a way that the static prediction scheme employed by the implementation becomes “self-full filling”. That scheme is: • Backward and short forward branches taken • Long forward branches not taken A short forward branch is a 16-bit branch instruction with a positive displacement. Although it is common to order blocks for code generation according to their natural order in the source code, there is no inherent requirement for the compiler to do so. Ordering according to the source code does facilitate debugging, and it normally gives User’s Manual 40 V1.4, 2003-12