[mips] [IAS] Add support for the DLA pseudo-instruction and fix problems with DLI
authorDaniel Sanders <daniel.sanders@imgtec.com>
Mon, 17 Aug 2015 10:11:55 +0000 (10:11 +0000)
committerDaniel Sanders <daniel.sanders@imgtec.com>
Mon, 17 Aug 2015 10:11:55 +0000 (10:11 +0000)
Summary: It is the same as LA, except that it can also load 64-bit addresses and it only works on 64-bit MIPS architectures.

Reviewers: tomatabacu, seanbruno, vkalintiris

Subscribers: brooks, seanbruno, emaste, llvm-commits

Differential Revision: http://reviews.llvm.org/D9524

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245208 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
lib/Target/Mips/MCTargetDesc/MipsABIInfo.h
lib/Target/Mips/Mips64InstrInfo.td
test/MC/Mips/macro-dla.s [new file with mode: 0644]
test/MC/Mips/macro-dli.s [new file with mode: 0644]
test/MC/Mips/macro-la-bad.s
test/MC/Mips/macro-la.s
test/MC/Mips/mips64-expansions.s

index 9855bf8..26ce745 100644 (file)
@@ -184,7 +184,7 @@ class MipsAsmParser : public MCTargetAsmParser {
                          SmallVectorImpl<MCInst> &Instructions);
 
   bool loadImmediate(int64_t ImmValue, unsigned DstReg, unsigned SrcReg,
-                     bool Is32BitImm, SMLoc IDLoc,
+                     bool Is32BitImm, bool IsAddress, SMLoc IDLoc,
                      SmallVectorImpl<MCInst> &Instructions);
 
   bool loadAndAddSymbolAddress(const MCExpr *SymExpr, unsigned DstReg,
@@ -194,11 +194,10 @@ class MipsAsmParser : public MCTargetAsmParser {
   bool expandLoadImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc,
                      SmallVectorImpl<MCInst> &Instructions);
 
-  bool expandLoadAddressImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc,
-                            SmallVectorImpl<MCInst> &Instructions);
+  bool expandLoadAddress(unsigned DstReg, unsigned BaseReg,
+                         const MCOperand &Offset, bool Is32BitAddress,
+                         SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions);
 
-  bool expandLoadAddressReg(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc,
-                            SmallVectorImpl<MCInst> &Instructions);
   bool expandUncondBranchMMPseudo(MCInst &Inst, SMLoc IDLoc,
                                   SmallVectorImpl<MCInst> &Instructions);
 
@@ -391,11 +390,11 @@ public:
 
     // Initialize the set of available features.
     setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
-    
+
     // Remember the initial assembler options. The user can not modify these.
     AssemblerOptions.push_back(
         llvm::make_unique<MipsAssemblerOptions>(STI.getFeatureBits()));
-    
+
     // Create an assembler options environment for the user to modify.
     AssemblerOptions.push_back(
         llvm::make_unique<MipsAssemblerOptions>(STI.getFeatureBits()));
@@ -878,7 +877,9 @@ public:
   void addMemOperands(MCInst &Inst, unsigned N) const {
     assert(N == 2 && "Invalid number of operands!");
 
-    Inst.addOperand(MCOperand::createReg(getMemBase()->getGPR32Reg()));
+    Inst.addOperand(MCOperand::createReg(AsmParser.getABI().ArePtrs64bit()
+                                             ? getMemBase()->getGPR64Reg()
+                                             : getMemBase()->getGPR32Reg()));
 
     const MCExpr *Expr = getMemOff();
     addExpr(Inst, Expr);
@@ -1663,7 +1664,9 @@ bool MipsAsmParser::needsExpansion(MCInst &Inst) {
   case Mips::LoadImm32:
   case Mips::LoadImm64:
   case Mips::LoadAddrImm32:
+  case Mips::LoadAddrImm64:
   case Mips::LoadAddrReg32:
+  case Mips::LoadAddrReg64:
   case Mips::B_MM_Pseudo:
   case Mips::LWM_MM:
   case Mips::SWM_MM:
@@ -1696,9 +1699,24 @@ bool MipsAsmParser::expandInstruction(MCInst &Inst, SMLoc IDLoc,
   case Mips::LoadImm64:
     return expandLoadImm(Inst, false, IDLoc, Instructions);
   case Mips::LoadAddrImm32:
-    return expandLoadAddressImm(Inst, true, IDLoc, Instructions);
+  case Mips::LoadAddrImm64:
+    assert(Inst.getOperand(0).isReg() && "expected register operand kind");
+    assert((Inst.getOperand(1).isImm() || Inst.getOperand(1).isExpr()) &&
+           "expected immediate operand kind");
+
+    return expandLoadAddress(
+        Inst.getOperand(0).getReg(), Mips::NoRegister, Inst.getOperand(1),
+        Inst.getOpcode() == Mips::LoadAddrImm32, IDLoc, Instructions);
   case Mips::LoadAddrReg32:
-    return expandLoadAddressReg(Inst, true, IDLoc, Instructions);
+  case Mips::LoadAddrReg64:
+    assert(Inst.getOperand(0).isReg() && "expected register operand kind");
+    assert(Inst.getOperand(1).isReg() && "expected register operand kind");
+    assert((Inst.getOperand(2).isImm() || Inst.getOperand(2).isExpr()) &&
+           "expected immediate operand kind");
+
+    return expandLoadAddress(
+        Inst.getOperand(0).getReg(), Inst.getOperand(1).getReg(), Inst.getOperand(2),
+        Inst.getOpcode() == Mips::LoadAddrReg32, IDLoc, Instructions);
   case Mips::B_MM_Pseudo:
     return expandUncondBranchMMPseudo(Inst, IDLoc, Instructions);
   case Mips::SWM_MM:
@@ -1727,68 +1745,55 @@ bool MipsAsmParser::expandInstruction(MCInst &Inst, SMLoc IDLoc,
 }
 
 namespace {
-void emitRX(unsigned Opcode, unsigned DstReg, MCOperand Imm, SMLoc IDLoc,
+void emitRX(unsigned Opcode, unsigned Reg0, MCOperand Op1, SMLoc IDLoc,
             SmallVectorImpl<MCInst> &Instructions) {
   MCInst tmpInst;
   tmpInst.setOpcode(Opcode);
-  tmpInst.addOperand(MCOperand::createReg(DstReg));
-  tmpInst.addOperand(Imm);
+  tmpInst.addOperand(MCOperand::createReg(Reg0));
+  tmpInst.addOperand(Op1);
   tmpInst.setLoc(IDLoc);
   Instructions.push_back(tmpInst);
 }
 
-void emitRI(unsigned Opcode, unsigned DstReg, int16_t Imm, SMLoc IDLoc,
+void emitRI(unsigned Opcode, unsigned Reg0, int16_t Imm, SMLoc IDLoc,
             SmallVectorImpl<MCInst> &Instructions) {
-  emitRX(Opcode, DstReg, MCOperand::createImm(Imm), IDLoc, Instructions);
+  emitRX(Opcode, Reg0, MCOperand::createImm(Imm), IDLoc, Instructions);
 }
 
-
-void emitRRX(unsigned Opcode, unsigned DstReg, unsigned SrcReg, MCOperand Imm,
+void emitRRX(unsigned Opcode, unsigned Reg0, unsigned Reg1, MCOperand Op2,
              SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) {
   MCInst tmpInst;
   tmpInst.setOpcode(Opcode);
-  tmpInst.addOperand(MCOperand::createReg(DstReg));
-  tmpInst.addOperand(MCOperand::createReg(SrcReg));
-  tmpInst.addOperand(Imm);
+  tmpInst.addOperand(MCOperand::createReg(Reg0));
+  tmpInst.addOperand(MCOperand::createReg(Reg1));
+  tmpInst.addOperand(Op2);
   tmpInst.setLoc(IDLoc);
   Instructions.push_back(tmpInst);
 }
 
-void emitRRR(unsigned Opcode, unsigned DstReg, unsigned SrcReg,
-             unsigned SrcReg2, SMLoc IDLoc,
-             SmallVectorImpl<MCInst> &Instructions) {
-  emitRRX(Opcode, DstReg, SrcReg, MCOperand::createReg(SrcReg2), IDLoc,
+void emitRRR(unsigned Opcode, unsigned Reg0, unsigned Reg1, unsigned Reg2,
+             SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) {
+  emitRRX(Opcode, Reg0, Reg1, MCOperand::createReg(Reg2), IDLoc,
           Instructions);
 }
 
-void emitRRI(unsigned Opcode, unsigned DstReg, unsigned SrcReg, int16_t Imm,
+void emitRRI(unsigned Opcode, unsigned Reg0, unsigned Reg1, int16_t Imm,
              SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) {
-  emitRRX(Opcode, DstReg, SrcReg, MCOperand::createImm(Imm), IDLoc,
+  emitRRX(Opcode, Reg0, Reg1, MCOperand::createImm(Imm), IDLoc,
           Instructions);
 }
 
-template <int16_t ShiftAmount>
-void createLShiftOri(MCOperand Operand, unsigned RegNo, SMLoc IDLoc,
-                     SmallVectorImpl<MCInst> &Instructions) {
-  if (ShiftAmount >= 32)
-    emitRRI(Mips::DSLL32, RegNo, RegNo, ShiftAmount - 32, IDLoc, Instructions);
-  else if (ShiftAmount > 0)
-    emitRRI(Mips::DSLL, RegNo, RegNo, ShiftAmount, IDLoc, Instructions);
-
-  // There's no need for an ORi if the immediate is 0.
-  if (Operand.isImm() && Operand.getImm() == 0)
+void emitAppropriateDSLL(unsigned DstReg, unsigned SrcReg, int16_t ShiftAmount,
+                         SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) {
+  if (ShiftAmount >= 32) {
+    emitRRI(Mips::DSLL32, DstReg, SrcReg, ShiftAmount - 32, IDLoc,
+            Instructions);
     return;
+  }
 
-  emitRRX(Mips::ORi, RegNo, RegNo, Operand, IDLoc, Instructions);
-}
-
-template <unsigned ShiftAmount>
-void createLShiftOri(int64_t Value, unsigned RegNo, SMLoc IDLoc,
-                     SmallVectorImpl<MCInst> &Instructions) {
-  createLShiftOri<ShiftAmount>(MCOperand::createImm(Value), RegNo, IDLoc,
-                               Instructions);
-}
+  emitRRI(Mips::DSLL, DstReg, SrcReg, ShiftAmount, IDLoc, Instructions);
 }
+} // end anonymous namespace.
 
 bool MipsAsmParser::expandJalWithRegs(MCInst &Inst, SMLoc IDLoc,
                                       SmallVectorImpl<MCInst> &Instructions) {
@@ -1832,8 +1837,28 @@ bool MipsAsmParser::expandJalWithRegs(MCInst &Inst, SMLoc IDLoc,
   return false;
 }
 
+/// Can the value be represented by a unsigned N-bit value and a shift left?
+template<unsigned N>
+bool isShiftedUIntAtAnyPosition(uint64_t x) {
+  unsigned BitNum = findFirstSet(x);
+
+  return (x == x >> BitNum << BitNum) && isUInt<N>(x >> BitNum);
+}
+
+/// Load (or add) an immediate into a register.
+///
+/// @param ImmValue     The immediate to load.
+/// @param DstReg       The register that will hold the immediate.
+/// @param SrcReg       A register to add to the immediate or Mips::NoRegister
+///                     for a simple initialization.
+/// @param Is32BitImm   Is ImmValue 32-bit or 64-bit?
+/// @param IsAddress    True if the immediate represents an address. False if it
+///                     is an integer.
+/// @param IDLoc        Location of the immediate in the source file.
+/// @param Instructions The instructions emitted by this expansion.
 bool MipsAsmParser::loadImmediate(int64_t ImmValue, unsigned DstReg,
-                                  unsigned SrcReg, bool Is32BitImm, SMLoc IDLoc,
+                                  unsigned SrcReg, bool Is32BitImm,
+                                  bool IsAddress, SMLoc IDLoc,
                                   SmallVectorImpl<MCInst> &Instructions) {
   if (!Is32BitImm && !isGP64bit()) {
     Error(IDLoc, "instruction requires a 64-bit architecture");
@@ -1852,6 +1877,9 @@ bool MipsAsmParser::loadImmediate(int64_t ImmValue, unsigned DstReg,
     }
   }
 
+  unsigned ZeroReg = IsAddress ? ABI.GetNullPtr() : ABI.GetZeroReg();
+  unsigned AdduOp = !Is32BitImm ? Mips::DADDu : Mips::ADDu;
+
   bool UseSrcReg = false;
   if (SrcReg != Mips::NoRegister)
     UseSrcReg = true;
@@ -1866,111 +1894,129 @@ bool MipsAsmParser::loadImmediate(int64_t ImmValue, unsigned DstReg,
     TmpReg = ATReg;
   }
 
-  // FIXME: gas has a special case for values that are 000...1111, which
-  // becomes a li -1 and then a dsrl
   if (isInt<16>(ImmValue)) {
-    // li d,j => addiu d,$zero,j
     if (!UseSrcReg)
-      SrcReg = Mips::ZERO;
+      SrcReg = ZeroReg;
+
+    // This doesn't quite follow the usual ABI expectations for N32 but matches
+    // traditional assembler behaviour. N32 would normally use addiu for both
+    // integers and addresses.
+    if (IsAddress && !Is32BitImm) {
+      emitRRI(Mips::DADDiu, DstReg, SrcReg, ImmValue, IDLoc, Instructions);
+      return false;
+    }
+
     emitRRI(Mips::ADDiu, DstReg, SrcReg, ImmValue, IDLoc, Instructions);
-  } else if (isUInt<16>(ImmValue)) {
-    // li d,j => ori d,$zero,j
+    return false;
+  }
+
+  if (isUInt<16>(ImmValue)) {
     unsigned TmpReg = DstReg;
     if (SrcReg == DstReg) {
-      unsigned ATReg = getATReg(IDLoc);
-      if (!ATReg)
+      TmpReg = getATReg(IDLoc);
+      if (!TmpReg)
         return true;
-      TmpReg = ATReg;
     }
 
-    emitRRI(Mips::ORi, TmpReg, Mips::ZERO, ImmValue, IDLoc, Instructions);
+    emitRRI(Mips::ORi, TmpReg, ZeroReg, ImmValue, IDLoc, Instructions);
     if (UseSrcReg)
-      emitRRR(Mips::ADDu, DstReg, TmpReg, SrcReg, IDLoc, Instructions);
-  } else if (isInt<32>(ImmValue) || isUInt<32>(ImmValue)) {
+      emitRRR(ABI.GetPtrAdduOp(), DstReg, TmpReg, SrcReg, IDLoc, Instructions);
+    return false;
+  }
+
+  if (isInt<32>(ImmValue) || isUInt<32>(ImmValue)) {
     warnIfNoMacro(IDLoc);
 
-    // For all other values which are representable as a 32-bit integer:
-    // li d,j => lui d,hi16(j)
-    //           ori d,d,lo16(j)
     uint16_t Bits31To16 = (ImmValue >> 16) & 0xffff;
     uint16_t Bits15To0 = ImmValue & 0xffff;
 
     if (!Is32BitImm && !isInt<32>(ImmValue)) {
-      // For DLI, expand to an ORi instead of a LUi to avoid sign-extending the
+      // Traditional behaviour seems to special case this particular value. It's
+      // not clear why other masks are handled differently.
+      if (ImmValue == 0xffffffff) {
+        emitRI(Mips::LUi, TmpReg, 0xffff, IDLoc, Instructions);
+        emitRRI(Mips::DSRL32, TmpReg, TmpReg, 0, IDLoc, Instructions);
+        if (UseSrcReg)
+          emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, Instructions);
+        return false;
+      }
+
+      // Expand to an ORi instead of a LUi to avoid sign-extending into the
       // upper 32 bits.
-      emitRRI(Mips::ORi, TmpReg, Mips::ZERO, Bits31To16, IDLoc, Instructions);
+      emitRRI(Mips::ORi, TmpReg, ZeroReg, Bits31To16, IDLoc, Instructions);
       emitRRI(Mips::DSLL, TmpReg, TmpReg, 16, IDLoc, Instructions);
-    } else
-      emitRI(Mips::LUi, TmpReg, Bits31To16, IDLoc, Instructions);
-    createLShiftOri<0>(Bits15To0, TmpReg, IDLoc, Instructions);
+      if (Bits15To0)
+        emitRRI(Mips::ORi, TmpReg, TmpReg, Bits15To0, IDLoc, Instructions);
+      if (UseSrcReg)
+        emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, Instructions);
+      return false;
+    }
 
+    emitRI(Mips::LUi, TmpReg, Bits31To16, IDLoc, Instructions);
+    if (Bits15To0)
+      emitRRI(Mips::ORi, TmpReg, TmpReg, Bits15To0, IDLoc, Instructions);
     if (UseSrcReg)
-      createAddu(DstReg, TmpReg, SrcReg, !Is32BitImm, Instructions);
-
-  } else if ((ImmValue & (0xffffLL << 48)) == 0) {
-    warnIfNoMacro(IDLoc);
+      emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, Instructions);
+    return false;
+  }
 
-    //            <-------  lo32 ------>
-    // <-------  hi32 ------>
-    // <- hi16 ->             <- lo16 ->
-    //  _________________________________
-    // |          |          |          |
-    // | 16-bits  | 16-bits  | 16-bits  |
-    // |__________|__________|__________|
-    //
-    // For any 64-bit value that is representable as a 48-bit integer:
-    // li d,j => lui d,hi16(j)
-    //           ori d,d,hi16(lo32(j))
-    //           dsll d,d,16
-    //           ori d,d,lo16(lo32(j))
-    uint16_t Bits47To32 = (ImmValue >> 32) & 0xffff;
-    uint16_t Bits31To16 = (ImmValue >> 16) & 0xffff;
-    uint16_t Bits15To0 = ImmValue & 0xffff;
+  if (isShiftedUIntAtAnyPosition<16>(ImmValue)) {
+    if (Is32BitImm) {
+      Error(IDLoc, "instruction requires a 32-bit immediate");
+      return true;
+    }
 
-    emitRI(Mips::LUi, TmpReg, Bits47To32, IDLoc, Instructions);
-    createLShiftOri<0>(Bits31To16, TmpReg, IDLoc, Instructions);
-    createLShiftOri<16>(Bits15To0, TmpReg, IDLoc, Instructions);
+    // Traditionally, these immediates are shifted as little as possible and as
+    // such we align the most significant bit to bit 15 of our temporary.
+    unsigned FirstSet = findFirstSet((uint64_t)ImmValue);
+    unsigned LastSet = findLastSet((uint64_t)ImmValue);
+    unsigned ShiftAmount = FirstSet - (15 - (LastSet - FirstSet));
+    uint16_t Bits = (ImmValue >> ShiftAmount) & 0xffff;
+    emitRRI(Mips::ORi, TmpReg, ZeroReg, Bits, IDLoc, Instructions);
+    emitRRI(Mips::DSLL, TmpReg, TmpReg, ShiftAmount, IDLoc, Instructions);
 
     if (UseSrcReg)
-      createAddu(DstReg, TmpReg, SrcReg, !Is32BitImm, Instructions);
+      emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, Instructions);
 
-  } else {
-    warnIfNoMacro(IDLoc);
+    return false;
+  }
 
-    // <-------  hi32 ------> <-------  lo32 ------>
-    // <- hi16 ->                        <- lo16 ->
-    //  ___________________________________________
-    // |          |          |          |          |
-    // | 16-bits  | 16-bits  | 16-bits  | 16-bits  |
-    // |__________|__________|__________|__________|
-    //
-    // For all other values which are representable as a 64-bit integer:
-    // li d,j => lui d,hi16(j)
-    //           ori d,d,lo16(hi32(j))
-    //           dsll d,d,16
-    //           ori d,d,hi16(lo32(j))
-    //           dsll d,d,16
-    //           ori d,d,lo16(lo32(j))
-    uint16_t Bits63To48 = (ImmValue >> 48) & 0xffff;
-    uint16_t Bits47To32 = (ImmValue >> 32) & 0xffff;
-    uint16_t Bits31To16 = (ImmValue >> 16) & 0xffff;
-    uint16_t Bits15To0 = ImmValue & 0xffff;
+  warnIfNoMacro(IDLoc);
 
-    emitRI(Mips::LUi, TmpReg, Bits63To48, IDLoc, Instructions);
-    createLShiftOri<0>(Bits47To32, TmpReg, IDLoc, Instructions);
+  // The remaining case is packed with a sequence of dsll and ori with zeros
+  // being omitted and any neighbouring dsll's being coalesced.
+  // The highest 32-bit's are equivalent to a 32-bit immediate load.
 
-    // When Bits31To16 is 0, do a left shift of 32 bits instead of doing
-    // two left shifts of 16 bits.
-    if (Bits31To16 == 0) {
-      createLShiftOri<32>(Bits15To0, TmpReg, IDLoc, Instructions);
-    } else {
-      createLShiftOri<16>(Bits31To16, TmpReg, IDLoc, Instructions);
-      createLShiftOri<16>(Bits15To0, TmpReg, IDLoc, Instructions);
+  // Load bits 32-63 of ImmValue into bits 0-31 of the temporary register.
+  if (loadImmediate(ImmValue >> 32, TmpReg, Mips::NoRegister, true, false,
+                    IDLoc, Instructions))
+    return false;
+
+  // Shift and accumulate into the register. If a 16-bit chunk is zero, then
+  // skip it and defer the shift to the next chunk.
+  unsigned ShiftCarriedForwards = 16;
+  for (int BitNum = 16; BitNum >= 0; BitNum -= 16) {
+    uint16_t ImmChunk = (ImmValue >> BitNum) & 0xffff;
+
+    if (ImmChunk != 0) {
+      emitAppropriateDSLL(TmpReg, TmpReg, ShiftCarriedForwards, IDLoc,
+                          Instructions);
+      emitRRI(Mips::ORi, TmpReg, TmpReg, ImmChunk, IDLoc, Instructions);
+      ShiftCarriedForwards = 0;
     }
 
-    if (UseSrcReg)
-      createAddu(DstReg, TmpReg, SrcReg, !Is32BitImm, Instructions);
+    ShiftCarriedForwards += 16;
   }
+  ShiftCarriedForwards -= 16;
+
+  // Finish any remaining shifts left by trailing zeros.
+  if (ShiftCarriedForwards)
+    emitAppropriateDSLL(TmpReg, TmpReg, ShiftCarriedForwards, IDLoc,
+                        Instructions);
+
+  if (UseSrcReg)
+    emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, Instructions);
+
   return false;
 }
 
@@ -1982,63 +2028,38 @@ bool MipsAsmParser::expandLoadImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc,
   assert(DstRegOp.isReg() && "expected register operand kind");
 
   if (loadImmediate(ImmOp.getImm(), DstRegOp.getReg(), Mips::NoRegister,
-                    Is32BitImm, IDLoc, Instructions))
+                    Is32BitImm, false, IDLoc, Instructions))
     return true;
 
   return false;
 }
 
-bool
-MipsAsmParser::expandLoadAddressReg(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc,
-                                    SmallVectorImpl<MCInst> &Instructions) {
-  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()) {
-    if (loadAndAddSymbolAddress(ImmOp.getExpr(), DstRegOp.getReg(),
-                                SrcRegOp.getReg(), Is32BitImm, IDLoc,
-                                Instructions))
-      return true;
-
-    return false;
-  }
-
-  if (loadImmediate(ImmOp.getImm(), DstRegOp.getReg(), SrcRegOp.getReg(),
-                    Is32BitImm, IDLoc, Instructions))
+bool MipsAsmParser::expandLoadAddress(unsigned DstReg, unsigned BaseReg,
+                                      const MCOperand &Offset,
+                                      bool Is32BitAddress, SMLoc IDLoc,
+                                      SmallVectorImpl<MCInst> &Instructions) {
+  // la can't produce a usable address when addresses are 64-bit.
+  if (Is32BitAddress && ABI.ArePtrs64bit()) {
+    // FIXME: Demote this to a warning and continue as if we had 'dla' instead.
+    //        We currently can't do this because we depend on the equality
+    //        operator and N64 can end up with a GPR32/GPR64 mismatch.
+    Error(IDLoc, "la used to load 64-bit address");
+    // Continue as if we had 'dla' instead.
+    Is32BitAddress = false;
+  }
+
+  // dla requires 64-bit addresses.
+  if (!Is32BitAddress && !ABI.ArePtrs64bit()) {
+    Error(IDLoc, "instruction requires a 64-bit architecture");
     return true;
-
-  return false;
-}
-
-bool
-MipsAsmParser::expandLoadAddressImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc,
-                                    SmallVectorImpl<MCInst> &Instructions) {
-  const MCOperand &DstRegOp = Inst.getOperand(0);
-  assert(DstRegOp.isReg() && "expected register operand kind");
-
-  const MCOperand &ImmOp = Inst.getOperand(1);
-  assert((ImmOp.isImm() || ImmOp.isExpr()) &&
-         "expected immediate operand kind");
-  if (!ImmOp.isImm()) {
-    if (loadAndAddSymbolAddress(ImmOp.getExpr(), DstRegOp.getReg(),
-                                Mips::NoRegister, Is32BitImm, IDLoc,
-                                Instructions))
-      return true;
-
-    return false;
   }
 
-  if (loadImmediate(ImmOp.getImm(), DstRegOp.getReg(), Mips::NoRegister,
-                    Is32BitImm, IDLoc, Instructions))
-    return true;
+  if (!Offset.isImm())
+    return loadAndAddSymbolAddress(Offset.getExpr(), DstReg, BaseReg,
+                                   Is32BitAddress, IDLoc, Instructions);
 
-  return false;
+  return loadImmediate(Offset.getImm(), DstReg, BaseReg, Is32BitAddress, true,
+                       IDLoc, Instructions);
 }
 
 bool MipsAsmParser::loadAndAddSymbolAddress(
@@ -2046,10 +2067,9 @@ bool MipsAsmParser::loadAndAddSymbolAddress(
     SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) {
   warnIfNoMacro(IDLoc);
 
-  if (Is32BitSym && isABI_N64())
-    Warning(IDLoc, "instruction loads the 32-bit address of a 64-bit symbol");
-
-  MCInst tmpInst;
+  // FIXME: The way we're handling symbols right now prevents simple expressions
+  //        like foo+8. We'll be able to fix this once our unary operators (%hi
+  //        and similar) are treated as operators rather than as fixup types.
   const MCSymbolRefExpr *Symbol = cast<MCSymbolRefExpr>(SymExpr);
   const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::create(
       &Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_ABS_HI, getContext());
@@ -2058,55 +2078,94 @@ bool MipsAsmParser::loadAndAddSymbolAddress(
 
   bool UseSrcReg = SrcReg != Mips::NoRegister;
 
-  unsigned TmpReg = DstReg;
-  if (UseSrcReg && (DstReg == SrcReg)) {
-    // At this point we need AT to perform the expansions and we exit if it is
-    // not available.
+  // This is the 64-bit symbol address expansion.
+  if (ABI.ArePtrs64bit() && isGP64bit()) {
+    // We always need AT for the 64-bit expansion.
+    // If it is not available we exit.
     unsigned ATReg = getATReg(IDLoc);
     if (!ATReg)
       return true;
-    TmpReg = ATReg;
-  }
 
-  if (!Is32BitSym) {
-    // If it's a 64-bit architecture, expand to:
-    // la d,sym => lui  d,highest(sym)
-    //             ori  d,d,higher(sym)
-    //             dsll d,d,16
-    //             ori  d,d,hi16(sym)
-    //             dsll d,d,16
-    //             ori  d,d,lo16(sym)
     const MCSymbolRefExpr *HighestExpr = MCSymbolRefExpr::create(
         &Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_HIGHEST, getContext());
     const MCSymbolRefExpr *HigherExpr = MCSymbolRefExpr::create(
         &Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_HIGHER, getContext());
 
-    tmpInst.setOpcode(Mips::LUi);
-    tmpInst.addOperand(MCOperand::createReg(TmpReg));
-    tmpInst.addOperand(MCOperand::createExpr(HighestExpr));
-    Instructions.push_back(tmpInst);
+    if (UseSrcReg && (DstReg == SrcReg)) {
+      // If $rs is the same as $rd:
+      // (d)la $rd, sym($rd) => lui    $at, %highest(sym)
+      //                        daddiu $at, $at, %higher(sym)
+      //                        dsll   $at, $at, 16
+      //                        daddiu $at, $at, %hi(sym)
+      //                        dsll   $at, $at, 16
+      //                        daddiu $at, $at, %lo(sym)
+      //                        daddu  $rd, $at, $rd
+      emitRX(Mips::LUi, ATReg, MCOperand::createExpr(HighestExpr), IDLoc,
+             Instructions);
+      emitRRX(Mips::DADDiu, ATReg, ATReg, MCOperand::createExpr(HigherExpr),
+              IDLoc, Instructions);
+      emitRRI(Mips::DSLL, ATReg, ATReg, 16, IDLoc, Instructions);
+      emitRRX(Mips::DADDiu, ATReg, ATReg, MCOperand::createExpr(HiExpr), IDLoc,
+              Instructions);
+      emitRRI(Mips::DSLL, ATReg, ATReg, 16, IDLoc, Instructions);
+      emitRRX(Mips::DADDiu, ATReg, ATReg, MCOperand::createExpr(LoExpr), IDLoc,
+              Instructions);
+      emitRRR(Mips::DADDu, DstReg, ATReg, SrcReg, IDLoc, Instructions);
 
-    createLShiftOri<0>(MCOperand::createExpr(HigherExpr), TmpReg, SMLoc(),
-                       Instructions);
-    createLShiftOri<16>(MCOperand::createExpr(HiExpr), TmpReg, SMLoc(),
-                        Instructions);
-    createLShiftOri<16>(MCOperand::createExpr(LoExpr), TmpReg, SMLoc(),
-                        Instructions);
-  } else {
-    // Otherwise, expand to:
-    // la d,sym => lui  d,hi16(sym)
-    //             ori  d,d,lo16(sym)
-    tmpInst.setOpcode(Mips::LUi);
-    tmpInst.addOperand(MCOperand::createReg(TmpReg));
-    tmpInst.addOperand(MCOperand::createExpr(HiExpr));
-    Instructions.push_back(tmpInst);
-
-    emitRRX(Mips::ADDiu, TmpReg, TmpReg, MCOperand::createExpr(LoExpr), SMLoc(),
+      return false;
+    }
+
+    // Otherwise, if the $rs is different from $rd or if $rs isn't specified:
+    // (d)la $rd, sym/sym($rs) => lui    $rd, %highest(sym)
+    //                            lui    $at, %hi(sym)
+    //                            daddiu $rd, $rd, %higher(sym)
+    //                            daddiu $at, $at, %lo(sym)
+    //                            dsll32 $rd, $rd, 0
+    //                            daddu  $rd, $rd, $at
+    //                            (daddu  $rd, $rd, $rs)
+    emitRX(Mips::LUi, DstReg, MCOperand::createExpr(HighestExpr), IDLoc,
+           Instructions);
+    emitRX(Mips::LUi, ATReg, MCOperand::createExpr(HiExpr), IDLoc,
+           Instructions);
+    emitRRX(Mips::DADDiu, DstReg, DstReg, MCOperand::createExpr(HigherExpr),
+            IDLoc, Instructions);
+    emitRRX(Mips::DADDiu, ATReg, ATReg, MCOperand::createExpr(LoExpr), IDLoc,
             Instructions);
+    emitRRI(Mips::DSLL32, DstReg, DstReg, 0, IDLoc, Instructions);
+    emitRRR(Mips::DADDu, DstReg, DstReg, ATReg, IDLoc, Instructions);
+    if (UseSrcReg)
+      emitRRR(Mips::DADDu, DstReg, DstReg, SrcReg, IDLoc, Instructions);
+
+    return false;
+  }
+
+  // And now, the 32-bit symbol address expansion:
+  // If $rs is the same as $rd:
+  // (d)la $rd, sym($rd)     => lui   $at, %hi(sym)
+  //                            ori   $at, $at, %lo(sym)
+  //                            addu  $rd, $at, $rd
+  // Otherwise, if the $rs is different from $rd or if $rs isn't specified:
+  // (d)la $rd, sym/sym($rs) => lui   $rd, %hi(sym)
+  //                            ori   $rd, $rd, %lo(sym)
+  //                            (addu $rd, $rd, $rs)
+  unsigned TmpReg = DstReg;
+  if (UseSrcReg && (DstReg == SrcReg)) {
+    // If $rs is the same as $rd, we need to use AT.
+    // If it is not available we exit.
+    unsigned ATReg = getATReg(IDLoc);
+    if (!ATReg)
+      return true;
+    TmpReg = ATReg;
   }
 
+  emitRX(Mips::LUi, TmpReg, MCOperand::createExpr(HiExpr), IDLoc, Instructions);
+  emitRRX(Mips::ADDiu, TmpReg, TmpReg, MCOperand::createExpr(LoExpr), IDLoc,
+          Instructions);
+
   if (UseSrcReg)
-    createAddu(DstReg, TmpReg, SrcReg, !Is32BitSym, Instructions);
+    emitRRR(Mips::ADDu, DstReg, TmpReg, SrcReg, IDLoc, Instructions);
+  else
+    assert(DstReg == TmpReg);
 
   return false;
 }
@@ -2189,8 +2248,8 @@ bool MipsAsmParser::expandBranchImm(MCInst &Inst, SMLoc IDLoc,
     if (!ATReg)
       return true;
 
-    if (loadImmediate(ImmValue, ATReg, Mips::NoRegister, !isGP64bit(), IDLoc,
-                      Instructions))
+    if (loadImmediate(ImmValue, ATReg, Mips::NoRegister, !isGP64bit(), true,
+                      IDLoc, Instructions))
       return true;
 
     MCInst BranchInst;
@@ -2562,7 +2621,7 @@ bool MipsAsmParser::expandUlhu(MCInst &Inst, SMLoc IDLoc,
     LoadedOffsetInAT = true;
 
     if (loadImmediate(OffsetValue, ATReg, Mips::NoRegister, !ABI.ArePtrs64bit(),
-                      IDLoc, Instructions))
+                      true, IDLoc, Instructions))
       return true;
 
     // NOTE: We do this (D)ADDu here instead of doing it in loadImmediate()
@@ -2654,7 +2713,7 @@ bool MipsAsmParser::expandUlw(MCInst &Inst, SMLoc IDLoc,
     warnIfNoMacro(IDLoc);
 
     if (loadImmediate(OffsetValue, ATReg, Mips::NoRegister, !ABI.ArePtrs64bit(),
-                      IDLoc, Instructions))
+                      true, IDLoc, Instructions))
       return true;
 
     // NOTE: We do this (D)ADDu here instead of doing it in loadImmediate()
@@ -3264,7 +3323,7 @@ MipsAsmParser::parseMemOperand(OperandVector &Operands) {
     const AsmToken &Tok = Parser.getTok(); // Get the next token.
     if (Tok.isNot(AsmToken::LParen)) {
       MipsOperand &Mnemonic = static_cast<MipsOperand &>(*Operands[0]);
-      if (Mnemonic.getToken() == "la") {
+      if (Mnemonic.getToken() == "la" || Mnemonic.getToken() == "dla") {
         SMLoc E =
             SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
         Operands.push_back(MipsOperand::CreateImm(IdVal, S, E, *this));
index 14c5a34..bd1feb8 100644 (file)
@@ -107,6 +107,10 @@ unsigned MipsABIInfo::GetNullPtr() const {
   return ArePtrs64bit() ? Mips::ZERO_64 : Mips::ZERO;
 }
 
+unsigned MipsABIInfo::GetZeroReg() const {
+  return AreGprs64bit() ? Mips::ZERO_64 : Mips::ZERO;
+}
+
 unsigned MipsABIInfo::GetPtrAdduOp() const {
   return ArePtrs64bit() ? Mips::DADDu : Mips::ADDu;
 }
index 926da90..cb3df44 100644 (file)
@@ -67,10 +67,12 @@ public:
   unsigned GetFramePtr() const;
   unsigned GetBasePtr() const;
   unsigned GetNullPtr() const;
+  unsigned GetZeroReg() const;
   unsigned GetPtrAdduOp() const;
   unsigned GetPtrAddiuOp() const;
   unsigned GetGPRMoveOp() const;
   inline bool ArePtrs64bit() const { return IsN64(); }
+  inline bool AreGprs64bit() const { return IsN32() || IsN64(); }
 
   unsigned GetEhDataReg(unsigned I) const;
 };
index fdf0530..0656a3b 100644 (file)
@@ -630,3 +630,8 @@ class LoadImmediate64<string instr_asm, Operand Od, RegisterOperand RO> :
   MipsAsmPseudoInst<(outs RO:$rt), (ins Od:$imm64),
                      !strconcat(instr_asm, "\t$rt, $imm64")> ;
 def LoadImm64 : LoadImmediate64<"dli", imm64, GPR64Opnd>;
+
+def LoadAddrReg64 : MipsAsmPseudoInst<(outs GPR64Opnd:$rt), (ins mem:$addr),
+                                       "dla\t$rt, $addr">;
+def LoadAddrImm64 : MipsAsmPseudoInst<(outs GPR64Opnd:$rt), (ins imm64:$imm64),
+                                       "dla\t$rt, $imm64">;
diff --git a/test/MC/Mips/macro-dla.s b/test/MC/Mips/macro-dla.s
new file mode 100644 (file)
index 0000000..9ded742
--- /dev/null
@@ -0,0 +1,684 @@
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r2 | \
+# RUN:   FileCheck %s
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r6 | \
+# RUN:   FileCheck %s
+
+bits_32_to_47_0x0000:           # CHECK-LABEL: bits_32_to_47_0x0000:
+dla $5, 0x0000000000000001      # CHECK: daddiu $5, $zero, 1         # encoding: [0x64,0x05,0x00,0x01]
+dla $5, 0x0000000000000002      # CHECK: daddiu $5, $zero, 2         # encoding: [0x64,0x05,0x00,0x02]
+dla $5, 0x0000000000004000      # CHECK: daddiu $5, $zero, 16384     # encoding: [0x64,0x05,0x40,0x00]
+dla $5, 0x0000000000008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+dla $5, 0x00000000ffff8000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x00000000ffffc000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 49152           # encoding: [0x34,0xa5,0xc0,0x00]
+dla $5, 0x00000000fffffffe      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 65534           # encoding: [0x34,0xa5,0xff,0xfe]
+dla $5, 0x00000000ffffffff      # CHECK: lui $5, 65535               # encoding: [0x3c,0x05,0xff,0xff]
+                                # CHECK: dsrl32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3e]
+dla $5, 0x0000000000010000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+dla $5, 0x0000000000020000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+dla $5, 0x0000000040000000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+dla $5, 0x0000000080000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x00000000c0000000      # CHECK: ori $5, $zero, 49152        # encoding: [0x34,0x05,0xc0,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x00000000fffe0000      # CHECK: ori $5, $zero, 65534        # encoding: [0x34,0x05,0xff,0xfe]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x00000000ffff0000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000000000010001      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000000020001      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000040000001      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000080000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000000010002      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000000020002      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000040000002      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000080000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000000014000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000000024000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000040004000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000080004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000000018000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000000028000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000040008000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000080008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x00000000c0008000      # CHECK: ori $5, $zero, 49152        # encoding: [0x34,0x05,0xc0,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x00000000fffe8000      # CHECK: ori $5, $zero, 65534        # encoding: [0x34,0x05,0xff,0xfe]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x00000000ffff8000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x0001:           # CHECK-LABEL: bits_32_to_47_0x0001:
+dla $5, 0x0000000100000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dla $5, 0x0000000100000001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000100000002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000100004000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000100008000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000100010000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000000100010001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000100010002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000100014000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000100018000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000100020000      # CHECK: ori $5, $zero, 32769        # encoding: [0x34,0x05,0x80,0x01]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dla $5, 0x0000000100020001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000100020002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000100024000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000100028000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000140000000      # CHECK: ori $5, $zero, 40960        # encoding: [0x34,0x05,0xa0,0x00]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dla $5, 0x0000000140000001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000140000002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000140004000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000140008000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000180000000      # CHECK: ori $5, $zero, 49152        # encoding: [0x34,0x05,0xc0,0x00]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dla $5, 0x0000000180000001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000180000002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000180004000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000180008000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x0002:           # CHECK-LABEL: bits_32_to_47_0x0002:
+dla $5, 0x0000000200000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 18             # encoding: [0x00,0x05,0x2c,0xb8]
+dla $5, 0x0000000200000001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000200000002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000200004000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000200008000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000200010000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000000200010001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000200010002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000200014000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000200018000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000200020000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000000200020001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000200020002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000200024000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000200028000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000240000000      # CHECK: ori $5, $zero, 36864        # encoding: [0x34,0x05,0x90,0x00]
+                                # CHECK: dsll $5, $5, 18             # encoding: [0x00,0x05,0x2c,0xb8]
+dla $5, 0x0000000240000001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000240000002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000240004000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000240008000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000000280000000      # CHECK: ori $5, $zero, 40960        # encoding: [0x34,0x05,0xa0,0x00]
+                                # CHECK: dsll $5, $5, 18             # encoding: [0x00,0x05,0x2c,0xb8]
+dla $5, 0x0000000280000001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000000280000002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000000280004000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000000280008000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x4000:           # CHECK-LABEL: bits_32_to_47_0x4000:
+dla $5, 0x0000400000000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 31             # encoding: [0x00,0x05,0x2f,0xf8]
+dla $5, 0x0000400000000001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000400000000002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000400000004000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000400000008000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000400000010000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000400000010001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000400000010002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000400000014000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000400000018000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000400000020000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000400000020001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000400000020002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000400000024000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000400000028000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000400040000000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000400040000001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000400040000002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000400040004000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000400040008000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000400080000000      # CHECK: ori $5, $zero, 32769        # encoding: [0x34,0x05,0x80,0x01]
+                                # CHECK: dsll $5, $5, 31             # encoding: [0x00,0x05,0x2f,0xf8]
+dla $5, 0x0000400080000001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000400080000002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000400080004000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000400080008000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x8000:           # CHECK-LABEL: bits_32_to_47_0x8000:
+dla $5, 0x0000800000000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 32             # encoding: [0x00,0x05,0x28,0x3c]
+dla $5, 0x0000800000000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000800000000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000800000004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000800000008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000800000010000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000800000010001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000800000010002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000800000014000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000800000018000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000800000020000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000800000020001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000800000020002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000800000024000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000800000028000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000800040000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000800040000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000800040000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000800040004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000800040008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0000800080000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dla $5, 0x0000800080000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dla $5, 0x0000800080000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dla $5, 0x0000800080004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dla $5, 0x0000800080008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+# Only test a few with bits 48-63 non-zero. It just adds an lui to the cases we've already done.
+dla $5, 0x0001800080008000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x0002800080008000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x4000800080008000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dla $5, 0x8000800080008000      # CHECK: lui $5, 32768               # encoding: [0x3c,0x05,0x80,0x00]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+
+dla $5, 0x000000000($6)         # CHECK: daddiu $5, $6, 0            # encoding: [0x64,0xc5,0x00,0x00]
+dla $5, 0x00000001($6)          # CHECK: daddiu $5, $6, 1            # encoding: [0x64,0xc5,0x00,0x01]
+dla $5, 0x00000002($6)          # CHECK: daddiu $5, $6, 2            # encoding: [0x64,0xc5,0x00,0x02]
+dla $5, 0x00004000($6)          # CHECK: daddiu $5, $6, 16384        # encoding: [0x64,0xc5,0x40,0x00]
+dla $5, 0x00008000($6)          # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: daddu $5, $5, $6            # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0xffffffff($6)          # CHECK: lui     $5, 65535           # encoding: [0x3c,0x05,0xff,0xff]
+                                # CHECK: dsrl32  $5, $5, 0           # encoding: [0x00,0x05,0x28,0x3e]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0xfffffffe($6)          # CHECK: ori     $5, $zero, 65535    # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori     $5, $5, 65534       # encoding: [0x34,0xa5,0xff,0xfe]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0xffffc000($6)          # CHECK: ori     $5, $zero, 65535    # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori     $5, $5, 49152       # encoding: [0x34,0xa5,0xc0,0x00]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0xffff8000($6)          # CHECK: ori     $5, $zero, 65535    # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori     $5, $5, 32768       # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+
+dla $5, 0x00010000($6)          # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: daddu $5, $5, $6            # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0x00020000($6)          # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: daddu $5, $5, $6            # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0x40000000($6)          # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: daddu $5, $5, $6            # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0x80000000($6)          # CHECK: ori     $5, $zero, 32768    # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0xffff0000($6)          # CHECK: ori     $5, $zero, 65535    # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0xfffe0000($6)          # CHECK: ori     $5, $zero, 65534    # encoding: [0x34,0x05,0xff,0xfe]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0xc0000000($6)          # CHECK: ori     $5, $zero, 49152    # encoding: [0x34,0x05,0xc0,0x00]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+dla $5, 0x80000000($6)          # CHECK: ori     $5, $zero, 32768    # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll    $5, $5, 16          # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: daddu   $5, $5, $6          # encoding: [0x00,0xa6,0x28,0x2d]
+
+dla $5, 0x00010001($6)          # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: daddu $5, $5, $6            # encoding: [0x00,0xa6,0x28,0x2d]
+# There are no further interesting immediates.
+
+dla $6, 0x00000001($6)          # CHECK: daddiu $6, $6, 1            # encoding: [0x64,0xc6,0x00,0x01]
+dla $6, 0x00000002($6)          # CHECK: daddiu $6, $6, 2            # encoding: [0x64,0xc6,0x00,0x02]
+dla $6, 0x00004000($6)          # CHECK: daddiu $6, $6, 16384        # encoding: [0x64,0xc6,0x40,0x00]
+dla $6, 0x00008000($6)          # CHECK: ori $1, $zero, 32768        # encoding: [0x34,0x01,0x80,0x00]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0xffffffff($6)          # CHECK: lui     $1, 65535           # encoding: [0x3c,0x01,0xff,0xff]
+                                # CHECK: dsrl32  $1, $1, 0           # encoding: [0x00,0x01,0x08,0x3e]
+                                # CHECK: daddu   $6, $1, $6          # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0xfffffffe($6)          # CHECK: ori     $1, $zero, 65535    # encoding: [0x34,0x01,0xff,0xff]
+                                # CHECK: dsll    $1, $1, 16          # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: ori     $1, $1, 65534       # encoding: [0x34,0x21,0xff,0xfe]
+                                # CHECK: daddu   $6, $1, $6          # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0xffffc000($6)          # CHECK: ori     $1, $zero, 65535    # encoding: [0x34,0x01,0xff,0xff]
+                                # CHECK: dsll    $1, $1, 16          # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: ori     $1, $1, 49152       # encoding: [0x34,0x21,0xc0,0x00]
+                                # CHECK: daddu   $6, $1, $6          # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0xffff8000($6)          # CHECK: ori     $1, $zero, 65535    # encoding: [0x34,0x01,0xff,0xff]
+                                # CHECK: dsll    $1, $1, 16          # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: ori     $1, $1, 32768       # encoding: [0x34,0x21,0x80,0x00]
+                                # CHECK: daddu   $6, $1, $6          # encoding: [0x00,0x26,0x30,0x2d]
+
+dla $6, 0x00010000($6)          # CHECK: lui $1, 1                   # encoding: [0x3c,0x01,0x00,0x01]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0x00020000($6)          # CHECK: lui $1, 2                   # encoding: [0x3c,0x01,0x00,0x02]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0x40000000($6)          # CHECK: lui $1, 16384               # encoding: [0x3c,0x01,0x40,0x00]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0x80000000($6)          # CHECK: ori   $1, $zero, 32768      # encoding: [0x34,0x01,0x80,0x00]
+                                # CHECK: dsll  $1, $1, 16            # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0xffff0000($6)          # CHECK: ori   $1, $zero, 65535      # encoding: [0x34,0x01,0xff,0xff]
+                                # CHECK: dsll  $1, $1, 16            # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0xfffe0000($6)          # CHECK: ori   $1, $zero, 65534      # encoding: [0x34,0x01,0xff,0xfe]
+                                # CHECK: dsll  $1, $1, 16            # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0xc0000000($6)          # CHECK: ori   $1, $zero, 49152      # encoding: [0x34,0x01,0xc0,0x00]
+                                # CHECK: dsll  $1, $1, 16            # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+dla $6, 0x80000000($6)          # CHECK: ori   $1, $zero, 32768      # encoding: [0x34,0x01,0x80,0x00]
+                                # CHECK: dsll  $1, $1, 16            # encoding: [0x00,0x01,0x0c,0x38]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+
+dla $6, 0x00010001($6)          # CHECK: lui $1, 1                   # encoding: [0x3c,0x01,0x00,0x01]
+                                # CHECK: ori $1, $1, 1               # encoding: [0x34,0x21,0x00,0x01]
+                                # CHECK: daddu $6, $1, $6            # encoding: [0x00,0x26,0x30,0x2d]
+# There are no further interesting immediates.
+
+symbol:           # CHECK-LABEL: symbol:
+.extern extern_sym
+.option pic0
+dla $5, extern_sym     # CHECK: lui $5, %highest(extern_sym)       # encoding: [0x3c,0x05,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
+                       # CHECK: lui $1, %hi(extern_sym)            # encoding: [0x3c,0x01,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
+                       # CHECK: daddiu $5, $5, %higher(extern_sym) # encoding: [0x64,0xa5,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
+                       # CHECK: daddiu $1, $1, %lo(extern_sym)     # encoding: [0x64,0x21,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
+                       # CHECK: dsll32  $5, $5, 0                  # encoding: [0x00,0x05,0x28,0x3c]
+                       # CHECK: daddu   $5, $5, $1                 # encoding: [0x00,0xa1,0x28,0x2d]
+# FIXME: Simple symbol expressions crash the assembler.
+#dla $5, extern_sym+8   # TODO: lui $5, %highest(extern_sym)       # encoding: [0x3c,0x05,A,A]
+                       # TODO:                                    # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
+                       # TODO: lui $1, %hi(extern_sym)            # encoding: [0x3c,0x01,A,A]
+                       # TODO:                                    # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
+                       # TODO: daddiu $5, $5, %higher(extern_sym) # encoding: [0x64,0xa5,A,A]
+                       # TODO:                                    # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
+                       # TODO: daddiu $1, $1, %lo(extern_sym)     # encoding: [0x64,0x21,A,A]
+                       # TODO:                                    # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
+                       # TODO: dsll32  $5, $5, 0                  # encoding: [0x00,0x05,0x28,0x3c]
+                       # TODO: daddu   $5, $5, $1                 # encoding: [0x00,0xa1,0x28,0x2d]
+
+dla $5, extern_sym($8) # CHECK: lui $5, %highest(extern_sym)       # encoding: [0x3c,0x05,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
+                       # CHECK: lui $1, %hi(extern_sym)            # encoding: [0x3c,0x01,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
+                       # CHECK: daddiu $5, $5, %higher(extern_sym) # encoding: [0x64,0xa5,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
+                       # CHECK: daddiu $1, $1, %lo(extern_sym)     # encoding: [0x64,0x21,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
+                       # CHECK: dsll32  $5, $5, 0                  # encoding: [0x00,0x05,0x28,0x3c]
+                       # CHECK: daddu   $5, $5, $1                 # encoding: [0x00,0xa1,0x28,0x2d]
+                       # CHECK: daddu   $5, $5, $8                 # encoding: [0x00,0xa8,0x28,0x2d]
+
+dla $5, extern_sym($5) # CHECK: lui $1, %highest(extern_sym)       # encoding: [0x3c,0x01,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@HIGHEST, kind: fixup_Mips_HIGHEST
+                       # CHECK: daddiu $1, $1, %higher(extern_sym) # encoding: [0x64,0x21,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@HIGHER, kind: fixup_Mips_HIGHER
+                       # CHECK: dsll $1, $1, 16                    # encoding: [0x00,0x01,0x0c,0x38]
+                       # CHECK: daddiu $1, $1, %hi(extern_sym)     # encoding: [0x64,0x21,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@ABS_HI, kind: fixup_Mips_HI16
+                       # CHECK: dsll $1, $1, 16                    # encoding: [0x00,0x01,0x0c,0x38]
+                       # CHECK: daddiu $1, $1, %lo(extern_sym)     # encoding: [0x64,0x21,A,A]
+                       # CHECK:                                    # fixup A - offset: 0, value: extern_sym@ABS_LO, kind: fixup_Mips_LO16
+                       # CHECK: daddu   $5, $1, $5                 # encoding: [0x00,0x25,0x28,0x2d]
+
+.option pic2
+#dla $5, symbol
diff --git a/test/MC/Mips/macro-dli.s b/test/MC/Mips/macro-dli.s
new file mode 100644 (file)
index 0000000..6faf505
--- /dev/null
@@ -0,0 +1,534 @@
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r2 | \
+# RUN:   FileCheck %s
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r6 | \
+# RUN:   FileCheck %s
+
+bits_32_to_47_0x0000:           # CHECK-LABEL: bits_32_to_47_0x0000:
+dli $5, 0x0000000000000001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+dli $5, 0x0000000000000002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+dli $5, 0x0000000000004000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+dli $5, 0x0000000000008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+dli $5, 0x00000000ffff8000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x00000000ffffc000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 49152           # encoding: [0x34,0xa5,0xc0,0x00]
+dli $5, 0x00000000fffffffe      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 65534           # encoding: [0x34,0xa5,0xff,0xfe]
+dli $5, 0x00000000ffffffff      # CHECK: lui $5, 65535               # encoding: [0x3c,0x05,0xff,0xff]
+                                # CHECK: dsrl32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3e]
+dli $5, 0x0000000000010000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+dli $5, 0x0000000000020000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+dli $5, 0x0000000040000000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+dli $5, 0x0000000080000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x00000000c0000000      # CHECK: ori $5, $zero, 49152        # encoding: [0x34,0x05,0xc0,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x00000000fffe0000      # CHECK: ori $5, $zero, 65534        # encoding: [0x34,0x05,0xff,0xfe]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x00000000ffff0000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000000000010001      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000000020001      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000040000001      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000080000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000000010002      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000000020002      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000040000002      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000080000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000000014000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000000024000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000040004000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000080004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000000018000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000000028000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000040008000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000080008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x00000000c0008000      # CHECK: ori $5, $zero, 49152        # encoding: [0x34,0x05,0xc0,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x00000000fffe8000      # CHECK: ori $5, $zero, 65534        # encoding: [0x34,0x05,0xff,0xfe]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x00000000ffff8000      # CHECK: ori $5, $zero, 65535        # encoding: [0x34,0x05,0xff,0xff]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x0001:           # CHECK-LABEL: bits_32_to_47_0x0001:
+dli $5, 0x0000000100000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dli $5, 0x0000000100000001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000100000002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000100004000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000100008000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000100010000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000000100010001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000100010002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000100014000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000100018000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000100020000      # CHECK: ori $5, $zero, 32769        # encoding: [0x34,0x05,0x80,0x01]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dli $5, 0x0000000100020001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000100020002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000100024000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000100028000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000140000000      # CHECK: ori $5, $zero, 40960        # encoding: [0x34,0x05,0xa0,0x00]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dli $5, 0x0000000140000001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000140000002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000140004000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000140008000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000180000000      # CHECK: ori $5, $zero, 49152        # encoding: [0x34,0x05,0xc0,0x00]
+                                # CHECK: dsll $5, $5, 17             # encoding: [0x00,0x05,0x2c,0x78]
+dli $5, 0x0000000180000001      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000180000002      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000180004000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000180008000      # CHECK: addiu $5, $zero, 1          # encoding: [0x24,0x05,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x0002:           # CHECK-LABEL: bits_32_to_47_0x0002:
+dli $5, 0x0000000200000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 18             # encoding: [0x00,0x05,0x2c,0xb8]
+dli $5, 0x0000000200000001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000200000002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000200004000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000200008000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000200010000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000000200010001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000200010002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000200014000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000200018000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000200020000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000000200020001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000200020002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000200024000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000200028000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000240000000      # CHECK: ori $5, $zero, 36864        # encoding: [0x34,0x05,0x90,0x00]
+                                # CHECK: dsll $5, $5, 18             # encoding: [0x00,0x05,0x2c,0xb8]
+dli $5, 0x0000000240000001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000240000002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000240004000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000240008000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000000280000000      # CHECK: ori $5, $zero, 40960        # encoding: [0x34,0x05,0xa0,0x00]
+                                # CHECK: dsll $5, $5, 18             # encoding: [0x00,0x05,0x2c,0xb8]
+dli $5, 0x0000000280000001      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000000280000002      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000000280004000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000000280008000      # CHECK: addiu $5, $zero, 2          # encoding: [0x24,0x05,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x4000:           # CHECK-LABEL: bits_32_to_47_0x4000:
+dli $5, 0x0000400000000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 31             # encoding: [0x00,0x05,0x2f,0xf8]
+dli $5, 0x0000400000000001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000400000000002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000400000004000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000400000008000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000400000010000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000400000010001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000400000010002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000400000014000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000400000018000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000400000020000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000400000020001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000400000020002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000400000024000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000400000028000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000400040000000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000400040000001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000400040000002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000400040004000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000400040008000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000400080000000      # CHECK: ori $5, $zero, 32769        # encoding: [0x34,0x05,0x80,0x01]
+                                # CHECK: dsll $5, $5, 31             # encoding: [0x00,0x05,0x2f,0xf8]
+dli $5, 0x0000400080000001      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000400080000002      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000400080004000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000400080008000      # CHECK: addiu $5, $zero, 16384      # encoding: [0x24,0x05,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+bits_32_to_47_0x8000:           # CHECK-LABEL: bits_32_to_47_0x8000:
+dli $5, 0x0000800000000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 32             # encoding: [0x00,0x05,0x28,0x3c]
+dli $5, 0x0000800000000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000800000000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000800000004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000800000008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll32 $5, $5, 0            # encoding: [0x00,0x05,0x28,0x3c]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000800000010000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000800000010001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000800000010002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000800000014000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000800000018000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000800000020000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000800000020001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000800000020002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000800000024000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000800000028000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000800040000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000800040000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000800040000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000800040004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000800040008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0000800080000000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+dli $5, 0x0000800080000001      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 1               # encoding: [0x34,0xa5,0x00,0x01]
+dli $5, 0x0000800080000002      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 2               # encoding: [0x34,0xa5,0x00,0x02]
+dli $5, 0x0000800080004000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 16384           # encoding: [0x34,0xa5,0x40,0x00]
+dli $5, 0x0000800080008000      # CHECK: ori $5, $zero, 32768        # encoding: [0x34,0x05,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+# Only test a few with bits 48-63 non-zero. It just adds an lui to the cases we've already done.
+dli $5, 0x0001800080008000      # CHECK: lui $5, 1                   # encoding: [0x3c,0x05,0x00,0x01]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x0002800080008000      # CHECK: lui $5, 2                   # encoding: [0x3c,0x05,0x00,0x02]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x4000800080008000      # CHECK: lui $5, 16384               # encoding: [0x3c,0x05,0x40,0x00]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+dli $5, 0x8000800080008000      # CHECK: lui $5, 32768               # encoding: [0x3c,0x05,0x80,0x00]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
+                                # CHECK: dsll $5, $5, 16             # encoding: [0x00,0x05,0x2c,0x38]
+                                # CHECK: ori $5, $5, 32768           # encoding: [0x34,0xa5,0x80,0x00]
index 89d3340..2a8cf2a 100644 (file)
@@ -1,17 +1,23 @@
 # RUN: not llvm-mc %s -arch=mips -mcpu=mips32r2 2>%t1
-# RUN: FileCheck %s < %t1 --check-prefix=32-BIT
+# RUN: FileCheck %s < %t1 --check-prefix=O32
 # RUN: not llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n32 2>&1 | \
-# RUN:   FileCheck %s --check-prefix=64-BIT --check-prefix=N32-ONLY
+# RUN:   FileCheck %s --check-prefix=N32
 # RUN: not llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 2>&1 | \
-# RUN:   FileCheck %s --check-prefix=64-BIT --check-prefix=N64-ONLY
+# RUN:   FileCheck %s --check-prefix=N64
 
   .text
   la $5, 0x100000000
-  # 32-BIT: :[[@LINE-1]]:3: error: instruction requires a 32-bit immediate
-  # 64-BIT: :[[@LINE-2]]:3: error: instruction requires a 32-bit immediate
+  # O32: :[[@LINE-1]]:3: error: instruction requires a 32-bit immediate
+  # N32: :[[@LINE-2]]:3: error: instruction requires a 32-bit immediate
+  # N64: :[[@LINE-3]]:3: error: la used to load 64-bit address
+
   la $5, 0x100000000($6)
-  # 32-BIT: :[[@LINE-1]]:3: error: instruction requires a 32-bit immediate
-  # 64-BIT: :[[@LINE-2]]:3: error: instruction requires a 32-bit immediate
+  # O32: :[[@LINE-1]]:3: error: instruction requires a 32-bit immediate
+  # N32: :[[@LINE-2]]:3: error: instruction requires a 32-bit immediate
+  # N64: :[[@LINE-3]]:3: error: la used to load 64-bit address
+
+  # FIXME: These should be warnings but we lack la -> dla promotion at the
+  #        moment.
   la $5, symbol
-  # N64-ONLY: :[[@LINE-1]]:3: warning: instruction loads the 32-bit address of a 64-bit symbol
-  # N32-ONLY-NOT: :[[@LINE-2]]:3: warning: instruction loads the 32-bit address of a 64-bit symbol
+  # N32-NOT: :[[@LINE-1]]:3: error: la used to load 64-bit address
+  # N64:     :[[@LINE-2]]:3: error: la used to load 64-bit address
index 8c183a7..d996918 100644 (file)
@@ -2,11 +2,13 @@
 # RUN:   FileCheck %s
 # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r6 | \
 # RUN:   FileCheck %s
-# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r2 | \
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r2 -target-abi=n32 | \
 # RUN:   FileCheck %s
-# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r6 | \
+# RUN: llvm-mc %s -triple=mips64-unknown-linux -show-encoding -mcpu=mips64r6 -target-abi=n32 | \
 # RUN:   FileCheck %s
 
+# N64 should be acceptable too but we cannot convert la to dla yet.
+
 la $5, 0x00000001 # CHECK: addiu $5, $zero, 1      # encoding: [0x24,0x05,0x00,0x01]
 la $5, 0x00000002 # CHECK: addiu $5, $zero, 2      # encoding: [0x24,0x05,0x00,0x02]
 la $5, 0x00004000 # CHECK: addiu $5, $zero, 16384  # encoding: [0x24,0x05,0x40,0x00]
index b8f1e7a..0b56cf5 100644 (file)
@@ -1,183 +1,4 @@
 # RUN: llvm-mc %s -triple=mips64el-unknown-linux -show-encoding -mcpu=mips64r2 | FileCheck %s
-#
-# Test the 'dli' and 'dla' 64-bit variants of 'li' and 'la'.
-
-# Immediate is <= 32 bits.
-  dli $5, 123
-# CHECK:     addiu $5, $zero, 123   # encoding: [0x7b,0x00,0x05,0x24]
-
-  dli $6, -2345
-# CHECK:     addiu $6, $zero, -2345 # encoding: [0xd7,0xf6,0x06,0x24]
-
-  dli $7, 65538
-# CHECK:     lui   $7, 1            # encoding: [0x01,0x00,0x07,0x3c]
-# CHECK:     ori   $7, $7, 2        # encoding: [0x02,0x00,0xe7,0x34]
-
-  dli $8, ~7
-# CHECK:     addiu $8, $zero, -8    # encoding: [0xf8,0xff,0x08,0x24]
-
-  dli $9, 0x10000
-# CHECK:     lui   $9, 1            # encoding: [0x01,0x00,0x09,0x3c]
-# CHECK-NOT: ori   $9, $9, 0        # encoding: [0x00,0x00,0x29,0x35]
-
-
-# Positive immediate which is => 32 bits and <= 48 bits.
-  dli $8, 0x100000000
-# CHECK: lui  $8, 1                 # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: dsll $8, $8, 16            # encoding: [0x38,0x44,0x08,0x00]
-
-  dli $8, 0x100000001
-# CHECK: lui  $8, 1                 # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: dsll $8, $8, 16            # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori  $8, $8, 1             # encoding: [0x01,0x00,0x08,0x35]
-
-  dli $8, 0x100010000
-# CHECK: lui  $8, 1                 # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: ori  $8, $8, 1             # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll $8, $8, 16            # encoding: [0x38,0x44,0x08,0x00]
-
-  dli $8, 0x100010001
-# CHECK: lui  $8, 1                 # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: ori  $8, $8, 1             # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll $8, $8, 16            # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori  $8, $8, 1             # encoding: [0x01,0x00,0x08,0x35]
-
-
-# Positive immediate which is > 48 bits.
-  dli $8, 0x1000000000000
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: dsll32 $8, $8, 0           # encoding: [0x3c,0x40,0x08,0x00]
-
-  dli $8, 0x1000000000001
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: dsll32 $8, $8, 0           # encoding: [0x3c,0x40,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-
-  dli $8, 0x1000000010000
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-
-  dli $8, 0x1000100000000
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll32 $8, $8, 0           # encoding: [0x3c,0x40,0x08,0x00]
-
-  dli $8, 0x1000000010001
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-
-  dli $8, 0x1000100010000
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-
-  dli $8, 0x1000100000001
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll32 $8, $8, 0           # encoding: [0x3c,0x40,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-
-  dli $8, 0x1000100010001
-# CHECK: lui    $8, 1               # encoding: [0x01,0x00,0x08,0x3c]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 1           # encoding: [0x01,0x00,0x08,0x35]
-
-
-# Negative immediate which is => 32 bits and <= 48 bits.
-  dli $8, -0x100000000
-# CHECK: lui    $8, 65535           # encoding: [0xff,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll32 $8, $8, 0           # encoding: [0x3c,0x40,0x08,0x00]
-
-  dli $8, -0x100000001
-# CHECK: lui    $8, 65535           # encoding: [0xff,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-
-  dli $8, -0x100010000
-# CHECK: lui    $8, 65535           # encoding: [0xff,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-
-  dli $8, -0x100010001
-# CHECK: lui    $8, 65535           # encoding: [0xff,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-
-
-# Negative immediate which is > 48 bits.
-  dli $8, -0x1000000000000
-# CHECK: lui    $8, 65535           # encoding: [0xff,0xff,0x08,0x3c]
-# CHECK: dsll32 $8, $8, 0           # encoding: [0x3c,0x40,0x08,0x00]
-
-  dli $8, -0x1000000000001
-# CHECK: lui    $8, 65534           # encoding: [0xfe,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-
-  dli $8, -0x1000000010000
-# CHECK: lui    $8, 65534           # encoding: [0xfe,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-
-  dli $8, -0x1000100000000
-# CHECK: lui    $8, 65534           # encoding: [0xfe,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll32 $8, $8, 0           # encoding: [0x3c,0x40,0x08,0x00]
-
-  dli $8, -0x1000000010001
-# CHECK: lui    $8, 65534           # encoding: [0xfe,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-
-  dli $8, -0x1000100010000
-# CHECK: lui    $8, 65534           # encoding: [0xfe,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-
-  dli $8, -0x1000100000001
-# CHECK: lui    $8, 65534           # encoding: [0xfe,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
-
-  dli $8, -0x1000100010001
-# CHECK: lui    $8, 65534           # encoding: [0xfe,0xff,0x08,0x3c]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65534       # encoding: [0xfe,0xff,0x08,0x35]
-# CHECK: dsll   $8, $8, 16          # encoding: [0x38,0x44,0x08,0x00]
-# CHECK: ori    $8, $8, 65535       # encoding: [0xff,0xff,0x08,0x35]
 
 # Check that signed negative 32-bit immediates are loaded correctly:
   li $10, ~(0x101010)
 # CHECK: ori $10, $10, 61423   # encoding: [0xef,0xef,0x4a,0x35]
 # CHECK-NOT: dsll
 
-  dli $10, ~(0x202020)
-# CHECK: lui $10, 65503        # encoding: [0xdf,0xff,0x0a,0x3c]
-# CHECK: ori $10, $10, 57311   # encoding: [0xdf,0xdf,0x4a,0x35]
-# CHECK-NOT: dsll
-
-  dli $9, 0x80000000
-# CHECK: ori  $9, $zero, 32768 # encoding: [0x00,0x80,0x09,0x34]
-# CHECK: dsll $9, $9, 16       # encoding: [0x38,0x4c,0x09,0x00]
-
 # Test bne with an immediate as the 2nd operand.
   bne $2, 0x100010001, 1332
-# CHECK: lui  $1, 1                 # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK: addiu $1, $zero, 1         # encoding: [0x01,0x00,0x01,0x24]
+# CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
 
   bne $2, -0x100010001, 1332
-# CHECK: lui  $1, 65535             # encoding: [0xff,0xff,0x01,0x3c]
-# CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
+# CHECK: addiu $1, $zero, -2        # encoding: [0xfe,0xff,0x01,0x24]
 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 
 # Test beq with an immediate as the 2nd operand.
   beq $2, 0x100010001, 1332
-# CHECK: lui  $1, 1                 # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK: addiu $1, $zero, 1         # encoding: [0x01,0x00,0x01,0x24]
+# CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 1             # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: nop                        # encoding: [0x00,0x00,0x00,0x00]
 
   beq $2, -0x100010001, 1332
-# CHECK: lui  $1, 65535             # encoding: [0xff,0xff,0x01,0x3c]
-# CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
+# CHECK: addiu $1, $zero, -2        # encoding: [0xfe,0xff,0x01,0x24]
 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 65534         # encoding: [0xfe,0xff,0x21,0x34]
 # CHECK: dsll $1, $1, 16            # encoding: [0x38,0x0c,0x01,0x00]
 
 # Test ulhu with 64-bit immediate addresses.
   ulhu $8, 0x100010001
-# CHECK: lui  $1, 1            # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK: addiu $1, $zero, 1    # encoding: [0x01,0x00,0x01,0x24]
 # CHECK: ori  $1, $1, 1        # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 1        # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: or   $8, $8, $1       # encoding: [0x25,0x40,0x01,0x01]
 
   ulhu $8, -0x100010001
-# CHECK: lui  $1, 65535        # encoding: [0xff,0xff,0x01,0x3c]
-# CHECK: ori  $1, $1, 65534    # encoding: [0xfe,0xff,0x21,0x34]
+# CHECK: addiu $1, $zero, -2   # encoding: [0xfe,0xff,0x01,0x24]
 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 65534    # encoding: [0xfe,0xff,0x21,0x34]
 # CHECK: dsll $1, $1, 16       # encoding: [0x38,0x0c,0x01,0x00]
 
 # Test ulhu with source register and 64-bit immediate offset.
   ulhu $8, 0x100010001($9)
-# CHECK: lui   $1, 1           # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK: addiu $1, $zero, 1    # encoding: [0x01,0x00,0x01,0x24]
 # CHECK: ori   $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori   $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: or    $8, $8, $1      # encoding: [0x25,0x40,0x01,0x01]
 
   ulhu $8, -0x100010001($9)
-# CHECK: lui   $1, 65535       # encoding: [0xff,0xff,0x01,0x3c]
-# CHECK: ori   $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
+# CHECK: addiu $1, $zero, -2   # encoding: [0xfe,0xff,0x01,0x24]
 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori   $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
 # CHECK: dsll  $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
-# CHECK: ori   $1, $1, 65535   # encoding: [0xff,0xff,0x21,0x34]
 # CHECK: daddu $1, $1, $9      # encoding: [0x2d,0x08,0x29,0x00]
 # CHECK: lbu   $8, 1($1)       # encoding: [0x01,0x00,0x28,0x90]
 # CHECK: lbu   $1, 0($1)       # encoding: [0x00,0x00,0x21,0x90]
 
 # Test ulw with 64-bit immediate addresses.
   ulw $8, 0x100010001
-# CHECK: lui  $1, 1           # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK: addiu $1, $zero, 1   # encoding: [0x01,0x00,0x01,0x24]
 # CHECK: ori  $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 1       # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: lwr  $8, 0($1)       # encoding: [0x00,0x00,0x28,0x98]
 
   ulw $8, -0x100010001
-# CHECK: lui  $1, 65535       # encoding: [0xff,0xff,0x01,0x3c]
-# CHECK: ori  $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
+# CHECK: addiu $1, $zero, -2  # encoding: [0xfe,0xff,0x01,0x24]
 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori  $1, $1, 65534   # encoding: [0xfe,0xff,0x21,0x34]
 # CHECK: dsll $1, $1, 16      # encoding: [0x38,0x0c,0x01,0x00]
 
 # Test ulw with source register and 64-bit immediate offset.
   ulw $8, 0x100010001($9)
-# CHECK: lui   $1, 1          # encoding: [0x01,0x00,0x01,0x3c]
+# CHECK: addiu $1, $zero, 1   # encoding: [0x01,0x00,0x01,0x24]
 # CHECK: ori   $1, $1, 1      # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori   $1, $1, 1      # encoding: [0x01,0x00,0x21,0x34]
 # CHECK: lwr   $8, 0($1)      # encoding: [0x00,0x00,0x28,0x98]
 
   ulw $8, -0x100010001($9)
-# CHECK: lui   $1, 65535      # encoding: [0xff,0xff,0x01,0x3c]
-# CHECK: ori   $1, $1, 65534  # encoding: [0xfe,0xff,0x21,0x34]
+# CHECK: addiu $1, $zero, -2  # encoding: [0xfe,0xff,0x01,0x24]
 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]
 # CHECK: ori   $1, $1, 65534  # encoding: [0xfe,0xff,0x21,0x34]
 # CHECK: dsll  $1, $1, 16     # encoding: [0x38,0x0c,0x01,0x00]