Commit Graph

283 Commits

Author SHA1 Message Date
Chad Rosier
756d2cc2f7 Remove an unused argument. The MCInst opcode is set in the ConvertToMCInst()
function nowadays.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163030 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31 22:12:31 +00:00
Chad Rosier
359956dc1b With the fix in r162954/162955 every cvt function returns true. Thus, have
the ConvertToMCInst() return void, rather then a bool.  Update all the cvt
functions as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162961 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31 00:03:31 +00:00
Chad Rosier
389536cf44 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162946 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30 21:47:00 +00:00
Chad Rosier
04508c6cb7 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162945 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30 21:46:00 +00:00
Chad Rosier
0bad086d6d Hoist a check to eliminate obvious mismatches as early as possible. Also, fix
an 80-column violation in the generated code.  No functional change intended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162944 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30 21:43:05 +00:00
Chad Rosier
62316fa00a [ms-inline asm] Add a new function, GetMCInstOperandNum, to the
AsmMatcherEmitter.  This function maps inline assembly operands to MCInst
operands.

For example, '__asm mov j, eax' is represented by the follow MCInst:

<MCInst 1460 <MCOperand Reg:0> <MCOperand Imm:1> <MCOperand Reg:0> 
             <MCOperand Expr:(j)> <MCOperand Reg:0> <MCOperand Reg:43>>

The first 5 MCInst operands are a result of j matching as a memory operand
consisting of a BaseReg (Reg:0), MemScale (Imm:1), MemIndexReg(Reg:0), 
Expr (Expr:(j), and a MemSegReg (Reg:0).  The 6th MCInst operand represents
the eax register (Reg:43).

This translation is necessary to determine the Input and Output Exprs.  If a
single asm operand maps to multiple MCInst operands, the index of the first
MCInst operand is returned.  Ideally, it would return the operand we really
care out (i.e., the Expr:(j) in this case), but I haven't found an easy way
of doing this yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162920 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30 17:59:25 +00:00
Andrew Trick
2b70dfaaeb Fix a nondeterminism in the ARM assembler.
Adding arbitrary records to ARM.td would break
basic-arm-instructions.s because selection of nop vs mov r0,r0 was
ambiguous (this will be tested by a subsequent addition to ARM.td).
An imperfect but sensible fix is to give precedence to match rules
that have more constraints.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162824 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-29 03:52:57 +00:00
Jakob Stoklund Olesen
376a8a773e Print out the location of expanded multiclass defs in TableGen errors.
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
2012-08-22 23:33:58 +00:00
Jim Grosbach
c8f267f669 TblGen: Make asm-matcher ConvertToMCInst() table driven.
No change in interface or functionality. Purely under-the-hood
details of the generated function that change.

The X86 assembly parser is reduced in size by over 15% and ARM by
over 10%.

No performance change by my measurements.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162337 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-22 01:06:23 +00:00
Chad Rosier
4c1d2baa7c Formatting. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162292 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-21 17:22:47 +00:00
Akira Hatanaka
72e9b6aeb4 Add stub methods for mips assembly matcher.
Patch by Vladimir Medic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162124 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-17 20:16:42 +00:00
Bill Wendling
087642f863 Remove extraneous ';'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161298 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-04 10:31:40 +00:00
Owen Anderson
b885dc8d39 Defer checking for registers in the MC AsmMatcher until the after user-defined match classes have been checked. This allows the creation of MatchClass's that are supersets of a register class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160327 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 23:20:09 +00:00
Jim Grosbach
151d81d1e7 TableGen: Assembly matcher 'insufficient operands' diagnostic.
Make sure the tblgen'erated asm matcher correctly returns numoperands+1
as the ErrorInfo when the problem was that there weren't enough operands
specified.

rdar://9142751

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160144 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 21:37:20 +00:00
Jim Grosbach
ef970c1091 TableGen: AsmMatcher diagnostics preference detail.
Don't override a custom diagnostic w/ a generic InvalidOperand, all else
being equal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159238 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-26 22:58:01 +00:00
Jim Grosbach
4dbfdfba6c TableGen: AsmMatcher support for better operand diagnostics.
"Invalid operand" may be a completely correct diagnostic, but it's often
insufficiently specific to really help identify and fix the problem in
assembly source. Allow a target to specify a more-specific diagnostic kind
for each AsmOperandClass derived definition and use that to provide
more detailed diagnostics when an operant of that class resulted in a
match failure.

rdar://8987109

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159050 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-22 23:56:44 +00:00
Jim Grosbach
325bd661ff TableGen: AsmMatcher missing-features list minimization.
When returning a 'cannot match due to missing CPU features' error code,
if there are multiple potential matches with different feature sets,
return the smallest set of missing features from the alternatives as
that's most likely to be the one that's desired.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158673 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 19:45:46 +00:00
Jakob Stoklund Olesen
6f36fa981a Write llvm-tblgen backends as functions instead of sub-classes.
The TableGenBackend base class doesn't do much, and will be removed
completely soon.

Patch by Sean Silva!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158311 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-11 15:37:55 +00:00
Jim Grosbach
8e27c96159 TableGen: AsmMatcher diagnostic when missing instruction mnemonic.
Previously, if an instruction definition was missing the mnemonic,
the next line would just assert(). Issue a real diagnostic instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156263 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-06 17:33:14 +00:00
Douglas Gregor
f657da2e48 Move llvm-tblgen's StringMatcher into the TableGen library so it can
be used by clang-tblgen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156000 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-02 17:32:48 +00:00
Craig Topper
8030e1a0df Add ifdef around getSubtargetFeatureName in tablegen output file so that only targets that want the function get it. This prevents other targets from getting an unused function warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155538 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-25 06:56:34 +00:00
Jim Grosbach
14ce6fac24 ARM: improved assembler diagnostics for missing CPU features.
When an instruction match is found, but the subtarget features it
requires are not available (missing floating point unit, or thumb vs arm
mode, for example), issue a diagnostic that identifies what the feature
mismatch is.

rdar://11257547

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155499 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-24 22:40:08 +00:00
Jim Grosbach
c1922c72ad TableGen support for auto-generating assembly two-operand aliases.
Assembly matchers for instructions with a two-operand form. ARM is full
of these, for example:
  add {Rd}, Rn, Rm  // Rd is optional and is the same as Rn if omitted.

The property TwoOperandAliasConstraint on the instruction definition controls
when, and if, an alias will be formed. No explicit InstAlias definitions
are required.

rdar://11255754

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155172 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 23:59:23 +00:00
Jim Grosbach
b423d18a00 Use a SmallVector instead of std::vector for ResOperands.
There's almost always a small number of instruction operands, so
use a SmallVector and save on heap allocations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155143 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 17:52:34 +00:00
Jim Grosbach
8caecdea56 Update some internal naming conventions to modern style.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155142 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 17:52:32 +00:00
Jim Grosbach
d4824fc8aa Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155075 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-18 23:46:25 +00:00
Jim Grosbach
67cd20d039 Sanity check error handling for TokenAlias.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154951 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 21:23:52 +00:00
Jim Grosbach
65da6fc8af Tidy up. 80 columns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154881 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 00:01:04 +00:00
Jim Grosbach
11fc6467e6 Tidy up. Remove hard tab characters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154532 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11 21:02:33 +00:00
Craig Topper
fab3f7ee6f Reorder fields in MatchEntry and OperandMatchEntry to reduce padding. A bit tricky due to the target specific sizes for some of the fields so the ordering is only optimal for the targets in the tree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153865 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-02 07:48:39 +00:00
Jakob Stoklund Olesen
7044cce1a3 Make MnemonicTable const again. That part of r152202 was OK.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152840 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 21:22:53 +00:00
Jakob Stoklund Olesen
dd20af266c Don't assume all mnemonics fit in 64k.
We currently assume that all targets have less than 64k opcodes. We
shouldn't limit it further.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152833 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 20:44:06 +00:00
Jakob Stoklund Olesen
bcfa982c48 Revert r152202: "Use uint16_t to store InstrNameIndices in MCInstrInfo."
We cannot limit the concatenated instruction names to 64K.  ARM is
already at 32K, and it is easy to imagine a target with more
instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152817 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 18:05:57 +00:00
Craig Topper
88d2fa438a Re-commit r152202 hopefully fixing the MSVC linker error.
Original commit message:
Use uint16_t to store InstrNameIndices in MCInstrInfo. Add asserts to protect all 16-bit string table offsets. Also make sure the string to offset table string is not larger than 65536 characters since larger string literals aren't portable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152296 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-08 06:55:27 +00:00
Chad Rosier
3c777947f4 Revert r152202 as it's causing internal buildbot failures.
Original commit message:
Use uint16_t to store InstrNameIndices in MCInstrInfo. Add asserts to protect 
all 16-bit string table offsets. Also make sure the string to offset table 
string is not larger than 65536 characters since larger string literals aren't 
portable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152233 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07 17:06:40 +00:00
Craig Topper
d3c9d9447e Use uint16_t to store InstrNameIndices in MCInstrInfo. Add asserts to protect all 16-bit string table offsets. Also make sure the string to offset table string is not larger than 65536 characters since larger string literals aren't portable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152202 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07 05:17:23 +00:00
Benjamin Kramer
b08bb34a6f Perform the string table optimization for OperandMatchEntries too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151986 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-03 20:44:43 +00:00
Benjamin Kramer
a4c5ecfb1b Shrink the asm matcher tables.
- Shrink the opcode field to 16 bits.
- Shrink the AsmVariantID field to 8 bits.
- Store the mnemonic string in a string table, store a 16 bit index.
- Store a pascal-style length byte in the string instead of a null terminator,
  so we can avoid calling strlen on every entry we visit during mnemonic search.

Shrinks X86AsmParser.o from 434k to 201k on x86_64 and eliminates relocs from the table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151984 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-03 19:13:26 +00:00
Jim Grosbach
194f3fa9ea Revert "Emit the SubRegTable with the smallest possible integer type."
This reverts commit 151760.

We want to move getSubReg() from TargetRegisterInfo into MCRegisterInfo,
but to do that, the type of the lookup table needs to be the same for
all targets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151814 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 17:30:35 +00:00
Benjamin Kramer
b9ace0215d Emit the SubRegTable with the smallest possible integer type.
Doesn't help ARM with its massive register set, but halves the size on x86 and all other targets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151760 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29 21:57:08 +00:00
Craig Topper
655b8de7b2 Convert assert(0) to llvm_unreachable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149814 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-05 07:21:30 +00:00
Jim Grosbach
f35307ceac Tidy up. Trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148856 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-24 21:06:59 +00:00
Devang Patel
40bced0306 Intel syntax: Ignore mnemonic aliases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148316 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-17 18:30:45 +00:00
Devang Patel
56315d319c Record asm variant id in MatchEntry and check it while matching instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147858 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-10 17:50:43 +00:00
David Blaikie
2bd335470f Remove unnecessary default cases in switches that cover all enum values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147855 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-10 16:47:17 +00:00
Devang Patel
d06b01c038 Use descriptive variable name and remove incorrect operand number check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147802 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-09 21:30:46 +00:00
Devang Patel
0dbcadaa2f Split AsmParser into two components - AsmParser and AsmParserVariant
AsmParser holds info specific to target parser.
AsmParserVariant holds info specific to asm variants supported by the target.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147787 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-09 19:13:28 +00:00
Devang Patel
63faf82d03 Refactor.
Store AsmParser info locally. A small step towards emitting match entries for multiple asm variants.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147710 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-07 01:33:34 +00:00
Devang Patel
b78307fc58 Eliminate an error check that may not work with all asm syntax variants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147708 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-07 01:22:23 +00:00
Devang Patel
59f7ee0400 Do not hard code asm variant number.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147583 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-05 00:51:28 +00:00
Jim Grosbach
a66512e591 Extend AsmMatcher token literal matching to allow aliasing.
For example, ARM allows:
    vmov.u32 s4, #0  -> vmov.i32, #0
'u32' is a more specific designator for the 32-bit integer type specifier
and is legal for any instruction which accepts 'i32' as a datatype suffix.

We want to say,
    def : TokenAlias<".u32", ".i32">;

This works by marking the match class of 'From' as a subclass of the
match class of 'To'.

rdar://10435076



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145992 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-06 23:43:54 +00:00
Jim Grosbach
3d5d8f6b76 Tidy up. Fix naming convention stuff for some internal functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145974 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-06 22:07:02 +00:00
Jim Grosbach
4a2242cea0 Replace an assert() with an actual diagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145535 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-30 23:16:25 +00:00
Jim Grosbach
48c1f84b10 Allow InstAlias's to use immediate matcher patterns that xform the value.
For example,

On ARM, "mov r3, #-3" is an alias for "mvn r3, #2", so we want to use a
matcher pattern that handles the bitwise negation when mapping to t2MVNi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143233 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-28 22:32:53 +00:00
Benjamin Kramer
af482cf301 Pick low-hanging MatchEntry shrinkage fruit.
Shaves 200k off Release-Asserts clang binaries on i386.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142191 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 16:18:09 +00:00
Jakob Stoklund Olesen
6fea31e730 TableGen: Privatize CodeGenRegisterClass::TheDef and Name.
When TableGen starts creating its own register classes, the synthesized
classes won't have a Record reference.  All register classes must have a
name, though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141081 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04 15:28:08 +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
Jakob Stoklund Olesen
29f018cee6 Switch to ArrayRef<CodeGenRegisterClass*>.
This makes it possible to allocate CodeGenRegisterClass instances
dynamically and reorder them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140816 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 22:28:37 +00:00
Jim Grosbach
578071a087 Prefer diagnostics from target predicate in asm matcher.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137742 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 20:12:35 +00:00
Jim Grosbach
19cb7f491f MCTargetAsmParser target match predicate support.
Allow a target assembly parser to do context sensitive constraint checking
on a potential instruction match. This will be used, for example, to handle
Thumb2 IT block parsing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137675 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 23:03:29 +00:00
Jim Grosbach
47a24ab4d7 Move MatchResultTy enum into base class definition.
No need for it to be redefined as part of every derived target asm parser
class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137649 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 20:53:08 +00:00
David Greene
05bce0beee Unconstify Inits
Remove const qualifiers from Init references, per Chris' request.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136531 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 22:43:06 +00:00
David Greene
f37dd02f77 [AVX] Constify Inits
Make references to Inits const everywhere.  This is the final step
before making them unique.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136485 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 19:07:05 +00:00
Evan Cheng
94b9550a32 Rename TargetAsmParser to MCTargetAsmParser and TargetAsmLexer to MCTargetAsmLexer; rename createAsmLexer to createMCAsmLexer and createAsmParser to createMCAsmParser.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136027 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 00:24:13 +00:00
Kevin Enderby
893818347e Have tblgen produce code that tolerates operands that return an invalid match class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135287 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 18:30:43 +00:00
Eric Christopher
d568b3f552 Revert r134921, 134917, 134908 and 134907. They're causing failures
in multiple buildbots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134936 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 23:06:52 +00:00
David Greene
d4a9066c93 [AVX] Make Inits Foldable
Manage Inits in a FoldingSet.  This provides several benefits:

- Memory for Inits is properly managed

- Duplicate Inits are folded into Flyweights, saving memory

- It enforces const-correctness, protecting against certain classes
  of bugs

The above benefits allow Inits to be used in more contexts, which in
turn provides more dynamism to TableGen.  This enhanced capability
will be used by the AVX code generator to a fold common patterns
together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134907 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 18:25:51 +00:00
Eli Friedman
6043548bfe Fix dangling pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134725 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 20:07:05 +00:00
Evan Cheng
fbc38d2c16 Fix a dangling reference. Patch by Dave Abrahams. pr10311
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134709 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 18:04:22 +00:00
Evan Cheng
ebdeeab812 Eliminate asm parser's dependency on TargetMachine:
- Each target asm parser now creates its own MCSubtatgetInfo (if needed).
- Changed AssemblerPredicate to take subtarget features which tablegen uses
  to generate asm matcher subtarget feature queries. e.g.
  "ModeThumb,FeatureThumb2" is translated to
  "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134678 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 01:53:10 +00:00
Owen Anderson
bea6f615ee Add support for alternative register names, useful for instructions whose operands are logically equivalent to existing registers, but happen to be printed specially. For example, an instruciton that prints d0[0] instead of s0.
Patch by Jim Grosbach.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133940 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 21:06:21 +00:00
Jim Grosbach
0b6a44afb9 Consolidate some TableGen diagnostic helper functions.
TableGen had diagnostic printers sprinkled about in a few places. Pull them
together into a single location in Error.cpp.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133568 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 22:55:50 +00:00
Jakob Stoklund Olesen
abdbc84b4e Store CodeGenRegisters as pointers so they won't be reallocated.
Reuse the CodeGenRegBank DenseMap in a few places that would build their
own or use linear search.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133333 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 04:26:06 +00:00
Jakob Stoklund Olesen
ae1920b1ef Give CodeGenRegisterClass a real sorted member set.
Make the Elements vector private and expose an ArrayRef through
getOrder() instead. getOrder will eventually provide multiple
user-specified allocation orders.

Use the sorted member set for member and subclass tests. Clean up a lot
of ad hoc searches.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133040 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 04:50:36 +00:00
Jim Grosbach
b9d5af05fd Tidy up. Add missing newline to generated file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130779 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-03 19:09:56 +00:00
Chris Lattner
7a2bdde0a0 Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-15 05:18:47 +00:00
Daniel Dunbar
27b83d4ff2 tlbgen/MC: StringRef's to temporary objects considered harmful.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128735 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-01 20:23:52 +00:00
Joerg Sonnenberger
6ef6ceda68 Check that MnemonicAlias doesn't map back to the same string.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125792 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 23:22:19 +00:00
Jim Grosbach
f922c47143 AsmMatcher custom operand parser failure enhancements.
Teach the AsmMatcher handling to distinguish between an error custom-parsing
an operand and a failure to match. The former should propogate the error
upwards, while the latter should continue attempting to parse with
alternative matchers.

Update the ARM asm parser accordingly.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125426 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-12 01:34:40 +00:00
Jim Grosbach
84cb033bf3 Tidy out asm matcher .inc output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125408 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-11 21:31:55 +00:00
Bill Wendling
b45c7c270c Don't return before calling the post-processing function(s).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125256 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-10 01:28:26 +00:00
Jim Grosbach
b9db0c50d8 Do AsmMatcher operand classification per-opcode.
When matching operands for a candidate opcode match in the auto-generated
AsmMatcher, check each operand against the expected operand match class.
Previously, operands were classified independently of the opcode being
handled, which led to difficulties when operand match classes were
more complicated than simple subclass relationships.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125245 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-10 00:08:28 +00:00
Bruno Cardoso Lopes
e7a54520b3 Implement support for custom target specific asm parsing of operands.
Motivation: Improve the parsing of not usual (different from registers or
immediates) operand forms.

This commit implements only the generic support. The ARM specific modifications
will come next.

A table like the one below is autogenerated for every instruction
containing a 'ParserMethod' in its AsmOperandClass

static const OperandMatchEntry OperandMatchTable[20] = {
 /* Mnemonic, Operand List Mask, Operand Class, Features */
 { "cdp", 29 /* 0, 2, 3, 4 */, MCK_Coproc, Feature_IsThumb|Feature_HasV6 },
 { "cdp", 58 /* 1, 3, 4, 5 */, MCK_Coproc, Feature_IsARM },

A matcher function very similar (but lot more naive) to
MatchInstructionImpl scans the table. After the mnemonic match, the
features are checked and if the "to be parsed" operand index is
present in the mask, there's a real match. Then, a switch like the one
below dispatch the parsing to the custom method provided in
'ParseMethod':

 case MCK_Coproc:
   return TryParseCoprocessorOperandName(Operands);




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125030 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-07 19:38:32 +00:00
Daniel Dunbar
5c228a945f MC/AsmMatcher: Sink ConvertToMCInst into the TargetAsmParser instance, which
implicitly allows custom conversions to be member functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124908 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 23:17:40 +00:00
Daniel Dunbar
b412915ff6 MC/AsmParser: Add support for allowing the conversion process to fail (via
custom conversion functions).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124872 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 17:12:23 +00:00
Daniel Dunbar
cf12067ae0 MC/AsmMatcher: Add support for custom conversion functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124870 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 17:12:15 +00:00
Kevin Enderby
79fcb6dec3 Changed the TableGen created MatchInstructionImpl() setting of ErrorInfo.
The algorithm for identifying which operand is invalid will now always point to
some operand and not the mnemonic sometimes.  The change is now that ErrorInfo
is the index of the highest operand that does not match for any of the matching
mnemonics records.  And no longer the ~0U value when the mnemonic matches and
not every record with a matching mnemonic has the same mismatching operand
index.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124734 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-02 18:20:55 +00:00
Bob Wilson
1fe3aa15e9 Add a MnemonicIsValid method to the asm matcher.
Patch by Bill Wendling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124328 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 21:43:46 +00:00
Bob Wilson
1f64ac4035 Fix spelling of CouldMatchAmbiguouslyWith method name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124324 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 21:26:21 +00:00
Bob Wilson
828295bb30 Whitespace and 80-column fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124323 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 21:26:19 +00:00
Bob Wilson
a49c7dfb36 Improve the AsmMatcher's ability to handle suboperands.
When an operand class is defined with MIOperandInfo set to a list of
suboperands, the AsmMatcher has so far required that operand to also define
a custom ParserMatchClass, and InstAlias patterns have not been able to
set the individual suboperands separately.  This patch removes both of those
restrictions.  If a "compound" operand does not override the default
ParserMatchClass, then the AsmMatcher will now parse its suboperands
separately.  If an InstAlias operand has the same class as the corresponding
compound operand, then it will be handled as before; but if that check fails,
TableGen will now try to match up a sequence of InstAlias operands with the
corresponding suboperands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124314 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 19:44:55 +00:00
Daniel Dunbar
c0a7007d3a tblgen/AsmMatcherEmitter: Fix alias handling to honor -match-prefix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124154 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 23:26:31 +00:00
Bill Wendling
0ef755d905 ARM uses '.' in their tokens. Give it a name instead of a numeric value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124026 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-22 09:44:32 +00:00
Bob Wilson
906bc368bc Tidy comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123933 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 18:38:07 +00:00
Bob Wilson
5e8f2a65ca Precompute InstAlias operand mapping to result instruction operand indices.
There should be no functional change from this, but I think it's simpler this
way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123931 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 18:38:02 +00:00
Owen Anderson
6cd0b17ba7 When matching asm operands, always try to match the most restricted type first.
Unfortunately, while this is the "right" thing to do, it breaks some ARM
asm parsing tests because MemMode5 and ThumbMemModeReg are ambiguous.  This
is tricky to resolve since neither is a subset of the other.

XFAIL the test for now.  The old way was broken in other ways, just ways
we didn't happen to be testing, and our ARM asm parsing is going to require
significant revisiting at a later point anyways.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123786 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 23:01:21 +00:00
Daniel Dunbar
55b5e85643 Formatting tweak.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123718 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 01:59:30 +00:00
Bob Wilson
dc1a2bd3aa Fix some tablegen issues to allow using zero_reg for InstAlias definitions.
This is needed to allow an InstAlias for an instruction with an "OptionalDef"
result register (like ARM's cc_out) where you want to set the optional register
to reg0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123490 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 22:58:09 +00:00
Daniel Dunbar
083203dde8 MC/AsmMatcher: Fix indirect 80-col viola.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123174 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 15:26:11 +00:00
Chris Lattner
9c6b60eb28 various cleanups to tblgen, patch by Garrison Venn!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121837 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 04:48:22 +00:00