This does not include support for the immediate variants of these pseudo-instructions.
Fixes llvm.org/PR20968.
Details
Diff Detail
Event Timeline
I think there's a couple bugs in this. GAS and IAS behave differently for the following input:
t1: blt $0, $0, t1 blt $0, $2, t1 blt $2, $0, t1 blt $2, $2, t1 blt $2, $3, t1 bltu $0, $0, t1 bltu $0, $2, t1 bltu $2, $0, t1 bltu $2, $2, t1 bltu $2, $3, t1 ble $0, $0, t1 ble $0, $2, t1 ble $2, $0, t1 ble $2, $2, t1 ble $2, $3, t1 bleu $0, $0, t1 bleu $0, $2, t1 bleu $2, $0, t1 bleu $2, $2, t1 bleu $2, $3, t1 bgt $0, $0, t1 bgt $0, $2, t1 bgt $2, $0, t1 bgt $2, $2, t1 bgt $2, $3, t1 bgtu $0, $0, t1 bgtu $0, $2, t1 bgtu $2, $0, t1 bgtu $2, $2, t1 bgtu $2, $3, t1 bge $0, $0, t1 bge $0, $2, t1 bge $2, $0, t1 bge $2, $2, t1 bge $2, $3, t1 bgeu $0, $0, t1 bgeu $0, $2, t1 bgeu $2, $0, t1 bgeu $2, $2, t1 bgeu $2, $3, t1
Assembling with each assembler then dissassembling the output with objdump shows several differences including missing/additional nops, different offsets (mostly caused by the nop differences), and different instructions. There's also a '...' in the disassembly for the IAS case and I'm not sure what that indicates. In each case the IAS is functionally equivalent, and in some cases is arguably better (e.g. 'blez $0, $0, t1' -> 'b t1'). However, we ought to be producing the same opcodes as GAS given the same input.
We should have a test that a warning is emitted when '.set noat' is in effect.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
211 | We should rename this to avoid ambiguity between conditional branches and compact branches | |
1602–1612 | This should probably be split into a separate patch which you can commit (with the braces nit fixed) without further review. | |
1605–1607 | Nit: Added unnecessary braces. | |
lib/Target/Mips/MipsInstrInfo.td | ||
1688 | We should rename this to avoid ambiguity between conditional branches and compact branches |
Made expansions identical with GAS (will report mismatches as bugs in GAS):
blt $0, $0 now expands to bltz $zero ble $0, $0 now expands to blez $zero bge $0, $0 now expands to bgez $zero bgt $0, $0 now expands to bgtz $zero bgtu $0, $0 now expands to bnez $zero
Renamed to avoid possible confusion with compact branches.
Added error test for using conditional branch pseudos after .set noat.
Committed suggested change as rL235601.
Rebased on top of new D8480.
Rewrote comment about what I thought were buggy expansions in GAS (turns out I was wrong).
Rebased.
LGTM with a style nit.
One thing that we will need to address soon is that my while earlier test produces the same results for clang+IAS and gcc+GAS but clang+GAS produces completely different output. Presumably there's a clang-driver bug. Still, IAS is doing the right thing so this patch is good.
Also just an interesting observation, GAS only emits three 'branch ... is always true' warnings whereas IAS emits six. It seems GAS doesn't recognise $0 >= $0 and similar as being always true. IAS is doing the right thing here.
lib/Target/Mips/AsmParser/MipsAsmParser.cpp | ||
---|---|---|
2308–2441 | Nit: Use early-return. Rather than: if (...) { ... } else if (...) { ... } else { ... } return false; Use: if (...) { ... return false; } if (...) { ... return false; } ... return false; |
Addressed LGTM style nit.
Updated the ATReg-related code comment, as a result of this refactoring.
We should rename this to avoid ambiguity between conditional branches and compact branches