Path: blob/21.2-virgl/src/intel/genxml/gen_macros.h
7178 views
/*1* Copyright © 2015 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef GEN_MACROS_H24#define GEN_MACROS_H2526/* Macros for handling per-gen compilation.27*28* The prefixing macros GENX() and genX() automatically prefix whatever you29* give them by GENX_ or genX_ where X is the gen number.30*31* You can do pseudo-runtime checks in your function such as32*33* if (GFX_VERx10 == 75) {34* // Do something35* }36*37* The contents of the if statement must be valid regardless of gen, but38* the if will get compiled away on everything except haswell.39*40* For places where you really do have a compile-time conflict, you can41* use preprocessor logic:42*43* #if (GFX_VERx10 == 75)44* // Do something45* #endif46*47* However, it is strongly recommended that the former be used whenever48* possible.49*/5051/* Base macro defined on the command line. If we don't have this, we can't52* do anything.53*/54#ifndef GFX_VERx1055# error "The GFX_VERx10 macro must be defined"56#endif5758#define GFX_VER ((GFX_VERx10) / 10)5960/* Prefixing macros */61#if (GFX_VERx10 == 40)62# define GENX(X) GFX4_##X63# define genX(x) gfx4_##x64#elif (GFX_VERx10 == 45)65# define GENX(X) GFX45_##X66# define genX(x) gfx45_##x67#elif (GFX_VERx10 == 50)68# define GENX(X) GFX5_##X69# define genX(x) gfx5_##x70#elif (GFX_VERx10 == 60)71# define GENX(X) GFX6_##X72# define genX(x) gfx6_##x73#elif (GFX_VERx10 == 70)74# define GENX(X) GFX7_##X75# define genX(x) gfx7_##x76#elif (GFX_VERx10 == 75)77# define GENX(X) GFX75_##X78# define genX(x) gfx75_##x79#elif (GFX_VERx10 == 80)80# define GENX(X) GFX8_##X81# define genX(x) gfx8_##x82#elif (GFX_VERx10 == 90)83# define GENX(X) GFX9_##X84# define genX(x) gfx9_##x85#elif (GFX_VERx10 == 110)86# define GENX(X) GFX11_##X87# define genX(x) gfx11_##x88#elif (GFX_VERx10 == 120)89# define GENX(X) GFX12_##X90# define genX(x) gfx12_##x91#elif (GFX_VERx10 == 125)92# define GENX(X) GFX125_##X93# define genX(x) gfx125_##x94#else95# error "Need to add prefixing macros for this gen"96#endif9798#endif /* GEN_MACROS_H */99100101