This only adds support for ULW of an immediate address with/without a source register.
It does not include support for ULW of the address of a symbol.
Details
Diff Detail
Event Timeline
Rebased on top of D9671 (because of the similarities between them).
Made expansion take into account endianness.
Fixed handling of some offset values and added test cases for them.
Moved generation of (D)ADDu locally in order to closer match GAS' output.
Added .set nomacro warning and test.
Refactored repetitive uses of the ternary operator.
expandUlw() looks very similar to expandUlh(). Could we share code between them?
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
2627–2632 | Could you tell me the cases where this matters? loadImmediate() will usually emit the same thing here. |
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
2627–2632 | For example: ulw/ulhu $8, 0x8000($9) If we give the SrcReg to loadImmediate, we generate: ori $1, $9, 32768 If we do the addd locally, we generate: ori $1, $zero, 32768 addu $1, $1, $9 GAS generates: addiu $1, $zero, 32768 addu $1, $1, $9 I added a code comment with this example to D9671. |
expandUlw() looks very similar to expandUlh(). Could we share code between them?
That's not nearly as similar as I thought it was. I thought it was >90% similar with just the odd line or two different but it is actually ~90% different with the odd similar chunk. Sorry to mess you about but could you roll back to the separated version in the previous diff?
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
2627–2632 | Thanks. One thing to point out. This: ori $1, $zero, 32768 addu $1, $1, $9 is not equivalent to: addiu $1, $zero, 32768 addu $1, $1, $9 because addiu uses a simm16 (giving 0xffff8000) and ori uses a uimm16 (giving 0x00008000). I suspect we have a bug in loadImmediate(). GAS probably shouldn't silently change 32768 to -32768 either though. | |
test/MC/Mips/mips-expansions-bad.s | ||
40 | Nit: Indentation, likewise for the other .set's |
Could you tell me the cases where this matters? loadImmediate() will usually emit the same thing here.