• 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 (GFX_VERx10 == 75) {
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 (GFX_VERx10 == 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.  If we don't have this, we can't
53  * do anything.
54  */
55 #ifndef GFX_VERx10
56 #  error "The GFX_VERx10 macro must be defined"
57 #endif
58 
59 #define GFX_VER ((GFX_VERx10) / 10)
60 
61 /* Prefixing macros */
62 #if (GFX_VERx10 == 40)
63 #  define GENX(X) GFX4_##X
64 #  define genX(x) gfx4_##x
65 #elif (GFX_VERx10 == 45)
66 #  define GENX(X) GFX45_##X
67 #  define genX(x) gfx45_##x
68 #elif (GFX_VERx10 == 50)
69 #  define GENX(X) GFX5_##X
70 #  define genX(x) gfx5_##x
71 #elif (GFX_VERx10 == 60)
72 #  define GENX(X) GFX6_##X
73 #  define genX(x) gfx6_##x
74 #elif (GFX_VERx10 == 70)
75 #  define GENX(X) GFX7_##X
76 #  define genX(x) gfx7_##x
77 #elif (GFX_VERx10 == 75)
78 #  define GENX(X) GFX75_##X
79 #  define genX(x) gfx75_##x
80 #elif (GFX_VERx10 == 80)
81 #  define GENX(X) GFX8_##X
82 #  define genX(x) gfx8_##x
83 #elif (GFX_VERx10 == 90)
84 #  define GENX(X) GFX9_##X
85 #  define genX(x) gfx9_##x
86 #elif (GFX_VERx10 == 110)
87 #  define GENX(X) GFX11_##X
88 #  define genX(x) gfx11_##x
89 #elif (GFX_VERx10 == 120)
90 #  define GENX(X) GFX12_##X
91 #  define genX(x) gfx12_##x
92 #elif (GFX_VERx10 == 125)
93 #  define GENX(X) GFX125_##X
94 #  define genX(x) gfx125_##x
95 #else
96 #  error "Need to add prefixing macros for this gen"
97 #endif
98 
99 #endif /* GEN_MACROS_H */
100