Path: blob/21.2-virgl/src/panfrost/lib/gen_macros.h
4560 views
/*1* Copyright ©2021 Collabora Ltd.2* Copyright © 2015 Intel Corporation3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS21* IN THE SOFTWARE.22*/2324#ifndef GEN_MACROS_H25#define GEN_MACROS_H2627/* Macros for handling per-gen compilation.28*29* The macro GENX() automatically suffixes whatever you give it with _vX30*31* You can do pseudo-runtime checks in your function such as32*33* if (PAN_ARCH == 4) {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 first-generation Midgard.39*40* For places where you really do have a compile-time conflict, you can41* use preprocessor logic:42*43* #if (PAN_ARCH == 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 PAN_ARCH55# error "The PAN_ARCH macro must be defined"56#endif5758/* Suffixing macros */59#if (PAN_ARCH == 4)60# define GENX(X) X##_v461#elif (PAN_ARCH == 5)62# define GENX(X) X##_v563#elif (PAN_ARCH == 6)64# define GENX(X) X##_v665#elif (PAN_ARCH == 7)66# define GENX(X) X##_v767#else68# error "Need to add suffixing macro for this architecture"69#endif7071#endif /* GEN_MACROS_H */727374