Path: blob/21.2-virgl/src/microsoft/compiler/dxil_internal.h
4564 views
/*1* Copyright © Microsoft Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef DXIL_INTERNAL_H24#define DXIL_INTERNAL_H2526#include "dxil_module.h"2728#include "util/list.h"2930#include <stdint.h>3132// Malloc.h defines a macro for alloca. Let's at least make sure that all includers33// of this header have the same definition of alloca.34#include <malloc.h>3536struct dxil_type_list {37struct dxil_type **types;38size_t num_types;39};4041struct dxil_type {42enum type_type {43TYPE_VOID,44TYPE_INTEGER,45TYPE_FLOAT,46TYPE_POINTER,47TYPE_STRUCT,48TYPE_ARRAY,49TYPE_VECTOR,50TYPE_FUNCTION51} type;5253union {54unsigned int_bits;55unsigned float_bits;56const struct dxil_type *ptr_target_type;57struct {58const char *name;59struct dxil_type_list elem;60} struct_def;61struct {62const struct dxil_type *ret_type;63struct dxil_type_list args;64} function_def;65struct {66const struct dxil_type *elem_type;67size_t num_elems;68} array_or_vector_def;69};7071struct list_head head;72unsigned id;73};7475struct dxil_value {76int id;77const struct dxil_type *type;78};7980struct dxil_gvar {81const char *name;82const struct dxil_type *type;83bool constant;84enum dxil_address_space as;85int align;8687const struct dxil_value *initializer;88struct dxil_value value;89struct list_head head;90};9192struct dxil_func {93char *name;94const struct dxil_type *type;95bool decl;96unsigned attr_set;9798struct dxil_value value;99struct list_head head;100};101102struct dxil_attrib {103enum {104DXIL_ATTR_ENUM105} type;106107union {108enum dxil_attr_kind kind;109};110};111112struct attrib_set {113struct dxil_attrib attrs[2];114unsigned num_attrs;115struct list_head head;116};117118struct dxil_instr_binop {119enum dxil_bin_opcode opcode;120const struct dxil_value *operands[2];121enum dxil_opt_flags flags;122};123124struct dxil_instr_cmp {125enum dxil_cmp_pred pred;126const struct dxil_value *operands[2];127};128129struct dxil_instr_select {130const struct dxil_value *operands[3];131};132133struct dxil_instr_cast {134enum dxil_cast_opcode opcode;135const struct dxil_type *type;136const struct dxil_value *value;137};138139struct dxil_instr_call {140const struct dxil_func *func;141struct dxil_value **args;142size_t num_args;143};144145struct dxil_instr_ret {146struct dxil_value *value;147};148149struct dxil_instr_extractval {150const struct dxil_value *src;151const struct dxil_type *type;152unsigned int idx;153};154155struct dxil_instr_br {156const struct dxil_value *cond;157unsigned succ[2];158};159160struct dxil_instr_phi {161const struct dxil_type *type;162struct dxil_phi_src {163const struct dxil_value *value;164unsigned block;165} incoming[127];166size_t num_incoming;167};168169struct dxil_instr_alloca {170const struct dxil_type *alloc_type;171const struct dxil_type *size_type;172const struct dxil_value *size;173unsigned align;174};175176struct dxil_instr_gep {177bool inbounds;178const struct dxil_type *source_elem_type;179struct dxil_value **operands;180size_t num_operands;181};182183struct dxil_instr_load {184const struct dxil_value *ptr;185const struct dxil_type *type;186unsigned align;187bool is_volatile;188};189190struct dxil_instr_store {191const struct dxil_value *value, *ptr;192unsigned align;193bool is_volatile;194};195196struct dxil_instr_atomicrmw {197const struct dxil_value *value, *ptr;198enum dxil_rmw_op op;199bool is_volatile;200enum dxil_atomic_ordering ordering;201enum dxil_sync_scope syncscope;202};203204struct dxil_instr_cmpxchg {205const struct dxil_value *cmpval, *newval, *ptr;206bool is_volatile;207enum dxil_atomic_ordering ordering;208enum dxil_sync_scope syncscope;209};210211struct dxil_instr {212enum instr_type {213INSTR_BINOP,214INSTR_CMP,215INSTR_SELECT,216INSTR_CAST,217INSTR_BR,218INSTR_PHI,219INSTR_CALL,220INSTR_RET,221INSTR_EXTRACTVAL,222INSTR_ALLOCA,223INSTR_GEP,224INSTR_LOAD,225INSTR_STORE,226INSTR_ATOMICRMW,227INSTR_CMPXCHG,228} type;229230union {231struct dxil_instr_binop binop;232struct dxil_instr_cmp cmp;233struct dxil_instr_select select;234struct dxil_instr_cast cast;235struct dxil_instr_call call;236struct dxil_instr_ret ret;237struct dxil_instr_extractval extractval;238struct dxil_instr_phi phi;239struct dxil_instr_br br;240struct dxil_instr_alloca alloca;241struct dxil_instr_gep gep;242struct dxil_instr_load load;243struct dxil_instr_store store;244struct dxil_instr_atomicrmw atomicrmw;245struct dxil_instr_cmpxchg cmpxchg;246};247248bool has_value;249struct dxil_value value;250251struct list_head head;252};253254struct dxil_const {255struct dxil_value value;256257bool undef;258union {259intmax_t int_value;260double float_value;261const struct dxil_value **array_values;262};263264struct list_head head;265};266267struct dxil_mdnode {268enum mdnode_type {269MD_STRING,270MD_VALUE,271MD_NODE272} type;273274union {275char *string;276277struct {278const struct dxil_type *type;279const struct dxil_value *value;280} value;281282struct {283const struct dxil_mdnode **subnodes;284size_t num_subnodes;285} node;286};287288struct list_head head;289unsigned id;290};291292struct dxil_named_node {293char *name;294const struct dxil_mdnode **subnodes;295size_t num_subnodes;296struct list_head head;297};298299#endif // DXIL_INTERNAL_H300301302