101e04c3fSmrg/*
201e04c3fSmrg * Copyright © 2015 Intel Corporation
301e04c3fSmrg *
401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a
501e04c3fSmrg * copy of this software and associated documentation files (the "Software"),
601e04c3fSmrg * to deal in the Software without restriction, including without limitation
701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the
901e04c3fSmrg * Software is furnished to do so, subject to the following conditions:
1001e04c3fSmrg *
1101e04c3fSmrg * The above copyright notice and this permission notice (including the next
1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the
1301e04c3fSmrg * Software.
1401e04c3fSmrg *
1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2101e04c3fSmrg * IN THE SOFTWARE.
2201e04c3fSmrg */
2301e04c3fSmrg
2401e04c3fSmrg#ifndef GEN_MACROS_H
2501e04c3fSmrg#define GEN_MACROS_H
2601e04c3fSmrg
2701e04c3fSmrg/* Macros for handling per-gen compilation.
2801e04c3fSmrg *
2901e04c3fSmrg * The prefixing macros GENX() and genX() automatically prefix whatever you
3001e04c3fSmrg * give them by GENX_ or genX_  where X is the gen number.
3101e04c3fSmrg *
3201e04c3fSmrg * You can do pseudo-runtime checks in your function such as
3301e04c3fSmrg *
347ec681f3Smrg * if (GFX_VERx10 == 75) {
3501e04c3fSmrg *    // Do something
3601e04c3fSmrg * }
3701e04c3fSmrg *
3801e04c3fSmrg * The contents of the if statement must be valid regardless of gen, but
3901e04c3fSmrg * the if will get compiled away on everything except haswell.
4001e04c3fSmrg *
4101e04c3fSmrg * For places where you really do have a compile-time conflict, you can
4201e04c3fSmrg * use preprocessor logic:
4301e04c3fSmrg *
447ec681f3Smrg * #if (GFX_VERx10 == 75)
4501e04c3fSmrg *    // Do something
4601e04c3fSmrg * #endif
4701e04c3fSmrg *
4801e04c3fSmrg * However, it is strongly recommended that the former be used whenever
4901e04c3fSmrg * possible.
5001e04c3fSmrg */
5101e04c3fSmrg
5201e04c3fSmrg/* Base macro defined on the command line.  If we don't have this, we can't
5301e04c3fSmrg * do anything.
5401e04c3fSmrg */
557ec681f3Smrg#ifndef GFX_VERx10
567ec681f3Smrg#  error "The GFX_VERx10 macro must be defined"
5701e04c3fSmrg#endif
5801e04c3fSmrg
597ec681f3Smrg#define GFX_VER ((GFX_VERx10) / 10)
6001e04c3fSmrg
6101e04c3fSmrg/* Prefixing macros */
627ec681f3Smrg#if (GFX_VERx10 == 40)
637ec681f3Smrg#  define GENX(X) GFX4_##X
647ec681f3Smrg#  define genX(x) gfx4_##x
657ec681f3Smrg#elif (GFX_VERx10 == 45)
667ec681f3Smrg#  define GENX(X) GFX45_##X
677ec681f3Smrg#  define genX(x) gfx45_##x
687ec681f3Smrg#elif (GFX_VERx10 == 50)
697ec681f3Smrg#  define GENX(X) GFX5_##X
707ec681f3Smrg#  define genX(x) gfx5_##x
717ec681f3Smrg#elif (GFX_VERx10 == 60)
727ec681f3Smrg#  define GENX(X) GFX6_##X
737ec681f3Smrg#  define genX(x) gfx6_##x
747ec681f3Smrg#elif (GFX_VERx10 == 70)
757ec681f3Smrg#  define GENX(X) GFX7_##X
767ec681f3Smrg#  define genX(x) gfx7_##x
777ec681f3Smrg#elif (GFX_VERx10 == 75)
787ec681f3Smrg#  define GENX(X) GFX75_##X
797ec681f3Smrg#  define genX(x) gfx75_##x
807ec681f3Smrg#elif (GFX_VERx10 == 80)
817ec681f3Smrg#  define GENX(X) GFX8_##X
827ec681f3Smrg#  define genX(x) gfx8_##x
837ec681f3Smrg#elif (GFX_VERx10 == 90)
847ec681f3Smrg#  define GENX(X) GFX9_##X
857ec681f3Smrg#  define genX(x) gfx9_##x
867ec681f3Smrg#elif (GFX_VERx10 == 110)
877ec681f3Smrg#  define GENX(X) GFX11_##X
887ec681f3Smrg#  define genX(x) gfx11_##x
897ec681f3Smrg#elif (GFX_VERx10 == 120)
907ec681f3Smrg#  define GENX(X) GFX12_##X
917ec681f3Smrg#  define genX(x) gfx12_##x
927ec681f3Smrg#elif (GFX_VERx10 == 125)
937ec681f3Smrg#  define GENX(X) GFX125_##X
947ec681f3Smrg#  define genX(x) gfx125_##x
9501e04c3fSmrg#else
9601e04c3fSmrg#  error "Need to add prefixing macros for this gen"
9701e04c3fSmrg#endif
9801e04c3fSmrg
9901e04c3fSmrg#endif /* GEN_MACROS_H */
100