summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/DAGISelEmitter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-1/+1
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-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
* [TableGen] Support multi-alternative pattern fragmentsUlrich Weigand2018-07-131-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A TableGen instruction record usually contains a DAG pattern that will describe the SelectionDAG operation that can be implemented by this instruction. However, there will be cases where several different DAG patterns can all be implemented by the same instruction. The way to represent this today is to write additional patterns in the Pattern (or usually Pat) class that map those extra DAG patterns to the instruction. This usually also works fine. However, I've noticed cases where the current setup seems to require quite a bit of extra (and duplicated) text in the target .td files. For example, in the SystemZ back-end, there are quite a number of instructions that can implement an "add-with-overflow" operation. The same instructions also need to be used to implement just plain addition (simply ignoring the extra overflow output). The current solution requires creating extra Pat pattern for every instruction, duplicating the information about which particular add operands map best to which particular instruction. This patch enhances TableGen to support a new PatFrags class, which can be used to encapsulate multiple alternative patterns that may all match to the same instruction. It operates the same way as the existing PatFrag class, except that it accepts a list of DAG patterns to match instead of just a single one. As an example, we can now define a PatFrags to match either an "add-with-overflow" or a regular add operation: def z_sadd : PatFrags<(ops node:$src1, node:$src2), [(z_saddo node:$src1, node:$src2), (add node:$src1, node:$src2)]>; and then use this in the add instruction pattern: defm AR : BinaryRRAndK<"ar", 0x1A, 0xB9F8, z_sadd, GR32, GR32>; These SystemZ target changes are implemented here as well. Note that PatFrag is now defined as a subclass of PatFrags, which means that some users of internals of PatFrag need to be updated. (E.g. instead of using PatFrag.Fragment you now need to use !head(PatFrag.Fragments).) The implementation is based on the following main ideas: - InlinePatternFragments may now replace each original pattern with several result patterns, not just one. - parseInstructionPattern delays calling InlinePatternFragments and InferAllTypes. Instead, it extracts a single DAG match pattern from the main instruction pattern. - Processing of the DAG match pattern part of the main instruction pattern now shares most code with processing match patterns from the Pattern class. - Direct use of main instruction patterns in InferFromPattern and EmitResultInstructionAsOperand is removed; everything now operates solely on DAG match patterns. Reviewed by: hfinkel Differential Revision: https://reviews.llvm.org/D48545 llvm-svn: 336999
* Revert r334764, as it breaks some botsFlorian Hahn2018-06-141-14/+14
| | | | llvm-svn: 334767
* [TableGen] Make TreePatternNode::getChild return a reference (NFC)Florian Hahn2018-06-141-14/+14
| | | | | | | | The return value of TreePatternNode::getChild is never null. This patch also updates various places that use return values of getChild to also use references. Those changes were suggested post-commit for D47463. llvm-svn: 334764
* Rename DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-141-7/+10
| | | | | | | | | | | | | | | | 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
* [TableGen] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. Reviewers: stoklund, kparzysz, dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45144 llvm-svn: 329451
* Allow separation of declarations and definitions in <Target>ISelDAGToDAG.incKrzysztof Parzyszek2017-11-101-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the ability to include the member function declarations in the instruction selector class separately from the member bodies. Defining GET_DAGISEL_DECL macro to any value will only include the member declarations. To include bodies, define GET_DAGISEL_BODY macro to be the selector class name. Example: class FooDAGToDAGISel : public SelectionDAGISel { // Pull in declarations only. #define GET_DAGISEL_DECL #include "FooISelDAGToDAG.inc" }; // Include the function bodies (with names qualified with the provided // class name). #define GET_DAGISEL_BODY FooDAGToDAGISel #include "FooISelDAGToDAG.inc" When neither of the two macros are defined, the function bodies are emitted inline (in the same way as before this patch). Differential Revision: https://reviews.llvm.org/D39596 llvm-svn: 317903
* TableGen support for parameterized register class informationKrzysztof Parzyszek2017-09-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | This replaces TableGen's type inference to operate on parameterized types instead of MVTs, and as a consequence, some interfaces have changed: - Uses of MVTs are replaced by ValueTypeByHwMode. - EEVT::TypeSet is replaced by TypeSetByHwMode. This affects the way that types and type sets are printed, and the tests relying on that have been updated. There are certain users of the inferred types outside of TableGen itself, namely FastISel and GlobalISel. For those users, the way that the types are accessed have changed. For typical scenarios, these replacements can be used: - TreePatternNode::getType(ResNo) -> getSimpleType(ResNo) - TreePatternNode::hasTypeSet(ResNo) -> hasConcreteType(ResNo) - TypeSet::isConcrete -> TypeSetByHwMode::isValueTypeByHwMode(false) For more information, please refer to the review page. Differential Revision: https://reviews.llvm.org/D31951 llvm-svn: 313271
* TableGen: Use StringRef instead of const std::string& in return vals.Matthias Braun2016-12-041-1/+1
| | | | | | | This will allow to switch to a different string storage in an upcoming commit. llvm-svn: 288612
* Use unique_ptr to remove explicit delete.Craig Topper2014-12-151-4/+4
| | | | llvm-svn: 224224
* TableGen: Allow AddedComplexity values to be negativeTom Stellard2014-08-011-2/+2
| | | | | | | | | | | | | This is useful for cases when stand-alone patterns are preferred to the patterns included in the instruction definitions. Instead of requiring that stand-alone patterns set a larger AddedComplexity value, which can be confusing to new developers, the allows us to reduce the complexity of the included patterns to achieve the same result. There will be test cases for this added to the R600 backend in a future commit. llvm-svn: 214466
* Revert of r213521. This change introduced a non-hermetic test (depending on aRichard Smith2014-07-221-2/+2
| | | | | | | | | | file not in the test/ area). Backing out now so that this test isn't part of the 3.5 branch. Original commit message: "TableGen: Allow AddedComplexity values to be negative [...]" llvm-svn: 213596
* TableGen: Allow AddedComplexity values to be negativeTom Stellard2014-07-211-2/+2
| | | | | | | | | | This is useful for cases when stand-alone patterns are preferred to the patterns included in the instruction definitions. Instead of requiring that stand-alone patterns set a larger AddedComplexity value, which can be confusing to new developers, the allows us to reduce the complexity of the included patterns to achieve the same result. llvm-svn: 213521
* [Modules] Make Support/Debug.h modular. This requires it to not changeChandler Carruth2014-04-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | behavior based on other files defining DEBUG_TYPE, which means it cannot define DEBUG_TYPE at all. This is actually better IMO as it forces folks to define relevant DEBUG_TYPEs for their files. However, it requires all files that currently use DEBUG(...) to define a DEBUG_TYPE if they don't already. I've updated all such files in LLVM and will do the same for other upstream projects. This still leaves one important change in how LLVM uses the DEBUG_TYPE macro going forward: we need to only define the macro *after* header files have been #include-ed. Previously, this wasn't possible because Debug.h required the macro to be pre-defined. This commit removes that. By defining DEBUG_TYPE after the includes two things are fixed: - Header files that need to provide a DEBUG_TYPE for some inline code can do so by defining the macro before their inline code and undef-ing it afterward so the macro does not escape. - We no longer have rampant ODR violations due to including headers with different DEBUG_TYPE definitions. This may be mostly an academic violation today, but with modules these types of violations are easy to check for and potentially very relevant. Where necessary to suppor headers with DEBUG_TYPE, I have moved the definitions below the includes in this commit. I plan to move the rest of the DEBUG_TYPE macros in LLVM in subsequent commits; this one is big enough. The comments in Debug.h, which were hilariously out of date already, have been updated to reflect the recommended practice going forward. llvm-svn: 206822
* Use ArrayRef to simplify some code.Craig Topper2014-01-211-2/+1
| | | | llvm-svn: 199712
* Fix pattern sort in DAGISelEmitter.cppRichard Sandiford2013-10-011-9/+7
| | | | | | | The old code skipped one of the sorting criteria if either pattern had no types. This could lead to cycles of the form X < Y, Y < Z, Z < X. llvm-svn: 191735
* Write llvm-tblgen backends as functions instead of sub-classes.Jakob Stoklund Olesen2012-06-111-4/+24
| | | | | | | | | The TableGenBackend base class doesn't do much, and will be removed completely soon. Patch by Sean Silva! llvm-svn: 158311
* Move TableGen's parser and entry point into a libraryPeter Collingbourne2011-10-011-1/+1
| | | | | | This is the first step towards splitting LLVM and Clang's tblgen executables. llvm-svn: 140951
* Teach TableGen to pre-calculate register enum values when creating theJim Grosbach2011-03-111-5/+1
| | | | | | | | | | | CodeGenRegister entries. Use this information to more intelligently build the literal register entires in the DAGISel matcher table. Specifically, use a single-byte OPC_EmitRegister entry for registers with a value of less than 256 and OPC_EmitRegister2 entry for registers with a larger value. rdar://9066491 llvm-svn: 127456
* trailing whitespace.Jim Grosbach2011-03-011-13/+13
| | | | llvm-svn: 126733
* Generalize the register matching code in DAGISel a bit.Jim Grosbach2011-03-011-1/+5
| | | | llvm-svn: 126731
* Stop emitting predicate functions. They are no longer used.Jakob Stoklund Olesen2010-09-031-48/+0
| | | | llvm-svn: 112924
* Switch pattern sorting predicate from stable sort -> sort, itChris Lattner2010-03-291-3/+14
| | | | | | | | | | | | | | | | | | | | | doesn't need to be stable because the patterns are fully ordered. Add a first level sort predicate that orders patterns in this order: 1) scalar integer operations 2) scalar floating point 3) vector int 4) vector float. This is a trivial sort on their top level pattern type so it is nice and transitive. The benefit of doing this is that simple integer operations are much more common than insane vector things and isel was trying to match the big complex vector patterns before the simple ones because the complexity of the vector operations was much higher. Since they can't both match, it is best (for compile time) to try the simple integer ones first. This cuts down the # failed match attempts on real code by quite a bit, for example, this reduces backtracks on crafty (as a random example) from 228285 -> 188369. llvm-svn: 99797
* revert 99795, as mentioned, it is disabled anyway.Chris Lattner2010-03-291-123/+2
| | | | llvm-svn: 99796
* Check in a (disabled) failed attempt to improve the ordering of Chris Lattner2010-03-291-2/+123
| | | | | | | | | patterns within the generated matcher. This works great except that the sort fails because the relation defined isn't transitive. I have a much simpler solution coming next, but want to archive the code. llvm-svn: 99795
* print the complexity of the pattern being matched in theChris Lattner2010-03-291-50/+9
| | | | | | comment in the generated table. llvm-svn: 99794
* major surgery on tblgen: generalize TreePatternNodeChris Lattner2010-03-191-2/+2
| | | | | | | | | to maintain a list of types (one for each result of the node) instead of a single type. There are liberal hacks added to emulate the old behavior in various situations, but they can start disolving now. llvm-svn: 98999
* look up instructions by record, not by name.Chris Lattner2010-03-191-1/+1
| | | | llvm-svn: 98904
* Completely rewrite tblgen's type inference mechanism,Chris Lattner2010-03-151-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | changing the primary datastructure from being a "std::vector<unsigned char>" to being a new TypeSet class that actually has (gasp) invariants! This changes more things than I remember, but one major innovation here is that it enforces that named input values agree in type with their output values. This also eliminates code that transparently assumes (in some cases) that SDNodeXForm input/output types are the same, because this is wrong in many case. This also eliminates a bug which caused a lot of ambiguous patterns to go undetected, where a register class would sometimes pick the first possible type, causing an ambiguous pattern to get arbitrary results. With all the recent target changes, this causes no functionality change! llvm-svn: 98534
* the sorting predicate should work for comparing an elementChris Lattner2010-03-021-1/+1
| | | | | | to itself, even though this isn't wildly useful. llvm-svn: 97574
* eliminate CodeGen/DAGISelHeader.h, it is empty now.Chris Lattner2010-03-021-4/+0
| | | | llvm-svn: 97556
* resolve a fixme by having the .td file parser reject thigns likeChris Lattner2010-03-011-1/+0
| | | | | | | | (set GPR, somecomplexpattern) if somecomplexpattern doesn't declare what it can match. llvm-svn: 97513
* Fix PR2590 by making PatternSortingPredicate actually be Chris Lattner2010-03-011-2/+8
| | | | | | | | | | | | | | | ordered correctly. Previously it would get in trouble when two patterns were too similar and give them nondet ordering. We force this by using the record ID order as a fallback. The testsuite diff is due to alpha patterns being ordered slightly differently, the change is a semantic noop afaict: < lda $0,-100($16) --- > subq $16,100,$0 llvm-svn: 97509
* optimize tblgen compile time by eliminating the old isel.Chris Lattner2010-03-011-1754/+3
| | | | llvm-svn: 97504
* don't emit the old sdnodexform stuff for the new isel.Chris Lattner2010-03-011-2/+2
| | | | llvm-svn: 97486
* Turn on the new isel by default. Here are some fun numbersChris Lattner2010-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | with a release-asserts build on x86-64-darwin10: LLC Size: Old: 15,426,852 New: 12,759,140 (down 2.7M) LLI Size: Old: 9,926,876 New: 8,864,292 (down 1.1M) X86ISelDAGToDAG.o size: Old: 1,401,232 New: 162,868 (down 1.3M) Time to build X86ISelDAGToDAG.o: Old: 67.147u 2.060s 1:09.78 New: 4.234u 0.387s 0:04.77 llvm-svn: 97475
* eliminate the CheckMultiOpcodeMatcher code and have each Chris Lattner2010-03-011-3/+10
| | | | | | | | | ComplexPattern at the root be generated multiple times, once for each opcode they are part of. This encourages factoring because the opcode checks get treated just like everything else in the matcher. llvm-svn: 97439
* inline the node transforms and node predicates into the generatedChris Lattner2010-03-011-10/+12
| | | | | | | | dispatcher method. This eliminates the dependence of the new isel's generated code on the old isel's predicates, however some random hand written isel code still uses them. llvm-svn: 97431
* enhance the new isel to use SelectNodeTo for most patterns,Chris Lattner2010-02-281-1/+1
| | | | | | | | | even some the old isel didn't. There are several parts of this that make me feel dirty, but it's no worse than the old isel. I'll clean up the parts I can do without ripping out the old one next. llvm-svn: 97415
* change the scope node to include a list of children to be checkedChris Lattner2010-02-251-16/+7
| | | | | | | | | instead of to have a chained series of scope nodes. This makes the generated table smaller, improves the efficiency of the interpreter, and make the factoring optimization much more reasonable to implement. llvm-svn: 97160
* rename fooMatcherNode to fooMatcher.Chris Lattner2010-02-251-8/+8
| | | | llvm-svn: 97096
* rename PushMatcherNode -> ScopeMatcherNode to more accuratelyChris Lattner2010-02-251-1/+1
| | | | | | | reflect what it does. Switch the sense of the Next and the Check arms to be more logical. No functionality change. llvm-svn: 97093
* lets not break the old isel.Chris Lattner2010-02-241-1/+0
| | | | llvm-svn: 97034
* Since the new instruction selector now works, I don't need to keepChris Lattner2010-02-241-7/+6
| | | | | | | | the old one around for comparative purposes: have the ENABLE_NEW_ISEL #define (which is not enabled on mainline) stop emitting the old isel at all, yay for build time win. llvm-svn: 97033
* implement a simple proof-of-concept optimization forChris Lattner2010-02-241-1/+1
| | | | | | | | the new isel: fold movechild+record+moveparent into a single recordchild N node. This shrinks the X86 table from 125443 to 117502 bytes. llvm-svn: 97031
* The new isel passes all tests, time to start making it go fast.Chris Lattner2010-02-241-2/+8
| | | | | | | Also add an easy macro at the top of DAGISelEmitter.cpp to enable it. Lets see if I can avoid accidentally turning it on :) llvm-svn: 97029
* Sort the patterns before adding them to the FA so that we get theChris Lattner2010-02-211-7/+52
| | | | | | least cost matches. This gets us from 195 -> 208 passes on the ppc codegen tests. llvm-svn: 96747
* oops don't turn this on for everyone yet.Chris Lattner2010-02-211-1/+1
| | | | llvm-svn: 96725
* implement the last known missing feature: updating uses of results Chris Lattner2010-02-211-1/+1
| | | | | | | of the matched pattern to use the newly created node results. Onto the "making it actually work" phase! llvm-svn: 96724
OpenPOWER on IntegriCloud