summaryrefslogtreecommitdiff
path: root/lib/TableGen/TGParser.cpp
Commit message (Collapse)AuthorAge
* 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
* 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
* [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
* 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
* 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
* 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
* 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: 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: 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
* 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
* 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
* Add support for range expressions in TableGen foreach loops.Jakob Stoklund Olesen2012-05-24
| | | | | | | | | | | | Like this: foreach i = 0-127 in ... Use braces for composite ranges: foreach i = {0-3,9-7} in ... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157432 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't put TGParser scratch results in the output.Jakob Stoklund Olesen2012-05-24
| | | | | | Only fully expanded Records should go into RecordKeeper. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157431 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify TGParser::ProcessForEachDefs.Jakob Stoklund Olesen2012-05-24
| | | | | | Use static type checking. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157430 91177308-0d34-0410-b5e6-96231b3b80d8
* Add Foreach LoopDavid Greene2012-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151164 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert assert(0) to llvm_unreachableCraig Topper2012-02-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149967 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Record Name ReferenceDavid Greene2012-01-28
| | | | | | Get the record name though the init to avoid an assert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149153 91177308-0d34-0410-b5e6-96231b3b80d8
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148578 91177308-0d34-0410-b5e6-96231b3b80d8
* TblGen diagnostic for mismatched template instantiation.Jim Grosbach2012-01-20
| | | | | | | | | | | | | | | | | | 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> { ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148565 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete CodeInit and CodeRecTy from TableGen.Jakob Stoklund Olesen2012-01-13
| | | | | | | The code type was always identical to a string anyway. Now it is simply a synonym. The code literal syntax [{...}] is still valid. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148092 91177308-0d34-0410-b5e6-96231b3b80d8
* Use uniqued StringInit pointers for lookups.Jakob Stoklund Olesen2012-01-13
| | | | | | | This avoids a gazillion StringMap and dynamic_cast calls, making TableGen run 3x faster. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148091 91177308-0d34-0410-b5e6-96231b3b80d8
* Check for error after InstantiateMultclassDef.Jim Grosbach2011-12-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145689 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement PasteDavid Greene2011-10-19
| | | | | | | | | | | | | | 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<...> } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142525 91177308-0d34-0410-b5e6-96231b3b80d8
* Process NAMEDavid Greene2011-10-19
| | | | | | | During multiclass def instantiation, replace NAME in any expressions with the value of the def or defm ID. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142524 91177308-0d34-0410-b5e6-96231b3b80d8
* Process Defm Prefix as InitDavid Greene2011-10-19
| | | | | | | Parse and process a defm prefix as an Init expression. This allows paste operations to create defm prefixes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142523 91177308-0d34-0410-b5e6-96231b3b80d8
* Parse Def ID as ValueDavid Greene2011-10-19
| | | | | | | Allow def and defm IDs to be general values. We need this for paste functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142522 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't Parse Object Body as a NameDavid Greene2011-10-19
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142521 91177308-0d34-0410-b5e6-96231b3b80d8
* Use Parse ModeDavid Greene2011-10-19
| | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142520 91177308-0d34-0410-b5e6-96231b3b80d8
* Make ID Parsing More FlexibleDavid Greene2011-10-19
| | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142519 91177308-0d34-0410-b5e6-96231b3b80d8
* Add NAME MemberDavid Greene2011-10-19
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142518 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Name AccessDavid Greene2011-10-19
| | | | | | Get the Record name as a string explicitly to avoid asserts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142517 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Name AccessDavid Greene2011-10-19
| | | | | | Get the Record name as a string explicitly to avoid asserts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142516 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Name AccessDavid Greene2011-10-19
| | | | | | Get the Record name as a string explicitly to avoid asserts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142515 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Name AccessDavid Greene2011-10-19
| | | | | | Get the Record name by string explicitly to avoid potential asserts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142514 91177308-0d34-0410-b5e6-96231b3b80d8
* Make Template Arg Names InitsDavid Greene2011-10-19
| | | | | | | | Allow template arg names to be Inits. This is further work to implement paste as it allows template names to participate in paste operations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142500 91177308-0d34-0410-b5e6-96231b3b80d8
* Let SetValue Take and Init NameDavid Greene2011-10-19
| | | | | | | Convert SetValue to take the value name as an Init. This allows us to set values for variables whose names are not yet fully resolved. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142499 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove MultidefsDavid Greene2011-10-07
| | | | | | | | | | | | | | | | | | | Multidefs are a bit unwieldy and incomplete. Remove them in favor of another mechanism, probably for loops. Revert "Make Test More Thorough" Revert "Fix a typo." Revert "Vim Support for Multidefs" Revert "Emacs Support for Multidefs" Revert "Document Multidefs" Revert "Add a Multidef Test" Revert "Update Test for Multidefs" Revert "Process Multidefs" Revert "Parser Multidef Support" Revert "Lexer Support for Multidefs" Revert "Add Multidef Data Structures" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141378 91177308-0d34-0410-b5e6-96231b3b80d8
* Prefix Template Arg Names with Multiclass NameDavid Greene2011-10-05
| | | | | | | | For consistency, prefix multiclass template arg names with the multiclass name followed by "::" to avoid name clashes among multiclass arguments and other entities in the multiclass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141239 91177308-0d34-0410-b5e6-96231b3b80d8