aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-24[NFC][TableGen] Use ArrayRef instead of const vector reference (#145323)Rahul Joshi1-2/+2
- Use `ArrayRef` instead of `SmallVector` reference in a few places. - Drop redundant `llvm::` in a few places.
2025-05-02[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#138236)Kazu Hirata1-1/+1
2025-02-09[TableGen] Remove recursive walk of linked list from ContractNodes. NFCCraig Topper1-221/+227
After f9250401ef120a4605ad67bb43d3b25500900498, this function is tail recursive so it was straightforward to convert this to iteratively walk the linkd list.
2025-02-08[TableGen] Fix an unused variable warning. NFCCraig Topper1-1/+1
2025-02-08[TableGen] Move formation of MoveSiblingMatcher earlier in ContractNodes. NFCCraig Topper1-24/+158
ContractNodes recursively walks forward through a linked list. During this recursion, Matchers are combined into other Matchers. Previously the formation of MoveSiblingMatcher was after the recursive call so it occurred as we were unwinding. If a MoveSiblingMatcher was formed, we would recursively walk forward to the end of the linked list again which isn't efficient. To make this more efficient, move the formation of MoveSiblingMatcher to the forward pass. Add additional rules to unfold MoveSiblingMatcher if it would be more efficient to use CheckChildType, CheckChildInteger, CheckChildSame, etc. As an added benefit, this makes the function tail recursive which the compiler can better optimize.
2025-02-06[TableGen] Use range-based for loops. NFCCraig Topper1-12/+11
2025-02-06[TableGen] Use std::copy instead of a manual copy loop. NFCCraig Topper1-7/+2
2025-02-04[TableGen] Don't try to move CheckOpcode before CheckType/CheckChildType in ↵Craig Topper1-7/+5
ContractNodes. NFC It appears that CheckOpcode is already emitted before CheckType so this hasn't been doing anything on any in tree targets.
2025-02-02[TableGen] Split DAGISelMatcherOpt FactorNodes into 2 functions. NFC (#125330)Craig Topper1-19/+21
The loop at the top of FactorNodes creates additional variables to deal with needing to use a pointer to a unique_ptr instead of a reference. Encapsulate this to its own function for better scoping. This also allows us to directly skip this loop when we already know we have a ScopeMatcher.
2025-01-31[TableGen] Reorder code in ContractNodes to prevents unnecessary recursion. NFCCraig Topper1-2/+2
The code that moves CheckOpcode before CheckType/CheckChildType/RecordDwith was running after ContractNodes started unwinding its recursion. If a move occurs we would start a new recursion going forward through the list again. I don't believe this can lead to any new combines so it was just wasted work. This patch moves the code earlier so it doesn't start a new recursion.
2025-01-31[TableGen] Remove unnecessary check before calling SmallVector::erase. NFCCraig Topper1-2/+1
This was checking whether the erase is needed, but erase is safe to call with equal iterators.
2025-01-16[TableGen] Use std::pair instead of std::make_pair. NFC. (#123174)Jay Foad1-2/+2
Also use brace initialization and emplace to avoid explicitly constructing std::pair, and the same for std::tuple.
2024-09-20[LLVM][TableGen] Adopt `indent` for indentation (#109275)Rahul Joshi1-2/+3
Adopt `indent` for indentation DAGISelMatcher and DecoderEmitter.
2024-03-25[RFC][TableGen] Restructure TableGen Source (#80847)Pierre van Houtryve1-3/+3
Refactor of the llvm-tblgen source into: - a "Basic" library, which contains the bare minimum utilities to build `llvm-min-tablegen` - a "Common" library which contains all of the helpers for TableGen backends. Such helpers can be shared by more than one backend, and even unit tested (e.g. CodeExpander is, maybe we can add more over time) Fixes #80647
2024-02-14[TableGen] Stop using make_pair and make_tuple. NFC. (#81730)Jay Foad1-2/+2
These are unnecessary since C++17.
2024-02-09[TableGen][NFC] convert TreePatternNode pointers to references (#81134)Tomas Matheson1-2/+2
Almost all uses of `*TreePatternNode` expect it to be non-null. There was the occasional check that it wasn't, which I have removed. Making them references makes it clear that they exist. This was attempted in 2018 (1b465767d6ca69f4b7201503f5f21e6125fe049a) for `TreePatternNode::getChild()` but that was reverted.
2024-02-09[NFC] clang-format utils/TableGen (#80973)Pierre van Houtryve1-3/+2
``` find llvm/utils/TableGen -iname "*.h" -o -iname "*.cpp" | xargs clang-format-16 -i ``` Split from #80847
2023-12-12[SelectionDAG] Add OPC_MoveSibling (#73643)Wang Pengcheng1-0/+24
There are a lot of operations to move current node to parent and then move to another child. So `OPC_MoveSibling` and its space-optimized forms are added to do this "move to sibling" operations. These new operations will be generated when optimizing matcher in `ContractNodes`. Currently `MoveParent+MoveChild` will be optimized to `MoveSibling` and sequences `MoveParent+RecordChild+MoveChild` will be transformed into `MoveSibling+RecordNode`. Overall this reduces the llc binary size with all in-tree targets by about 30K.
2023-04-22[TableGen] Re-work FactorNodes to avoid an extra temporary vector.Craig Topper1-51/+62
Instead of copying elements to the NewOptionsToMatchVector, we now shift down elements in OptionsToMatch as we create holes by pulling out equal matchers. After we finish processing the vector, we'll trim the size to just the elements that are still in use.
2023-04-12[TableGen] Store CodeGenInstruction reference in EmitNodeMatcherCommon. NFCCraig Topper1-3/+3
Instead of storing a string containing the instruction name, store a reference to the instruction. We can use that reference to print the instruction name when we emit the table. The only slightly annoying part is that we have to find the CodeGenInstruction for IMPLICIT_DEF. GlobalISel is doing a similar thing.
2023-04-02[TableGen] Rename InFlag/OutFlag->InGlue/OutGlue. NFCCraig Topper1-3/+3
Flag was renamed to Glue a long time ago, but rename was incomplete.
2023-04-02[TableGen] clang-format DAGISelMatcherOpt.cpp. NFCCraig Topper1-79/+70
2023-04-02[TableGen] Avoid creating a ScopeMatcher full of nullptrs.Craig Topper1-13/+14
The call to FactorNodes will catch it and remove it, but it's easy to catch at creation. Remove the now unnecessary null checks from a loop in factor nodes.
2023-04-01[TableGen] Move some vectors into place instead of copying them.Craig Topper1-8/+8
2023-02-17llvm-tblgen: Apply IWYU partiallyNAKAMURA Takumi1-0/+1
2022-01-07[llvm] Use true/false instead of 1/0 (NFC)Kazu Hirata1-1/+1
Identified with modernize-use-bool-literals.
2019-09-26DAGISelMatcherOpt - TGParser::ParseOperation - silence static analyzer ↵Simon Pilgrim1-4/+5
cast_or_null<CheckTypeMatcher> null dereference warning. NFCI. The static analyzer is warning about a potential null dereference, replace with an null/isa assertion and cast<CheckTypeMatcher>. llvm-svn: 373001
2019-02-25[SelectionDAG] Add a OPC_CheckChild2CondCode to SelectionDAGISel to remove a ↵Craig Topper1-2/+6
MoveChild and MoveParent pair. OPC_CheckCondCode is always used as operand 2 of a setcc. And its always surrounded by a MoveChild2 and a MoveParent. By having a dedicated opcode for this case we can reduce the number of bytes needed for this pattern from 4 bytes to 2. This saves ~3000 bytes in the X86 table. llvm-svn: 354763
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-05-14Rename DEBUG macro to LLVM_DEBUG.Nicola Zaghen1-9/+6
The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM - Manual change to APInt - Manually chage DOCS as regex doesn't match it. In the transition period the DEBUG() macro is still present and aliased to the LLVM_DEBUG() one. Differential Revision: https://reviews.llvm.org/D43624 llvm-svn: 332240
2017-02-06[TableGen] Use less stack in DAGISelMatcherOptJon Chesterfield1-9/+15
Refactor a helper function, FactorNodes, to search for a push node in constant space. This resolves a problem in a not-yet-upstreamed backend where a recursive pattern blew the call stack (at a depth of 255) under a debug build of tablegen. No functional change so no new test coverage. The change is minimal to avoid disturbing existing behaviour. Differential Revision: https://reviews.llvm.org/D29080 llvm-svn: 294230
2016-11-22[TableGen][ISel] When factoring ScopeMatcher, if the child of the ↵Craig Topper1-2/+9
ScopeMatcher we're working on is also a ScopeMatcher, merge all its children into the one we're working on. There were several cases in X86 where we were unable to fully factor a ScopeMatcher but created nested ScopeMatchers for some portions of it. Then we created a SwitchType that split it up and further factored it so that we ended up with something like this: SwitchType Scope Scope Sequence of matchers Some other sequence of matchers EndScope Another sequence of matchers EndScope ...Next type This change turns it into this: SwitchType Scope Sequence of matchers Some other sequence of matchers Another sequence of matchers EndScope ...Next type Several other in-tree targets had similar nested scopes like this. Overall this doesn't save many bytes, but makes the isel output a little more regular. llvm-svn: 287624
2016-11-21[TableGen][ISel] Do a better job of factoring ScopeMatchers created during ↵Craig Topper1-3/+11
creation of SwitchTypeMatcher. Previously we were factoring when the ScopeMatcher was initially created, but it might get more Matchers added to it later. Delay factoring until we have fully created/populated the ScopeMatchers. This reduces X86 isel tables by 154 bytes. llvm-svn: 287520
2016-05-06[TableGen] Fix a memory leak when creating SwitchOpcodeMatchers.Craig Topper1-1/+2
llvm-svn: 268712
2016-05-06[TableGen] Remove SinkPatternPredicates from the DAG isel matcher optimizer.Craig Topper1-54/+0
Pattern predicates already appear to be emitted as far down as they can be. The optimization was making no changes on any in-tree target. llvm-svn: 268705
2016-05-05SDAG: Remove OPC_MarkGlueResults and associated logic. NFCJustin Bogner1-18/+0
This opcode never happens in practice, and yet the logic we have in place to handle it would be undefined behaviour if we ever executed it. Remove it rather than trying to refactor code that's never reached. llvm-svn: 268692
2016-05-05[TableGen] Make sure to recursively factor any ScopeMatchers created while ↵Craig Topper1-1/+3
forming a SwitchType node. Remove a couple hundred bytes from the X86 matcher table. llvm-svn: 268611
2016-05-05[TableGen] Remove stale comment.Craig Topper1-2/+1
llvm-svn: 268610
2016-04-18[NFC] Header cleanupMehdi Amini1-1/+0
Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
2014-12-15Use unique_ptr to remove explicit delete.Craig Topper1-4/+3
llvm-svn: 224224
2014-11-19Make StringSet::insert return pair<iterator, bool> like other ↵David Blaikie1-1/+1
self-associative containers StringSet is still a bit dodgy in that it exposes the raw iterator of the StringMap parent, which exposes the weird detail that StringSet actually has a 'value'... but anyway, this is useful for a handful of clients that want to reference the newly inserted/persistent string data in the StringSet/Map/Entry/thing. llvm-svn: 222302
2014-08-29Fix typos in comments, NFCRobin Morisset1-1/+1
Summary: Just fixing comments, no functional change. Test Plan: N/A Reviewers: jfb Subscribers: mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D5130 llvm-svn: 216784
2014-07-19Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ↵David Blaikie1-1/+1
".reset()" It's also possible to just write "= nullptr", but there's some question of whether that's as readable, so I leave it up to authors to pick which they prefer for now. If we want to discuss standardizing on one or the other, we can do that at some point in the future. llvm-svn: 213438
2014-04-22[Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth1-1/+2
definition below all of the header #include lines, TableGen edition. llvm-svn: 206846
2014-04-15[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper1-10/+10
instead of comparing to nullptr. llvm-svn: 206254
2014-03-06Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles1-7/+7
This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
2014-03-05[C++11] Replace OwningPtr::take() with OwningPtr::release().Ahmed Charles1-8/+8
llvm-svn: 202957
2014-02-05Add CheckChildInteger to ISelMatcher operations. Removes nearly 2000 bytes ↵Craig Topper1-1/+5
from X86 matcher table. llvm-svn: 200821
2014-01-21Use ArrayRef to simplify some code.Craig Topper1-6/+5
llvm-svn: 199712
2013-10-05Add OPC_CheckChildSame0-3 to the DAG isel matcher. This replaces sequences ↵Craig Topper1-1/+5
of MoveChild, CheckSame, MoveParent. Saves 846 bytes from the X86 DAG isel matcher, ~300 from ARM, ~840 from Hexagon. llvm-svn: 192026