Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/panfrost/lib/gen_macros.h
4560 views
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. If we don't have this, we can't
53
* do anything.
54
*/
55
#ifndef PAN_ARCH
56
# error "The PAN_ARCH macro must be defined"
57
#endif
58
59
/* Suffixing macros */
60
#if (PAN_ARCH == 4)
61
# define GENX(X) X##_v4
62
#elif (PAN_ARCH == 5)
63
# define GENX(X) X##_v5
64
#elif (PAN_ARCH == 6)
65
# define GENX(X) X##_v6
66
#elif (PAN_ARCH == 7)
67
# define GENX(X) X##_v7
68
#else
69
# error "Need to add suffixing macro for this architecture"
70
#endif
71
72
#endif /* GEN_MACROS_H */
73
74