From: Gert Wollny Date: Thu, 27 Feb 2020 07:12:16 +0000 (+0100) Subject: r600/sfn: Use static_cast when type is already known X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b66170b53785dea3bfc00901277273b7bde9b561;p=mesa.git r600/sfn: Use static_cast when type is already known In all these cases the type was tested before based, so don't use dynamic_casts. Closes #2566 Signed-off-by: Gert Wollny Tested-by: Mauro Rossi Part-of: --- diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_cf.cpp b/src/gallium/drivers/r600/sfn/sfn_instruction_cf.cpp index 0c10e162bee..dc2b37a0df3 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instruction_cf.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_cf.cpp @@ -56,7 +56,7 @@ void IfInstruction::do_evalue_liveness(LiverangeEvaluator& eval) const bool IfInstruction::is_equal_to(const Instruction& lhs) const { assert(lhs.type() == cond_if); - const IfInstruction& l = dynamic_cast(lhs); + const IfInstruction& l = static_cast(lhs); return *l.m_pred == *m_pred; } diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_export.cpp b/src/gallium/drivers/r600/sfn/sfn_instruction_export.cpp index b109846489f..a841eccdcbb 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instruction_export.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_export.cpp @@ -128,7 +128,7 @@ bool WriteScratchInstruction::is_equal_to(const Instruction& lhs) const { if (lhs.type() != Instruction::mem_wr_scratch) return false; - const auto& other = dynamic_cast(lhs); + const auto& other = static_cast(lhs); if (m_address) { if (!other.m_address) diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_fetch.cpp b/src/gallium/drivers/r600/sfn/sfn_instruction_fetch.cpp index 0fc4f26358d..09fd80776c6 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instruction_fetch.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_fetch.cpp @@ -215,7 +215,7 @@ FetchInstruction::FetchInstruction(GPRVector dst, PValue src, int scratch_size): m_dest_swizzle({0,1,2,3}) { if (src->type() == Value::literal) { - const auto& lv = dynamic_cast(*src); + const auto& lv = static_cast(*src); m_array_base = lv.value(); m_indexed = false; m_src.reset(new GPRValue(0,0)); diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp index 0eac46abb2f..1c1a98c4034 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp @@ -56,7 +56,7 @@ WaitAck::WaitAck(int nack): bool WaitAck::is_equal_to(const Instruction& lhs) const { - const auto& l = dynamic_cast(lhs); + const auto& l = static_cast(lhs); return m_nack == l.m_nack; } diff --git a/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp b/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp index db75b908f5f..56a134c3e72 100644 --- a/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp @@ -697,7 +697,7 @@ bool AssemblyFromShaderLegacyImpl::emit_vtx(const FetchInstruction& fetch_instr) if (addr) { if (addr->type() == Value::literal) { - const auto& boffs = dynamic_cast(*addr); + const auto& boffs = static_cast(*addr); buffer_offset = boffs.value(); } else { index_mode = bim_zero; @@ -895,7 +895,7 @@ bool AssemblyFromShaderLegacyImpl::emit_gds(const GDSInstr& instr) m_bc->index_loaded[1] = true; } } else { - const LiteralValue& addr_reg = dynamic_cast(*addr); + const LiteralValue& addr_reg = static_cast(*addr); uav_idx = addr_reg.value() >> 2; } @@ -972,7 +972,7 @@ bool AssemblyFromShaderLegacyImpl::emit_rat(const RatInstruction& instr) } } else { - const LiteralValue& addr_reg = dynamic_cast(*addr); + const LiteralValue& addr_reg = static_cast(*addr); rat_idx = addr_reg.value(); } } diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp index 0e2d1a81350..25db8db8b16 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp @@ -517,7 +517,7 @@ bool ShaderFromNirProcessor::emit_store_scratch(nir_intrinsic_instr* instr) WriteScratchInstruction *ir = nullptr; if (address->type() == Value::literal) { - const auto& lv = dynamic_cast(*address); + const auto& lv = static_cast(*address); ir = new WriteScratchInstruction(lv.value(), value, align, align_offset, writemask); } else { address = from_nir_with_fetch_constant(instr->src[1], 0); diff --git a/src/gallium/drivers/r600/sfn/sfn_value_gpr.cpp b/src/gallium/drivers/r600/sfn/sfn_value_gpr.cpp index 4eb5bfb18c4..7dbf2871180 100644 --- a/src/gallium/drivers/r600/sfn/sfn_value_gpr.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_value_gpr.cpp @@ -284,7 +284,7 @@ void GPRArray::do_print(std::ostream& os) const bool GPRArray::is_equal_to(const Value& other) const { - const GPRArray& o = dynamic_cast(other); + const GPRArray& o = static_cast(other); return o.sel() == sel() && o.m_values.size() == m_values.size() && o.m_component_mask == m_component_mask; diff --git a/src/gallium/drivers/r600/sfn/sfn_valuepool.cpp b/src/gallium/drivers/r600/sfn/sfn_valuepool.cpp index 3c7d9d36c69..3ff386d5a0f 100644 --- a/src/gallium/drivers/r600/sfn/sfn_valuepool.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_valuepool.cpp @@ -68,7 +68,7 @@ PValue ValuePool::from_nir(const nir_src& v, unsigned component, unsigned swizzl auto reg = lookup_register(idx, swizzled, false); if (reg) { if (reg->type() == Value::gpr_vector) { - auto& array = dynamic_cast(*reg); + auto& array = static_cast(*reg); reg = array.get_indirect(v.reg.base_offset, v.reg.indirect ? from_nir(*v.reg.indirect, 0, 0) : nullptr, @@ -216,7 +216,7 @@ PValue ValuePool::from_nir(const nir_dest& v, unsigned component) if (retval->type() == Value::gpr_vector) { assert(!v.is_ssa); - auto& array = dynamic_cast(*retval); + auto& array = static_cast(*retval); retval = array.get_indirect(v.reg.base_offset, v.reg.indirect ? from_nir(*v.reg.indirect, 0, 0) : nullptr, @@ -234,7 +234,7 @@ ValueMap ValuePool::get_temp_registers() const if (v.second->type() == Value::gpr) result.insert(v.second); else if (v.second->type() == Value::gpr_vector) { - auto& array = dynamic_cast(*v.second); + auto& array = static_cast(*v.second); array.collect_registers(result); } }