Go to the documentation of this file.
9 #ifndef LLVM_CODEGEN_PBQP_MATH_H
10 #define LLVM_CODEGEN_PBQP_MATH_H
31 : Length(Length), Data(
std::make_unique<
PBQPNum []>(Length)) {}
35 : Length(Length), Data(
std::make_unique<
PBQPNum []>(Length)) {
36 std::fill(Data.get(), Data.get() + Length, InitVal);
41 : Length(V.Length), Data(
std::make_unique<
PBQPNum []>(Length)) {
42 std::copy(V.Data.get(), V.Data.get() + Length, Data.get());
47 : Length(V.Length), Data(
std::
move(V.Data)) {
53 assert(Length != 0 && Data &&
"Invalid vector");
54 if (Length != V.Length)
56 return std::equal(Data.get(), Data.get() + Length, V.Data.get());
61 assert(Length != 0 && Data &&
"Invalid vector");
67 assert(Length != 0 && Data &&
"Invalid vector");
68 assert(Index < Length &&
"Vector element access out of bounds.");
74 assert(Length != 0 && Data &&
"Invalid vector");
75 assert(Index < Length &&
"Vector element access out of bounds.");
81 assert(Length != 0 && Data &&
"Invalid vector");
82 assert(Length == V.Length &&
"Vector length mismatch.");
83 std::transform(Data.get(), Data.get() + Length, V.Data.get(), Data.get(),
84 std::plus<PBQPNum>());
90 assert(Length != 0 && Data &&
"Invalid vector");
91 return std::min_element(Data.get(), Data.get() + Length) - Data.get();
96 std::unique_ptr<PBQPNum []> Data;
101 unsigned *VBegin =
reinterpret_cast<unsigned*
>(V.Data.get());
102 unsigned *VEnd =
reinterpret_cast<unsigned*
>(V.Data.get() + V.Length);
108 template <
typename OStream>
113 for (
unsigned i = 1;
i < V.getLength(); ++
i)
128 Rows(Rows), Cols(Cols), Data(
std::make_unique<
PBQPNum []>(Rows * Cols)) {
134 : Rows(Rows), Cols(Cols),
135 Data(
std::make_unique<
PBQPNum []>(Rows * Cols)) {
136 std::fill(Data.get(), Data.get() + (Rows * Cols), InitVal);
141 : Rows(
M.Rows), Cols(
M.Cols),
142 Data(
std::make_unique<
PBQPNum []>(Rows * Cols)) {
143 std::copy(
M.Data.get(),
M.Data.get() + (Rows * Cols), Data.get());
148 : Rows(
M.Rows), Cols(
M.Cols), Data(
std::
move(
M.Data)) {
154 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
155 if (Rows !=
M.Rows || Cols !=
M.Cols)
157 return std::equal(Data.get(), Data.get() + (Rows * Cols),
M.Data.get());
162 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
168 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
174 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
175 assert(R < Rows &&
"Row out of bounds.");
176 return Data.get() + (R * Cols);
181 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
182 assert(R < Rows &&
"Row out of bounds.");
183 return Data.get() + (R * Cols);
188 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
190 for (
unsigned C = 0;
C < Cols; ++
C)
191 V[
C] = (*
this)[R][
C];
197 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
199 for (
unsigned R = 0; R < Rows; ++R)
200 V[R] = (*
this)[R][
C];
206 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
208 for (
unsigned r = 0; r < Rows; ++r)
209 for (
unsigned c = 0;
c < Cols; ++
c)
210 M[
c][r] = (*
this)[r][
c];
216 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
217 assert(Rows ==
M.Rows && Cols ==
M.Cols &&
218 "Matrix dimensions mismatch.");
220 Data.get(), std::plus<PBQPNum>());
225 assert(Rows != 0 && Cols != 0 && Data &&
"Invalid matrix");
233 std::unique_ptr<PBQPNum []> Data;
238 unsigned *MBegin =
reinterpret_cast<unsigned*
>(
M.Data.get());
240 reinterpret_cast<unsigned*
>(
M.Data.get() + (
M.Rows *
M.Cols));
246 template <
typename OStream>
248 assert((
M.getRows() != 0) &&
"Zero-row matrix badness.");
249 for (
unsigned i = 0;
i <
M.getRows(); ++
i)
250 OS <<
M.getRowAsVector(
i) <<
"\n";
254 template <
typename Metadata>
266 template <
typename Metadata>
271 template <
typename Metadata>
283 template <
typename Metadata>
291 #endif // LLVM_CODEGEN_PBQP_MATH_H
MDVector(const Vector &v)
Vector getRowAsVector(unsigned R) const
Returns the given row as a vector.
Matrix(unsigned Rows, unsigned Cols)
Construct a PBQP Matrix with the given dimensions.
This is an optimization pass for GlobalISel generic memory operations.
unsigned getCols() const
Return the number of cols in this matrix.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Vector(const Vector &V)
Copy construct a PBQP vector.
friend hash_code hash_value(const Matrix &)
Return a hash_code for the given matrix.
PBQPNum * operator[](unsigned R)
Matrix element access.
Matrix(Matrix &&M)
Move construct a PBQP matrix.
bool operator==(const Vector &V) const
Comparison operator.
Vector & operator+=(const Vector &V)
Add another vector to this one.
Vector getColAsVector(unsigned C) const
Returns the given column as a vector.
Vector(Vector &&V)
Move construct a PBQP vector.
(vector float) vec_cmpeq(*A, *B) C
unsigned getRows() const
Return the number of rows in this matrix.
Vector(unsigned Length, PBQPNum InitVal)
Construct a PBQP vector with initializer.
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
hash_code hash_value(const Vector &V)
Return a hash_value for the given vector.
Matrix transpose() const
Matrix transpose.
unsigned getLength() const
Return the length of the vector.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
const PBQPNum * operator[](unsigned R) const
Matrix element access.
PBQPNum & operator[](unsigned Index)
Element access.
Matrix & operator+=(const Matrix &M)
Add the given matrix to this one.
MDMatrix(const Matrix &m)
Analysis the ScalarEvolution expression for r is this
Matrix(const Matrix &M)
Copy construct a PBQP matrix.
OStream & operator<<(OStream &OS, const Vector &V)
Output a textual representation of the given vector on the given output stream.
bool operator==(const Matrix &M) const
Comparison operator.
instcombine should handle this transform
unsigned minIndex() const
Returns the index of the minimum value in this vector.
const PBQPNum & operator[](unsigned Index) const
Const element access.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
friend hash_code hash_value(const Vector &)
Return a hash_value for the given vector.
Matrix(unsigned Rows, unsigned Cols, PBQPNum InitVal)
Construct a PBQP Matrix with the given dimensions and initial value.
Vector(unsigned Length)
Construct a PBQP vector of the given size.
const Metadata & getMetadata() const
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same we currently get code like const It could be done with a smaller encoding like local tee $pop5 local copy
const Metadata & getMetadata() const
An opaque object representing a hash code.
Matrix operator+(const Matrix &M)