static struct ir2_src_register * add_src_reg(struct fd2_compile_context *ctx, struct ir2_instruction *alu, const struct tgsi_src_register *src) { static const char swiz_vals[] = { 'x', 'y', 'z', 'w', }; char swiz[5]; unsigned flags = 0, num = 0; switch (src->File) { case TGSI_FILE_CONSTANT: num = src->Index; flags |= IR2_REG_CONST; break; case TGSI_FILE_INPUT: if (ctx->type == PIPE_SHADER_VERTEX) { num = src->Index + 1; } else { flags |= IR2_REG_INPUT; num = export_linkage(ctx, ctx->input_export_idx[src->Index]); } break; case TGSI_FILE_TEMPORARY: num = get_temp_gpr(ctx, src->Index); break; case TGSI_FILE_IMMEDIATE: num = src->Index + ctx->num_regs[TGSI_FILE_CONSTANT]; flags |= IR2_REG_CONST; break; default: DBG("unsupported src register file: %s", tgsi_file_name(src->File)); assert(0); break; } if (src->Absolute) flags |= IR2_REG_ABS; if (src->Negate) flags |= IR2_REG_NEGATE; swiz[0] = swiz_vals[src->SwizzleX]; swiz[1] = swiz_vals[src->SwizzleY]; swiz[2] = swiz_vals[src->SwizzleZ]; swiz[3] = swiz_vals[src->SwizzleW]; swiz[4] = '\0'; if ((ctx->need_sync & ((uint64_t)1 << num)) && !(flags & IR2_REG_CONST)) { alu->sync = true; ctx->need_sync &= ~((uint64_t)1 << num); } return ir2_reg_create(alu, num, swiz, flags); }
static void get_predicate(struct fd2_compile_context *ctx, struct tgsi_dst_register *dst, struct tgsi_src_register *src) { assert(ctx->pred_reg != -1); dst->File = TGSI_FILE_TEMPORARY; dst->WriteMask = TGSI_WRITEMASK_W; dst->Indirect = 0; dst->Dimension = 0; dst->Index = get_temp_gpr(ctx, ctx->pred_reg); if (src) { src_from_dst(src, dst); src->SwizzleX = TGSI_SWIZZLE_W; src->SwizzleY = TGSI_SWIZZLE_W; src->SwizzleZ = TGSI_SWIZZLE_W; src->SwizzleW = TGSI_SWIZZLE_W; } }
static struct ir2_register * add_dst_reg(struct fd2_compile_context *ctx, struct ir2_instruction *alu, const struct tgsi_dst_register *dst) { unsigned flags = 0, num = 0; char swiz[5]; switch (dst->File) { case TGSI_FILE_OUTPUT: flags |= IR2_REG_EXPORT; if (ctx->type == PIPE_SHADER_VERTEX) { if (dst->Index == ctx->position) { num = 62; } else if (dst->Index == ctx->psize) { num = 63; } else { num = export_linkage(ctx, ctx->output_export_idx[dst->Index]); } } else { num = dst->Index; } break; case TGSI_FILE_TEMPORARY: num = get_temp_gpr(ctx, dst->Index); break; default: DBG("unsupported dst register file: %s", tgsi_file_name(dst->File)); assert(0); break; } swiz[0] = (dst->WriteMask & TGSI_WRITEMASK_X) ? 'x' : '_'; swiz[1] = (dst->WriteMask & TGSI_WRITEMASK_Y) ? 'y' : '_'; swiz[2] = (dst->WriteMask & TGSI_WRITEMASK_Z) ? 'z' : '_'; swiz[3] = (dst->WriteMask & TGSI_WRITEMASK_W) ? 'w' : '_'; swiz[4] = '\0'; return ir2_reg_create(alu, num, swiz, flags); }