radv: enable sisched toggle in perftest flags.
[mesa.git] / src / amd / common / ac_llvm_util.h
1 /*
2 * Copyright 2016 Bas Nieuwenhuizen
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
15 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18 * USE OR OTHER DEALINGS IN THE SOFTWARE.
19 *
20 * The above copyright notice and this permission notice (including the
21 * next paragraph) shall be included in all copies or substantial portions
22 * of the Software.
23 *
24 */
25
26 #ifndef AC_LLVM_UTIL_H
27 #define AC_LLVM_UTIL_H
28
29 #include <stdbool.h>
30 #include <llvm-c/TargetMachine.h>
31
32 #include "amd_family.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 enum ac_func_attr {
39 AC_FUNC_ATTR_ALWAYSINLINE = (1 << 0),
40 AC_FUNC_ATTR_BYVAL = (1 << 1),
41 AC_FUNC_ATTR_INREG = (1 << 2),
42 AC_FUNC_ATTR_NOALIAS = (1 << 3),
43 AC_FUNC_ATTR_NOUNWIND = (1 << 4),
44 AC_FUNC_ATTR_READNONE = (1 << 5),
45 AC_FUNC_ATTR_READONLY = (1 << 6),
46 AC_FUNC_ATTR_WRITEONLY = HAVE_LLVM >= 0x0400 ? (1 << 7) : 0,
47 AC_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = HAVE_LLVM >= 0x0400 ? (1 << 8) : 0,
48 AC_FUNC_ATTR_CONVERGENT = HAVE_LLVM >= 0x0400 ? (1 << 9) : 0,
49
50 /* Legacy intrinsic that needs attributes on function declarations
51 * and they must match the internal LLVM definition exactly, otherwise
52 * intrinsic selection fails.
53 */
54 AC_FUNC_ATTR_LEGACY = (1u << 31),
55 };
56
57 enum ac_target_machine_options {
58 AC_TM_SUPPORTS_SPILL = (1 << 0),
59 AC_TM_SISCHED = (1 << 1),
60 };
61 LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac_target_machine_options tm_options);
62
63 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
64 bool ac_is_sgpr_param(LLVMValueRef param);
65 void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,
66 int attr_idx, enum ac_func_attr attr);
67 void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,
68 unsigned attrib_mask);
69 void ac_dump_module(LLVMModuleRef module);
70
71 LLVMValueRef ac_llvm_get_called_value(LLVMValueRef call);
72 bool ac_llvm_is_function(LLVMValueRef v);
73
74 void
75 ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
76 const char *name, int value);
77
78 #ifdef __cplusplus
79 }
80 #endif
81
82 #endif /* AC_LLVM_UTIL_H */