Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -1888,15 +1888,25 @@ const MCOperand *DstRegOp = &Inst.getOperand(0); assert(DstRegOp->isReg() && "expected register operand kind"); + const MCOperand *SrcRegOp = &Inst.getOperand(1); + assert(SrcRegOp->isReg() && "expected register operand kind"); + const MCOperand *ImmOp = &Inst.getOperand(2); assert((ImmOp->isImm() || ImmOp->isExpr()) && "expected immediate operand kind"); if (!ImmOp->isImm()) { expandLoadAddressSym(DstRegOp, ImmOp, Is32BitImm, IDLoc, Instructions); + + unsigned DstReg = DstRegOp->getReg(); + MCInst TmpInst; + TmpInst.setOpcode(Mips::ADDu); + TmpInst.addOperand(MCOperand::CreateReg(DstReg)); + TmpInst.addOperand(MCOperand::CreateReg(DstReg)); + TmpInst.addOperand(MCOperand::CreateReg(SrcRegOp->getReg())); + Instructions.push_back(TmpInst); + return false; } - const MCOperand *SrcRegOp = &Inst.getOperand(1); - assert(SrcRegOp->isReg() && "expected register operand kind"); if (loadImmediate(ImmOp, DstRegOp, SrcRegOp, Is32BitImm, IDLoc, Instructions)) return true; Index: test/MC/Mips/mips-expansions.s =================================================================== --- test/MC/Mips/mips-expansions.s +++ test/MC/Mips/mips-expansions.s @@ -56,6 +56,52 @@ # CHECK: ori $8, $8, %lo(symbol-4369) # encoding: [0xef'A',0xee'A',0x08,0x35] # CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol) # encoding: [A,A,0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol+1) # encoding: [0x01'A',A,0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol+1) # encoding: [0x01'A',A,0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol-32766) # encoding: [0x02'A',0x80'A',0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol+1) # encoding: [0x01'A',A,0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol+2) # encoding: [0x02'A',A,0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol+1) # encoding: [0x01'A',A,0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol+4369) # encoding: [0x11'A',0x11'A',0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol-1) # encoding: [0xff'A',0xff'A',0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol-1) # encoding: [0xff'A',0xff'A',0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol+32766) # encoding: [0xfe'A',0x7f'A',0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol-1) # encoding: [0xff'A',0xff'A',0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol-2) # encoding: [0xfe'A',0xff'A',0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] +# CHECK: lui $8, %hi(symbol-1) # encoding: [0xff'A',0xff'A',0x08,0x3c] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 +# CHECK: ori $8, $8, %lo(symbol-4369) # encoding: [0xef'A',0xee'A',0x08,0x35] +# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 +# CHECK: addu $8, $8, $9 # encoding: [0x21,0x40,0x09,0x01] + # CHECK: lui $10, %hi(symbol) # encoding: [A,A,0x0a,0x3c] # CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 # CHECK: addu $10, $10, $4 # encoding: [0x21,0x50,0x44,0x01] @@ -109,6 +155,16 @@ la $8, symbol-65538 la $8, symbol-0x11111 + la $8, symbol($9) + la $8, symbol+1($9) + la $8, symbol+32770($9) + la $8, symbol+65538($9) + la $8, symbol+0x11111($9) + la $8, symbol-1($9) + la $8, symbol-32770($9) + la $8, symbol-65538($9) + la $8, symbol-0x11111($9) + .set noat lw $t2, symbol($a0) .set at