aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TableGen/TGParser.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-08-23Fix some Clang-tidy modernize-use-using and Include What You Use warnings; ↵Eugene Zelenko1-14/+19
other minor fixes. Differential revision: https://reviews.llvm.org/D23789 llvm-svn: 279535
2016-08-17Fix a use of LLVM_FALLTHROUGH that wasn't even in a switch.Justin Bogner1-1/+0
I was over-aggressive in my conversions from comments to the fallthrough attribute. llvm-svn: 278903
2016-08-17Replace "fallthrough" comments with LLVM_FALLTHROUGHJustin Bogner1-0/+1
This is a mechanical change of comments in switches like fallthrough, fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead. llvm-svn: 278902
2016-07-05TableGen: promote "code" type from syntactic sugar.Tim Northover1-2/+2
It's being immediately converted to a "string", but being able to tell what type the field was originally can be useful in backends. llvm-svn: 274575
2016-04-18[NFC] Header cleanupMehdi Amini1-2/+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
2016-02-26[TableGen] Fix typos in comments. NFCCraig Topper1-2/+2
llvm-svn: 261984
2016-01-29Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren1-1/+1
r259192 post commit comment. clang part in r259232, this is the LLVM part of the patch. llvm-svn: 259240
2016-01-18[TableGen] Merge the SuperClass Record and SMRange vector into a single ↵Craig Topper1-6/+5
vector. This removes the state needed to manage the extra vector thus reducing the size of the Record class. NFC llvm-svn: 258065
2016-01-04[TableGen] Change TGParser::SetValue to take an ArrayRef instead of ↵Craig Topper1-13/+8
std::vector reference. Use None in many places where a default constructed vector was being passed. NFC llvm-svn: 256726
2016-01-04[TableGen] Fix a bug that caused the wrong name for a record built from a ↵Craig Topper1-4/+6
multiclass containing a defm called NAME that references another multiclass that contains a defm that uses NAME concatenated with other strings. It would end up doing the concatenations from the second multiclass twice. This occured because SetValue detected a self assignment when trying to set the value of NAME to a VarInit called NAME. NAME is special here and it will get cleaned up later. So add a flag to suppress the self assignment check for this case. Strangely the self-assignment error was returning false indicating it wasn't an error, but it wasn't doing the right thing. So this also changes it to report an error. This fixes the names of some AVX512 FMA instructions that showed this double expansion. llvm-svn: 256725
2015-10-24[TblGen] ArrayRefize TGParser. No functional change intended.Benjamin Kramer1-17/+13
llvm-svn: 251186
2015-07-06[TableGen] Change a couple methods to return an ArrayRef instead of a const ↵Craig Topper1-1/+1
std::vector reference. NFC llvm-svn: 241430
2015-06-02[TableGen] Use range-based for loops. NFCCraig Topper1-12/+10
llvm-svn: 238808
2015-06-02[TableGen] Rename ListInit::getSize to just 'size' to be more consistent.Craig Topper1-1/+1
llvm-svn: 238806
2015-05-29Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer1-2/+2
If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238602
2015-05-28Don't call utostr in Twine/raw_ostream contexts.Benjamin Kramer1-10/+7
Creating temporary std::strings there is unnecessary. llvm-svn: 238412
2015-05-21[TableGen] Resolve complex def names inside multiclassesHal Finkel1-5/+41
We had not been trying hard enough to resolve def names inside multiclasses that had complex concatenations, etc. Now we'll try harder. Patch by Amaury Sechet! llvm-svn: 237877
2015-05-14[TableGen] Replace some calls to ListInit::getSize() with ListInit::empty() ↵Craig Topper1-1/+1
if it was just comparing to 0. NFC. llvm-svn: 237340
2015-05-04[TableGen] Formatting cleanup. Mostly removing trailing whitespace and ↵Craig Topper1-32/+18
unnecessary curly braces. NFC llvm-svn: 236397
2015-04-30[TableGen] Cleanup formatting by moving operators from beginning of line to ↵Craig Topper1-29/+27
end of previous line. NFC llvm-svn: 236206
2015-04-29[TableGen] Replace some dyn_casts followed by an assert with just a regular ↵Craig Topper1-2/+1
cast which asserts internally. NFC llvm-svn: 236087
2015-04-29[TableGen] Use range-based for loops. NFCCraig Topper1-57/+28
llvm-svn: 236083
2015-03-01Add missing includes. make_unique proliferated everywhere.Benjamin Kramer1-0/+1
llvm-svn: 230909
2015-02-16MSVC 2013 does not ICE on this code in the same fashion that MSVC 2012 did; NFC.Aaron Ballman1-2/+1
llvm-svn: 229422
2015-01-15Replace size method call of containers to empty method where appropriateAlexander Kornienko1-1/+1
This patch was generated by a clang tidy checker that is being open sourced. The documentation of that checker is the following: /// The emptiness of a container should be checked using the empty method /// instead of the size method. It is not guaranteed that size is a /// constant-time function, and it is generally more efficient and also shows /// clearer intent to use empty. Furthermore some containers may implement the /// empty method but not implement the size method. Using empty whenever /// possible makes it easier to switch to another container in the future. Patch by Gábor Horváth! llvm-svn: 226161
2014-12-11Make MultiClass::DefPrototypes own their Records to fix memory leaks.Craig Topper1-13/+8
llvm-svn: 223998
2014-12-11Replace std::map<K, V*> with std::map<K, std::unique_ptr<V>> to handle ↵Craig Topper1-5/+8
ownership and deletion of the values. Ideally we would store the MultiClasses by value directly in the maps, but I had some trouble with that before and this at least fixes the leak. llvm-svn: 223997
2014-11-30Revert r222957 "Replace std::map<K, V*> with std::map<K, V> to handle ↵Craig Topper1-11/+8
ownership and deletion of the values." Upon further review I think the MultiClass is being copied into the map instead of being moved due to the copy constructor on the nested Record type. This ultimately got exposed when the vector in DefPrototype vector was changed to hold unique_ptrs in another commit. This caused gcc 4.7 to fail due to the use of the copy constructor on unique_ptr with the error pointing back to one of the insert calls from this commit. Not sure why clang was able to build. This reverts commit 710cdf729f84b428bf41aa8d32dbdb35fff79fde. llvm-svn: 222971
2014-11-30Revert r222965 "Make MultiClass::DefPrototypes own their Records to fix ↵Hans Wennborg1-6/+6
memory leaks." The bots started failing with the error below. I suspect this revision was the cause. FAILED: /home/bb/bin/g++47 -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -DNDEBUG -Ilib/TableGen -I/home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen -Iinclude -I/home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/include -fno-exceptions -fno-rtti -MMD -MT lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.o -MF "lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.o.d" -o lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.o -c /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen/TGParser.cpp In file included from /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_tempbuf.h:62:0, from /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_algo.h:64, from /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/algorithm:63, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/include/llvm/ADT/StringRef.h:13, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen/TGLexer.h:17, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen/TGParser.h:17, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen/TGParser.cpp:14: /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_construct.h: In instantiation of 'void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::unique_ptr<llvm::Record>; _Args = {const std::unique_ptr<llvm::Record, std::default_delete<llvm::Record> >&}]': /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_uninitialized.h:77:3: required from 'static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<llvm::Record>*, std::vector<std::unique_ptr<llvm::Record> > >; _ForwardIterator = std::unique_ptr<llvm::Record>*; bool _TrivialValueTypes = false]' /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_uninitialized.h:119:41: required from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<llvm::Record>*, std::vector<std::unique_ptr<llvm::Record> > >; _ForwardIterator = std::unique_ptr<llvm::Record>*]' /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_uninitialized.h:260:63: required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<llvm::Record>*, std::vector<std::unique_ptr<llvm::Record> > >; _ForwardIterator = std::unique_ptr<llvm::Record>*; _Tp = std::unique_ptr<llvm::Record>]' /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_vector.h:310:9: required from 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<llvm::Record>; _Alloc = std::allocator<std::unique_ptr<llvm::Record> >]' /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/include/llvm/TableGen/Record.h:1664:8: required from 'constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = std::basic_string<char>&; _U2 = llvm::MultiClass; <template-parameter-2-3> = void; _T1 = std::basic_string<char>; _T2 = llvm::MultiClass]' /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h:273:72: required from 'constexpr std::pair<typename std::__decay_and_strip<_T1>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = std::basic_string<char>&; _T2 = llvm::MultiClass; typename std::__decay_and_strip<_T2>::__type = llvm::MultiClass; typename std::__decay_and_strip<_T1>::__type = std::basic_string<char>]' /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen/TGParser.cpp:2295:78: required from here /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_construct.h:77:7: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = llvm::Record; _Dp = std::default_delete<llvm::Record>]' In file included from /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/memory:86:0, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/include/llvm/ADT/STLExtras.h:25, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:14, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/include/llvm/Support/SourceMgr.h:19, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen/TGParser.h:19, from /home/bb/cmake-llvm-x86_64-linux/llvm-project/llvm/lib/TableGen/TGParser.cpp:14: /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/unique_ptr.h:262:7: error: declared here ninja: build stopped: subcommand failed. llvm-svn: 222970
2014-11-30Qualify one more make_unique call.Hans Wennborg1-2/+2
The previous patch had effect, but missed this one. It seems MSVC gets ADL-confused by the calls where the first argument is a function call? llvm-svn: 222968
2014-11-30Speculatively qualify some llvm::make_unique calls trying to please MSVCHans Wennborg1-4/+4
It was failing with this kind of error: C:\b\build\slave\CrWinClang\build\src\third_party\llvm\lib\TableGen\TGParser.cpp(1243) : error C2668: 'llvm::make_unique' : ambiguous call to overloaded function C:\b\build\slave\CrWinClang\build\src\third_party\llvm\include\llvm/ADT/STLExtras.h(408): could be 'std::unique_ptr<llvm::Record,std::default_delete<_Ty>> llvm::make_unique<llvm::Record,std::string,llvm::SMLoc&,llvm::RecordKeeper&,bool>(std::string &&,llvm::SMLoc &,llvm::RecordKeeper &,bool &&)' with [ _Ty=llvm::Record ] C:\b\depot_tools\win_toolchain\vs2013_files\win8sdk\bin\..\..\VC\include\memory(1637): or 'std::unique_ptr<llvm::Record,std::default_delete<_Ty>> std::make_unique<llvm::Record,std::string,llvm::SMLoc&,llvm::RecordKeeper&,bool>(std::string &&,llvm::SMLoc &,llvm::RecordKeeper &,bool &&)' [found using argument-dependent lookup] with [ _Ty=llvm::Record ] while trying to match the argument list '(std::string, llvm::SMLoc, llvm::RecordKeeper, bool)' llvm-svn: 222967
2014-11-30Use an unsigned type because there seems to be no reason for it to be signed.Craig Topper1-1/+1
llvm-svn: 222966
2014-11-30Make MultiClass::DefPrototypes own their Records to fix memory leaks.Craig Topper1-6/+6
llvm-svn: 222965
2014-11-29Replace std::map<K, V*> with std::map<K, V> to handle ownership and deletion ↵Craig Topper1-8/+11
of the values. llvm-svn: 222957
2014-11-29Remove 'else' after 'return'. Fix formatting of a 'switch' statement.Craig Topper1-12/+11
llvm-svn: 222955
2014-11-29Make RecordKeeper::addClass/addDef take unique_ptrs instead of creating one ↵Craig Topper1-6/+8
internally. llvm-svn: 222948
2014-11-29Use unique_ptr to remove some explicit deletes on some error case returns. ↵Craig Topper1-68/+46
At least one spot of weird ownership passing that needs some future cleanup. llvm-svn: 222947
2014-10-03Eliminate some deep std::vector copies. NFC.Benjamin Kramer1-1/+1
llvm-svn: 218999
2014-09-25Refactoring: raw pointer -> unique_ptrAnton Yartsev1-5/+3
llvm-svn: 218462
2014-09-16[TableGen] Fully resolve class-instance values before defs in multiclassesAdam Nemet1-0/+9
By class-instance values I mean 'Class<Arg>' in 'Class<Arg>.Field' or in 'Other<Class<Arg>>' (syntactically s SimpleValue). This is to differentiate from unnamed/anonymous record definitions (syntactically an ObjectBody) which are not affected by this change. Consider the testcase: class Struct<int i> { int I = !shl(i, 1); int J = !shl(I, 1); } class Class<Struct s> { int Class_J = s.J; } multiclass MultiClass<int i> { def Def : Class<Struct<i>>; } defm Defm : MultiClass<2>; Before this fix, DefmDef.Class_J yields !shl(I, 1) instead of 8. This is the sequence of events. We start with this: multiclass MultiClass<int i> { def Def : Class<Struct<i>>; } During ParseDef the anonymous object for the class-instance value is created: multiclass Multiclass<int i> { def anonymous_0 : Struct<i>; def Def : Class<NAME#anonymous_0>; } Then class Struct<i> is added to anonymous_0. Also Class<NAME#anonymous_0> is added to Def: multiclass Multiclass<int i> { def anonymous_0 { int I = !shl(i, 1); int J = !shl(I, 1); } def Def { int Class_J = NAME#anonymous_0.J; } } So far so good but then we move on to instantiating this in the defm by substituting the template arg 'i'. This is how the anonymous prototype looks after fully instantiating. defm Defm = { def Defmanonymous_0 { int I = 4; int J = !shl(I, 1); } Note that we only resolved the reference to the template arg. The non-template-arg reference in 'J' has not been resolved yet. Then we go on to instantiating the Def prototype: def DefmDef { int Class_J = NAME#anonymous_0.J; } Which is resolved to Defmanonymous_0.J and then to !shl(I, 1). When we fully resolve each record in a defm, Defmanonymous_0.J does get set to 8 but that's too late for its use. The patch adds a new attribute to the Record class that indicates that this def is actually a class-instance value that may be *used* by other defs in a multiclass. (This is unlike regular defs which don't reference each other and thus can be resolved indepedently.) They are then fully resolved before the other defs while the multiclass is instantiated. I added vg_leak to the new test. I am not sure if this is necessary but I don't think I have a way to test it. I can also check in without the XFAIL and let the bots test this part. Also tested that X86.td.expanded and AAarch64.td.expanded were unchange before and after this change. (This issue triggering this problem is a WIP patch.) Part of <rdar://problem/17688758> llvm-svn: 217886
2014-08-29Comment only: Annotate loop as per mailing list discussionJean-Luc Duprat1-0/+3
llvm-svn: 216798
2014-08-29Tablegen fixes for new syntax when initializing bits from variables.Jean-Luc Duprat1-0/+9
Followup to r215086. llvm-svn: 216757
2014-08-08[tablegen] - Eliminate memory leaks in TGParser.cppAnton Yartsev1-4/+26
Ugly solution indicating that a refactoring is necessary to get the ownership under control. llvm-svn: 215176
2014-08-07Silencing an MSVC C4334 warning ('<<' : result of 32-bit shift implicitly ↵Aaron Ballman1-1/+1
converted to 64 bits (was 64-bit shift intended?)). No functional changes intended. llvm-svn: 215100
2014-08-07Change the { } expression in tablegen to accept sized binary literals which ↵Pete Cooper1-2/+13
are not just 0 and 1. It also allows nested { } expressions, as now that they are sized, we can merge pull bits from the nested value. In the current behaviour, everything in { } must have been convertible to a single bit. However, now that binary literals are sized, its useful to be able to initialize a range of bits. So, for example, its now possible to do bits<8> x = { 0, 1, { 0b1001 }, 0, 0b0 } llvm-svn: 215086
2014-08-07Change TableGen so that binary literals such as 0b001 are now sized.Pete Cooper1-0/+9
Instead of these becoming an integer literal internally, they now become bits<n> values. Prior to this change, 0b001 was 1 bit long. This is confusing as clearly the user gave 3 bits. This new type holds both the literal value and the size, and so can ensure sizes match on initializers. For example, this used to be legal bits<1> x = 0b00; but now it must be written as bits<2> x = 0b00; llvm-svn: 215084
2014-08-05Allow binary and for tblgen math.Joerg Sonnenberger1-0/+3
llvm-svn: 214851
2014-07-31Don't fail tablegen immediately after failing to set a value.Pete Cooper1-1/+4
Instead allow the variable to be declared, but don't attach an initializer. This allows more than a single error to be emitted before we exit. Test case to follow soon in another patch. llvm-svn: 214375
2014-07-31Add a better error message when failing to assign one tablegen value to anotherPete Cooper1-1/+8
This is currently for assigning from one bit init to another. It can easily be extended to other types. Test to follow soon in another patch. llvm-svn: 214374
2014-06-26Revert "Introduce a string_ostream string builder facilty"Alp Toker1-1/+2
Temporarily back out commits r211749, r211752 and r211754. llvm-svn: 211814