The target independent AsmParser doesn't recognise .hword, .word, .dword which are required for Mips. Currently MipsAsmParser recognises these through dispatch to MipsAsmParser::parseDataDirective. This contains equivalent logic to AsmParser::parseDirectiveValue. This patch allows reuse of AsmParser::parseDirectiveValue by making use of addAliasForDirective to support .hword, .word and .dword.
Details
Diff Detail
Event Timeline
Apologies, I missed that there is a test failure/change with this patch. Symbol h in micromips-label-test.s now looks like:
Symbol { Name: h (40) Value: 0x8 Size: 0 Binding: Local (0x0) Type: None (0x0) Other [ (0x80) STO_MIPS_MICROMIPS (0x80) ] Section: .text (0x2) }
Rather than:
Symbol { Name: h (40) Value: 0x8 Size: 0 Binding: Local (0x0) Type: None (0x0) Other: 0 Section: .text (0x2) }
I'm not familiar with STO_MIPS_MICROMIPS so I'm not sure if this is a breaking change or not.
This change isn't quite correct, as microMIPS traditionally doesn't mark inline data (.word and friends) which have a symbol associated with them as being microMIPS. The linker needs to know what symbols are microMIPS / MIPS to support interlinking the two. Inline data isn't code, so marking the symbol associated with it as microMIPS could result in buggy linkers seeing a microMIPS symbol in an address calculation, setting the lowest bit (as required for jumps to microMIPS symbols) leading to an unaligned load.
I believe this patch also needs to override EmitIntValue() as well so that the pending set of microMIPS symbols can be cleared.
Thanks for the explanation. In that case, the wrong marker is going to be produced for any of the target independent data directives that aren't handled specifically by the Mips asm parser (e.g. .4byte, .long etc) so this is definitely something that's worth fixing. That's probably a separate, parent patch to this one.
Sure, but it does sound like the handling of .4byte, .long may incorrectly set STO_MIPS_MICROMIPS in the current implementation so perhaps there's a bug to be filed.