// Copyright Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include namespace rocRoller { template <> std::shared_ptr> GetGenerator(Register::ValuePtr dst, Register::ValuePtr arg, Expression::BitwiseNegate const&) { return Component::Get>( getContextFromValues(dst, arg), dst->regType(), dst->variableType().dataType); } Generator BitwiseNegateGenerator::generate(Register::ValuePtr dest, Register::ValuePtr arg, Expression::BitwiseNegate const&) { AssertFatal(arg != nullptr); AssertFatal(dest != nullptr); auto elementBits = std::max(DataTypeInfo::Get(dest->variableType()).elementBits, DataTypeInfo::Get(arg->variableType()).elementBits); if(dest->regType() == Register::Type::Scalar) { if(elementBits <= 32u) co_yield_(Instruction("s_not_b32", {dest}, {arg}, {}, "")); else if(elementBits == 64u) co_yield_(Instruction("s_not_b64", {dest}, {arg}, {}, "")); else Throw("Unsupported elementBits for bitwiseNegate operation:: ", ShowValue(elementBits)); } else if(dest->regType() == Register::Type::Vector) { if(elementBits <= 32u) { co_yield_(Instruction("v_not_b32", {dest}, {arg}, {}, "")); } else if(elementBits == 64u) { co_yield_( Instruction("v_not_b32", {dest->subset({0})}, {arg->subset({0})}, {}, "")); co_yield_( Instruction("v_not_b32", {dest->subset({1})}, {arg->subset({1})}, {}, "")); } else { Throw("Unsupported elementBits for bitwiseNegate operation:: ", ShowValue(elementBits)); } } else { Throw("Unsupported register type for bitwiseNegate operation: ", ShowValue(dest->regType())); } } }