• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2007-2019 Advanced Micro Devices, Inc.
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16  * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
17  * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20  * USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * The above copyright notice and this permission notice (including the
23  * next paragraph) shall be included in all copies or substantial portions
24  * of the Software.
25  */
26 
27 // Class used to define a coordinate bit
28 
29 #ifndef __COORD_H
30 #define __COORD_H
31 
32 namespace Addr
33 {
34 namespace V2
35 {
36 #if defined(__cplusplus)
37 #if defined(_MSC_VER)
38     #if _MSC_VER >= 1900
39         #define ADDR_CPP11_COMPILER TRUE
40     #endif
41 #else
42     #if __cplusplus >= 201103L
43         #define ADDR_CPP11_COMPILER TRUE
44     #endif
45 #endif
46 #endif
47 
48 #if defined(ADDR_CPP11_COMPILER)
49 enum Dim : INT_8
50 #else
51 enum Dim
52 #endif
53 {
54    DIM_X,
55    DIM_Y,
56    DIM_Z,
57    DIM_S,
58    DIM_M,
59    NUM_DIMS
60 };
61 
62 class Coordinate
63 {
64 public:
65     Coordinate();
66     Coordinate(enum Dim dim, INT_32 n);
67 
68     VOID set(enum Dim dim, INT_32 n);
69     UINT_32 ison(const UINT_32 *coords) const;
70     enum Dim getdim();
71     INT_8   getord();
72 
73     BOOL_32 operator==(const Coordinate& b);
74     BOOL_32 operator<(const Coordinate& b);
75     BOOL_32 operator>(const Coordinate& b);
76     BOOL_32 operator<=(const Coordinate& b);
77     BOOL_32 operator>=(const Coordinate& b);
78     BOOL_32 operator!=(const Coordinate& b);
79     Coordinate& operator++(INT_32);
80 
81 private:
82     enum Dim dim;
83     INT_8 ord;
84 };
85 
86 class CoordTerm
87 {
88 public:
89     CoordTerm();
90     VOID Clear();
91     VOID add(Coordinate& co);
92     VOID add(CoordTerm& cl);
93     BOOL_32 remove(Coordinate& co);
94     BOOL_32 Exists(Coordinate& co);
95     VOID copyto(CoordTerm& cl);
96     UINT_32 getsize();
97     UINT_32 getxor(const UINT_32 *coords) const;
98 
99     VOID getsmallest(Coordinate& co);
100     UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, enum Dim axis = NUM_DIMS);
101     Coordinate& operator[](UINT_32 i);
102     BOOL_32 operator==(const CoordTerm& b);
103     BOOL_32 operator!=(const CoordTerm& b);
104     BOOL_32 exceedRange(const UINT_32 *ranges);
105 
106 private:
107     static const UINT_32 MaxCoords = 8;
108     UINT_32 num_coords;
109     Coordinate m_coord[MaxCoords];
110 };
111 
112 class CoordEq
113 {
114 public:
115     CoordEq();
116     VOID remove(Coordinate& co);
117     BOOL_32 Exists(Coordinate& co);
118     VOID resize(UINT_32 n);
119     UINT_32 getsize();
120     virtual UINT_64 solve(const UINT_32 *coords) const;
121     virtual VOID solveAddr(UINT_64 addr, UINT_32 sliceInM,
122                            UINT_32 *coords) const;
123 
124     VOID copy(CoordEq& o, UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF);
125     VOID reverse(UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF);
126     VOID xorin(CoordEq& x, UINT_32 start = 0);
127     UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, enum Dim axis = NUM_DIMS);
128     VOID shift(INT_32 amount, INT_32 start = 0);
129     virtual CoordTerm& operator[](UINT_32 i);
130     VOID mort2d(Coordinate& c0, Coordinate& c1, UINT_32 start = 0, UINT_32 end = 0);
131     VOID mort3d(Coordinate& c0, Coordinate& c1, Coordinate& c2, UINT_32 start = 0, UINT_32 end = 0);
132 
133     BOOL_32 operator==(const CoordEq& b);
134     BOOL_32 operator!=(const CoordEq& b);
135 
136 private:
137     static const UINT_32 MaxEqBits = 64;
138     UINT_32 m_numBits;
139 
140     CoordTerm m_eq[MaxEqBits];
141 };
142 
143 } // V2
144 } // Addr
145 
146 #endif
147 
148