Commit Graph

17 Commits

Author SHA1 Message Date
Craig Topper
8a0d1c8f06 [C++11] Make use of 'nullptr' in TableGen library.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205830 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-09 04:50:04 +00:00
Sean Silva
a170f520a9 tblgen: Diagnose duplicate includes.
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
2013-02-07 04:30:39 +00:00
Hal Finkel
d23a41c153 Add an addition operator to TableGen
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
2013-01-25 14:49:08 +00:00
Chandler Carruth
d04a8d4b33 Use the new script to sort the includes of every file under lib.
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
2012-12-03 16:50:05 +00:00
David Greene
cebb4ee93a Add Foreach Loop
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
2012-02-22 16:09:41 +00:00
Dylan Noblesmith
bfbc9fcb83 TableGen: add a comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147199 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22 23:16:09 +00:00
Dylan Noblesmith
8cc300cb34 try to fix MSVC build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147198 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22 23:08:39 +00:00
Dylan Noblesmith
9421406aad drop unneeded config.h includes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147197 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22 23:04:07 +00:00
David Greene
d3d1cad535 Implement Paste
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
2011-10-19 13:04:43 +00:00
David Greene
7efe936251 Disambiguate Numbers and Identifiers
Use lookahead to determine whether a number is really a number or is
part of something forming an identifier.  This won't come into play
until the paste operator is recognized as a unique token.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142513 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-19 13:03:39 +00:00
David Greene
a761f92cd3 Add Peek
Add a peek function to let the Lexer look at a character arbitrarily
far ahead in the stream without consuming anything.  We need this to
disambiguate numbers and operands of a paste operation.  For example:

def foo#8i

Without lookahead the lexer will treat '8' as a number rather than as
part of a string to be pasted to form an identifier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142512 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-19 13:03:35 +00:00
David Greene
a1b1b79be1 Remove Multidefs
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
2011-10-07 18:25:05 +00:00
Benjamin Kramer
ee573189c6 Use StringSwitch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141305 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 18:53:43 +00:00
Benjamin Kramer
37d42af584 Simplify code. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141299 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 18:23:56 +00:00
David Greene
c2d18f8929 Fix Typo
Compare the entire keyword string.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141295 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 14:37:47 +00:00
David Greene
b9c29eaa3d Lexer Support for Multidefs
Add keyword support for multidefs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141231 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 22:42:35 +00:00
Peter Collingbourne
7c78888887 Move TableGen's parser and entry point into a library
This is the first step towards splitting LLVM and Clang's tblgen executables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140951 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-01 16:41:13 +00:00