Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21062,12 +21062,15 @@ integer element type.

Syntax:
"""""""
This is an overloaded intrinsic.
This is an overloaded intrinsic. You can use ``llvm.matrix.column.major.load``
to load any vector type with a stride of any bitwidth up to 64.

::

declare vectorty @llvm.matrix.column.major.load.*(
declare <4 x i32> @llvm.matrix.column.major.load.v4i32.i64(
ptrty %Ptr, i64 %Stride, i1 <IsVolatile>, i32 <Rows>, i32 <Cols>)
declare <9 x double> @llvm.matrix.column.major.load.v9f64.i32(
ptrty %Ptr, i32 %Stride, i1 <IsVolatile>, i32 <Rows>, i32 <Cols>)

Overview:
"""""""""
Expand All @@ -21086,9 +21089,9 @@ Arguments:

The first argument ``%Ptr`` is a pointer type to the returned vector type, and
corresponds to the start address to load from. The second argument ``%Stride``
is a positive, constant integer with ``%Stride >= <Rows>``. ``%Stride`` is used
to compute the column memory addresses. I.e., for a column ``C``, its start
memory addresses is calculated with ``%Ptr + C * %Stride``. The third Argument
is a positive integer for which ``%Stride >= <Rows>``. ``%Stride`` is used to
compute the column memory addresses. I.e., for a column ``C``, its start memory
addresses is calculated with ``%Ptr + C * %Stride``. The third Argument
``<IsVolatile>`` is a boolean value. The fourth and fifth arguments,
``<Rows>`` and ``<Cols>``, correspond to the number of rows and columns,
respectively, and must be positive, constant integers. The returned vector must
Expand All @@ -21103,11 +21106,17 @@ The :ref:`align <attr_align>` parameter attribute can be provided for the

Syntax:
"""""""
This is an overloaded intrinsic. ``llvm.matrix.column.major.store`` to store
any vector type with a stride of any bitwidth up to 64.

::

declare void @llvm.matrix.column.major.store.*(
vectorty %In, ptrty %Ptr, i64 %Stride, i1 <IsVolatile>, i32 <Rows>, i32 <Cols>)
declare void @llvm.matrix.column.major.store.v4i32.i64(
<4 x i32> %In, ptrty %Ptr, i64 %Stride, i1 <IsVolatile>, i32 <Rows>,
i32 <Cols>)
declare void @llvm.matrix.column.major.store.v9f64.i32(
<9 x double> %In, ptrty %Ptr, i32 %Stride, i1 <IsVolatile>, i32
<Rows>, i32 <Cols>)

Overview:
"""""""""
Expand All @@ -21127,7 +21136,7 @@ Arguments:
The first argument ``%In`` is a vector that corresponds to a ``<Rows> x
<Cols>`` matrix to be stored to memory. The second argument ``%Ptr`` is a
pointer to the vector type of ``%In``, and is the start address of the matrix
in memory. The third argument ``%Stride`` is a positive, constant integer with
in memory. The third argument ``%Stride`` is a positive integer for which
``%Stride >= <Rows>``. ``%Stride`` is used to compute the column memory
addresses. I.e., for a column ``C``, its start memory addresses is calculated
with ``%Ptr + C * %Stride``. The fourth argument ``<IsVolatile>`` is a boolean
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6479,9 +6479,12 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
NumRows->getZExtValue() * NumColumns->getZExtValue(),
"Result of a matrix operation does not fit in the returned vector!");

if (Stride)
if (Stride) {
Check(Stride->getBitWidth() <= 64, "Stride bitwidth cannot exceed 64!",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks fine to me. Are there any cases where it could be less than 64 where we might want this to be configurable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in practice on targets with 32 bit index width (or lower), it may be smaller, matching the index width

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood Farzon's question as asking whether we might want the cap to be configurable so that, e.g., we can reject 64-bit strides when verifying IR targeting 32-bit platforms

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restriction in the verifier is mostly just so we can use getZExtValue() on it.

Regardless of the type width, stride, stride, columns, rows must be such that we can access all data without wrapping the address space. Restricting to i32 on 32 bit targets wouldn't really help to enforce that, as it would still be possible to provide arguments that would cause the accesses to wrap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

IF);
Check(Stride->getZExtValue() >= NumRows->getZExtValue(),
"Stride must be greater or equal than the number of rows!", IF);
}

break;
}
Expand Down
Loading
Loading