1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
Commit Graph

413 Commits

Author SHA1 Message Date
Stephen Neuendorffer
b0a805b25d Convert TableGen assert to error
This gives a nice message about the location of errors in a large
tablegen file, which is much more useful for users

Differential Revision: https://reviews.llvm.org/D102740
2021-06-01 13:17:58 -07:00
Eli Friedman
1638fc9086 [AArch64][RISCV] Make sure isel correctly honors failure orderings.
If a cmpxchg specifies acquire or seq_cst on failure, make sure we
generate code consistent with that ordering even if the success ordering
is not acquire/seq_cst.

At one point, it was ambiguous whether this sort of construct was valid,
but the C++ standad and LLVM now accept arbitrary combinations of
success/failure orderings.

This doesn't address the corresponding issue in AtomicExpand. (This was
reported as https://bugs.llvm.org/show_bug.cgi?id=33332 .)

Fixes https://bugs.llvm.org/show_bug.cgi?id=50512.

Differential Revision: https://reviews.llvm.org/D103284
2021-05-28 12:47:40 -07:00
Simon Pilgrim
919f54daef Revert rG632668c1c0e7dcf97154d2e377491cdc8cb6963c : "[TableGen] TreePatternNode::isIsomorphicTo - early out for matching leafs. NFCI."
Revert premature (and very broken....) experimental commit.
2021-05-15 15:49:14 +01:00
Simon Pilgrim
7e5bfbbe69 [TableGen] TreePatternNode::isIsomorphicTo - early out for matching leafs. NFCI.
If the leafs are the same then no need to perform DefInit matching.
2021-05-15 15:34:43 +01:00
Craig Topper
f3f2380881 [ValueTypes] Rename MVT::getVectorNumElements() to MVT::getVectorMinNumElements(). Fix some misuses of getVectorNumElements()
getVectorNumElements() returns a value for scalable vectors
without any warning so it is effectively getVectorMinNumElements().
By renaming it and making getVectorNumElements() forward to
it, we can insert a check for scalable vectors into getVectorNumElements()
similar to EVT. I didn't do that in this patch because there are still more
fixes needed, but I was able to temporarily do it and passed the RISCV
lit tests with these changes.

The changes to isPow2VectorType and getPow2VectorType are copied from EVT.

The change to TypeInfer::EnforceSameNumElts reduces the size of AArch64's isel table.
We're now considering SameNumElts to require the scalable property to match which
removes some unneeded type checks.

This was motivated by the bug I fixed yesterday in 80b9510806cf11c57f2dd87191d3989fc45defa8

Reviewed By: frasercrmck, sdesmalen

Differential Revision: https://reviews.llvm.org/D102262
2021-05-12 07:46:45 -07:00
Craig Topper
20783a20c4 [TableGen] Remove predicate filtering from GenerateVariants.
After D100691, predicates should be cheap to compare again so
we don't need to filter anymore.

This is mostly just a revert of several patches going back to 2018.

Reviewed By: kparzysz

Differential Revision: https://reviews.llvm.org/D100695
2021-04-28 16:02:13 -07:00
Craig Topper
c793cba446 [TableGen] Store predicates in PatternToMatch as ListInit *. Add string for HwModeFeatures
This uses to be how predicates were handled prior to HwMode being
added. When the Predicates were converted to a std::vector it
significantly increased the cost of a compare in GenerateVariants.
Since ListInit's are uniquified by tablegen, we can use a simple
pointer comparison to check for identical lists.

In order to store the HwMode, we now add a separate string to
PatternToMatch. This will be appended separately to the predicate
string in getPredicateCheck. A new getPredicateRecords is added
to allow GlobalISel and getPredicateCheck to both get the sorted
list of Records. GlobalISel was ignoring any HwMode predicates
before and still is.

There is one slight change here, ListInits with different predicate
orders aren't sorted so the filtering in GenerateVariants might
fail to detect two isomorphic patterns with different predicate
orders. This doesn't seem to be happening in tree today.

My hope is this will allow us to remove all the BitVector tracking
in GenerateVariants that was making up for predicates beeing
expensive to compare. There's a decent amount of heap allocations
there on large targets like X86, AMDGPU, and RISCV.

Differential Revision: https://reviews.llvm.org/D100691
2021-04-28 12:05:49 -07:00
Craig Topper
6cf780d2b7 [TableGen] Add predicate checks to isel patterns for default HwMode.
As discussed in D100691 and based on D100889.

I removed the ModeChecks cache which provides little value. Reduced
from three loops to two. Used ArrayRef to pass the Predicate to
AppendPattern to avoid needing to construct a vector for single
mode. Used SmallVector to avoid heap allocation constructing
DefaultCheck for the in tree targets the use it.

Reviewed By: kparzysz

Differential Revision: https://reviews.llvm.org/D101240
2021-04-27 10:46:51 -07:00
Craig Topper
59da2ddc9a [TableGen] Pass SmallVector to union_modes instead of returning a std::vector.
The number of modes is small so this should avoid a heap allocation.

Also replace std::set with SmallSet.
2021-04-18 15:59:52 -07:00
Craig Topper
fdef0cf249 [TableGen] Use MachineValueTypeSet in place of SmallSet.
MachineValueTypeSet is effectively a std::bitset<256>. This allows
us quickly insert into the set and check if a type is in the set.
2021-04-18 13:38:30 -07:00
Craig Topper
e51b3ceb31 [TableGen] Remove local SmallSet from TypeSetByHwMode::insert.
This keeps track of which modes are in VVT so we can find out
if a mode is missing later. But we can just ask VVT whether it
has a particular mode.
2021-04-17 10:48:57 -07:00
Craig Topper
da04af3736 [TableGen] Replace two SmallDenseSets with SmallSets.
The key here is HwMode indices. They're going to be small numbers,
contiguous, and only a few different values. I don't think we need
to go through the SmallDenseSet hashing.

A BitVector would be even better, but we don't have the upper
bound here.
2021-04-16 17:57:53 -07:00
Craig Topper
d27dd156eb [TableGen] Run GenerateVariants before ExpandHwModeBasedTypes.
A large portion of the patterns are duplicated for HwMode on RISCV.
If we expand HwMode first, we need to check nearly twice as many
patterns for variants. HwModes shouldn't affect whether a variant
is valid so we should be able to expand after.

This also reduces the RISCV isel table by 539 bytes due to factoring
working better on this pattern order. Unfortunately it increases
Hexagon table size by ~50 bytes. But I think this is a reasonable
trade.
2021-04-16 15:05:33 -07:00
Fangrui Song
adec14b680 [TableGen] Fix -Wparentheses 2021-04-16 13:37:52 -07:00
Benjamin Kramer
773674bb59 [tblgen] Fold loop into assert to avoid unused variable warnings. NFCI. 2021-04-16 20:47:38 +02:00
Simon Pilgrim
5af801c347 [TableGen] CodeGenDAGPatterns - use const references on for-range loops to avoid unnecessary copies. NFCI. 2021-04-16 18:55:23 +01:00
Simon Pilgrim
9844b69219 [TableGen] CodeGenDAGPatterns - (style) remove if-else chain when if block always returns. NFCI. 2021-04-16 18:26:33 +01:00
Alex Richardson
99e7c8e198 [TableGen] Emit more helpful error messages on empty type set
I have seen this error quite frequently in our out-of-tree CHERI backends
and the lack of location information sometimes makes it quite difficult
to track down the actual source of the error.
This patch changes the llvm_unreachable() to a PrintFatalError() so that
tablegen prints a stack of source locations.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D99468
2021-03-31 09:24:03 +01:00
Craig Topper
48f016a681 [RISCV] Add support for VECTOR_REVERSE for scalable vector types.
I've left mask registers to a future patch as we'll need
to convert them to full vectors, shuffle, and then truncate.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D97609
2021-03-09 10:03:45 -08:00
Kazu Hirata
ea4b300a92 [TableGen] Use ListSeparator (NFC) 2021-02-26 22:36:38 -08:00
Kazu Hirata
01ea295bd7 [TableGen] Use ListSeparator (NFC) 2021-02-11 23:31:27 -08:00
Craig Topper
cb8d88249b [RISCV] Use SplatPat/SplatPat_simm5 to handle PseudoVMV_V_X_/PseudoVMV_V_I_ selection as well.
This ensures that we'll match immediates consistently regardless
of whether we match them as a standalone splat or as part of
another operation.

While I was there I added complexities to the simm5/uimm5 patterns so
we didn't have to assume that the 1 on the non-immediate was lower
than what tablegen inferred.

I had to make a minor tweak to tablegen to fix one place that
didn't expect to see a ComplexPattern that wasn't a "leaf".

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D96199
2021-02-08 09:48:27 -08:00
Craig Topper
0d9ccf3b16 [TableGen] Make all the fields in PatternToMatch private. NFCI
Add the few missing accessor methods. Use accessor methdods
everywhere.
2021-02-06 22:34:01 -08:00
Kazu Hirata
e420343cf4 [TableGen] Use range-based for loops (NFC) 2021-02-01 20:55:09 -08:00
Craig Topper
86592d2f7a [TableGen] Don't commute isel patterns if it would put an immAllOnesV or immAllZerosV on the left hand side.
This primarily occurs with isel patterns using vnot. This reduces
the number of variants in the isel tables.

We generally canonicalize build_vectors of constants to the RHS. I think
we might fail if there is a bitcast on the build_vector, but that
should be easy to fix if we can find a case. Usually the
bitcast is introduced by type legalization or lowering. It's
likely canonicalization would have already occured.
2021-01-31 21:18:21 -08:00
Craig Topper
aa315ff5e6 [TableGen] Use emplace_back to add to PatternsToMatch in GenerateVariants. Use std::move when adding to PatternsToMatch in AddPatternToMatch.
We already used emplace_back in at least one other place so be
consistent.

AddPatternToMatch already took PTM as an rvalue reference, but
we need to use std::move again to move it into the PatternToMatch
vector.
2021-01-30 13:16:39 -08:00
Craig Topper
f0f998bb55 [TableGen] Avoid a couple vector copies in ExpandHwModeBasedTypes.
Use vector::swap instead of copying to a local vector and clearing
the original. We can just swap into the just created local vector
instead which will move the pointers and not the data.

Use std::move in another place to avoid a copy.
2021-01-30 13:16:39 -08:00
Kazu Hirata
dfbe37a54f [llvm] Remove redundant string initialization (NFC)
Identified with readability-redundant-string-init.
2021-01-12 21:43:46 -08:00
Kazu Hirata
3da3875591 [Tablegen] Use llvm::find_if (NFC) 2021-01-08 18:39:55 -08:00
Craig Topper
05e081e550 [TableGen] Make CodeGenDAGPatterns::getSDNodeNamed take a StringRef instead of const std::string &.
All callers use a string literal and the getDef method the string
is passed to already takes a StringRef.
2021-01-07 14:20:16 -08:00
Kazu Hirata
201d0ba7d2 [TableGen] Use llvm::append_range (NFC) 2021-01-02 09:24:13 -08:00
David Sherwood
4d9ff7d9d6 [SVE] Replace TypeSize comparison operators in llvm/utils/TableGen
In CodeGenDAGPatterns.cpp we were relying upon TypeSize comparison
operators for ordering types, when we can actually just use the known
minimum size since the scalable property is already being taken into
account. Also, in TypeInfer::EnforceSameSize I fixed some implicit
TypeSize->uint64_t casts by changing the code to test the equality
of TypeSize objects instead.

In other places I have replaced calls to getSizeInBits() with
getFixedSizeInBits() because we are only ever expecting integer values.

Differential Revision: https://reviews.llvm.org/D88947
2020-10-19 08:21:36 +01:00
David Green
ac0f328513 [ARM] Extra MVE select(binop) patterns
This is very similar to 243970d03cace2, but handling a slightly
different form of predicated operations. When starting with a pattern of
the form select(p, BinOp(x, y), x), Instcombine will often transform
this to BinOp(x, select(p, y, 0)), where 0 is the identity value of the
binop (0 for adds/subs, 1 for muls, -1 for ands etc). This adds the
patterns that transforms those back into predicated binary operations.

There is also a very minor adjustment to tablegen null_frag in here, to
allow it to also be recognized as a PatLeaf node, so that it can be used
in MVE_TwoOpPattern to easily exclude the cases where we do not need the
alternate transform.

Differential Revision: https://reviews.llvm.org/D84091
2020-07-22 14:08:29 +01:00
Guillaume Chatelet
58e1dd33cd [Alignment][NFC] Transitionning more getMachineMemOperand call sites
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: arsenm, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, hiraditya, kbarton, jrtc27, atanasyan, Jim, kerbowa, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77121
2020-03-31 08:36:18 +00:00
Matt Arsenault
d09873308c TableGen: Fix typo 2020-03-13 10:45:28 -04:00
Matt Arsenault
3e62f38540 TableGen: Fix logic for default operands
This was checking for default operands in the current DAG instruction,
rather than the correct result operand list. I'm not entirly sure how
this managed to work before, but was failing for me when multiple
default operands were overridden.
2020-02-19 23:41:07 -05:00
Simon Tatham
270ded9a96 [TableGen] Don't elide bitconverts in PatFrag fragments.
Summary:
In the DAG pattern backend, `SimplifyTree` simplifies a pattern by
removing bitconverts between two identical types. But that function is
also run on the fragments list in instances of `PatFrags`, in which
the types haven't been specified yet. So the input and output of the
bitconvert always evaluate to the empty set of types, which makes them
compare equal. So the test always passes, and bitconverts are
unconditionally removed from the PatFrag RHS.

Fixed by spotting the empty type set and using it to inhibit the
optimization.

Reviewers: nhaehnle, hfinkel

Reviewed By: nhaehnle

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74627
2020-02-17 09:30:45 +00:00
Benjamin Kramer
8d50d8820b Fix a couple more implicit conversions that Clang doesn't diagnose. 2020-01-29 00:42:56 +01:00
Benjamin Kramer
87d13166c7 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
Matt Arsenault
295d2fea14 TableGen: Fix assert on PatFrags with predicate code
This assumed a single pattern if there was a predicate. Relax this a
bit, and allow multiple patterns as long as they have the same class.

This was only broken for the DAG path. GlobalISel seems to have
handled this correctly already.
2019-12-30 14:24:25 -05:00
Mark de Wever
fe7ca9d333 [TableGen] Fixes -Wrange-loop-analysis warnings
This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Differential Revision: https://reviews.llvm.org/D71807
2019-12-22 18:58:32 +01:00
Reid Kleckner
f986e0d356 [TableGen] Remove unused target intrinsic generation logic
AMDGPU was the last in tree target to use this tablegen mode. I plan to
split up the global intrinsic enum similar to the way that clang
diagnostics are split up today. I don't plan to build on this mode.

Reviewers: arsenm, echristo, efriedma

Reviewed By: echristo

Differential Revision: https://reviews.llvm.org/D71318
2019-12-11 07:38:45 -08:00
Graham Hunter
6e15087bc5 [SVE][CodeGen] Scalable vector MVT size queries
* Implements scalable size queries for MVTs, split out from D53137.

* Contains a fix for FindMemType to avoid using scalable vector type
  to contain non-scalable types.

* Explicit casts for several places where implicit integer sign
  changes or promotion from 32 to 64 bits caused problems.

* CodeGenDAGPatterns will treat scalable and non-scalable vector types
  as different.

Reviewers: greened, cameron.mcinally, sdesmalen, rovka

Reviewed By: rovka

Differential Revision: https://reviews.llvm.org/D66871
2019-11-18 12:30:59 +00:00
Simon Pilgrim
02298af81b Stop static analyzer warnings about using bitwise operators on booleans. NFCI.
Call each of the rebase_if() calls separately.
2019-11-02 22:40:04 +00:00
Dávid Bolvanský
197accdae6 Revert "[Codegen] Both sides of '&&' are same; fixed"
This reverts commit edb42dccfafb2c0d25d19175c49d016a7c2e0b13. Buildbot timeouts.
2019-11-02 19:02:33 +01:00
Dávid Bolvanský
7d756df5a7 [Codegen] Both sides of '&&' are same; fixed
Summary:
Found by PVS Studio

Not familiar with this code; no testcase.

Reviewers: craig.topper, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69741
2019-11-02 16:43:16 +01:00
Craig Topper
e9c90270ed [X86][TableGen] Allow timm to appear in output patterns. Use it to remove ConvertToTarget opcodes from the X86 isel table.
We're now using a lot more TargetConstant nodes in SelectionDAG.
But we were still telling isel to convert some of them
to TargetConstants even though they already are. This is because
isel emits a conversion anytime the output pattern has a an 'imm'.
I guess for patterns in instructions we take the 'timm' from the
'set' pattern, but for Pat patterns with explcicit output we
previously had to say 'imm' since 'timm' wasn't allowed in outputs.

llvm-svn: 372525
2019-09-22 19:49:39 +00:00
Graham Hunter
15543f7650 [SVE][MVT] Fixed-length vector MVT ranges
* Reordered MVT simple types to group scalable vector types
    together.
  * New range functions in MachineValueType.h to only iterate over
    the fixed-length int/fp vector types.
  * Stopped backends which don't support scalable vector types from
    iterating over scalable types.

Reviewers: sdesmalen, greened

Reviewed By: greened

Differential Revision: https://reviews.llvm.org/D66339

llvm-svn: 372099
2019-09-17 10:19:23 +00:00
Matt Arsenault
44317511dd AMDGPU: Remove code address space predicates
Fixes 8-byte, 8-byte aligned LDS loads. 16-byte case still broken due
to not be reported as legal.

llvm-svn: 371413
2019-09-09 16:02:07 +00:00
Benjamin Kramer
db09140c2c Retire llvm::less/equal in favor of C++14 std::less<>/equal_to<>.
llvm-svn: 369674
2019-08-22 17:31:59 +00:00