• 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 
37 enum Dim
38 {
39    DIM_X,
40    DIM_Y,
41    DIM_Z,
42    DIM_S,
43    DIM_M,
44    NUM_DIMS
45 };
46 
47 class Coordinate
48 {
49 public:
50     Coordinate();
51     Coordinate(enum Dim dim, INT_32 n);
52 
53     VOID set(enum Dim dim, INT_32 n);
54     UINT_32 ison(const UINT_32 *coords) const;
55     enum Dim getdim();
56     INT_8   getord();
57 
58     BOOL_32 operator==(const Coordinate& b);
59     BOOL_32 operator<(const Coordinate& b);
60     BOOL_32 operator>(const Coordinate& b);
61     BOOL_32 operator<=(const Coordinate& b);
62     BOOL_32 operator>=(const Coordinate& b);
63     BOOL_32 operator!=(const Coordinate& b);
64     Coordinate& operator++(INT_32);
65 
66 private:
67     enum Dim dim;
68     INT_8 ord;
69 };
70 
71 class CoordTerm
72 {
73 public:
74     CoordTerm();
75     VOID Clear();
76     VOID add(Coordinate& co);
77     VOID add(CoordTerm& cl);
78     BOOL_32 remove(Coordinate& co);
79     BOOL_32 Exists(Coordinate& co);
80     VOID copyto(CoordTerm& cl);
81     UINT_32 getsize();
82     UINT_32 getxor(const UINT_32 *coords) const;
83 
84     VOID getsmallest(Coordinate& co);
85     UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, enum Dim axis = NUM_DIMS);
86     Coordinate& operator[](UINT_32 i);
87     BOOL_32 operator==(const CoordTerm& b);
88     BOOL_32 operator!=(const CoordTerm& b);
89     BOOL_32 exceedRange(const UINT_32 *ranges);
90 
91 private:
92     static const UINT_32 MaxCoords = 8;
93     UINT_32 num_coords;
94     Coordinate m_coord[MaxCoords];
95 };
96 
97 class CoordEq
98 {
99 public:
100     CoordEq();
101     VOID remove(Coordinate& co);
102     BOOL_32 Exists(Coordinate& co);
103     VOID resize(UINT_32 n);
104     UINT_32 getsize();
105     virtual UINT_64 solve(const UINT_32 *coords) const;
106     virtual VOID solveAddr(UINT_64 addr, UINT_32 sliceInM,
107                            UINT_32 *coords) const;
108 
109     VOID copy(CoordEq& o, UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF);
110     VOID reverse(UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF);
111     VOID xorin(CoordEq& x, UINT_32 start = 0);
112     UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, enum Dim axis = NUM_DIMS);
113     VOID shift(INT_32 amount, INT_32 start = 0);
114     virtual CoordTerm& operator[](UINT_32 i);
115     VOID mort2d(Coordinate& c0, Coordinate& c1, UINT_32 start = 0, UINT_32 end = 0);
116     VOID mort3d(Coordinate& c0, Coordinate& c1, Coordinate& c2, UINT_32 start = 0, UINT_32 end = 0);
117 
118     BOOL_32 operator==(const CoordEq& b);
119     BOOL_32 operator!=(const CoordEq& b);
120 
121 private:
122     static const UINT_32 MaxEqBits = 64;
123     UINT_32 m_numBits;
124 
125     CoordTerm m_eq[MaxEqBits];
126 };
127 
128 } // V2
129 } // Addr
130 
131 #endif
132 
133