This work is based on r239905.
Details
Diff Detail
Event Timeline
LGTM with a couple nits and a revised commit message.
This work is based on http://reviews.llvm.org/D8537
Nit: Please reference r239905 rather than D8537 when you commit.
There's rarely a need to reference the MIPS bugzilla here. http://llvm.org/PR22994 is the LLVM ticket for this.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
2799–2803 | Nit: Don't use redundant braces. | |
test/MC/Mips/branch-pseudos.s | ||
190–191 | Nit: Unnecessary blank lines |
New diff contains fix for error reporting when branch likely instructions are used on mips32r6/mips64r6.
Please, take a look at AsmToken::Identifier case, since I am not sure this is the right way to parse a label.
New diff contains fix for error reporting when branch likely instructions are used on mips32r6/mips64r6.
I should have thought of that :-). Could you add test cases for this?
Please, take a look at AsmToken::Identifier case, since I am not sure this is the right way to parse a label.
You shouldn't need any of the code you added for this. We can already parse labels so specifying 'brtarget' should be sufficient. I'll take a quick look.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
2383–2385 | Nit: You seem to have added some extra indentation since the last version of your patch. It was correct in the previous patch | |
lib/Target/Mips/MipsInstrInfo.td | ||
1698 | PredicateControl belongs on MipsAsmPseudoInst rather than CondBranchPseudo |
Please, take a look at AsmToken::Identifier case, since I am not sure this is the right way to parse a label.
You shouldn't need any of the code you added for this. We can already parse labels so specifying 'brtarget' should be sufficient. I'll take a quick look.
Hmm... I see the problem. We use a custom parser function (parseJumpTarget()) for jump targets for various reasons. However, it never calls parseJumpTarget() for these branch likely instructions on 32r6/64r6 because the the AvailableFeatures leave no possibility of a valid match. Then, because it didn't call parseJumpTarget() it isn't able to parse the remainder of the instruction and (correctly) rejects the instruction but for the wrong reason.
Fixing this properly is going to be a bit big for this patch. We either need to eliminate custom parser functions as far as possible in favour of a generic parser along the lines of your change, or change the handling of custom parsers such that the parsing happens regardless of the prospects for a successful match. For this patch, I'd suggest omitting the fix for the wrong-error issue.
New diff includes formatting fixes, test cases for error on using BL instructions on r6, and a fix for other test cases in test files test/MC/Mips/mips??r6/invalid.s, which were not executing.
New diff contain changes that are needed to apply patch to latest version of source code.
Hi,
I believe you already have a conditional LGTM for this patch (for diff 28228) and that the quoted text above contains the only remaining issue. It was asking that you remove the AsmToken::Identifier code (because it introduces another way to parse labels which is already handled elsewhere) and fix the wrong-error issue it was intended to fix in a later patch that deals with other cases too.
PredicateControl moved from CondBranchPseudo to the MipsAsmPseudoInst
I'm not sure why this change was made but it seems to have been reverted in the next diff. I'm not sure if that was intended so I thought I should mention it.
New diff contain changes that are needed to apply patch to latest version of source code.
This update removed all the context lines so I can't tell what it did.
Hi,
I believe you already have a conditional LGTM for this patch (for diff 28228) and that the quoted text above contains the only remaining issue. It was asking that you remove the AsmToken::Identifier code (because it introduces another way to parse labels which is already handled elsewhere) and fix the wrong-error issue it was intended to fix in a later patch that deals with other cases too.
OK, I will do this, but now there is another problem to be solved. As You noticed...
PredicateControl moved from CondBranchPseudo to the MipsAsmPseudoInst
I'm not sure why this change was made but it seems to have been reverted in the next diff. I'm not sure if that was intended so I thought I should mention it.
There is a problem with ULHU/ULW tests, similar to the one with parsing labels. When PredicateControl is attached to the MipsAsmPseudoInst, second parameter of ULHU/ULW cant be parsed correctly, causing tests to fail. Moving it to CondBranchPseudo is workaround to make the patch applicable.
Please take a look at https://dmz-portal.mips.com/bugz/show_bug.cgi?id=2190
I agree this is not the smartest way to fix it and we have internal communication about possible ways to resolve this.
At the time of creating these diffs, ULHU/ULW support was not implemented, it was added few days after first patch here. This is why this error emerged in later versions. The same problem prevents another patch to be committed, the one for ROL/DROL support, since it also requires PredicateControl attached to MipsAsmPseudoInst.
There is a problem with ULHU/ULW tests, similar to the one with parsing labels. When PredicateControl is attached to the MipsAsmPseudoInst, second parameter of ULHU/ULW cant be parsed correctly, causing tests to fail. Moving it to CondBranchPseudo is workaround to make the patch applicable.
The problem seems to be that we matched these instructions regardless of the predicates because PredicateControl wasn't in the hierarchy. This is definitely a bug, but it also had a somewhat desirable effect. The expansion emits a better error message than the tablegen-erated code does.
Given that this is a macro, one possible fix would be to drop the ISA_MIPS1_NOT_32R6_64R6 and comment on why it matches for unsupported cases (to emit a more precise error message during the expansion). I'd go with that and try to make the tablegen-erated errors better in a later patch (and remove this hack when that's done).
OK. I agree this is a good way to go. Then, the final corrections for this patch would be to remove AsmToken::Identifier case, remove ISA_MIPS1_NOT_32R6_64R6 from ULHU/ULW, and change tests appropriately.
remove ISA_MIPS1_NOT_32R6_64R6 from ULHU/ULW
... and comment on why it was removed :-).
... remove ISA_MIPS1_NOT_32R6_64R6 from ULHU/ULW, and change tests appropriately.
I don't think we need to do the latter if we do the former. The former is restoring the 'match but reject bad cases later' behaviour from before this patch which gives us the error messages that are already in the test.
The problem expands, because now another instruction prevents adding PredicateControl to MIspAsmPseudoInst.
class MicroMipsR6Inst16 : PredicateControl {
string DecoderNamespace = "MicroMipsR6"; let InsnPredicates = [HasMicroMips32r6];
}
Workaround is to change
def : MipsInstAlias<"nop", (SLL_MMR6 ZERO, ZERO, 0), 1>, ISA_MICROMIPS32R6;
def B_MMR6_Pseudo : MipsAsmPseudoInst<(outs), (ins brtarget_mm:$offset),
!strconcat("b", "\t$offset")>, PredicateControl;
}
into
def : MipsInstAlias<"nop", (SLL_MMR6 ZERO, ZERO, 0), 1>, ISA_MICROMIPS32R6;
def B_MMR6_Pseudo : MipsAsmPseudoInst<(outs), (ins brtarget_mm:$offset),
!strconcat("b", "\t$offset")> { string DecoderNamespace = "MicroMipsR6";
}
Is this good enough?
My bad, its:
def B_MMR6_Pseudo : MipsAsmPseudoInst<(outs), (ins brtarget_mm:$offset),
!strconcat("b", "\t$offset")>, MicroMipsR6Inst16;
The same problem appeared with latest changes from http://reviews.llvm.org/D11675
All these have predicates, but not PredicateControl in hierarchy. Patch is not aplicable until this is fixed.
def SDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
"div\t$rs, $rt">, ISA_MIPS1_NOT_32R6_64R6;
def UDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
"divu\t$rs, $rt">, ISA_MIPS1_NOT_32R6_64R6;
def DSDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
"ddiv\t$rs, $rt">, ISA_MIPS64_NOT_64R6;
def DUDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt),
"ddivu\t$rs, $rt">, ISA_MIPS64_NOT_64R6;
New diff contains changes necessary to make patch applicable. Predicates are removed from few pseudo instructions in order to enable including PredicateControl into MipsAsmPseudoInst inheritance hierarchy. Some tests are disabled.
Nit: You seem to have added some extra indentation since the last version of your patch. It was correct in the previous patch