1*e4b17023SJohn Marino/* Definitions for the branch prediction routines in the GNU compiler. 2*e4b17023SJohn Marino Copyright (C) 2001, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. 3*e4b17023SJohn Marino 4*e4b17023SJohn MarinoThis file is part of GCC. 5*e4b17023SJohn Marino 6*e4b17023SJohn MarinoGCC is free software; you can redistribute it and/or modify it under 7*e4b17023SJohn Marinothe terms of the GNU General Public License as published by the Free 8*e4b17023SJohn MarinoSoftware Foundation; either version 3, or (at your option) any later 9*e4b17023SJohn Marinoversion. 10*e4b17023SJohn Marino 11*e4b17023SJohn MarinoGCC is distributed in the hope that it will be useful, but WITHOUT ANY 12*e4b17023SJohn MarinoWARRANTY; without even the implied warranty of MERCHANTABILITY or 13*e4b17023SJohn MarinoFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14*e4b17023SJohn Marinofor more details. 15*e4b17023SJohn Marino 16*e4b17023SJohn MarinoYou should have received a copy of the GNU General Public License 17*e4b17023SJohn Marinoalong with GCC; see the file COPYING3. If not see 18*e4b17023SJohn Marino<http://www.gnu.org/licenses/>. */ 19*e4b17023SJohn Marino 20*e4b17023SJohn Marino/* Before including this file, you should define a macro: 21*e4b17023SJohn Marino 22*e4b17023SJohn Marino DEF_PREDICTOR (ENUM, NAME, HITRATE) 23*e4b17023SJohn Marino 24*e4b17023SJohn Marino This macro will be called once for each predictor. The ENUM will 25*e4b17023SJohn Marino be of type `enum predictor', and will enumerate all supported 26*e4b17023SJohn Marino predictors. The order of DEF_PREDICTOR calls is important, as 27*e4b17023SJohn Marino in the first match combining heuristics, the predictor appearing 28*e4b17023SJohn Marino first in this file will win. 29*e4b17023SJohn Marino 30*e4b17023SJohn Marino NAME is used in the debugging output to determine predictor type. 31*e4b17023SJohn Marino 32*e4b17023SJohn Marino HITRATE is the probability that edge predicted by predictor as taken 33*e4b17023SJohn Marino will be really taken (so it should be always above 34*e4b17023SJohn Marino REG_BR_PROB_BASE / 2). */ 35*e4b17023SJohn Marino 36*e4b17023SJohn Marino 37*e4b17023SJohn Marino/* A value used as final outcome of all heuristics. */ 38*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_COMBINED, "combined", PROB_ALWAYS, 0) 39*e4b17023SJohn Marino 40*e4b17023SJohn Marino/* An outcome estimated by Dempster-Shaffer theory. */ 41*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_DS_THEORY, "DS theory", PROB_ALWAYS, 0) 42*e4b17023SJohn Marino 43*e4b17023SJohn Marino/* A combined heuristics using probability determined by first 44*e4b17023SJohn Marino matching heuristics from this list. */ 45*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_FIRST_MATCH, "first match", PROB_ALWAYS, 0) 46*e4b17023SJohn Marino 47*e4b17023SJohn Marino/* Heuristic applying when no heuristic below applies. */ 48*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_NO_PREDICTION, "no prediction", PROB_ALWAYS, 0) 49*e4b17023SJohn Marino 50*e4b17023SJohn Marino/* Mark unconditional jump as taken. */ 51*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_UNCONDITIONAL, "unconditional jump", PROB_ALWAYS, 52*e4b17023SJohn Marino PRED_FLAG_FIRST_MATCH) 53*e4b17023SJohn Marino 54*e4b17023SJohn Marino/* Use number of loop iterations determined by # of iterations 55*e4b17023SJohn Marino analysis to set probability. We don't want to use Dempster-Shaffer 56*e4b17023SJohn Marino theory here, as the predictions is exact. */ 57*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_LOOP_ITERATIONS, "loop iterations", PROB_ALWAYS, 58*e4b17023SJohn Marino PRED_FLAG_FIRST_MATCH) 59*e4b17023SJohn Marino 60*e4b17023SJohn Marino/* Hints dropped by user via __builtin_expect feature. */ 61*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_BUILTIN_EXPECT, "__builtin_expect", PROB_VERY_LIKELY, 62*e4b17023SJohn Marino PRED_FLAG_FIRST_MATCH) 63*e4b17023SJohn Marino 64*e4b17023SJohn Marino/* Use number of loop iterations guessed by the contents of the loop. */ 65*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_LOOP_ITERATIONS_GUESSED, "guessed loop iterations", 66*e4b17023SJohn Marino PROB_ALWAYS, PRED_FLAG_FIRST_MATCH) 67*e4b17023SJohn Marino 68*e4b17023SJohn Marino/* Branch containing goto is probably not taken. */ 69*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_CONTINUE, "continue", HITRATE (50), 0) 70*e4b17023SJohn Marino 71*e4b17023SJohn Marino/* Branch to basic block containing call marked by noreturn attribute. */ 72*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_NORETURN, "noreturn call", PROB_VERY_LIKELY, 73*e4b17023SJohn Marino PRED_FLAG_FIRST_MATCH) 74*e4b17023SJohn Marino 75*e4b17023SJohn Marino/* Branch to basic block containing call marked by cold function attribute. */ 76*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_COLD_FUNCTION, "cold function call", PROB_VERY_LIKELY, 77*e4b17023SJohn Marino PRED_FLAG_FIRST_MATCH) 78*e4b17023SJohn Marino 79*e4b17023SJohn Marino/* Loopback edge is taken. */ 80*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_LOOP_BRANCH, "loop branch", HITRATE (86), 81*e4b17023SJohn Marino PRED_FLAG_FIRST_MATCH) 82*e4b17023SJohn Marino 83*e4b17023SJohn Marino/* Edge causing loop to terminate is probably not taken. */ 84*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_LOOP_EXIT, "loop exit", HITRATE (91), 85*e4b17023SJohn Marino PRED_FLAG_FIRST_MATCH) 86*e4b17023SJohn Marino 87*e4b17023SJohn Marino/* Pointers are usually not NULL. */ 88*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_POINTER, "pointer", HITRATE (85), 0) 89*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_TREE_POINTER, "pointer (on trees)", HITRATE (85), 0) 90*e4b17023SJohn Marino 91*e4b17023SJohn Marino/* NE is probable, EQ not etc... */ 92*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_OPCODE_POSITIVE, "opcode values positive", HITRATE (79), 0) 93*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_OPCODE_NONEQUAL, "opcode values nonequal", HITRATE (71), 0) 94*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_FPOPCODE, "fp_opcode", HITRATE (90), 0) 95*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_TREE_OPCODE_POSITIVE, "opcode values positive (on trees)", HITRATE (73), 0) 96*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_TREE_OPCODE_NONEQUAL, "opcode values nonequal (on trees)", HITRATE (72), 0) 97*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_TREE_FPOPCODE, "fp_opcode (on trees)", HITRATE (90), 0) 98*e4b17023SJohn Marino 99*e4b17023SJohn Marino/* Branch guarding call is probably taken. */ 100*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_CALL, "call", HITRATE (71), 0) 101*e4b17023SJohn Marino 102*e4b17023SJohn Marino/* Branch causing function to terminate is probably not taken. */ 103*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (61), 0) 104*e4b17023SJohn Marino 105*e4b17023SJohn Marino/* Branch containing goto is probably not taken. */ 106*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_GOTO, "goto", HITRATE (70), 0) 107*e4b17023SJohn Marino 108*e4b17023SJohn Marino/* Branch ending with return constant is probably not taken. */ 109*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_CONST_RETURN, "const return", HITRATE (67), 0) 110*e4b17023SJohn Marino 111*e4b17023SJohn Marino/* Branch ending with return negative constant is probably not taken. */ 112*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_NEGATIVE_RETURN, "negative return", HITRATE (96), 0) 113*e4b17023SJohn Marino 114*e4b17023SJohn Marino/* Branch ending with return; is probably not taken */ 115*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_NULL_RETURN, "null return", HITRATE (90), 0) 116*e4b17023SJohn Marino 117*e4b17023SJohn Marino/* Branches to a mudflap bounds check are extremely unlikely. */ 118*e4b17023SJohn MarinoDEF_PREDICTOR (PRED_MUDFLAP, "mudflap check", PROB_VERY_LIKELY, 0) 119