1 /* 2 * Copyright ©2021 Collabora Ltd. 3 * Copyright © 2015 Intel Corporation 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 * IN THE SOFTWARE. 23 */ 24 25 #ifndef GEN_MACROS_H 26 #define GEN_MACROS_H 27 28 /* Macros for handling per-gen compilation. 29 * 30 * The macro GENX() automatically suffixes whatever you give it with _vX 31 * 32 * You can do pseudo-runtime checks in your function such as 33 * 34 * if (PAN_ARCH == 4) { 35 * // Do something 36 * } 37 * 38 * The contents of the if statement must be valid regardless of gen, but 39 * the if will get compiled away on everything except first-generation Midgard. 40 * 41 * For places where you really do have a compile-time conflict, you can 42 * use preprocessor logic: 43 * 44 * #if (PAN_ARCH == 75) 45 * // Do something 46 * #endif 47 * 48 * However, it is strongly recommended that the former be used whenever 49 * possible. 50 */ 51 52 /* Base macro defined on the command line. */ 53 #ifndef PAN_ARCH 54 #include "genxml/common_pack.h" 55 #else 56 57 /* Suffixing macros */ 58 #if (PAN_ARCH == 4) 59 #define GENX(X) X##_v4 60 #include "genxml/v4_pack.h" 61 #elif (PAN_ARCH == 5) 62 #define GENX(X) X##_v5 63 #include "genxml/v5_pack.h" 64 #elif (PAN_ARCH == 6) 65 #define GENX(X) X##_v6 66 #include "genxml/v6_pack.h" 67 #elif (PAN_ARCH == 7) 68 #define GENX(X) X##_v7 69 #include "genxml/v7_pack.h" 70 #elif (PAN_ARCH == 9) 71 #define GENX(X) X##_v9 72 #include "genxml/v9_pack.h" 73 #elif (PAN_ARCH == 10) 74 #define GENX(X) X##_v10 75 #include "genxml/v10_pack.h" 76 #else 77 #error "Need to add suffixing macro for this architecture" 78 #endif 79 80 #endif /* PAN_ARCH */ 81 #endif /* GEN_MACROS_H */ 82