• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2015 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef GEN_MACROS_H
25 #define GEN_MACROS_H
26 
27 /* Macros for handling per-gen compilation.
28  *
29  * The prefixing macros GENX() and genX() automatically prefix whatever you
30  * give them by GENX_ or genX_  where X is the gen number.
31  *
32  * You can do pseudo-runtime checks in your function such as
33  *
34  * if (GEN_GEN > 8 || GEN_IS_HASWELL) {
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 haswell.
40  *
41  * For places where you really do have a compile-time conflict, you can
42  * use preprocessor logic:
43  *
44  * #if (GEN_GEN > 8 || GEN_IS_HASWELL)
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.  If we don't have this, we can't
53  * do anything.
54  */
55 #ifndef GEN_VERSIONx10
56 #  error "The GEN_VERSIONx10 macro must be defined"
57 #endif
58 
59 #define GEN_GEN ((GEN_VERSIONx10) / 10)
60 #define GEN_IS_HASWELL ((GEN_VERSIONx10) == 75)
61 #define GEN_IS_G4X ((GEN_VERSIONx10) == 45)
62 
63 /* Prefixing macros */
64 #if (GEN_VERSIONx10 == 40)
65 #  define GENX(X) GEN4_##X
66 #  define genX(x) gen4_##x
67 #elif (GEN_VERSIONx10 == 45)
68 #  define GENX(X) GEN45_##X
69 #  define genX(x) gen45_##x
70 #elif (GEN_VERSIONx10 == 50)
71 #  define GENX(X) GEN5_##X
72 #  define genX(x) gen5_##x
73 #elif (GEN_VERSIONx10 == 60)
74 #  define GENX(X) GEN6_##X
75 #  define genX(x) gen6_##x
76 #elif (GEN_VERSIONx10 == 70)
77 #  define GENX(X) GEN7_##X
78 #  define genX(x) gen7_##x
79 #elif (GEN_VERSIONx10 == 75)
80 #  define GENX(X) GEN75_##X
81 #  define genX(x) gen75_##x
82 #elif (GEN_VERSIONx10 == 80)
83 #  define GENX(X) GEN8_##X
84 #  define genX(x) gen8_##x
85 #elif (GEN_VERSIONx10 == 90)
86 #  define GENX(X) GEN9_##X
87 #  define genX(x) gen9_##x
88 #elif (GEN_VERSIONx10 == 100)
89 #  define GENX(X) GEN10_##X
90 #  define genX(x) gen10_##x
91 #else
92 #  error "Need to add prefixing macros for this gen"
93 #endif
94 
95 #endif /* GEN_MACROS_H */
96