Implemented R_MIPS_PC19_S2 relocation.
Details
Diff Detail
Event Timeline
Fixed one comment, one error message nad added check for relocation address and symbol value.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
1961–1981 | There should only be one kind of immediate (including symbols and relocations) in the parser. Adding more causes erratic behaviour that depends on the order instructions appear in the matcher table. Instead of adding additional parsers you should use custom predicates and/or renderers to restrict and/or convert the immediates parsed by the generic parser. | |
lib/Target/Mips/MipsInstrInfo.td | ||
321 | Delete this line. The generic parser should correctly parse constants and expressions. |
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
1961–1981 | Current implementation does not have method that parses immediate or symbol as instruction operand, thus it seems appropriate to implement one for pc relative instructions. |
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
1961–1981 |
Yes it does, it's ParseJumpTarget. 'ParseJumpTarget' is not meant to correspond to 'jumptarget' in the tablegen definitions (although admittedly this influenced the name since ParseImmOrAnyRegisterOrSymbol is rather long). It is meant to accept any input that could be used with the target of any branch-like/jump-like/call-like instruction. Just to illustrate the problem with having multiple parsers that accept the same input tokens: One obvious bug in ParsePCRelImm is that it will parse $sp as a symbol named '$sp' rather than as a register. If this parser function is called first it will commit the assembly matcher to treating it as a symbol, even when trying to match another instruction that could accept a GPR (MipsOperand::isGPRAsmReg() will return false because the operand is a k_Immediate). Even if you fixed that bug by adding the missing ParseAnyRegister call to ParsePCRelImm, having two identical functions will eventually lead to them diverging. |
There should only be one kind of immediate (including symbols and relocations) in the parser. Adding more causes erratic behaviour that depends on the order instructions appear in the matcher table.
Instead of adding additional parsers you should use custom predicates and/or renderers to restrict and/or convert the immediates parsed by the generic parser.