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
61 lines
3.5 KiB
TeX
61 lines
3.5 KiB
TeX
\subsection{BinaryFunction Class}
|
|
\label{sec:binaryFunction}
|
|
|
|
A \code{BinaryFunction} object represents a function that can combine two \code{Expression}s
|
|
and produce another \code{ValueComputation}.
|
|
|
|
For the purposes of representing a single operand of an instruction, the
|
|
\code{BinaryFunction}s of interest are addition and multiplication of integer values;
|
|
this allows an \code{Expression} to represent all addressing modes on the architectures
|
|
currently supported by the Instruction API.
|
|
|
|
\begin{apient}
|
|
BinaryFunction(Expression::Ptr arg1,
|
|
Expression::Ptr arg2,
|
|
Result_Type result_type,
|
|
funcT:Ptr func)
|
|
\end{apient}
|
|
\apidesc{
|
|
The constructor for a \code{BinaryFunction} may take a reference-\/counted pointer or a plain C++ pointer to each of the child \code{Expression}s that represent its arguments. Since the reference-\/counted implementation requires explicit construction, we provide overloads for all four combinations of plain and reference-\/counted pointers. Note that regardless of which constructor is used, the pointers \code{arg1} and \code{arg2} become owned by the \code{BinaryFunction} being constructed, and should not be deleted. They will be cleaned up when the \code{BinaryFunction} object is destroyed.
|
|
|
|
The \code{func} parameter is a binary functor on two \code{Result}s. It should be derived from \code{funcT}. \code{addResult} and \code{multResult}, which respectively add and multiply two \code{Result}s, are provided as part of the InstructionAPI, as they are necessary for representing address calculations. Other \code{funcTs} may be implemented by the user if desired. \code{funcTs} have names associated with them for output and debugging purposes. The addition and multiplication functors provided with the Instruction API are named "+" and "*", respectively.
|
|
}
|
|
|
|
\begin{apient}
|
|
const Result & eval () const
|
|
\end{apient}
|
|
\apidesc{
|
|
The \code{BinaryFunction} version of \code{eval} allows the \code{eval} mechanism to handle complex addressing
|
|
modes. Like all of the \code{ValueComputation} implementations, a \code{BinaryFunction}'s \code{eval} will return the
|
|
result of evaluating the expression it represents if possible, or an empty \code{Result} otherwise. A \code{BinaryFunction} may have arguments that can be evaluated, or arguments that cannot. Additionally, it
|
|
may have a real function pointer, or it may have a null function pointer. If the arguments can be
|
|
evaluated and the function pointer is real, a result other than an empty \code{Result} is guaranteed to
|
|
be returned. This result is cached after its initial calculation; the caching mechanism also allows
|
|
outside information to override the results of the \code{BinaryFunction}'s internal computation. If the
|
|
cached result exists, it is guaranteed to be returned even if the arguments or the function are not
|
|
evaluable.
|
|
}
|
|
|
|
\begin{apient}
|
|
void getChildren (vector< InstructionAST::Ptr > & children) const
|
|
\end{apient}
|
|
\apidesc{
|
|
The children of a \code{BinaryFunction} are its two arguments.
|
|
Appends the children of this BinaryFunction to \code{children}.
|
|
}
|
|
|
|
\begin{apient}
|
|
void getUses (set< InstructionAST::Ptr > & uses)
|
|
\end{apient}
|
|
\apidesc{
|
|
The use set of a \code{BinaryFunction} is the union of the use sets of its children.
|
|
Appends the use set of this \code{BinaryFunction} to \code{uses}.
|
|
}
|
|
|
|
\begin{apient}
|
|
bool isUsed (InstructionAST::Ptr findMe) const
|
|
\end{apient}
|
|
\apidesc{
|
|
\code{isUsed} returns \code{true} if \code{findMe} is an argument of this \code{BinaryFunction}, or if it is in the use set of either argument.
|
|
}
|