1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © Microsoft Corporation 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 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci /* 25bf215546Sopenharmony_ci * See the DirectX Shader Compiler for documentation for DXIL details: 26bf215546Sopenharmony_ci * https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst 27bf215546Sopenharmony_ci */ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifndef DXIL_MODULE_H 30bf215546Sopenharmony_ci#define DXIL_MODULE_H 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#ifdef __cplusplus 33bf215546Sopenharmony_ciextern "C" { 34bf215546Sopenharmony_ci#endif 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#include "dxil_buffer.h" 37bf215546Sopenharmony_ci#include "dxil_signature.h" 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci#include "util/list.h" 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_ci#define DXIL_SHADER_MAX_IO_ROWS 80 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_cienum dxil_shader_kind { 45bf215546Sopenharmony_ci DXIL_PIXEL_SHADER = 0, 46bf215546Sopenharmony_ci DXIL_VERTEX_SHADER = 1, 47bf215546Sopenharmony_ci DXIL_GEOMETRY_SHADER = 2, 48bf215546Sopenharmony_ci DXIL_HULL_SHADER = 3, 49bf215546Sopenharmony_ci DXIL_DOMAIN_SHADER = 4, 50bf215546Sopenharmony_ci DXIL_COMPUTE_SHADER = 5, 51bf215546Sopenharmony_ci}; 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ciextern int debug_dxil; 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_cienum dxil_debug_flags { 56bf215546Sopenharmony_ci DXIL_DEBUG_VERBOSE = 1 << 0, 57bf215546Sopenharmony_ci DXIL_DEBUG_DUMP_BLOB = 1 << 1, 58bf215546Sopenharmony_ci DXIL_DEBUG_TRACE = 1 << 2, 59bf215546Sopenharmony_ci DXIL_DEBUG_DUMP_MODULE = 1 << 3, 60bf215546Sopenharmony_ci}; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_cienum dxil_bin_opcode { 63bf215546Sopenharmony_ci DXIL_BINOP_ADD = 0, 64bf215546Sopenharmony_ci DXIL_BINOP_SUB = 1, 65bf215546Sopenharmony_ci DXIL_BINOP_MUL = 2, 66bf215546Sopenharmony_ci DXIL_BINOP_UDIV = 3, 67bf215546Sopenharmony_ci DXIL_BINOP_SDIV = 4, 68bf215546Sopenharmony_ci DXIL_BINOP_UREM = 5, 69bf215546Sopenharmony_ci DXIL_BINOP_SREM = 6, 70bf215546Sopenharmony_ci DXIL_BINOP_SHL = 7, 71bf215546Sopenharmony_ci DXIL_BINOP_LSHR = 8, 72bf215546Sopenharmony_ci DXIL_BINOP_ASHR = 9, 73bf215546Sopenharmony_ci DXIL_BINOP_AND = 10, 74bf215546Sopenharmony_ci DXIL_BINOP_OR = 11, 75bf215546Sopenharmony_ci DXIL_BINOP_XOR = 12, 76bf215546Sopenharmony_ci DXIL_BINOP_INSTR_COUNT 77bf215546Sopenharmony_ci}; 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_cienum dxil_cast_opcode { 80bf215546Sopenharmony_ci DXIL_CAST_TRUNC = 0, 81bf215546Sopenharmony_ci DXIL_CAST_ZEXT = 1, 82bf215546Sopenharmony_ci DXIL_CAST_SEXT = 2, 83bf215546Sopenharmony_ci DXIL_CAST_FPTOUI = 3, 84bf215546Sopenharmony_ci DXIL_CAST_FPTOSI = 4, 85bf215546Sopenharmony_ci DXIL_CAST_UITOFP = 5, 86bf215546Sopenharmony_ci DXIL_CAST_SITOFP = 6, 87bf215546Sopenharmony_ci DXIL_CAST_FPTRUNC = 7, 88bf215546Sopenharmony_ci DXIL_CAST_FPEXT = 8, 89bf215546Sopenharmony_ci DXIL_CAST_PTRTOINT = 9, 90bf215546Sopenharmony_ci DXIL_CAST_INTTOPTR = 10, 91bf215546Sopenharmony_ci DXIL_CAST_BITCAST = 11, 92bf215546Sopenharmony_ci DXIL_CAST_ADDRSPACECAST = 12, 93bf215546Sopenharmony_ci DXIL_CAST_INSTR_COUNT 94bf215546Sopenharmony_ci}; 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_cienum dxil_cmp_pred { 97bf215546Sopenharmony_ci DXIL_FCMP_FALSE = 0, 98bf215546Sopenharmony_ci DXIL_FCMP_OEQ = 1, 99bf215546Sopenharmony_ci DXIL_FCMP_OGT = 2, 100bf215546Sopenharmony_ci DXIL_FCMP_OGE = 3, 101bf215546Sopenharmony_ci DXIL_FCMP_OLT = 4, 102bf215546Sopenharmony_ci DXIL_FCMP_OLE = 5, 103bf215546Sopenharmony_ci DXIL_FCMP_ONE = 6, 104bf215546Sopenharmony_ci DXIL_FCMP_ORD = 7, 105bf215546Sopenharmony_ci DXIL_FCMP_UNO = 8, 106bf215546Sopenharmony_ci DXIL_FCMP_UEQ = 9, 107bf215546Sopenharmony_ci DXIL_FCMP_UGT = 10, 108bf215546Sopenharmony_ci DXIL_FCMP_UGE = 11, 109bf215546Sopenharmony_ci DXIL_FCMP_ULT = 12, 110bf215546Sopenharmony_ci DXIL_FCMP_ULE = 13, 111bf215546Sopenharmony_ci DXIL_FCMP_UNE = 14, 112bf215546Sopenharmony_ci DXIL_FCMP_TRUE = 15, 113bf215546Sopenharmony_ci DXIL_ICMP_EQ = 32, 114bf215546Sopenharmony_ci DXIL_ICMP_NE = 33, 115bf215546Sopenharmony_ci DXIL_ICMP_UGT = 34, 116bf215546Sopenharmony_ci DXIL_ICMP_UGE = 35, 117bf215546Sopenharmony_ci DXIL_ICMP_ULT = 36, 118bf215546Sopenharmony_ci DXIL_ICMP_ULE = 37, 119bf215546Sopenharmony_ci DXIL_ICMP_SGT = 38, 120bf215546Sopenharmony_ci DXIL_ICMP_SGE = 39, 121bf215546Sopenharmony_ci DXIL_ICMP_SLT = 40, 122bf215546Sopenharmony_ci DXIL_ICMP_SLE = 41, 123bf215546Sopenharmony_ci DXIL_CMP_INSTR_COUNT 124bf215546Sopenharmony_ci}; 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_cienum dxil_opt_flags { 127bf215546Sopenharmony_ci DXIL_UNSAFE_ALGEBRA = (1 << 0), 128bf215546Sopenharmony_ci DXIL_NO_NANS = (1 << 1), 129bf215546Sopenharmony_ci DXIL_NO_INFS = (1 << 2), 130bf215546Sopenharmony_ci DXIL_NO_SIGNED_ZEROS = (1 << 3), 131bf215546Sopenharmony_ci DXIL_ALLOW_RECIPROCAL = (1 << 4) 132bf215546Sopenharmony_ci}; 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_cistruct dxil_features { 135bf215546Sopenharmony_ci unsigned doubles : 1, 136bf215546Sopenharmony_ci cs_4x_raw_sb : 1, 137bf215546Sopenharmony_ci uavs_at_every_stage : 1, 138bf215546Sopenharmony_ci use_64uavs : 1, 139bf215546Sopenharmony_ci min_precision : 1, 140bf215546Sopenharmony_ci dx11_1_double_extensions : 1, 141bf215546Sopenharmony_ci dx11_1_shader_extensions : 1, 142bf215546Sopenharmony_ci dx9_comparison_filtering : 1, 143bf215546Sopenharmony_ci tiled_resources : 1, 144bf215546Sopenharmony_ci stencil_ref : 1, 145bf215546Sopenharmony_ci inner_coverage : 1, 146bf215546Sopenharmony_ci typed_uav_load_additional_formats : 1, 147bf215546Sopenharmony_ci rovs : 1, 148bf215546Sopenharmony_ci array_layer_from_vs_or_ds : 1, 149bf215546Sopenharmony_ci wave_ops : 1, 150bf215546Sopenharmony_ci int64_ops : 1, 151bf215546Sopenharmony_ci view_id : 1, 152bf215546Sopenharmony_ci barycentrics : 1, 153bf215546Sopenharmony_ci native_low_precision : 1, 154bf215546Sopenharmony_ci shading_rate : 1, 155bf215546Sopenharmony_ci raytracing_tier_1_1 : 1, 156bf215546Sopenharmony_ci sampler_feedback : 1; 157bf215546Sopenharmony_ci}; 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_cistruct dxil_shader_info { 160bf215546Sopenharmony_ci unsigned has_out_position:1; 161bf215546Sopenharmony_ci unsigned has_out_depth:1; 162bf215546Sopenharmony_ci unsigned has_per_sample_input:1; 163bf215546Sopenharmony_ci}; 164bf215546Sopenharmony_ci 165bf215546Sopenharmony_cistruct dxil_func_def { 166bf215546Sopenharmony_ci struct list_head head; 167bf215546Sopenharmony_ci const struct dxil_func *func; 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_ci struct list_head instr_list; 170bf215546Sopenharmony_ci int *basic_block_ids; /* maps from "user" ids to LLVM ids */ 171bf215546Sopenharmony_ci size_t num_basic_block_ids; 172bf215546Sopenharmony_ci unsigned curr_block; 173bf215546Sopenharmony_ci}; 174bf215546Sopenharmony_ci 175bf215546Sopenharmony_cistruct dxil_module { 176bf215546Sopenharmony_ci void *ralloc_ctx; 177bf215546Sopenharmony_ci enum dxil_shader_kind shader_kind; 178bf215546Sopenharmony_ci unsigned major_version, minor_version; 179bf215546Sopenharmony_ci unsigned major_validator, minor_validator; 180bf215546Sopenharmony_ci struct dxil_features feats; 181bf215546Sopenharmony_ci unsigned raw_and_structured_buffers : 1; 182bf215546Sopenharmony_ci struct dxil_shader_info info; 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci struct dxil_buffer buf; 185bf215546Sopenharmony_ci 186bf215546Sopenharmony_ci /* The number of entries in the arrays below */ 187bf215546Sopenharmony_ci unsigned num_sig_inputs; 188bf215546Sopenharmony_ci unsigned num_sig_outputs; 189bf215546Sopenharmony_ci unsigned num_sig_patch_consts; 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci /* The number of "vectors" of elements. This is used to determine the sizes 192bf215546Sopenharmony_ci * of the dependency tables. 193bf215546Sopenharmony_ci */ 194bf215546Sopenharmony_ci unsigned num_psv_inputs; 195bf215546Sopenharmony_ci unsigned num_psv_outputs[4]; 196bf215546Sopenharmony_ci unsigned num_psv_patch_consts; 197bf215546Sopenharmony_ci 198bf215546Sopenharmony_ci struct dxil_signature_record inputs[DXIL_SHADER_MAX_IO_ROWS]; 199bf215546Sopenharmony_ci struct dxil_signature_record outputs[DXIL_SHADER_MAX_IO_ROWS]; 200bf215546Sopenharmony_ci struct dxil_signature_record patch_consts[DXIL_SHADER_MAX_IO_ROWS]; 201bf215546Sopenharmony_ci 202bf215546Sopenharmony_ci /* This array is indexed using var->data.driver_location, which 203bf215546Sopenharmony_ci * is not a direct match to IO rows, since a row is a vec4, and 204bf215546Sopenharmony_ci * variables can occupy less than that, and several vars can 205bf215546Sopenharmony_ci * be packed in a row. Hence the x4, but I doubt we can end up 206bf215546Sopenharmony_ci * with more than 80x4 variables in practice. Maybe this array 207bf215546Sopenharmony_ci * should be allocated dynamically based on on the maximum 208bf215546Sopenharmony_ci * driver_location across all input vars. 209bf215546Sopenharmony_ci */ 210bf215546Sopenharmony_ci unsigned input_mappings[DXIL_SHADER_MAX_IO_ROWS * 4]; 211bf215546Sopenharmony_ci 212bf215546Sopenharmony_ci struct dxil_psv_signature_element psv_inputs[DXIL_SHADER_MAX_IO_ROWS]; 213bf215546Sopenharmony_ci struct dxil_psv_signature_element psv_outputs[DXIL_SHADER_MAX_IO_ROWS]; 214bf215546Sopenharmony_ci struct dxil_psv_signature_element psv_patch_consts[DXIL_SHADER_MAX_IO_ROWS]; 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_ci struct _mesa_string_buffer *sem_string_table; 217bf215546Sopenharmony_ci struct dxil_psv_sem_index_table sem_index_table; 218bf215546Sopenharmony_ci 219bf215546Sopenharmony_ci struct { 220bf215546Sopenharmony_ci unsigned abbrev_width; 221bf215546Sopenharmony_ci intptr_t offset; 222bf215546Sopenharmony_ci } blocks[16]; 223bf215546Sopenharmony_ci size_t num_blocks; 224bf215546Sopenharmony_ci 225bf215546Sopenharmony_ci struct list_head type_list; 226bf215546Sopenharmony_ci struct list_head gvar_list; 227bf215546Sopenharmony_ci struct list_head func_list; 228bf215546Sopenharmony_ci struct list_head func_def_list; 229bf215546Sopenharmony_ci struct list_head attr_set_list; 230bf215546Sopenharmony_ci struct list_head const_list; 231bf215546Sopenharmony_ci struct list_head mdnode_list; 232bf215546Sopenharmony_ci struct list_head md_named_node_list; 233bf215546Sopenharmony_ci const struct dxil_type *void_type; 234bf215546Sopenharmony_ci const struct dxil_type *int1_type, *int8_type, *int16_type, 235bf215546Sopenharmony_ci *int32_type, *int64_type; 236bf215546Sopenharmony_ci const struct dxil_type *float16_type, *float32_type, *float64_type; 237bf215546Sopenharmony_ci 238bf215546Sopenharmony_ci struct rb_tree *functions; 239bf215546Sopenharmony_ci 240bf215546Sopenharmony_ci struct dxil_func_def *cur_emitting_func; 241bf215546Sopenharmony_ci}; 242bf215546Sopenharmony_ci 243bf215546Sopenharmony_cistruct dxil_instr; 244bf215546Sopenharmony_cistruct dxil_value; 245bf215546Sopenharmony_ci 246bf215546Sopenharmony_civoid 247bf215546Sopenharmony_cidxil_module_init(struct dxil_module *m, void *ralloc_ctx); 248bf215546Sopenharmony_ci 249bf215546Sopenharmony_civoid 250bf215546Sopenharmony_cidxil_module_release(struct dxil_module *m); 251bf215546Sopenharmony_ci 252bf215546Sopenharmony_ciconst struct dxil_value * 253bf215546Sopenharmony_cidxil_add_global_var(struct dxil_module *m, const char *name, 254bf215546Sopenharmony_ci const struct dxil_type *type, 255bf215546Sopenharmony_ci enum dxil_address_space as, int align, 256bf215546Sopenharmony_ci const struct dxil_value *value); 257bf215546Sopenharmony_ci 258bf215546Sopenharmony_ciconst struct dxil_value * 259bf215546Sopenharmony_cidxil_add_global_ptr_var(struct dxil_module *m, const char *name, 260bf215546Sopenharmony_ci const struct dxil_type *type, 261bf215546Sopenharmony_ci enum dxil_address_space as, int align, 262bf215546Sopenharmony_ci const struct dxil_value *value); 263bf215546Sopenharmony_ci 264bf215546Sopenharmony_cistruct dxil_func_def * 265bf215546Sopenharmony_cidxil_add_function_def(struct dxil_module *m, const char *name, 266bf215546Sopenharmony_ci const struct dxil_type *type, unsigned num_blocks); 267bf215546Sopenharmony_ci 268bf215546Sopenharmony_ciconst struct dxil_func * 269bf215546Sopenharmony_cidxil_add_function_decl(struct dxil_module *m, const char *name, 270bf215546Sopenharmony_ci const struct dxil_type *type, 271bf215546Sopenharmony_ci enum dxil_attr_kind attr); 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_ciconst struct dxil_type * 274bf215546Sopenharmony_cidxil_module_get_void_type(struct dxil_module *m); 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_ciconst struct dxil_type * 277bf215546Sopenharmony_cidxil_module_get_int_type(struct dxil_module *m, unsigned bit_size); 278bf215546Sopenharmony_ci 279bf215546Sopenharmony_ciconst struct dxil_type * 280bf215546Sopenharmony_cidxil_module_get_float_type(struct dxil_module *m, unsigned bit_size); 281bf215546Sopenharmony_ci 282bf215546Sopenharmony_ciconst struct dxil_type * 283bf215546Sopenharmony_cidxil_module_get_pointer_type(struct dxil_module *m, 284bf215546Sopenharmony_ci const struct dxil_type *target); 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_ciconst struct dxil_type * 287bf215546Sopenharmony_cidxil_get_overload_type(struct dxil_module *mod, enum overload_type overload); 288bf215546Sopenharmony_ci 289bf215546Sopenharmony_ciconst struct dxil_type * 290bf215546Sopenharmony_cidxil_module_get_handle_type(struct dxil_module *m); 291bf215546Sopenharmony_ci 292bf215546Sopenharmony_ciconst struct dxil_type * 293bf215546Sopenharmony_cidxil_module_get_cbuf_ret_type(struct dxil_module *mod, enum overload_type overload); 294bf215546Sopenharmony_ci 295bf215546Sopenharmony_ciconst struct dxil_type * 296bf215546Sopenharmony_cidxil_module_get_split_double_ret_type(struct dxil_module *mod); 297bf215546Sopenharmony_ci 298bf215546Sopenharmony_ciconst struct dxil_type * 299bf215546Sopenharmony_cidxil_module_get_res_type(struct dxil_module *m, enum dxil_resource_kind kind, 300bf215546Sopenharmony_ci enum dxil_component_type comp_type, bool readwrite); 301bf215546Sopenharmony_ci 302bf215546Sopenharmony_ciconst struct dxil_type * 303bf215546Sopenharmony_cidxil_module_get_resret_type(struct dxil_module *m, enum overload_type overload); 304bf215546Sopenharmony_ci 305bf215546Sopenharmony_ciconst struct dxil_type * 306bf215546Sopenharmony_cidxil_module_get_dimret_type(struct dxil_module *m); 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_ciconst struct dxil_type * 309bf215546Sopenharmony_cidxil_module_get_samplepos_type(struct dxil_module *m); 310bf215546Sopenharmony_ci 311bf215546Sopenharmony_ciconst struct dxil_type * 312bf215546Sopenharmony_cidxil_module_get_struct_type(struct dxil_module *m, 313bf215546Sopenharmony_ci const char *name, 314bf215546Sopenharmony_ci const struct dxil_type **elem_types, 315bf215546Sopenharmony_ci size_t num_elem_types); 316bf215546Sopenharmony_ci 317bf215546Sopenharmony_ciconst struct dxil_type * 318bf215546Sopenharmony_cidxil_module_get_array_type(struct dxil_module *m, 319bf215546Sopenharmony_ci const struct dxil_type *elem_type, 320bf215546Sopenharmony_ci size_t num_elems); 321bf215546Sopenharmony_ci 322bf215546Sopenharmony_ciconst struct dxil_type * 323bf215546Sopenharmony_cidxil_module_get_vector_type(struct dxil_module *m, 324bf215546Sopenharmony_ci const struct dxil_type *elem_type, 325bf215546Sopenharmony_ci size_t num_elems); 326bf215546Sopenharmony_ci 327bf215546Sopenharmony_ciconst struct dxil_type * 328bf215546Sopenharmony_cidxil_module_add_function_type(struct dxil_module *m, 329bf215546Sopenharmony_ci const struct dxil_type *ret_type, 330bf215546Sopenharmony_ci const struct dxil_type **arg_types, 331bf215546Sopenharmony_ci size_t num_arg_types); 332bf215546Sopenharmony_ci 333bf215546Sopenharmony_cinir_alu_type 334bf215546Sopenharmony_cidxil_type_to_nir_type(const struct dxil_type *type); 335bf215546Sopenharmony_ci 336bf215546Sopenharmony_cibool 337bf215546Sopenharmony_cidxil_value_type_equal_to(const struct dxil_value *value, 338bf215546Sopenharmony_ci const struct dxil_type *lhs); 339bf215546Sopenharmony_ci 340bf215546Sopenharmony_cibool 341bf215546Sopenharmony_cidxil_value_type_bitsize_equal_to(const struct dxil_value *value, unsigned bitsize); 342bf215546Sopenharmony_ci 343bf215546Sopenharmony_ciconst struct dxil_type * 344bf215546Sopenharmony_cidxil_value_get_type(const struct dxil_value *value); 345bf215546Sopenharmony_ci 346bf215546Sopenharmony_ciconst struct dxil_value * 347bf215546Sopenharmony_cidxil_module_get_int1_const(struct dxil_module *m, bool value); 348bf215546Sopenharmony_ci 349bf215546Sopenharmony_ciconst struct dxil_value * 350bf215546Sopenharmony_cidxil_module_get_int8_const(struct dxil_module *m, int8_t value); 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_ciconst struct dxil_value * 353bf215546Sopenharmony_cidxil_module_get_int16_const(struct dxil_module *m, int16_t value); 354bf215546Sopenharmony_ci 355bf215546Sopenharmony_ciconst struct dxil_value * 356bf215546Sopenharmony_cidxil_module_get_int32_const(struct dxil_module *m, int32_t value); 357bf215546Sopenharmony_ci 358bf215546Sopenharmony_ciconst struct dxil_value * 359bf215546Sopenharmony_cidxil_module_get_int64_const(struct dxil_module *m, int64_t value); 360bf215546Sopenharmony_ci 361bf215546Sopenharmony_ciconst struct dxil_value * 362bf215546Sopenharmony_cidxil_module_get_int_const(struct dxil_module *m, intmax_t value, 363bf215546Sopenharmony_ci unsigned bit_size); 364bf215546Sopenharmony_ci 365bf215546Sopenharmony_ciconst struct dxil_value * 366bf215546Sopenharmony_cidxil_module_get_float16_const(struct dxil_module *m, uint16_t); 367bf215546Sopenharmony_ci 368bf215546Sopenharmony_ciconst struct dxil_value * 369bf215546Sopenharmony_cidxil_module_get_float_const(struct dxil_module *m, float value); 370bf215546Sopenharmony_ci 371bf215546Sopenharmony_ciconst struct dxil_value * 372bf215546Sopenharmony_cidxil_module_get_double_const(struct dxil_module *m, double value); 373bf215546Sopenharmony_ci 374bf215546Sopenharmony_ciconst struct dxil_value * 375bf215546Sopenharmony_cidxil_module_get_array_const(struct dxil_module *m, const struct dxil_type *type, 376bf215546Sopenharmony_ci const struct dxil_value **values); 377bf215546Sopenharmony_ci 378bf215546Sopenharmony_ciconst struct dxil_value * 379bf215546Sopenharmony_cidxil_module_get_undef(struct dxil_module *m, const struct dxil_type *type); 380bf215546Sopenharmony_ci 381bf215546Sopenharmony_ciconst struct dxil_mdnode * 382bf215546Sopenharmony_cidxil_get_metadata_string(struct dxil_module *m, const char *str); 383bf215546Sopenharmony_ci 384bf215546Sopenharmony_ciconst struct dxil_mdnode * 385bf215546Sopenharmony_cidxil_get_metadata_value(struct dxil_module *m, const struct dxil_type *type, 386bf215546Sopenharmony_ci const struct dxil_value *value); 387bf215546Sopenharmony_ci 388bf215546Sopenharmony_ciconst struct dxil_mdnode * 389bf215546Sopenharmony_cidxil_get_metadata_func(struct dxil_module *m, const struct dxil_func *func); 390bf215546Sopenharmony_ci 391bf215546Sopenharmony_ciconst struct dxil_mdnode * 392bf215546Sopenharmony_cidxil_get_metadata_int1(struct dxil_module *m, bool value); 393bf215546Sopenharmony_ci 394bf215546Sopenharmony_ciconst struct dxil_mdnode * 395bf215546Sopenharmony_cidxil_get_metadata_int8(struct dxil_module *m, int8_t value); 396bf215546Sopenharmony_ci 397bf215546Sopenharmony_ciconst struct dxil_mdnode * 398bf215546Sopenharmony_cidxil_get_metadata_int32(struct dxil_module *m, int32_t value); 399bf215546Sopenharmony_ci 400bf215546Sopenharmony_ciconst struct dxil_mdnode * 401bf215546Sopenharmony_cidxil_get_metadata_int64(struct dxil_module *m, int64_t value); 402bf215546Sopenharmony_ci 403bf215546Sopenharmony_ciconst struct dxil_mdnode * 404bf215546Sopenharmony_cidxil_get_metadata_float32(struct dxil_module *m, float value); 405bf215546Sopenharmony_ci 406bf215546Sopenharmony_ciconst struct dxil_mdnode * 407bf215546Sopenharmony_cidxil_get_metadata_node(struct dxil_module *m, 408bf215546Sopenharmony_ci const struct dxil_mdnode *subnodes[], 409bf215546Sopenharmony_ci size_t num_subnodes); 410bf215546Sopenharmony_ci 411bf215546Sopenharmony_cibool 412bf215546Sopenharmony_cidxil_add_metadata_named_node(struct dxil_module *m, const char *name, 413bf215546Sopenharmony_ci const struct dxil_mdnode *subnodes[], 414bf215546Sopenharmony_ci size_t num_subnodes); 415bf215546Sopenharmony_ci 416bf215546Sopenharmony_ciconst struct dxil_value * 417bf215546Sopenharmony_cidxil_emit_binop(struct dxil_module *m, enum dxil_bin_opcode opcode, 418bf215546Sopenharmony_ci const struct dxil_value *op0, const struct dxil_value *op1, 419bf215546Sopenharmony_ci enum dxil_opt_flags flags); 420bf215546Sopenharmony_ci 421bf215546Sopenharmony_ciconst struct dxil_value * 422bf215546Sopenharmony_cidxil_emit_cmp(struct dxil_module *m, enum dxil_cmp_pred pred, 423bf215546Sopenharmony_ci const struct dxil_value *op0, const struct dxil_value *op1); 424bf215546Sopenharmony_ci 425bf215546Sopenharmony_ciconst struct dxil_value * 426bf215546Sopenharmony_cidxil_emit_select(struct dxil_module *m, 427bf215546Sopenharmony_ci const struct dxil_value *op0, 428bf215546Sopenharmony_ci const struct dxil_value *op1, 429bf215546Sopenharmony_ci const struct dxil_value *op2); 430bf215546Sopenharmony_ci 431bf215546Sopenharmony_ciconst struct dxil_value * 432bf215546Sopenharmony_cidxil_emit_extractval(struct dxil_module *m, const struct dxil_value *src, 433bf215546Sopenharmony_ci const unsigned int index); 434bf215546Sopenharmony_ci 435bf215546Sopenharmony_ciconst struct dxil_value * 436bf215546Sopenharmony_cidxil_emit_cast(struct dxil_module *m, enum dxil_cast_opcode opcode, 437bf215546Sopenharmony_ci const struct dxil_type *type, 438bf215546Sopenharmony_ci const struct dxil_value *value); 439bf215546Sopenharmony_ci 440bf215546Sopenharmony_cibool 441bf215546Sopenharmony_cidxil_emit_branch(struct dxil_module *m, const struct dxil_value *cond, 442bf215546Sopenharmony_ci unsigned true_block, unsigned false_block); 443bf215546Sopenharmony_ci 444bf215546Sopenharmony_ciconst struct dxil_value * 445bf215546Sopenharmony_cidxil_instr_get_return_value(struct dxil_instr *instr); 446bf215546Sopenharmony_ci 447bf215546Sopenharmony_cistruct dxil_instr * 448bf215546Sopenharmony_cidxil_emit_phi(struct dxil_module *m, const struct dxil_type *type); 449bf215546Sopenharmony_ci 450bf215546Sopenharmony_cibool 451bf215546Sopenharmony_cidxil_phi_add_incoming(struct dxil_instr *instr, 452bf215546Sopenharmony_ci const struct dxil_value *incoming_values[], 453bf215546Sopenharmony_ci const unsigned incoming_blocks[], 454bf215546Sopenharmony_ci size_t num_incoming); 455bf215546Sopenharmony_ci 456bf215546Sopenharmony_ciconst struct dxil_value * 457bf215546Sopenharmony_cidxil_emit_call(struct dxil_module *m, 458bf215546Sopenharmony_ci const struct dxil_func *func, 459bf215546Sopenharmony_ci const struct dxil_value **args, size_t num_args); 460bf215546Sopenharmony_ci 461bf215546Sopenharmony_cibool 462bf215546Sopenharmony_cidxil_emit_call_void(struct dxil_module *m, 463bf215546Sopenharmony_ci const struct dxil_func *func, 464bf215546Sopenharmony_ci const struct dxil_value **args, size_t num_args); 465bf215546Sopenharmony_ci 466bf215546Sopenharmony_cibool 467bf215546Sopenharmony_cidxil_emit_ret_void(struct dxil_module *m); 468bf215546Sopenharmony_ci 469bf215546Sopenharmony_ciconst struct dxil_value * 470bf215546Sopenharmony_cidxil_emit_alloca(struct dxil_module *m, const struct dxil_type *alloc_type, 471bf215546Sopenharmony_ci const struct dxil_type *size_type, 472bf215546Sopenharmony_ci const struct dxil_value *size, 473bf215546Sopenharmony_ci unsigned int align); 474bf215546Sopenharmony_ci 475bf215546Sopenharmony_ciconst struct dxil_value * 476bf215546Sopenharmony_cidxil_emit_gep_inbounds(struct dxil_module *m, 477bf215546Sopenharmony_ci const struct dxil_value **operands, 478bf215546Sopenharmony_ci size_t num_operands); 479bf215546Sopenharmony_ci 480bf215546Sopenharmony_ciconst struct dxil_value * 481bf215546Sopenharmony_cidxil_emit_load(struct dxil_module *m, const struct dxil_value *ptr, 482bf215546Sopenharmony_ci unsigned align, 483bf215546Sopenharmony_ci bool is_volatile); 484bf215546Sopenharmony_ci 485bf215546Sopenharmony_cibool 486bf215546Sopenharmony_cidxil_emit_store(struct dxil_module *m, const struct dxil_value *value, 487bf215546Sopenharmony_ci const struct dxil_value *ptr, unsigned align, 488bf215546Sopenharmony_ci bool is_volatile); 489bf215546Sopenharmony_ci 490bf215546Sopenharmony_ciconst struct dxil_value * 491bf215546Sopenharmony_cidxil_emit_cmpxchg(struct dxil_module *m, const struct dxil_value *cmpval, 492bf215546Sopenharmony_ci const struct dxil_value *newval, 493bf215546Sopenharmony_ci const struct dxil_value *ptr, bool is_volatile, 494bf215546Sopenharmony_ci enum dxil_atomic_ordering ordering, 495bf215546Sopenharmony_ci enum dxil_sync_scope syncscope); 496bf215546Sopenharmony_ci 497bf215546Sopenharmony_ciconst struct dxil_value * 498bf215546Sopenharmony_cidxil_emit_atomicrmw(struct dxil_module *m, const struct dxil_value *value, 499bf215546Sopenharmony_ci const struct dxil_value *ptr, enum dxil_rmw_op op, 500bf215546Sopenharmony_ci bool is_volatile, enum dxil_atomic_ordering ordering, 501bf215546Sopenharmony_ci enum dxil_sync_scope syncscope); 502bf215546Sopenharmony_ci 503bf215546Sopenharmony_cibool 504bf215546Sopenharmony_cidxil_emit_module(struct dxil_module *m); 505bf215546Sopenharmony_ci 506bf215546Sopenharmony_ci#ifdef __cplusplus 507bf215546Sopenharmony_ci} 508bf215546Sopenharmony_ci#endif 509bf215546Sopenharmony_ci 510bf215546Sopenharmony_ci#endif 511