summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/TGParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [TableGen] Correctly generate implicit anonymous prototype defs in multiclassesHal Finkel2014-01-021-5/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 198348
* [TableGen] Use the same anonymous name as the prefix on all multiclass defsHal Finkel2014-01-021-1/+1
| | | | | | | | | | | | | | | | 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). llvm-svn: 198340
* TableGen: Generate valid identifiers for anonymous recordsAlp Toker2013-12-211-7/+5
| | | | | | | | | | 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. llvm-svn: 197869
* Add an error check for a typo I accidentally made in a td file that caused ↵Craig Topper2013-08-201-0/+3
| | | | | | an assert to fire. llvm-svn: 188742
* Remove some std stream usage from Support and TableGenReid Kleckner2013-08-061-4/+5
| | | | | | | | | | 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. llvm-svn: 187826
* Allow TableGen DAG arguments to be just a name.Jakob Stoklund Olesen2013-03-241-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | 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)>; llvm-svn: 177843
* [TableGen] Fix ICE on MSVC 2012 Release builds.Michael J. Spencer2013-02-261-1/+2
| | | | llvm-svn: 176125
* Add an addition operator to TableGenHal Finkel2013-01-251-0/+4
| | | | | | | This adds an !add(a, b) operator to tablegen; this will be used to cleanup the PPC register definitions. llvm-svn: 173445
* TableGen: Keep track of superclass reference ranges.Jordan Rose2013-01-101-33/+45
| | | | | | | | | | def foo : bar; ~~~ This allows us to produce more precise diagnostics about a certain superclass, and even provide fixits. llvm-svn: 172085
* TableGen: record anonymous instantiations of classes.Jordan Rose2013-01-101-6/+16
| | | | llvm-svn: 172084
* tblgen: use an early return to reduce indentation.Sean Silva2013-01-091-18/+18
| | | | llvm-svn: 171954
* tblgen: Factor out common code.Sean Silva2013-01-091-17/+17
| | | | llvm-svn: 171951
* Inline this into its only caller.Sean Silva2013-01-091-11/+5
| | | | | | | | | | | 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. llvm-svn: 171938
* tblgen: Reuse function that is 2 lines above.Sean Silva2013-01-091-11/+2
| | | | llvm-svn: 171937
* fix copy-paste-oSean Silva2013-01-091-2/+2
| | | | llvm-svn: 171936
* docs: Bring TableGen syntax a bit closer to reality.Sean Silva2013-01-091-1/+6
| | | | | | | | | It's not just def's but actually a limited subset of Object's that are allowed inside a multiclass. Spotted by Joel Jones. llvm-svn: 171935
* Revert r171140. We don't actually need to support #NAME. Because NAME by ↵Craig Topper2013-01-071-5/+1
| | | | | | itself is interpreted just fine. llvm-svn: 171695
* Update tablegen parser to allow defm names to start with #NAME.Craig Topper2012-12-271-1/+5
| | | | llvm-svn: 171140
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-3/+3
| | | | | | | | | | | | | | | | | 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. =] llvm-svn: 169131
* tblgen: Use semantically correct RTTI functions.Sean Silva2012-10-101-6/+5
| | | | | | Also, some minor cleanup. llvm-svn: 165647
* tblgen: Mechanically move dynamic_cast<> to dyn_cast<>.Sean Silva2012-10-101-26/+26
| | | | | | | | | | 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<>. llvm-svn: 165646
* tblgen: Remove pointless method call.Sean Silva2012-10-091-1/+0
| | | | llvm-svn: 165511
* tblgen: Replace uses of dynamic_cast<XXXRecTy> with dyn_cast<>.Sean Silva2012-10-051-5/+5
| | | | | | | | 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. llvm-svn: 165291
* Re-work bit/bits value resolving in tblgenMichael Liao2012-09-061-24/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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. llvm-svn: 163360
* Print out the location of expanded multiclass defs in TableGen errors.Jakob Stoklund Olesen2012-08-221-1/+4
| | | | | | | | | | | | | | | | | | | 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), ^ llvm-svn: 162409
* TableGen: Allow use of #NAME# outside of 'def' names.Jim Grosbach2012-08-021-11/+21
| | | | | | | | | | | | | | | | | | | | | 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)>; } llvm-svn: 161198
* Add support for range expressions in TableGen foreach loops.Jakob Stoklund Olesen2012-05-241-15/+50
| | | | | | | | | | | | Like this: foreach i = 0-127 in ... Use braces for composite ranges: foreach i = {0-3,9-7} in ... llvm-svn: 157432
* Don't put TGParser scratch results in the output.Jakob Stoklund Olesen2012-05-241-2/+2
| | | | | | Only fully expanded Records should go into RecordKeeper. llvm-svn: 157431
* Simplify TGParser::ProcessForEachDefs.Jakob Stoklund Olesen2012-05-241-92/+63
| | | | | | Use static type checking. llvm-svn: 157430
* Add Foreach LoopDavid Greene2012-02-221-2/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add some data structures to represent for loops. These will be referenced during object processing to do any needed iteration and instantiation. Add foreach keyword support to the lexer. Add a mode to indicate that we're parsing a foreach loop. This allows the value parser to early-out when processing the foreach value list. Add a routine to parse foreach iteration declarations. This is separate from ParseDeclaration because the type of the named value (the iterator) doesn't match the type of the initializer value (the value list). It also needs to add two values to the foreach record: the iterator and the value list. Add parsing support for foreach. Add the code to process foreach loops and create defs based on iterator values. Allow foreach loops to be matched at the top level. When parsing an IDValue check if it is a foreach loop iterator for one of the active loops. If so, return a VarInit for it. Add Emacs keyword support for foreach. Add VIM keyword support for foreach. Add tests to check foreach operation. Add TableGen documentation for foreach. Support foreach with multiple objects. Support non-braced foreach body with one object. Do not require types for the foreach declaration. Assume the iterator type from the iteration list element type. llvm-svn: 151164
* Convert assert(0) to llvm_unreachableCraig Topper2012-02-071-4/+4
| | | | llvm-svn: 149967
* Fix Record Name ReferenceDavid Greene2012-01-281-1/+1
| | | | | | Get the record name though the init to avoid an assert. llvm-svn: 149153
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-5/+0
| | | | llvm-svn: 148578
* TblGen diagnostic for mismatched template instantiation.Jim Grosbach2012-01-201-0/+4
| | | | | | | | | | | | | | | | | | Providing a template argment to a non-templatized class was crashing tblgen. Add a diagnostic. For example, $ cat bug.td class A; def B : A<0> { } $ llvm-tblgen bug.td bug.td:3:11: error: template argument provided to non-template class def B : A<0> { ^ llvm-svn: 148565
* Delete CodeInit and CodeRecTy from TableGen.Jakob Stoklund Olesen2012-01-131-3/+3
| | | | | | | The code type was always identical to a string anyway. Now it is simply a synonym. The code literal syntax [{...}] is still valid. llvm-svn: 148092
* Use uniqued StringInit pointers for lookups.Jakob Stoklund Olesen2012-01-131-1/+1
| | | | | | | This avoids a gazillion StringMap and dynamic_cast calls, making TableGen run 3x faster. llvm-svn: 148091
* Check for error after InstantiateMultclassDef.Jim Grosbach2011-12-021-0/+2
| | | | llvm-svn: 145689
* Implement PasteDavid Greene2011-10-191-22/+60
| | | | | | | | | | | | | | Add a paste operator '#' to take two identifier-like strings and joint them. Internally paste gets represented as a !strconcat() with any necessary casts to string added. This will be used to implement basic for loop functionality as in: for i = [0, 1, 2, 3, 4, 5, 6, 7] { def R#i : Register<...> } llvm-svn: 142525
* Process NAMEDavid Greene2011-10-191-8/+35
| | | | | | | During multiclass def instantiation, replace NAME in any expressions with the value of the def or defm ID. llvm-svn: 142524
* Process Defm Prefix as InitDavid Greene2011-10-191-19/+39
| | | | | | | Parse and process a defm prefix as an Init expression. This allows paste operations to create defm prefixes. llvm-svn: 142523
* Parse Def ID as ValueDavid Greene2011-10-191-13/+41
| | | | | | | Allow def and defm IDs to be general values. We need this for paste functionality. llvm-svn: 142522
* Don't Parse Object Body as a NameDavid Greene2011-10-191-0/+4
| | | | | | | | Stop parsing a value if we are in name parsing mode and we see a left brace. A left brace indicates the start of an object body when we are parsing a name. llvm-svn: 142521
* Use Parse ModeDavid Greene2011-10-191-2/+9
| | | | | | | Augment the value parser to respect the parse mode and not error if an ID doesn't map to an object and we are in name parsing mode. llvm-svn: 142520
* Make ID Parsing More FlexibleDavid Greene2011-10-191-6/+8
| | | | | | | | | | | | | | | | | | | Add a mode control to value and ID parsers. The two modes are: - Parse a value. Expect the parsed ID to map to an existing object. - Parse a name. Expect the parsed ID to not map to any existing object. The first is used when parsing an identifier to be looked up, for example a record field or template argument. The second is used for parsing declarations. Paste functionality implies that declarations can contain arbitrary expressions so we need to be able to call into the general value parser to parse declarations with paste operators. So we need a way to parse a value-like thing without expecting that the result will map to some existing object. This parse mode provides that. llvm-svn: 142519
* Add NAME MemberDavid Greene2011-10-191-1/+1
| | | | | | | | Add a Value named "NAME" to each Record. This will be set to the def or defm name when instantiating multiclasses. This will replace the #NAME# processing hack once paste functionality is in place. llvm-svn: 142518
* Fix Name AccessDavid Greene2011-10-191-2/+3
| | | | | | Get the Record name as a string explicitly to avoid asserts. llvm-svn: 142517
* Fix Name AccessDavid Greene2011-10-191-1/+2
| | | | | | Get the Record name as a string explicitly to avoid asserts. llvm-svn: 142516
* Fix Name AccessDavid Greene2011-10-191-2/+3
| | | | | | Get the Record name as a string explicitly to avoid asserts. llvm-svn: 142515
* Fix Name AccessDavid Greene2011-10-191-1/+2
| | | | | | Get the Record name by string explicitly to avoid potential asserts. llvm-svn: 142514
* Make Template Arg Names InitsDavid Greene2011-10-191-29/+35
| | | | | | | | Allow template arg names to be Inits. This is further work to implement paste as it allows template names to participate in paste operations. llvm-svn: 142500
OpenPOWER on IntegriCloud