The patch implements microMIPS64r6 DBITSWAP, DLSA, LWUPC and adds tests for AUI instructions.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
The LLX/SCX family of instructions are being changed, so they can be dropped from this patch.
You should retitle this patch to reflect that you're adding tests for aui, rather than implementing it.
Can you rebase and repost?
lib/Target/Mips/MicroMips64r6InstrInfo.td | ||
---|---|---|
111 ↗ | (On Diff #45654) | Needs MayLoad = 1. |
125 ↗ | (On Diff #45654) | Needs mayLoad = 1 |
lib/Target/Mips/Mips64r6InstrInfo.td | ||
96 ↗ | (On Diff #45654) | DLSA also needs to have the NotInMicroMips predicate. |
Some small nits.
Thanks,
Simon
lib/Target/Mips/MicroMips64r6InstrFormats.td | ||
---|---|---|
169–170 ↗ | (On Diff #56665) | Nit, bits 25-21 encode rt, 20-16 encode rs. |
178–184 ↗ | (On Diff #56665) | Nit: rs should be rt here. |
lib/Target/Mips/MicroMips64r6InstrInfo.td | ||
188–190 ↗ | (On Diff #56665) | Nit, rs -> rt. |
194–202 ↗ | (On Diff #56665) | I believe this is redundant, I'm not seeing anything use this. |
test/MC/Mips/micromips64r6/invalid.s | ||
233 ↗ | (On Diff #56665) | Check that a signed immediate offset > 19 bits is rejected for lwupc. |
Some small nits. There's only one significant change required for the predicate for lwupc. We need to see if we can evaluate it as something relocatable and that the constant part is scaled too.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
1110–1116 ↗ | (On Diff #59036) | This almost correct. We need to check for constants, symbols and symbols + offsets. The offset then has to be in the scaled form. I've given this an attempt with: if (isConstantImm() && isShiftedInt<Bits, ShiftLeftAmount>(getConstantImm())) return true; // Operand can also be a symbol or symbol plus offset in case of relocations. if (Kind != k_Immediate) return false; MCValue Res; bool Success = getImm()->evaluateAsRelocatable(Res, nullptr, nullptr); return Success && isShiftedInt<Bits, ShiftLeftAmount>(Res.getConstant()); Which also checks the offset. The code would also need to check that it's an immediate. |
lib/Target/Mips/MicroMips64r6InstrFormats.td | ||
189 ↗ | (On Diff #59036) | This should be called POOL32S_DBITSWAP_FM_MMR6, as it's in pool32s. |
207–215 ↗ | (On Diff #59036) | 'imm' should be 'sa' to match the documentation |
lib/Target/Mips/MicroMips64r6InstrInfo.td | ||
257–258 ↗ | (On Diff #59036) | Nit: imm should be sa. |
262–267 ↗ | (On Diff #59036) | Needs MayLoad = 1. |
lib/Target/Mips/Mips32r6InstrInfo.td | ||
769–772 ↗ | (On Diff #59036) | Join these "let AdditionalPredicates =" blocks together. |
lib/Target/Mips/MipsInstrInfo.td | ||
409 ↗ | (On Diff #59036) | I think this should have a different name, as lwupc doesn't jump. |
test/MC/Mips/micromips64r6/invalid.s | ||
282 ↗ | (On Diff #59036) | Check that symbol + offset where the offset is not a multiple of 4 is rejected as well and that register + register is rejected as well. |
test/MC/Mips/micromips64r6/valid.s | ||
283 ↗ | (On Diff #59036) | Also check that a symbol and symbol + offset where the offset is a multiple of 4 is also accepted for lwupc. |
isScaledSimm code replaced with the code you suggested.
Changed FM classes so that they inherit from MipsR6Inst and MMR6Arch.
Changed DESC classes so that they don't inherit from MipsR6Inst and MMR6Arch.
Changed name of MipsJumpTargetAsmOperandClass to MipsSimmAsmOperandClass.
Added DBITSWAP, LWUPC and DLCA to instruction mapping tables.
Added valid and invalid tests for LWUPC with symbols.
Note: Didn't set the MayLoad flag to 1 in LWUPC DESC class, because with it, LWUPC tests with symbols cause an assertion fail: "Assertion `isReg() && "This is not a register operand!"' failed.". I didn't find a way around that.
Note: Didn't set the MayLoad flag to 1 in LWUPC DESC class, because with it, LWUPC tests with symbols cause an assertion fail: "Assertion `isReg() && "This is not a register operand!"' failed.". I didn't find a way around that.
Yes, when an instruction with mayLoad/myStore is processed in MipsAsmParser::expandLoadInst assumes that all load instructions have both a source and destination register. lwupc however doesn't have a source register, merely an enlarged offset or symbol.
Tablegen has inferred that lwupc doesn't load, and so doesn't mark it as a load, the symbol 'bar' gets handled with a relocation. This leads to a correct result but it has a mis-defined instruction.
You can fix this easily enough by making some fairly simple changes. Extend the MipsInst class to have a "isPCRelativeLoad" member in MipsInstrFormats.td, make the corresponding change in MipsInstrInfo.h, then only check normal load/store instructions for expansion in processInstruction. Look at isCTI for an example.
I have some more comments inline.
Thanks
lib/Target/Mips/MicroMips64r6InstrInfo.td | ||
---|---|---|
319 ↗ | (On Diff #64109) | This requires the instruction itinerary, II_DBITSWAP. |
325 ↗ | (On Diff #64109) | This requires the instruction itinerary, II_DLSA. |
lib/Target/Mips/MipsInstrInfo.td | ||
416–424 ↗ | (On Diff #64109) | Calll this SimmLslAsmOperandClass instead, change the Name to reflect the class and remove the ParserMethod, the generic parser can handle the necessary cases. |
631–632 ↗ | (On Diff #64109) | Drop the 'Mips' from the names here. |
Added instruction itineraries to DBITSWAP and DLSA instructions.
Changed to MipsSimmAsmOperandClass to SimmLslAsmOperandClass, removed the parser method and changed the Name.
Changed MipsSimm19Lsl2AsmOperand to Simm19Lsl2AsmOperand.
Added isPCRelativeLoad flag to TSFlags.
Added mayLoad and is PCRelativeLoad to LWUPC instruction.
Added isPCRelativeLoad check to processInstruction.
LGTM. Add the relevant disassembler tests when you commit.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
1848 ↗ | (On Diff #69560) | Add a space before this line for vertical separation, so it's clear the the following code is unrelated to the block above. |
lib/Target/Mips/MCTargetDesc/MipsBaseInfo.h | ||
124–126 ↗ | (On Diff #69560) | Nit: Style, capitalize the first letter in IsPCRelativeLoad. A better description is 'A Load instruction with implicit source register ($pc) with explicit offset and destination register'. |
lib/Target/Mips/MipsInstrFormats.td | ||
101 ↗ | (On Diff #69560) | See my comment about IsPCRelativeLoad in MipsBaseInfo.h |