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
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
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
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
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
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 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
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
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
When resolving Record values, be sure to update the Record name as it
may contain references to the value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142511 91177308-0d34-0410-b5e6-96231b3b80d8
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142510 91177308-0d34-0410-b5e6-96231b3b80d8
Add a Record constructor that takes the Record name as an Init. This
is more work toward paste functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142508 91177308-0d34-0410-b5e6-96231b3b80d8
Record names may not be fully resolved at this point so ask for the
record name as a string explicitly. This avoids a potential assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142502 91177308-0d34-0410-b5e6-96231b3b80d8
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
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
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142498 91177308-0d34-0410-b5e6-96231b3b80d8
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142497 91177308-0d34-0410-b5e6-96231b3b80d8
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142496 91177308-0d34-0410-b5e6-96231b3b80d8
Add a utility to get the name init and get the string representation
of the name. This will be used for paste functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142495 91177308-0d34-0410-b5e6-96231b3b80d8
Add a couple of utility functions to get at the name init and return
the name init as a string. This will be used for paste functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142494 91177308-0d34-0410-b5e6-96231b3b80d8
and switches, with arbitrary numbers of successors. Still optimized for
the common case of 2 successors for a conditional branch.
Add a test case for switch metadata showing up in the BlockFrequencyInfo pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142493 91177308-0d34-0410-b5e6-96231b3b80d8
encoding of probabilities. In the absense of metadata, it continues to
fall back on static heuristics.
This allows __builtin_expect, after lowering through llvm.expect
a branch instruction's metadata, to actually enter the branch
probability model. This is one component of resolving PR2577.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142492 91177308-0d34-0410-b5e6-96231b3b80d8
layer already had support for printing the results of this analysis, but
the wiring was missing.
Now that printing the analysis works, actually bring some of this
analysis, and the BranchProbabilityInfo analysis that it wraps, under
test! I'm planning on fixing some bugs and doing other work here, so
having a nice place to add regression tests and a way to observe the
results is really useful.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142491 91177308-0d34-0410-b5e6-96231b3b80d8