src/lima/pp_lir/peephole.c
//Given a pipeline register, finds a move instruction with it as a source,
//guarenteeing that the move found is the only ALU instruction
Given a pipeline register, finds a move instruction with it as a source,
guarenteeing that the move found is the only ALU instruction
Given a pipeline register finds a move instruction with it as a source guarenteeing that the move found is the only ALU instruction
static lima_pp_lir_instr_t* find_single_pipeline_move(
	lima_pp_lir_scheduled_instr_t* instr, lima_pp_lir_pipeline_reg_e in,
	unsigned width)
{
	lima_pp_lir_instr_t* ret = NULL;
	unsigned i, j;
	for (i = 0; i < 5; i++)
		if (instr->alu_instrs[i])
		{
			if (ret)
				return NULL;
			if (instr->alu_instrs[i]->op != lima_pp_hir_op_mov)
				return NULL;
			if (!instr->alu_instrs[i]->sources[0].pipeline)
				return NULL;
			if (instr->alu_instrs[i]->sources[0].pipeline_reg != in)
				return NULL;
			if (instr->alu_instrs[i]->sources[0].absolute ||
				instr->alu_instrs[i]->sources[0].negate)
				return NULL;
			if (instr->alu_instrs[i]->dest.pipeline)
				return NULL;
			if (instr->alu_instrs[i]->dest.reg->precolored)
				return NULL;
			if (instr->alu_instrs[i]->dest.modifier != lima_pp_outmod_none)
				return NULL;
			for (j = 0; j < width; j++)
				if (!instr->alu_instrs[i]->dest.mask[j] ||
					instr->alu_instrs[i]->sources[0].swizzle[j] != j)
					return NULL;
			ret = instr->alu_instrs[i];
		}
	return ret;
}
static lima_pp_lir_instr_t * find_single_pipeline_move ( lima_pp_lir_scheduled_instr_t * instr , lima_pp_lir_pipeline_reg_e in , unsigned width ) { lima_pp_lir_instr_t * ret = NULL ; unsigned i , j ; for ( i = 0 ; i < 5 ; i ++ ) if ( instr -> alu_instrs [ i ] ) { if ( ret ) return NULL ; if ( instr -> alu_instrs [ i ] -> op != lima_pp_hir_op_mov ) return NULL ; if ( ! instr -> alu_instrs [ i ] -> sources [ 0 ] . pipeline ) return NULL ; if ( instr -> alu_instrs [ i ] -> sources [ 0 ] . pipeline_reg != in ) return NULL ; if ( instr -> alu_instrs [ i ] -> sources [ 0 ] . absolute || instr -> alu_instrs [ i ] -> sources [ 0 ] . negate ) return NULL ; if ( instr -> alu_instrs [ i ] -> dest . pipeline ) return NULL ; if ( instr -> alu_instrs [ i ] -> dest . reg -> precolored ) return NULL ; if ( instr -> alu_instrs [ i ] -> dest . modifier != lima_pp_outmod_none ) return NULL ; for ( j = 0 ; j < width ; j ++ ) if ( ! instr -> alu_instrs [ i ] -> dest . mask [ j ] || instr -> alu_instrs [ i ] -> sources [ 0 ] . swizzle [ j ] != j ) return NULL ; ret = instr -> alu_instrs [ i ] ; } return ret ; }
Given a pipeline register, finds a move instruction with it as a source,
guarenteeing that the move found is the only ALU instruction
Given a pipeline register finds a move instruction with it as a source guarenteeing that the move found is the only ALU instruction