summaryrefslogtreecommitdiff
path: root/lib/TableGen
Commit message (Collapse)AuthorAge
* [TableGen] Correctly generate implicit anonymous prototype defs in multiclassesHal Finkel2014-01-02
| | | | | | | | | | | | | | | | | | | | | | | | | | Even within a multiclass, we had been generating concrete implicit anonymous defs when parsing values (generally in value lists). This behavior was incorrect, and led to errors when multiclass parameters were used in the parameter list of the implicit anonymous def. If we had some multiclass: multiclass mc<string n> { ... : SomeClass<SomeOtherClass<n> > The capture of the multiclass parameter 'n' would not work correctly, and depending on how the implicit SomeOtherClass was used, either TableGen would ignore something it shouldn't, or would crash. To fix this problem, when inside a multiclass, we generate prototype anonymous defs for implicit anonymous defs (just as we do for explicit anonymous defs). Within the multiclass, the current record prototype is populated with a node that is essentially: !cast<SomeOtherClass>(!strconcat(NAME, anon_value_name)). This is then resolved to the correct concrete anonymous def, in the usual way, when NAME is resolved during multiclass instantiation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198348 91177308-0d34-0410-b5e6-96231b3b80d8
* [TableGen] Use the same anonymous name as the prefix on all multiclass defsHal Finkel2014-01-02
| | | | | | | | | | | | | | | | TableGen had been generating a different name for an anonymous multiclass's NAME for every def in the multiclass. This had an unfortunate side effect: it was impossible to reference one def within the multiclass from another (in the parameter list, for example). By making sure we only generate an anonymous name once per multiclass (which, as it turns out, requires only changing the name parameter to reference type), we can now concatenate NAME within the multiclass with a def name in order to generate a reference to that def. This does not matter so much, in and of itself, but is necessary for a follow-up commit that will fix variable capturing in implicit anonymous multiclass defs (and that is important). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198340 91177308-0d34-0410-b5e6-96231b3b80d8
* TableGen: Generate valid identifiers for anonymous recordsAlp Toker2013-12-21
| | | | | | | | | | Backends like OptParserEmitter assume that record names can be used as valid identifiers. The period '.' in generated anonymous names broke that assumption, causing a build-time error and in practice forcing all records to be named. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197869 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix most memory leaks in tablegen.Rafael Espindola2013-10-31
| | | | | | Found by the valgrind bot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193736 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an error check for a typo I accidentally made in a td file that caused ↵Craig Topper2013-08-20
| | | | | | an assert to fire. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188742 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove some std stream usage from Support and TableGenReid Kleckner2013-08-06
| | | | | | | | | | LLVM's coding standards recommend raw_ostream and MemoryBuffer for reading and writing text. This has the side effect of allowing clang to compile more of Support and TableGen in the Microsoft C++ ABI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187826 91177308-0d34-0410-b5e6-96231b3b80d8
* keep only the StringRef version of getFileOrSTDIN.Rafael Espindola2013-06-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184826 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow TableGen DAG arguments to be just a name.Jakob Stoklund Olesen2013-03-24
| | | | | | | | | | | | | | | | | | | | | | | | | | DAG arguments can optionally be named: (dag node, node:$name) With this change, the node is also optional: (dag node, node:$name, $name) The missing node is treated as an UnsetInit, so the above is equivalent to: (dag node, node:$name, ?:$name) This syntax is useful in output patterns where we currently require the types of variables to be repeated: def : Pat<(subc i32:$b, i32:$c), (SUBCCrr i32:$b, i32:$c)>; This is preferable: def : Pat<(subc i32:$b, i32:$c), (SUBCCrr $b, $c)>; git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177843 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure TableGen exits with an error code after printing errors.Jakob Stoklund Olesen2013-03-20
| | | | | | | | | | This makes it possible to report multiple errors in one invocation. There are already calls to PrintError in CodeGenDAGPatterns.cpp which previously would not cause TableGen to fail. <rdar://problem/13463339> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177573 91177308-0d34-0410-b5e6-96231b3b80d8
* [TableGen] Fix ICE on MSVC 2012 Release builds.Michael J. Spencer2013-02-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176125 91177308-0d34-0410-b5e6-96231b3b80d8
* Make helpers static. Add missing include so LLVMInitializeObjCARCOpts gets C ↵Benjamin Kramer2013-02-15
| | | | | | linkage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175264 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Diagnose duplicate includes.Sean Silva2013-02-07
| | | | | | | | | | | | | | | A double inclusion will pretty much always be an error in TableGen, so there's no point going on just to die with "def already defined" or whatnot. I'm not too thrilled about the "public: ... private: ..." to expose the DependenciesMapTy, but I really didn't see a better way to keep that type centralized. It's a smell that indicates that some refactoring is needed to make this code more loosely coupled. This should avoid all bugs of the same nature as PR15189. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174582 91177308-0d34-0410-b5e6-96231b3b80d8
* A bugfix for tblgen, in the function ‘emitSourceFileHeader’.Nadav Rotem2013-01-28
| | | | | | | | | | | When the first parameter (‘Desc’) is more than 80 characters long, it will result the header line that contains the description to be more Than (4GB!) long. Not only it takes forever to produce, the output file cannot be open, since its ginormous. Patch by Elior Malul. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173672 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an addition operator to TableGenHal Finkel2013-01-25
| | | | | | | This adds an !add(a, b) operator to tablegen; this will be used to cleanup the PPC register definitions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173445 91177308-0d34-0410-b5e6-96231b3b80d8
* TableGen: Keep track of superclass reference ranges.Jordan Rose2013-01-10
| | | | | | | | | | def foo : bar; ~~~ This allows us to produce more precise diagnostics about a certain superclass, and even provide fixits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172085 91177308-0d34-0410-b5e6-96231b3b80d8
* TableGen: record anonymous instantiations of classes.Jordan Rose2013-01-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172084 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: use an early return to reduce indentation.Sean Silva2013-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171954 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Factor out common code.Sean Silva2013-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171951 91177308-0d34-0410-b5e6-96231b3b80d8
* Inline this into its only caller.Sean Silva2013-01-09
| | | | | | | | | | | It's clearer and additionally this gets rid of the usage of `DefmID`, which doesn't really correspond to anything in the language (it was just used in the name of this parsing function which parsed a `MultiClassID` and returned that multiclass's record). This area of the code still needs a lot of work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171938 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Reuse function that is 2 lines above.Sean Silva2013-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171937 91177308-0d34-0410-b5e6-96231b3b80d8
* fix copy-paste-oSean Silva2013-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171936 91177308-0d34-0410-b5e6-96231b3b80d8
* docs: Bring TableGen syntax a bit closer to reality.Sean Silva2013-01-09
| | | | | | | | | It's not just def's but actually a limited subset of Object's that are allowed inside a multiclass. Spotted by Joel Jones. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171935 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r171140. We don't actually need to support #NAME. Because NAME by ↵Craig Topper2013-01-07
| | | | | | itself is interpreted just fine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171695 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify TableGen type-compatibility checks.Sean Silva2013-01-07
| | | | | | Patch by Elior Malul! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171684 91177308-0d34-0410-b5e6-96231b3b80d8
* Update tablegen parser to allow defm names to start with #NAME.Craig Topper2012-12-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171140 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort includes for all of the .h files under the 'lib' tree. These wereChandler Carruth2012-12-04
| | | | | | | | | | missed in the first pass because the script didn't yet handle include guards. Note that the script is now able to handle all of these headers without manual edits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169224 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove exception handling usage from tblgen.Joerg Sonnenberger2012-10-25
| | | | | | | | | | | | Most places can use PrintFatalError as the unwinding mechanism was not used for anything other than printing the error. The single exception was CodeGenDAGPatterns.cpp, where intermediate errors during type resolution were ignored to simplify incremental platform development. This use is replaced by an error flag in TreePattern and bailout earlier in various places if it is set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166712 91177308-0d34-0410-b5e6-96231b3b80d8
* In preparation for removing exception handling in tablegen, addJoerg Sonnenberger2012-10-25
| | | | | | | PrintFatalError, which combines PrintError with exit(1). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166690 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Compile TableGen without RTTI.Sean Silva2012-10-10
| | | | | | TableGen no longer needs RTTI! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165651 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Use semantically correct RTTI functions.Sean Silva2012-10-10
| | | | | | Also, some minor cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165647 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Mechanically move dynamic_cast<> to dyn_cast<>.Sean Silva2012-10-10
| | | | | | | | | | Some of these dyn_cast<>'s would be better phrased as isa<> or cast<>. That will happen in a future patch. There are also two dyn_cast_or_null<>'s slipped in instead of dyn_cast<>'s, since they were causing crashes with just dyn_cast<>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165646 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Rename handleDependencies -> createDependencyFileSean Silva2012-10-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165544 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Move dependency file output to a separate function.Sean Silva2012-10-09
| | | | | | This keeps it out of the main flow of TableGenMain. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165542 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Remove pointless method call.Sean Silva2012-10-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165511 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Use appropriate LLVM-style RTTI functions.Sean Silva2012-10-05
| | | | | | | Use isa<> or cast<> when semantically that is what is happening. Also some trivial "style" cleanups at fix sites. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165292 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Replace uses of dynamic_cast<XXXRecTy> with dyn_cast<>.Sean Silva2012-10-05
| | | | | | | | This is a mechanical change of dynamic_cast<> to dyn_cast<>. A number of these uses are actually more like isa<> or cast<>, and will be changed to the semanticaly appropriate one in a future patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165291 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Whitespace and 80-col cleanup.Sean Silva2012-10-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165190 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Remove last traces of old TableGenMain API.Sean Silva2012-10-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165168 91177308-0d34-0410-b5e6-96231b3b80d8
* tblgen: Put new TableGenMain API in place.Sean Silva2012-10-03
| | | | | | | | In order to avoid rev-lock with Clang when moving to the new API, also preserve the current API temporarily and insert a shim to implement the new API in terms of the old. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165165 91177308-0d34-0410-b5e6-96231b3b80d8
* De-nest if's and fix mix-upSean Silva2012-09-19
| | | | | | | | | | | | | | | | | | Two deeply nested if's obscured that the sense of the conditions was mixed up. Amazingly, TableGen's output is exactly the same even with the sense of the tests fixed; it seems that all of TableGen's conversions are symmetric so that the inverted sense was nonetheless correct "by accident". As such, I couldn't come up with a test case. If there does in fact exist a non-symmetric conversion in TableGen's type system, then a test case should be prepared. Despite the symmetry, both if's are left in place for robustness in the face of future changes. Review by Jakob. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164195 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-work bit/bits value resolving in tblgenMichael Liao2012-09-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - This patch is inspired by the failure of the following code snippet which is used to convert enumerable values into encoding bits to improve the readability of td files. class S<int s> { bits<2> V = !if(!eq(s, 8), {0, 0}, !if(!eq(s, 16), {0, 1}, !if(!eq(s, 32), {1, 0}, !if(!eq(s, 64), {1, 1}, {?, ?})))); } Later, PR8330 is found to report not exactly the same bug relevant issue to bit/bits values. - Instead of resolving bit/bits values separately through resolveBitReference(), this patch adds getBit() for all Inits and resolves bit value by resolving plus getting the specified bit. This unifies the resolving of bit with other values and removes redundant logic for resolving bit only. In addition, BitsInit::resolveReferences() is optimized to take advantage of this origanization by resolving VarBitInit's variable reference first and then getting bits from it. - The type interference in '!if' operator is revised to support possible combinations of int and bits/bit in MHS and RHS. - As there may be illegal assignments from integer value to bit, says assign 2 to a bit, but we only check this during instantiation in some cases, e.g. bit V = !if(!eq(x, 17), 0, 2); Verbose diagnostic message is generated when invalid value is resolveed to help locating the error. - PR8330 is fixed as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163360 91177308-0d34-0410-b5e6-96231b3b80d8
* Tristate mayLoad, mayStore, and hasSideEffects.Jakob Stoklund Olesen2012-08-23
| | | | | | | Keep track of the set/unset state of these bits along with their true/false values, but treat '?' as '0' for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162461 91177308-0d34-0410-b5e6-96231b3b80d8
* Print out the location of expanded multiclass defs in TableGen errors.Jakob Stoklund Olesen2012-08-22
| | | | | | | | | | | | | | | | | | | When reporting an error for a defm, we would previously only report the location of the outer defm, which is not always where the error is. Now we also print the location of the expanded multiclass defs: lib/Target/X86/X86InstrSSE.td:2902:12: error: foo defm ADD : basic_sse12_fp_binop_s<0x58, "add", fadd, SSE_ALU_ITINS_S>, ^ lib/Target/X86/X86InstrSSE.td:2801:11: note: instantiated from multiclass defm PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, VR128, ^ lib/Target/X86/X86InstrSSE.td:194:5: note: instantiated from multiclass def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2), ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162409 91177308-0d34-0410-b5e6-96231b3b80d8
* TableGen: Allow use of #NAME# outside of 'def' names.Jim Grosbach2012-08-02
| | | | | | | | | | | | | | | | | | | | | Previously, def NAME values were only populated, and references to NAME resolved, when NAME was referenced in the 'def' entry of the multiclass sub-entry. e.g., multiclass foo<...> { def prefix_#NAME : ... } It's useful, however, to be able to reference NAME even when the default def name is used. For example, when a multiclass has 'def : Pat<...>' or 'def : InstAlias<...>' entries which refer to earlier instruction definitions in the same multiclass. e.g., multiclass myMulti<RegisterClass rc> { def _r : myI<(outs rc:$d), (ins rc:$r), "r $d, $r", []>; def : InstAlias<\"wilma $r\", (!cast<Instruction>(NAME#\"_r\") rc:$r, rc:$r)>; } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161198 91177308-0d34-0410-b5e6-96231b3b80d8
* TableGen: Location information for diagnostic.Jim Grosbach2012-07-12
| | | | | | | | | | | def Pat<...>; Results in 'record name is not a string!' diagnostic. Not the best, but the lack of location information moves it from not very helpful into completely useless. We're in the Record class when throwing the error, so just add the location info directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160098 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit TableGen's header comment with C-style comments, so it can be used from ↵Benjamin Kramer2012-06-19
| | | | | | | | C89 code. Should silence warnings when compiling the X86 disassembler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158723 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate struct TableGenBackend.Jakob Stoklund Olesen2012-06-13
| | | | | | | | TableGen backends are simply written as functions now. Patch by Sean Silva! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158389 91177308-0d34-0410-b5e6-96231b3b80d8
* Write llvm-tblgen backends as functions instead of sub-classes.Jakob Stoklund Olesen2012-06-11
| | | | | | | | | The TableGenBackend base class doesn't do much, and will be removed completely soon. Patch by Sean Silva! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158311 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix 80 columns.Michael J. Spencer2012-06-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157788 91177308-0d34-0410-b5e6-96231b3b80d8