GCC Middle and Back End API Reference
hierarchical_discriminator.h
Go to the documentation of this file.
1/* Copyright The GNU Toolchain Authors
2
3This file is part of GCC.
4
5GCC is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free
7Software Foundation; either version 3, or (at your option) any later
8version.
9
10GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or
12FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13for more details.
14
15You should have received a copy of the GNU General Public License
16along with GCC; see the file COPYING3. If not see
17<http://www.gnu.org/licenses/>. */
18
19#ifndef GCC_HIERARCHICAL_DISCRIMINATOR_H
20#define GCC_HIERARCHICAL_DISCRIMINATOR_H
21
22#include "config.h"
23#include "system.h"
24#include "coretypes.h"
25#include "gimple.h"
26#include "tree.h"
27#include "basic-block.h"
28#include "input.h"
29
30/* Hierarchical discriminator layout (32 bits total):
31 Discriminator format: [Base:8][Multiplicity:7][CopyID:11][Unused:6]
32 - Base: bits 0-7 (8 bits, 0-255)
33 - Multiplicity: bits 8-14 (7 bits, 0-127)
34 - CopyID: bits 15-25 (11 bits, 0-2047)
35 - Unused: bits 26-31 (6 bits, reserved)
36
37 Base discriminator: Used by front-end and early passes to distinguish
38 different statements on the same source line.
39
40 Multiplicity: Represents when a single IR statement corresponds to
41 multiple scalar iterations or executions
42
43 CopyID: Unique identifier for distinct code copies to distinguish
44 */
45
46
47/* Helper function to assign discriminators to a statement.
48 This preserves the base discriminator and updates multiplicity
49 and/or copyid. */
50extern void assign_discriminators_to_stmt (gimple* stmt,
51 unsigned int multiplicity_factor,
52 unsigned int copyid);
53
54/* Helper function to assign discriminators to all statements in a basic
55 block. This preserves the base discriminator and updates multiplicity
56 and/or copyid. PHI statements, PHI arguments, and edge locations are
57 also updated. */
59 unsigned int multiplicity_factor,
60 unsigned int copyid);
61
62/* Helper function to assign discriminators to all basic blocks in a loop.
63 This is used by loop versioning passes to distinguish different versions
64 of the same loop and to indicate vectorization factors. */
65extern void assign_discriminators_to_loop (class loop *loop,
66 unsigned int multiplicity_factor,
67 unsigned int copyid);
68
69/* Copy ID allocator for tracking unique copy_id assignments per location.
70 This ensures that nested code duplication (e.g., unroll + vectorize) gets
71 unique copy_ids even when the same location is duplicated
72 multiple times. */
73
75{
76 /* Hash map from location to the next available copy_id base.
77 Key: location_t, Value: unsigned int (next available base). */
79 unsigned int> *location_map;
80
81 /* Whether the allocator has been initialized. */
83};
84
85/* Allocate a unique copy_id base for the given location.
86 STRIDE indicates how many copy_ids to reserve (for unrolling N times,
87 use stride=N). Returns the base copy_id. */
88extern unsigned int allocate_copyid_base (location_t loc, unsigned int stride);
89
90/* Free the copy_id allocator for a function. */
91extern void free_copyid_allocator (struct function *fn);
92
93#endif /* GCC_HIERARCHICAL_DISCRIMINATOR_H. */
Definition hash-map.h:40
Definition cfgloop.h:120
struct basic_block_def * basic_block
Definition coretypes.h:372
void assign_discriminators_to_bb(basic_block bb, unsigned int multiplicity_factor, unsigned int copyid)
Definition hierarchical_discriminator.cc:104
void free_copyid_allocator(struct function *fn)
Definition hierarchical_discriminator.cc:333
unsigned int allocate_copyid_base(location_t loc, unsigned int stride)
Definition hierarchical_discriminator.cc:287
void assign_discriminators_to_loop(class loop *loop, unsigned int multiplicity_factor, unsigned int copyid)
Definition hierarchical_discriminator.cc:169
void assign_discriminators_to_stmt(gimple *stmt, unsigned int multiplicity_factor, unsigned int copyid)
Definition hierarchical_discriminator.cc:78
Definition hierarchical_discriminator.h:75
bool initialized
Definition hierarchical_discriminator.h:82
hash_map< int_hash< location_t, UNKNOWN_LOCATION, UNKNOWN_LOCATION >, unsigned int > * location_map
Definition hierarchical_discriminator.h:79
Definition function.h:249
Definition gimple.h:221