/* Common vector helpers and macros for IBM z13 and later
Copyright 2021 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
or
* the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
or both in parallel, as here.
The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* * Vector intrinsics use vector element types that kind-of make sense for the * specific operation (e.g., vec_permi permutes doublewords). To use VRs * interchangeably with different intrinsics, typedef the two variants and wrap * them in a union.
*/ #define VLEN_BYTES 16 typedefunsignedlonglong v2di __attribute__ ((vector_size (VLEN_BYTES))); typedefunsignedchar v16qi __attribute__ ((vector_size (VLEN_BYTES)));
/* * The Z vector intrinsics use vectors with different element types (e.g., * v16qi for the 128-bit adds and v2di for vec_permi).
*/ union vec
{
v2di dw;
v16qi sw;
};
typedefunion vec vec_t;
/* * single-instruction combine of two GPRs into a VR
*/ staticinline v2di
vec_load_2di_as_pair (unsignedlong a, unsignedlong b)
{
v2di res;
__asm__("vlvgp\t%0,%1,%2" : "=v"(res) : "r"(a), "r"(b)); return res;
}
/* * 64x64 mult where caller needs to care about proper register allocation: * multiply xl with m1, treating both as unsigned, and place the result in * xh:xl. * mlgr operates on register pairs, so xh must be an even gpr followed by xl
*/ #define s390_umul_ppmm(xh, xl, m1) \ do \
{ \ asm("mlgr\t%0,%3" : "=r"(xh), "=r"(xl) : "%1"(xl), "r"(m1)); \
} \ while (0);
/* * two 64x64 multiplications, scheduled so that they will dispatch and issue to * different sides: each mlgr is dispatched alone in an instruction group and * subsequent groups will issue on different execution sides. * there is a variant where both products use the same multiplicand and one * that uses two different multiplicands. constraints from s390_umul_ppmm apply * here.
*/ #define s390_double_umul_ppmm(X0H, X0L, X1H, X1L, MX) \ do \
{ \ asm("mlgr\t%[x0h],%[mx]\n\t" \ "mlgr\t%[x1h],%[mx]" \
: [x0h] "=&r"(X0H), [x0l] "=&r"(X0L), [x1h] "=r"(X1H), \
[x1l] "=r"(X1L) \
: "[x0l]"(X0L), "[x1l]"(X1L), [mx] "r"(MX)); \
} \ while (0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.