1 /* 2 * Copyright © 2017 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 class Coordinate 33 { 34 public: 35 Coordinate(); 36 Coordinate(INT_8 c, INT_32 n); 37 38 VOID set(INT_8 c, INT_32 n); 39 UINT_32 ison(UINT_32 x, UINT_32 y, UINT_32 z = 0, UINT_32 s = 0, UINT_32 m = 0) const; 40 INT_8 getdim(); 41 INT_8 getord(); 42 43 BOOL_32 operator==(const Coordinate& b); 44 BOOL_32 operator<(const Coordinate& b); 45 BOOL_32 operator>(const Coordinate& b); 46 BOOL_32 operator<=(const Coordinate& b); 47 BOOL_32 operator>=(const Coordinate& b); 48 BOOL_32 operator!=(const Coordinate& b); 49 Coordinate& operator++(INT_32); 50 51 private: 52 INT_8 dim; 53 INT_8 ord; 54 }; 55 56 class CoordTerm 57 { 58 public: 59 CoordTerm(); 60 VOID Clear(); 61 VOID add(Coordinate& co); 62 VOID add(CoordTerm& cl); 63 BOOL_32 remove(Coordinate& co); 64 BOOL_32 Exists(Coordinate& co); 65 VOID copyto(CoordTerm& cl); 66 UINT_32 getsize(); 67 UINT_32 getxor(UINT_32 x, UINT_32 y, UINT_32 z = 0, UINT_32 s = 0, UINT_32 m = 0) const; 68 69 VOID getsmallest(Coordinate& co); 70 UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, INT_8 axis = '\0'); 71 Coordinate& operator[](UINT_32 i); 72 BOOL_32 operator==(const CoordTerm& b); 73 BOOL_32 operator!=(const CoordTerm& b); 74 BOOL_32 exceedRange(UINT_32 xRange, UINT_32 yRange = 0, UINT_32 zRange = 0, UINT_32 sRange = 0); 75 76 private: 77 static const UINT_32 MaxCoords = 8; 78 UINT_32 num_coords; 79 Coordinate m_coord[MaxCoords]; 80 }; 81 82 class CoordEq 83 { 84 public: 85 CoordEq(); 86 VOID remove(Coordinate& co); 87 BOOL_32 Exists(Coordinate& co); 88 VOID resize(UINT_32 n); 89 UINT_32 getsize(); 90 virtual UINT_64 solve(UINT_32 x, UINT_32 y, UINT_32 z = 0, UINT_32 s = 0, UINT_32 m = 0) const; 91 virtual VOID solveAddr(UINT_64 addr, UINT_32 sliceInM, 92 UINT_32& x, UINT_32& y, UINT_32& z, UINT_32& s, UINT_32& m) const; 93 94 VOID copy(CoordEq& o, UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF); 95 VOID reverse(UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF); 96 VOID xorin(CoordEq& x, UINT_32 start = 0); 97 UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, INT_8 axis = '\0'); 98 VOID shift(INT_32 amount, INT_32 start = 0); 99 virtual CoordTerm& operator[](UINT_32 i); 100 VOID mort2d(Coordinate& c0, Coordinate& c1, UINT_32 start = 0, UINT_32 end = 0); 101 VOID mort3d(Coordinate& c0, Coordinate& c1, Coordinate& c2, UINT_32 start = 0, UINT_32 end = 0); 102 103 BOOL_32 operator==(const CoordEq& b); 104 BOOL_32 operator!=(const CoordEq& b); 105 106 private: 107 static const UINT_32 MaxEqBits = 64; 108 UINT_32 m_numBits; 109 110 CoordTerm m_eq[MaxEqBits]; 111 }; 112 113 #endif 114 115