void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens) { struct tgsi_full_instruction *inst; struct tgsi_parse_context parser; unsigned imm_index = 0; int i; /* Allocate constants placeholders. * * Note: What if declared constants are not contiguous? */ for(i = 0; i <= ttr->info->file_max[TGSI_FILE_CONSTANT]; ++i) { struct rc_constant constant; memset(&constant, 0, sizeof(constant)); constant.Type = RC_CONSTANT_EXTERNAL; constant.Size = 4; constant.u.External = i; rc_constants_add(&ttr->compiler->Program.Constants, &constant); } ttr->immediate_offset = ttr->compiler->Program.Constants.Count; ttr->imms_to_swizzle = malloc(ttr->info->immediate_count * sizeof(struct swizzled_imms)); ttr->imms_to_swizzle_count = 0; tgsi_parse_init(&parser, tokens); while (!tgsi_parse_end_of_tokens(&parser)) { tgsi_parse_token(&parser); switch (parser.FullToken.Token.Type) { case TGSI_TOKEN_TYPE_DECLARATION: break; case TGSI_TOKEN_TYPE_IMMEDIATE: handle_immediate(ttr, &parser.FullToken.FullImmediate, imm_index); imm_index++; break; case TGSI_TOKEN_TYPE_INSTRUCTION: inst = &parser.FullToken.FullInstruction; /* This hack with the RET opcode woudn't work with * conditionals. */ if (inst->Instruction.Opcode == TGSI_OPCODE_END || inst->Instruction.Opcode == TGSI_OPCODE_RET) { break; } transform_instruction(ttr, inst); break; } } tgsi_parse_free(&parser); free(ttr->imms_to_swizzle); rc_calculate_inputs_outputs(ttr->compiler); }
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens) { struct tgsi_parse_context parser; int i; /* Allocate constants placeholders. * * Note: What if declared constants are not contiguous? */ for(i = 0; i <= ttr->info->file_max[TGSI_FILE_CONSTANT]; ++i) { struct rc_constant constant; memset(&constant, 0, sizeof(constant)); constant.Type = RC_CONSTANT_EXTERNAL; constant.Size = 4; constant.u.External = i; rc_constants_add(&ttr->compiler->Program.Constants, &constant); } ttr->immediate_offset = ttr->compiler->Program.Constants.Count; tgsi_parse_init(&parser, tokens); while (!tgsi_parse_end_of_tokens(&parser)) { tgsi_parse_token(&parser); switch (parser.FullToken.Token.Type) { case TGSI_TOKEN_TYPE_DECLARATION: break; case TGSI_TOKEN_TYPE_IMMEDIATE: handle_immediate(ttr, &parser.FullToken.FullImmediate); break; case TGSI_TOKEN_TYPE_INSTRUCTION: transform_instruction(ttr, &parser.FullToken.FullInstruction); break; } } tgsi_parse_free(&parser); rc_calculate_inputs_outputs(ttr->compiler); }