Lines Matching defs:instr
2637 struct dxil_instr *instr = create_instr(m, INSTR_BINOP, op0->type);
2638 if (!instr)
2641 instr->binop.opcode = opcode;
2642 instr->binop.operands[0] = op0;
2643 instr->binop.operands[1] = op1;
2644 instr->binop.flags = flags;
2645 instr->has_value = true;
2646 return &instr->value;
2655 struct dxil_instr *instr = create_instr(m, INSTR_CMP, get_int1_type(m));
2656 if (!instr)
2659 instr->cmp.pred = pred;
2660 instr->cmp.operands[0] = op0;
2661 instr->cmp.operands[1] = op1;
2662 instr->has_value = true;
2663 return &instr->value;
2676 struct dxil_instr *instr = create_instr(m, INSTR_SELECT, op1->type);
2677 if (!instr)
2680 instr->select.operands[0] = op0;
2681 instr->select.operands[1] = op1;
2682 instr->select.operands[2] = op2;
2683 instr->has_value = true;
2684 return &instr->value;
2695 struct dxil_instr *instr = create_instr(m, INSTR_CAST, type);
2696 if (!instr)
2699 instr->cast.opcode = opcode;
2700 instr->cast.type = type;
2701 instr->cast.value = value;
2702 instr->has_value = true;
2703 return &instr->value;
2712 struct dxil_instr *instr = create_instr(m, INSTR_BR,
2714 if (!instr)
2717 instr->br.cond = cond;
2718 instr->br.succ[0] = true_block;
2719 instr->br.succ[1] = false_block;
2725 dxil_instr_get_return_value(struct dxil_instr *instr)
2727 return instr->has_value ? &instr->value : NULL;
2735 struct dxil_instr *instr = create_instr(m, INSTR_PHI, type);
2736 if (!instr)
2739 instr->phi.type = type;
2740 instr->phi.incoming = NULL;
2741 instr->phi.num_incoming = 0;
2742 instr->has_value = true;
2744 return instr;
2748 dxil_phi_add_incoming(struct dxil_instr *instr,
2753 assert(instr->type == INSTR_PHI);
2756 instr->phi.incoming = reralloc(instr, instr->phi.incoming,
2758 instr->phi.num_incoming + num_incoming);
2759 if (!instr->phi.incoming)
2764 assert(types_equal(incoming_values[i]->type, instr->phi.type));
2765 int dst = instr->phi.num_incoming + i;
2766 instr->phi.incoming[dst].value = incoming_values[i];
2767 instr->phi.incoming[dst].block = incoming_blocks[i];
2769 instr->phi.num_incoming += num_incoming;
2782 struct dxil_instr *instr = create_instr(m, INSTR_CALL,
2784 if (instr) {
2785 instr->call.func = func;
2786 instr->call.args = ralloc_array(instr, struct dxil_value *, num_args);
2789 memcpy(instr->call.args, args, sizeof(struct dxil_value *) * num_args);
2790 instr->call.num_args = num_args;
2792 return instr;
2802 struct dxil_instr *instr = create_call_instr(m, func, args, num_args);
2803 if (!instr)
2806 instr->has_value = true;
2807 return &instr->value;
2817 struct dxil_instr *instr = create_call_instr(m, func, args, num_args);
2818 if (!instr)
2827 struct dxil_instr *instr = create_instr(m, INSTR_RET,
2829 if (!instr)
2832 instr->ret.value = NULL;
2844 struct dxil_instr *instr =
2847 if (!instr)
2850 instr->extractval.src = src;
2851 instr->extractval.type = src->type;
2852 instr->extractval.idx = index;
2853 instr->has_value = true;
2855 return &instr->value;
2871 struct dxil_instr *instr = create_instr(m, INSTR_ALLOCA, return_type);
2872 if (!instr)
2875 instr->alloca.alloc_type = alloc_type;
2876 instr->alloca.size_type = size_type;
2877 instr->alloca.size = size;
2878 instr->alloca.align = util_logbase2(align) + 1;
2879 assert(instr->alloca.align < (1 << 5));
2880 instr->alloca.align |= 1 << 6;
2882 instr->has_value = true;
2883 return &instr->value;
2915 struct dxil_instr *instr = create_instr(m, INSTR_GEP, type);
2916 if (!instr)
2919 instr->gep.operands = ralloc_array(instr, struct dxil_value *,
2921 if (!instr->gep.operands)
2924 instr->gep.source_elem_type = source_elem_type;
2925 memcpy(instr->gep.operands, operands,
2927 instr->gep.num_operands = num_operands;
2928 instr->gep.inbounds = true;
2930 instr->has_value = true;
2931 return &instr->value;
2945 struct dxil_instr *instr = create_instr(m, INSTR_LOAD, type);
2946 if (!instr)
2949 instr->load.ptr = ptr;
2950 instr->load.type = type;
2951 instr->load.align = util_logbase2(align) + 1;
2952 instr->load.is_volatile = is_volatile;
2954 instr->has_value = true;
2955 return &instr->value;
2965 struct dxil_instr *instr = create_instr(m, INSTR_STORE,
2967 if (!instr)
2970 instr->store.value = value;
2971 instr->store.ptr = ptr;
2972 instr->store.align = util_logbase2(align) + 1;
2973 instr->store.is_volatile = is_volatile;
2986 struct dxil_instr *instr = create_instr(m, INSTR_CMPXCHG,
2988 if (!instr)
2991 instr->cmpxchg.cmpval = cmpval;
2992 instr->cmpxchg.newval = newval;
2993 instr->cmpxchg.ptr = ptr;
2994 instr->cmpxchg.is_volatile = is_volatile;
2995 instr->cmpxchg.ordering = ordering;
2996 instr->cmpxchg.syncscope = syncscope;
2998 instr->has_value = true;
2999 return &instr->value;
3010 struct dxil_instr *instr = create_instr(m, INSTR_ATOMICRMW,
3012 if (!instr)
3015 instr->atomicrmw.value = value;
3016 instr->atomicrmw.ptr = ptr;
3017 instr->atomicrmw.op = op;
3018 instr->atomicrmw.is_volatile = is_volatile;
3019 instr->atomicrmw.ordering = ordering;
3020 instr->atomicrmw.syncscope = syncscope;
3022 instr->has_value = true;
3023 return &instr->value;
3027 emit_binop(struct dxil_module *m, struct dxil_instr *instr)
3029 assert(instr->type == INSTR_BINOP);
3030 assert(instr->value.id > instr->binop.operands[0]->id);
3031 assert(instr->value.id > instr->binop.operands[1]->id);
3033 if (instr->binop.flags) {
3036 instr->value.id - instr->binop.operands[0]->id,
3037 instr->value.id - instr->binop.operands[1]->id,
3038 instr->binop.opcode,
3039 instr->binop.flags
3046 instr->value.id - instr->binop.operands[0]->id,
3047 instr->value.id - instr->binop.operands[1]->id,
3048 instr->binop.opcode
3055 emit_cmp(struct dxil_module *m, struct dxil_instr *instr)
3057 assert(instr->type == INSTR_CMP);
3058 assert(instr->value.id > instr->cmp.operands[0]->id);
3059 assert(instr->value.id > instr->cmp.operands[1]->id);
3061 instr->value.id - instr->cmp.operands[0]->id,
3062 instr->value.id - instr->cmp.operands[1]->id,
3063 instr->cmp.pred
3070 emit_select(struct dxil_module *m, struct dxil_instr *instr)
3072 assert(instr->type == INSTR_SELECT);
3073 assert(instr->value.id > instr->select.operands[0]->id);
3074 assert(instr->value.id > instr->select.operands[1]->id);
3075 assert(instr->value.id > instr->select.operands[2]->id);
3077 instr->value.id - instr->select.operands[1]->id,
3078 instr->value.id - instr->select.operands[2]->id,
3079 instr->value.id - instr->select.operands[0]->id
3086 emit_cast(struct dxil_module *m, struct dxil_instr *instr)
3088 assert(instr->type == INSTR_CAST);
3089 assert(instr->value.id > instr->cast.value->id);
3092 instr->value.id - instr->cast.value->id,
3093 instr->cast.type->id,
3094 instr->cast.opcode
3101 emit_branch(struct dxil_module *m, struct dxil_func_def *func, struct dxil_instr *instr)
3103 assert(instr->type == INSTR_BR);
3104 assert(instr->br.succ[0] < func->num_basic_block_ids);
3105 assert(func->basic_block_ids[instr->br.succ[0]] >= 0);
3107 if (!instr->br.cond) {
3109 uint64_t succ = func->basic_block_ids[instr->br.succ[0]];
3113 assert(instr->value.id > instr->br.cond->id);
3114 assert(instr->br.succ[1] < func->num_basic_block_ids);
3115 assert(func->basic_block_ids[instr->br.succ[1]] >= 0);
3118 func->basic_block_ids[instr->br.succ[0]],
3119 func->basic_block_ids[instr->br.succ[1]],
3120 instr->value.id - instr->br.cond->id
3127 emit_phi(struct dxil_module *m, struct dxil_func_def *func, struct dxil_instr *instr)
3129 assert(instr->type == INSTR_PHI);
3131 data[0] = instr->phi.type->id;
3132 assert(instr->phi.num_incoming > 0);
3133 for (int i = 0; i < instr->phi.num_incoming; ++i) {
3134 int64_t value_delta = instr->value.id - instr->phi.incoming[i].value->id;
3136 assert(instr->phi.incoming[i].block < func->num_basic_block_ids);
3137 assert(func->basic_block_ids[instr->phi.incoming[i].block] >= 0);
3138 data[1 + i * 2 + 1] = func->basic_block_ids[instr->phi.incoming[i].block];
3141 data, 1 + 2 * instr->phi.num_incoming);
3145 emit_extractval(struct dxil_module *m, struct dxil_instr *instr)
3147 assert(instr->type == INSTR_EXTRACTVAL);
3148 assert(instr->value.id > instr->extractval.src->id);
3149 assert(instr->value.id > instr->extractval.type->id);
3154 instr->value.id - instr->extractval.src->id,
3155 instr->extractval.idx
3162 emit_call(struct dxil_module *m, struct dxil_instr *instr)
3164 assert(instr->type == INSTR_CALL);
3165 assert(instr->call.func->value.id >= 0 && instr->value.id >= 0);
3166 assert(instr->call.func->type->id >= 0);
3167 assert(instr->call.func->value.id <= instr->value.id);
3168 int value_id_delta = instr->value.id - instr->call.func->value.id;
3173 data[2] = instr->call.func->type->id;
3176 assert(instr->call.num_args < ARRAY_SIZE(data) - 4);
3177 for (size_t i = 0; i < instr->call.num_args; ++i) {
3178 assert(instr->call.args[i]->id >= 0);
3179 data[4 + i] = instr->value.id - instr->call.args[i]->id;
3183 data, 4 + instr->call.num_args);
3187 emit_ret(struct dxil_module *m, struct dxil_instr *instr)
3189 assert(instr->type == INSTR_RET);
3191 if (instr->ret.value) {
3192 assert(instr->ret.value->id >= 0);
3193 uint64_t data[] = { FUNC_CODE_INST_RET, instr->ret.value->id };
3204 emit_alloca(struct dxil_module *m, struct dxil_instr *instr)
3206 assert(instr->type == INSTR_ALLOCA);
3207 assert(instr->alloca.alloc_type->id >= 0);
3208 assert(instr->alloca.size_type->id >= 0);
3209 assert(instr->alloca.size->id >= 0);
3212 instr->alloca.alloc_type->id,
3213 instr->alloca.size_type->id,
3214 instr->alloca.size->id,
3215 instr->alloca.align,
3222 emit_gep(struct dxil_module *m, struct dxil_instr *instr)
3224 assert(instr->type == INSTR_GEP);
3225 assert(instr->gep.source_elem_type->id >= 0);
3229 data[1] = instr->gep.inbounds;
3230 data[2] = instr->gep.source_elem_type->id;
3232 assert(instr->gep.num_operands < ARRAY_SIZE(data) - 3);
3233 for (int i = 0; i < instr->gep.num_operands; ++i) {
3234 assert(instr->value.id > instr->gep.operands[i]->id);
3235 data[3 + i] = instr->value.id - instr->gep.operands[i]->id;
3238 data, 3 + instr->gep.num_operands);
3242 emit_load(struct dxil_module *m, struct dxil_instr *instr)
3244 assert(instr->type == INSTR_LOAD);
3245 assert(instr->value.id > instr->load.ptr->id);
3246 assert(instr->load.type->id >= 0);
3249 instr->value.id - instr->load.ptr->id,
3250 instr->load.type->id,
3251 instr->load.align,
3252 instr->load.is_volatile
3258 emit_store(struct dxil_module *m, struct dxil_instr *instr)
3260 assert(instr->type == INSTR_STORE);
3261 assert(instr->value.id > instr->store.value->id);
3262 assert(instr->value.id > instr->store.ptr->id);
3265 instr->value.id - instr->store.ptr->id,
3266 instr->value.id - instr->store.value->id,
3267 instr->store.align,
3268 instr->store.is_volatile
3275 emit_cmpxchg(struct dxil_module *m, struct dxil_instr *instr)
3277 assert(instr->type == INSTR_CMPXCHG);
3278 assert(instr->value.id > instr->cmpxchg.cmpval->id);
3279 assert(instr->value.id > instr->cmpxchg.newval->id);
3280 assert(instr->value.id > instr->cmpxchg.ptr->id);
3282 instr->value.id - instr->cmpxchg.ptr->id,
3283 instr->value.id - instr->cmpxchg.cmpval->id,
3284 instr->value.id - instr->cmpxchg.newval->id,
3285 instr->cmpxchg.is_volatile,
3286 instr->cmpxchg.ordering,
3287 instr->cmpxchg.syncscope,
3294 emit_atomicrmw(struct dxil_module *m, struct dxil_instr *instr)
3296 assert(instr->type == INSTR_ATOMICRMW);
3297 assert(instr->value.id > instr->atomicrmw.value->id);
3298 assert(instr->value.id > instr->atomicrmw.ptr->id);
3300 instr->value.id - instr->atomicrmw.ptr->id,
3301 instr->value.id - instr->atomicrmw.value->id,
3302 instr->atomicrmw.op,
3303 instr->atomicrmw.is_volatile,
3304 instr->atomicrmw.ordering,
3305 instr->atomicrmw.syncscope,
3312 emit_instr(struct dxil_module *m, struct dxil_func_def *func, struct dxil_instr *instr)
3314 switch (instr->type) {
3316 return emit_binop(m, instr);
3319 return emit_cmp(m, instr);
3322 return emit_select(m, instr);
3325 return emit_cast(m, instr);
3328 return emit_branch(m, func, instr);
3331 return emit_phi(m, func, instr);
3334 return emit_call(m, instr);
3337 return emit_ret(m, instr);
3340 return emit_extractval(m, instr);
3343 return emit_alloca(m, instr);
3346 return emit_gep(m, instr);
3349 return emit_load(m, instr);
3352 return emit_store(m, instr);
3355 return emit_atomicrmw(m, instr);
3358 return emit_cmpxchg(m, instr);
3372 list_for_each_entry(struct dxil_instr, instr, &func->instr_list, head) {
3373 if (!emit_instr(m, func, instr))
3405 struct dxil_instr *instr;
3407 LIST_FOR_EACH_ENTRY(instr, &func_def->instr_list, head) {
3408 instr->value.id = next_value_id;
3409 if (instr->has_value)