1 /*========================== begin_copyright_notice ============================
2 
3 Copyright (C) 2021 Intel Corporation
4 
5 SPDX-License-Identifier: MIT
6 
7 ============================= end_copyright_notice ===========================*/
8 
9 #ifndef KERNELINFO_
10 #define KERNELINFO_
11 
12 
13 #include <string>
14 #include <map>
15 
16 class VarInfo
17 {
18 public:
19     enum AddressModel {
20         GLOBAL = 0,
21         LOCAL = 1
22     };
23 
24     enum MemAccess {
25         NONE = 0,
26         BLOCKED = 1,
27         STATEFUL = 2,
28         STATELESS = 3,
29         ATOMIC = 4
30     };
31 
32     int lineNb;
33     const char* srcFilename;
34     int size;
35     short type;
36     AddressModel addrModel;
37     MemAccess memoryAccess;
38     bool isSpill;
39     bool isUniform;
40     bool isConst;
41     bool promoted2GRF;
42 
43     // BankConflictInfo
44     int bc_count;
45     int bc_sameBank;
46     int bc_twoSrc;
47 };
48 
49 class KERNEL_INFO
50 {
51 public:
52     std::map<std::string, VarInfo*> variables;
53     std::string name;
54 
KERNEL_INFO()55     KERNEL_INFO() { }
~KERNEL_INFO()56     ~KERNEL_INFO()
57     {
58         for (auto i = variables.begin(); i != variables.end(); ++i)
59         {
60             delete i->second;
61         }
62         variables.clear();
63     }
64 
AddVarInfo(const char * name)65     VarInfo* AddVarInfo(const char* name)
66     {
67         // Add only not existing item
68         if (variables.find(name) == variables.end())
69         {
70             VarInfo* varInfo = new VarInfo();
71             variables.insert({name, varInfo });
72             return varInfo;
73         }
74         // If exists, return nullptr
75         return nullptr;
76     }
77 };
78 
79 #endif
80