Commit Graph

167 Commits

Author SHA1 Message Date
Jim Grosbach cc6cbf05a3 TableGen add warning diagnostic helper functions.
llvm-svn: 155012
2012-04-18 17:46:31 +00:00
Jakob Stoklund Olesen aa0f752fc8 Fix infinite loop in nested multiclasses.
Patch by Michael Liao!

llvm-svn: 152232
2012-03-07 16:39:35 +00:00
Chandler Carruth 08a47fd708 Switch the TableGen record's string-based DenseMap key to use the new
hashing infrastructure. I wonder why we don't just use StringMap here,
and I may revisit the issue if I have time, but for now I'm just trying
to consolidate.

llvm-svn: 152023
2012-03-05 10:36:16 +00:00
Daniel Dunbar 9512c46cc3 Remove stray semi-colon.
llvm-svn: 151629
2012-02-28 15:35:52 +00:00
David Greene fb927af24f 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.

llvm-svn: 151164
2012-02-22 16:09:41 +00:00
Ahmed Charles a4704ab080 StringRef'ize EmitSourceFileHeader().
llvm-svn: 150917
2012-02-19 11:35:20 +00:00
Craig Topper a2886c21d9 Convert assert(0) to llvm_unreachable
llvm-svn: 149967
2012-02-07 05:05:23 +00:00
David Greene 6291f3a43c Implement String Cast from Integer
Allow casts from integer to string.

llvm-svn: 149273
2012-01-30 20:47:04 +00:00
David Greene ebb006fc3d Fix Record Name Reference
Get the record name though the init to avoid an assert.

llvm-svn: 149153
2012-01-28 00:03:24 +00:00
David Blaikie 46a9f016c5 More dead code removal (using -Wunreachable-code)
llvm-svn: 148578
2012-01-20 21:51:11 +00:00
Jim Grosbach 91f5a3f253 TblGen diagnostic for mismatched template instantiation.
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
2012-01-20 20:02:39 +00:00
David Blaikie 486df738c3 Removing unused default switch cases in switches over enums that already account for all enumeration values explicitly.
(This time I believe I've checked all the -Wreturn-type warnings from GCC & added the couple of llvm_unreachables necessary to silence them. If I've missed any, I'll happily fix them as soon as I know about them)

llvm-svn: 148262
2012-01-16 23:24:27 +00:00
Jakob Stoklund Olesen dd8fbf572e Delete CodeInit and CodeRecTy from TableGen.
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
2012-01-13 03:38:34 +00:00
Jakob Stoklund Olesen 9d1c5eeb32 Use uniqued StringInit pointers for lookups.
This avoids a gazillion StringMap and dynamic_cast calls, making
TableGen run 3x faster.

llvm-svn: 148091
2012-01-13 03:16:35 +00:00
Dylan Noblesmith f3b1760496 TableGen: add a comment
llvm-svn: 147199
2011-12-22 23:16:09 +00:00
Dylan Noblesmith 345b7430a9 try to fix MSVC build
llvm-svn: 147198
2011-12-22 23:08:39 +00:00
Dylan Noblesmith 9e5b178ecc drop unneeded config.h includes
llvm-svn: 147197
2011-12-22 23:04:07 +00:00
Chandler Carruth e805b16e3d Fix up the CMake build for the new files added in r146960, they're
likely to stay either way that discussion ends up resolving itself.

llvm-svn: 146966
2011-12-20 08:42:11 +00:00
David Blaikie a379b18173 Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch
llvm-svn: 146960
2011-12-20 02:50:00 +00:00
Daniel Dunbar 27a7489a03 LLVMBuild: Remove trailing newline, which irked me.
llvm-svn: 146409
2011-12-12 19:48:00 +00:00
Jim Grosbach bccc4c17f3 Check for error after InstantiateMultclassDef.
llvm-svn: 145689
2011-12-02 18:33:03 +00:00
Daniel Dunbar 539d0a8a09 build/CMake: Finish removal of add_llvm_library_dependencies.
llvm-svn: 145420
2011-11-29 19:25:30 +00:00
Jim Grosbach 12952fef71 ARM vldm and vstm VFP instructions can take a data type suffix.
It's ignored by the assembler when present, but is legal syntax. Other
instructions have something similar, but for some mnemonics it's
only sometimes not significant, so this quick check in the parser will
need refactored into something more robust soon-ish. This gets some
basics working in the meantime.

Partial for rdar://10435264

llvm-svn: 144422
2011-11-11 23:08:10 +00:00
Daniel Dunbar bf9bba47a1 build: Add initial cut at LLVMBuild.txt files.
llvm-svn: 143634
2011-11-03 18:53:17 +00:00
David Greene 8e85b480d5 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<...>
}

llvm-svn: 142525
2011-10-19 13:04:43 +00:00
David Greene 8bf0d72f0e Process NAME
During multiclass def instantiation, replace NAME in any expressions
with the value of the def or defm ID.

llvm-svn: 142524
2011-10-19 13:04:35 +00:00
David Greene 5d5d88cc1a Process Defm Prefix as Init
Parse and process a defm prefix as an Init expression.  This allows
paste operations to create defm prefixes.

llvm-svn: 142523
2011-10-19 13:04:31 +00:00
David Greene 2affd67b51 Parse Def ID as Value
Allow def and defm IDs to be general values.  We need this for paste
functionality.

llvm-svn: 142522
2011-10-19 13:04:29 +00:00
David Greene b8a7c9d0bf Don't Parse Object Body as a Name
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
2011-10-19 13:04:26 +00:00
David Greene 232bd6017c Use Parse Mode
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
2011-10-19 13:04:21 +00:00
David Greene d4263a6ad0 Make ID Parsing More Flexible
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
2011-10-19 13:04:20 +00:00
David Greene d699161a99 Add NAME Member
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
2011-10-19 13:04:13 +00:00
David Greene 7b6e641144 Fix Name Access
Get the Record name as a string explicitly to avoid asserts.

llvm-svn: 142517
2011-10-19 13:04:02 +00:00
David Greene 8eed9988b1 Fix Name Access
Get the Record name as a string explicitly to avoid asserts.

llvm-svn: 142516
2011-10-19 13:03:58 +00:00
David Greene 07e055f919 Fix Name Access
Get the Record name as a string explicitly to avoid asserts.

llvm-svn: 142515
2011-10-19 13:03:51 +00:00
David Greene 3a20f5a687 Fix Name Access
Get the Record name by string explicitly to avoid potential asserts.

llvm-svn: 142514
2011-10-19 13:03:45 +00:00
David Greene 5c9fa026dc 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.

llvm-svn: 142513
2011-10-19 13:03:39 +00:00
David Greene 9ba42085da 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.

llvm-svn: 142512
2011-10-19 13:03:35 +00:00
David Greene 9effff28c8 Resolve Record Names
When resolving Record values, be sure to update the Record name as it
may contain references to the value.

llvm-svn: 142511
2011-10-19 13:03:30 +00:00
David Greene f651a2a5c0 Allow Names Changes on Unregistered Records
Add Record names to be changed even on Records that aren't yet
registered.  We need to be able to do this for paste functionality
because we do not want to register def names before they are unique
and that can only happen once all paste operations are done.  This
change lets us update Record names formed by paste operations and
register the result later.

llvm-svn: 142510
2011-10-19 13:03:25 +00:00
David Greene 077d84e6f3 Fix Name Access
Ask for the Record name as a string explicitly to avoid a possible assert.

llvm-svn: 142506
2011-10-19 13:03:02 +00:00
David Greene 98be78aeea Fix Name Access
Ask for the Record name as a string explicitly to avoid a possible
assert.

llvm-svn: 142505
2011-10-19 13:02:57 +00:00
David Greene 658a4b71b6 Fix Name Access
Ask for the record name as a string explicitly to avoid a potential
assert.

llvm-svn: 142504
2011-10-19 13:02:52 +00:00
David Greene b77fc0d906 Add Record Init
Add an init function to be shared among Record constructors.

llvm-svn: 142501
2011-10-19 13:02:45 +00:00
David Greene db10e69138 Make Template Arg Names Inits
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
2011-10-19 13:02:42 +00:00
David Greene 3ca42126f5 Let SetValue Take and Init Name
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.

llvm-svn: 142499
2011-10-19 13:02:39 +00:00
David Greene e714512cb6 Add Utility to Scope Names
Add a couple of utility functions to take a variable name and qualify
it with the namespace of the enclosing class and/or multiclass.  This
is inpreparation for making template arg names first-class Inits.

llvm-svn: 142498
2011-10-19 13:02:36 +00:00
David Greene 914adf0ecb Make VarInit Name an Init
Make the VarInit name an Init itself.  We need this to implement paste
functionality so we can reference variables whose names are not yet
completely resolved.

llvm-svn: 142497
2011-10-19 13:02:33 +00:00
David Greene 28438acd46 Add Value Accessors
Add accessors to get Record values by Init name.  This lets us look up
Record values whose names are not yet fully resolved.  More work
toward paste.

llvm-svn: 142496
2011-10-19 13:02:29 +00:00
Chris Lattner 03b80a4027 Make SMDiagnostic a little more sane. Instead of passing around note/warning/error as a
string, pass it around as an enum.

llvm-svn: 142107
2011-10-16 05:43:57 +00:00
Che-Liang Chiou 8a984e9418 Revert r141079: tblgen: add preprocessor as a separate mode
llvm-svn: 141492
2011-10-08 12:39:26 +00:00
David Greene 33f619971f 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"

llvm-svn: 141378
2011-10-07 18:25:05 +00:00
David Greene 7475ad05fa Fix List-of-List Processing
Fix VarListElementInit::resolveListElementReference to return a
partially resolved VarListElementInint in the case where full
resolution is not possible.  This allows TableGen to make forward
progress resolving certain complex list expressions.

llvm-svn: 141315
2011-10-06 21:20:46 +00:00
Benjamin Kramer f9389a361e Use StringSwitch.
llvm-svn: 141305
2011-10-06 18:53:43 +00:00
Benjamin Kramer a54985ee90 Simplify code. No functionality change.
llvm-svn: 141299
2011-10-06 18:23:56 +00:00
David Greene 2b724f65d5 Fix Typo
Compare the entire keyword string.

llvm-svn: 141295
2011-10-06 14:37:47 +00:00
David Greene 47a665e93e Prefix Template Arg Names with Multiclass Name
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.

llvm-svn: 141239
2011-10-05 22:42:54 +00:00
David Greene 2ac084dbb2 Process Multidefs
Process each multidef declared in a multiclass.  Iterate through the
list and instantiate a def in the multiclass for each item, resolving
the list item to the temporary iterator (possibly) used in the
multidef ObjectBody.  We then process each generated def in the normal
way.

llvm-svn: 141233
2011-10-05 22:42:45 +00:00
David Greene dd1eb61298 Parser Multidef Support
Add parser support to recognize multidefs.  No processing on the
multidef is done at this point.  The grammar is:

MultiDef = MULTIDEF ObjectName < Value, Declaration, Value > ObjectBody

The first Value must be resolveable to a list and the second Value
must be resolveable to an integer.  The Declaration is a temporary
value used as an iterator to refer to list items during processing.
It may be passed into the ObjectBody where it will be substituted with
the list value used to instantiate each def.

llvm-svn: 141232
2011-10-05 22:42:44 +00:00
David Greene dd88abaa97 Lexer Support for Multidefs
Add keyword support for multidefs.

llvm-svn: 141231
2011-10-05 22:42:35 +00:00
David Greene db44597494 Refactor Multiclass Def Processing
Move the code to instantiate a multiclass def, bind its arguments and
resolve its members into three helper functions.  These will be reused
to support a new kind of multiclass def: a multidef.

llvm-svn: 141229
2011-10-05 22:42:07 +00:00
Duncan Sands efb31f3f3c Fix compilation when using gcc-4.6. Patch by wanders.
llvm-svn: 141178
2011-10-05 14:36:12 +00:00
Francois Pichet aec9739e16 Replace snprintf with raw_string_ostream.
llvm-svn: 141116
2011-10-04 21:08:56 +00:00
David Greene a8b8ab6b20 Allow Operator Arguments
When resolving an operator list element reference, resolve all
operator operands and try to fold the operator first.  This allows the
operator to collapse to a list which may then be indexed.

Before, it was not possible to do this:
class D<int a, int b> { ... }
class C<list<int> A> : D<A[0], A[1]>;
class B<list<int> b> : C<!foreach(...,b)>;

Now it is.

llvm-svn: 141101
2011-10-04 18:55:36 +00:00
Francois Pichet b26b49ca63 Unbreak MSVC build.
llvm-svn: 141093
2011-10-04 16:28:07 +00:00
Che-Liang Chiou 67a16e2564 tblgen: add preprocessor as a separate mode
This patch adds a preprocessor that can expand nested for-loops for
saving some copy-n-paste in *.td files.

The preprocessor is not yet integrated with TGParser, and so it has
no direct effect on *.td inputs.  However, you may preprocess an td
input (and only preprocess it).

To test the proprecessor, type:
  tblgen -E -o $@ $<

llvm-svn: 141079
2011-10-04 15:14:51 +00:00
Peter Collingbourne 84c287e33c Move TableGen's parser and entry point into a library
This is the first step towards splitting LLVM and Clang's tblgen executables.

llvm-svn: 140951
2011-10-01 16:41:13 +00:00