/* This functions offsets the temporary register indices by the number * of input registers, because input registers are actually temporaries and * should not occupy the same space. * * This pass is supposed to be used to maintain correct allocation of inputs * if the standard register allocation is disabled. */ void rc_pair_regalloc_inputs_only(struct radeon_compiler *cc, void *user) { struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc; struct regalloc_state s; compute_live_intervals(cc, &s); c->AllocateHwInputs(c, &alloc_input, &s); int temp_reg_offset = 0; for (unsigned i = 0; i < RC_REGISTER_MAX_INDEX; i++) { if (s.Input[i].Allocated && temp_reg_offset <= s.Input[i].Index) temp_reg_offset = s.Input[i].Index + 1; } if (temp_reg_offset) { for (unsigned i = 0; i < RC_REGISTER_MAX_INDEX; i++) { if (s.Temporary[i].Used) { s.Temporary[i].Allocated = 1; s.Temporary[i].File = RC_FILE_TEMPORARY; s.Temporary[i].Index = i + temp_reg_offset; } } /* Rewrite all registers. */ for (struct rc_instruction *inst = cc->Program.Instructions.Next; inst != &cc->Program.Instructions; inst = inst->Next) { rc_remap_registers(inst, &remap_register, &s); } } }
void rc_pair_regalloc(struct radeon_compiler *cc, void *user) { struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc; struct regalloc_state s; compute_live_intervals(cc, &s); c->AllocateHwInputs(c, &alloc_input, &s); do_regalloc(&s); }
void rc_pair_regalloc(struct r300_fragment_program_compiler *c, unsigned maxtemps) { struct regalloc_state s; memset(&s, 0, sizeof(s)); s.C = &c->Base; s.NumHwTemporaries = maxtemps; s.HwTemporary = memory_pool_malloc(&s.C->Pool, maxtemps*sizeof(struct hardware_register)); memset(s.HwTemporary, 0, maxtemps*sizeof(struct hardware_register)); compute_live_intervals(&s); c->AllocateHwInputs(c, &alloc_input, &s); do_regalloc(&s); }