• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Advanced Micro Devices, Inc.
3  *
4  * SPDX-License-Identifier: MIT
5  */
6 
7 #ifndef SI_SHADER_LLVM_H
8 #define SI_SHADER_LLVM_H
9 
10 #include "ac_shader_abi.h"
11 #include "ac_llvm_build.h"
12 #include "si_shader.h"
13 
14 #define SI_MERGED_WRAP_IF_LABEL 11500
15 
16 struct si_shader_args;
17 
18 struct si_shader_context {
19    struct ac_llvm_context ac;
20    struct si_shader *shader;
21    struct si_screen *screen;
22 
23    gl_shader_stage stage;
24 
25    struct si_shader_args *args;
26    struct ac_shader_abi abi;
27 
28    struct ac_llvm_pointer main_fn;
29    LLVMTypeRef return_type;
30 
31    struct ac_llvm_compiler *compiler;
32 
33    LLVMValueRef gs_ngg_emit;
34    struct ac_llvm_pointer gs_ngg_scratch;
35    LLVMValueRef return_value;
36 };
37 
si_shader_context_from_abi(struct ac_shader_abi * abi)38 static inline struct si_shader_context *si_shader_context_from_abi(struct ac_shader_abi *abi)
39 {
40    return container_of(abi, struct si_shader_context, abi);
41 }
42 
43 /* si_shader_llvm.c */
44 void si_llvm_create_func(struct si_shader_context *ctx, const char *name, LLVMTypeRef *return_types,
45                          unsigned num_return_elems, unsigned max_workgroup_size);
46 LLVMValueRef si_buffer_load_const(struct si_shader_context *ctx, LLVMValueRef resource,
47                                   LLVMValueRef offset);
48 void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret);
49 LLVMValueRef si_insert_input_ret(struct si_shader_context *ctx, LLVMValueRef ret,
50                                  struct ac_arg param, unsigned return_index);
51 LLVMValueRef si_insert_input_ret_float(struct si_shader_context *ctx, LLVMValueRef ret,
52                                        struct ac_arg param, unsigned return_index);
53 LLVMValueRef si_insert_input_ptr(struct si_shader_context *ctx, LLVMValueRef ret,
54                                  struct ac_arg param, unsigned return_index);
55 LLVMValueRef si_prolog_get_internal_binding_slot(struct si_shader_context *ctx, unsigned slot);
56 LLVMValueRef si_unpack_param(struct si_shader_context *ctx, struct ac_arg param, unsigned rshift,
57                              unsigned bitwidth);
58 
59 /* si_shader_llvm_gs.c */
60 LLVMValueRef si_is_es_thread(struct si_shader_context *ctx);
61 LLVMValueRef si_is_gs_thread(struct si_shader_context *ctx);
62 void si_llvm_es_build_end(struct si_shader_context *ctx);
63 void si_llvm_gs_build_end(struct si_shader_context *ctx);
64 
65 /* si_shader_llvm_tess.c */
66 void si_llvm_ls_build_end(struct si_shader_context *ctx);
67 void si_llvm_tcs_build_end(struct si_shader_context *ctx);
68 void si_llvm_init_tcs_callbacks(struct si_shader_context *ctx);
69 
70 /* si_shader_llvm_ps.c */
71 void si_llvm_build_ps_prolog(struct si_shader_context *ctx, union si_shader_part_key *key);
72 void si_llvm_build_ps_epilog(struct si_shader_context *ctx, union si_shader_part_key *key);
73 void si_llvm_ps_build_end(struct si_shader_context *ctx);
74 
75 #endif
76