// Copyright Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include #include #include namespace rocRoller { template <> std::shared_ptr> GetGenerator(Register::ValuePtr dst, Register::ValuePtr lhs, Register::ValuePtr rhs, Expression::BitwiseOr const&) { return Component::Get>( getContextFromValues(dst, lhs, rhs), dst->regType(), dst->variableType().dataType); } Generator BitwiseOrGenerator::generate(Register::ValuePtr dest, Register::ValuePtr lhs, Register::ValuePtr rhs, Expression::BitwiseOr const&) { AssertFatal(lhs != nullptr); AssertFatal(rhs != nullptr); auto elementBits = std::max({DataTypeInfo::Get(dest->variableType()).elementBits, DataTypeInfo::Get(lhs->variableType()).elementBits, DataTypeInfo::Get(rhs->variableType()).elementBits}); if(dest->regType() == Register::Type::Scalar) { if(elementBits <= 32u) { co_yield_(Instruction("s_or_b32", {dest}, {lhs, rhs}, {}, "")); } else if(elementBits == 64u) { co_yield_(Instruction("s_or_b64", {dest}, {lhs, rhs}, {}, "")); } else { Throw("Unsupported elementBits for bitwiseOr operation:: ", ShowValue(elementBits)); } } else if(dest->regType() == Register::Type::Vector) { co_yield m_context->copier()->ensureTypeCommutative( {Register::Type::Vector, Register::Type::Literal}, lhs, {Register::Type::Vector}, rhs); if(elementBits <= 32u) { co_yield_(Instruction("v_or_b32", {dest}, {lhs, rhs}, {}, "")); } else if(elementBits == 64u) { co_yield_(Instruction( "v_or_b32", {dest->subset({0})}, {lhs->subset({0}), rhs->subset({0})}, {}, "")); co_yield_(Instruction( "v_or_b32", {dest->subset({1})}, {lhs->subset({1}), rhs->subset({1})}, {}, "")); } else { Throw("Unsupported elementBits for bitwiseOr operation:: ", ShowValue(elementBits)); } } else { Throw("Unsupported register type for bitwiseOr operation: ", ShowValue(dest->regType())); } } }