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