1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (C) 2019-2020 Collabora, Ltd.
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21bf215546Sopenharmony_ci * SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci#ifndef __BI_QUIRKS_H
25bf215546Sopenharmony_ci#define __BI_QUIRKS_H
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci/* Model-specific quirks requiring compiler workarounds/etc. Quirks
28bf215546Sopenharmony_ci * may be errata requiring a workaround, or features. We're trying to be
29bf215546Sopenharmony_ci * quirk-positive here; quirky is the best! */
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci/* Whether this GPU lacks support for fp32 transcendentals, requiring backend
32bf215546Sopenharmony_ci * lowering to low-precision lookup tables and polynomial approximation */
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci#define BIFROST_NO_FP32_TRANSCENDENTALS (1 << 0)
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci/* Whether this GPU lacks support for the full form of the CLPER instruction.
37bf215546Sopenharmony_ci * These GPUs use a simple encoding of CLPER that does not support
38bf215546Sopenharmony_ci * inactive_result, subgroup_size, or lane_op. Using those features requires
39bf215546Sopenharmony_ci * lowering to additional ALU instructions. The encoding forces inactive_result
40bf215546Sopenharmony_ci * = zero, subgroup_size = subgroup4, and lane_op = none. */
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci#define BIFROST_LIMITED_CLPER (1 << 1)
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_cistatic inline unsigned
45bf215546Sopenharmony_cibifrost_get_quirks(unsigned product_id)
46bf215546Sopenharmony_ci{
47bf215546Sopenharmony_ci        switch (product_id >> 8) {
48bf215546Sopenharmony_ci        case 0x60: /* G71 */
49bf215546Sopenharmony_ci                return BIFROST_NO_FP32_TRANSCENDENTALS | BIFROST_LIMITED_CLPER;
50bf215546Sopenharmony_ci        case 0x62: /* G72 */
51bf215546Sopenharmony_ci        case 0x70: /* G31 */
52bf215546Sopenharmony_ci                return BIFROST_LIMITED_CLPER;
53bf215546Sopenharmony_ci        default:
54bf215546Sopenharmony_ci                return 0;
55bf215546Sopenharmony_ci        }
56bf215546Sopenharmony_ci}
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci#endif
59