llvm/utils/TableGen
Daniel Sanders 1f35f2fa6a [mips][ias] Check '$rs = $rd' constraints when both registers are in AsmText.
Summary:
This is one possible solution to the problem of ignoring constraints that Simon
raised in D21473 but it's a bit of a hack.

The integrated assembler currently ignores violations of the tied register
constraints when the operands involved in a tie are both present in the AsmText.
For example, 'dati $rs, $rt, $imm' with the '$rs = $rt' will silently replace
$rt with $rs. So 'dati $2, $3, 1' is processed as if the user provided
'dati $2, $2, 1' without any diagnostic being emitted.

This is difficult to solve properly because there are multiple parts of the
matcher that are silently forcing these constraints to be met. Tied operands are
rendered to instructions by cloning previously rendered operands but this is
unnecessary because the matcher was already instructed to render the operand it
would have cloned. This is also unnecessary because earlier code has already
replaced the MCParsedOperand with the one it was tied to (so the parsed input
is matched as if it were 'dati <RegIdx 2>, <RegIdx 2>, <Imm 1>'). As a result,
it looks like fixing this properly amounts to a rewrite of the tied operand
handling which affects all targets.

This patch however, merely inserts a checking hook just before the
substitution of MCParsedOperands and the Mips target overrides it. It's not
possible to accurately check the registers are the same this early (because
numeric registers haven't been bound to a register class yet) so it cheats a
bit and checks that the tokens that produced the operand are lexically
identical. This works because tied registers need to have the same register
class but it does have a flaw. It will reject 'dati $4, $a0, 1' for violating
the constraint even though $a0 ends up as the same register as $4.

Reviewers: sdardis

Subscribers: dsanders, llvm-commits, sdardis

Differential Revision: https://reviews.llvm.org/D21994

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276867 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 13:49:44 +00:00
..
AsmMatcherEmitter.cpp [mips][ias] Check '$rs = $rd' constraints when both registers are in AsmText. 2016-07-27 13:49:44 +00:00
AsmWriterEmitter.cpp TableGen: promote "code" type from syntactic sugar. 2016-07-05 21:22:55 +00:00
AsmWriterInst.cpp [TableGen] Remove the CGIOpNo from AsmWriterOperand as its not used for anything. NFC 2016-01-22 05:59:37 +00:00
AsmWriterInst.h [TableGen] Reorder fields in AsmWriterOperand to remove padding and reduce size. NFC 2016-01-22 05:59:40 +00:00
Attributes.cpp Add LLVMGetAttrKindID in the C API in order to facilitate migration away from LLVMAttribute 2016-04-20 01:02:12 +00:00
CallingConvEmitter.cpp
CMakeLists.txt AArch64: TableGenerate system instruction operands. 2016-07-05 21:23:04 +00:00
CodeEmitterGen.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
CodeGenDAGPatterns.cpp IR: Sort generic intrinsics before target specific ones 2016-07-15 16:31:37 +00:00
CodeGenDAGPatterns.h IR: Sort generic intrinsics before target specific ones 2016-07-15 16:31:37 +00:00
CodeGenInstruction.cpp TableGen: Add hasNoSchedulingInfo to instructions 2016-03-01 20:03:11 +00:00
CodeGenInstruction.h Apply clang-tidy's misc-move-constructor-init throughout LLVM. 2016-05-27 14:27:24 +00:00
CodeGenIntrinsics.h IR: Sort generic intrinsics before target specific ones 2016-07-15 16:31:37 +00:00
CodeGenMapTable.cpp [TableGen] more helpful error message in MapTableEmitter 2016-03-10 18:51:58 +00:00
CodeGenRegisters.cpp TableGen: Produce CoveredBySubRegs summary for register classes 2016-04-28 03:07:11 +00:00
CodeGenRegisters.h TableGen: Produce CoveredBySubRegs summary for register classes 2016-04-28 03:07:11 +00:00
CodeGenSchedule.cpp Revert "Revert "[misched] Extend scheduler to handle unsupported features"" 2016-06-24 08:43:27 +00:00
CodeGenSchedule.h Revert "Revert "[misched] Extend scheduler to handle unsupported features"" 2016-06-24 08:43:27 +00:00
CodeGenTarget.cpp GlobalISel: Remove explicit enumerator values from .def file. 2016-07-20 22:58:01 +00:00
CodeGenTarget.h TableGen: Use StringRef instead of std::string 2016-05-25 18:07:40 +00:00
CTagsEmitter.cpp
DAGISelEmitter.cpp
DAGISelMatcher.cpp [TableGen] Remove getHash support from DAGISelMatcher. It hasn't been used for some time. 2016-05-06 02:37:59 +00:00
DAGISelMatcher.h [TableGen] Remove isSafeToReorderWithPatternPredicate from DAGISelMatchers as its not used anymore. 2016-05-06 06:21:27 +00:00
DAGISelMatcherEmitter.cpp SDAG: Make SelectCodeCommon return void 2016-05-10 22:58:26 +00:00
DAGISelMatcherGen.cpp Apply most suggestions of clang-tidy's performance-unnecessary-value-param 2016-06-08 19:09:22 +00:00
DAGISelMatcherOpt.cpp [TableGen] Fix a memory leak when creating SwitchOpcodeMatchers. 2016-05-06 06:56:14 +00:00
DFAPacketizerEmitter.cpp Run clang-tidy's performance-unnecessary-copy-initialization over LLVM. 2016-06-12 17:30:47 +00:00
DisassemblerEmitter.cpp Apply most suggestions of clang-tidy's performance-unnecessary-value-param 2016-06-08 19:09:22 +00:00
FastISelEmitter.cpp Apply clang-tidy's misc-move-constructor-init throughout LLVM. 2016-05-27 14:27:24 +00:00
FixedLenDecoderEmitter.cpp TableGen: Allow custom register operand decoder method 2016-07-18 23:20:46 +00:00
InstrInfoEmitter.cpp XRay: Add entry and exit sleds 2016-07-14 04:06:33 +00:00
IntrinsicEmitter.cpp IR: Sort generic intrinsics before target specific ones 2016-07-15 16:31:37 +00:00
LLVMBuild.txt
OptParserEmitter.cpp Fix some Clang-tidy modernize warnings, other minor fixes. 2015-11-04 22:32:32 +00:00
PseudoLoweringEmitter.cpp
RegisterInfoEmitter.cpp Avoid some copies by using const references. 2016-05-27 12:30:51 +00:00
SearchableTableEmitter.cpp [tblgen] Compare const char * with strcmp instead of creating StringRef. 2016-07-26 09:27:51 +00:00
SequenceToOffsetTable.h [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
SubtargetEmitter.cpp Apply most suggestions of clang-tidy's performance-unnecessary-value-param 2016-06-08 19:09:22 +00:00
TableGen.cpp AArch64: TableGenerate system instruction operands. 2016-07-05 21:23:04 +00:00
TableGenBackends.h AArch64: TableGenerate system instruction operands. 2016-07-05 21:23:04 +00:00
tdtags
X86DisassemblerShared.h
X86DisassemblerTables.cpp test commit: remove trailing whitespace 2016-06-20 20:43:26 +00:00
X86DisassemblerTables.h
X86ModRMFilters.cpp
X86ModRMFilters.h
X86RecognizableInstr.cpp AVX512F: Add GATHER/SCATTER assembler Intel syntax tests for knl/skx/avx . Change memory operand parser handling. 2016-02-25 13:30:17 +00:00
X86RecognizableInstr.h [NFC] Header cleanup 2016-04-18 09:17:29 +00:00