Files
TheRock/rocm-libraries/shared/rocroller/lib/source/Expression_creation.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

138 lines
5.2 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <variant>
#include <rocRoller/DataTypes/DataTypes.hpp>
#include <rocRoller/InstructionValues/Register_fwd.hpp>
#include <rocRoller/Utilities/Generator.hpp>
#include <rocRoller/AssemblyKernel.hpp>
#include <rocRoller/CodeGen/ArgumentLoader.hpp>
#include <rocRoller/CodeGen/Instruction.hpp>
#include <rocRoller/Context.hpp>
#include <rocRoller/Expression.hpp>
#include <rocRoller/Utilities/Timer.hpp>
namespace rocRoller
{
namespace Expression
{
ExpressionPtr fromKernelArgument(AssemblyKernelArgument const& arg)
{
return std::make_shared<Expression>(std::make_shared<AssemblyKernelArgument>(arg));
}
ExpressionPtr multiplyHigh(ExpressionPtr a, ExpressionPtr b)
{
AssertFatal(!isRaw32Literal(a) and !isRaw32Literal(b),
"Raw32 is a bit type and cannot be used in multiplyHigh operation: ",
ShowValue(a),
", ",
ShowValue(b));
return std::make_shared<Expression>(MultiplyHigh{a, b});
}
ExpressionPtr multiplyAdd(ExpressionPtr a, ExpressionPtr b, ExpressionPtr c)
{
AssertFatal(!isRaw32Literal(a) and !isRaw32Literal(b) and !isRaw32Literal(c),
"Raw32 is a bit type and cannot be used in multiplyAdd operation: ",
ShowValue(a),
", ",
ShowValue(b),
", ",
ShowValue(c));
return std::make_shared<Expression>(MultiplyAdd{a, b, c});
}
ExpressionPtr addShiftL(ExpressionPtr a, ExpressionPtr b, ExpressionPtr c)
{
AssertFatal(!isRaw32Literal(a) and !isRaw32Literal(b) and !isRaw32Literal(c),
"Raw32 is a bit type and cannot be used in addShiftL operation: ",
ShowValue(a),
", ",
ShowValue(b),
", ",
ShowValue(c));
return std::make_shared<Expression>(AddShiftL{a, b, c});
}
ExpressionPtr shiftLAdd(ExpressionPtr a, ExpressionPtr b, ExpressionPtr c)
{
AssertFatal(!isRaw32Literal(b) and !isRaw32Literal(c),
"Raw32 is a bit type and cannot be used in shiftLAdd operation: ",
ShowValue(b),
", ",
ShowValue(c));
return std::make_shared<Expression>(ShiftLAdd{a, b, c});
}
ExpressionPtr conditional(ExpressionPtr a, ExpressionPtr b, ExpressionPtr c)
{
return std::make_shared<Expression>(Conditional{a, b, c});
}
ExpressionPtr magicMultiple(ExpressionPtr a)
{
AssertFatal(!isRaw32Literal(a),
"Raw32 is a bit type and cannot be used in magicMultiple operation: ",
ShowValue(a));
return std::make_shared<Expression>(MagicMultiple{a});
}
ExpressionPtr magicShifts(ExpressionPtr a)
{
AssertFatal(!isRaw32Literal(a),
"Raw32 is a bit type and cannot be used in magicShifts operation: ",
ShowValue(a));
return std::make_shared<Expression>(MagicShifts{a});
}
ExpressionPtr magicShiftAndSign(ExpressionPtr a)
{
AssertFatal(!isRaw32Literal(a),
"Raw32 is a bit type and cannot be used in magicShiftAndSign operation: ",
ShowValue(a));
return std::make_shared<Expression>(MagicShiftAndSign{a});
}
ExpressionPtr bfe(ExpressionPtr a, uint32_t offset, uint32_t width)
{
return std::make_shared<Expression>(
BitFieldExtract{{.arg{a}}, DataType::None, offset, width});
}
ExpressionPtr bfe(DataType dt, ExpressionPtr a, uint32_t offset, uint32_t width)
{
return std::make_shared<Expression>(BitFieldExtract{{.arg{a}}, dt, offset, width});
}
ExpressionPtr bfc(ExpressionPtr src,
ExpressionPtr dst,
uint32_t srcOffset,
uint32_t dstOffset,
uint32_t width,
std::optional<bool> srcIsZero,
std::optional<bool> dstIsZero)
{
return std::make_shared<Expression>(
BitfieldCombine{{src, dst}, srcOffset, dstOffset, width, srcIsZero, dstIsZero});
}
ExpressionPtr concat(const std::vector<ExpressionPtr>& ops, VariableType v)
{
return std::make_shared<Expression>(Concatenate{{ops}, v});
}
ExpressionPtr dataFlowTag(int tag, Register::Type t, VariableType v)
{
return std::make_shared<Expression>(DataFlowTag{tag, t, v});
}
ExpressionPtr positionalArgument(int slot, Register::Type t, VariableType v)
{
return std::make_shared<Expression>(PositionalArgument{slot, t, v});
}
}
}