Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -5452,6 +5452,9 @@ case Match_MemSImm16: return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 16-bit signed offset"); + case Match_MemSImm32: + return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), + "expected memory with 32-bit signed offset"); case Match_RequiresPosSizeRange0_32: { SMLoc ErrorStart = Operands[3]->getStartLoc(); SMLoc ErrorEnd = Operands[4]->getEndLoc(); Index: lib/Target/Mips/MipsInstrInfo.td =================================================================== --- lib/Target/Mips/MipsInstrInfo.td +++ lib/Target/Mips/MipsInstrInfo.td @@ -1108,6 +1108,15 @@ let DiagnosticType = "MemSImm16"; } +def MipsMemSimm32AsmOperand : AsmOperandClass { + let Name = "MemOffsetSimm32"; + let SuperClasses = [MipsMemAsmOperand]; + let RenderMethod = "addMemOperands"; + let ParserMethod = "parseMemOperand"; + let PredicateMethod = "isMemWithSimmOffset<32>"; + let DiagnosticType = "MemSImm32"; +} + def MipsInvertedImmoperand : AsmOperandClass { let Name = "InvNum"; let RenderMethod = "addImmOperands"; @@ -1181,6 +1190,12 @@ let ParserMatchClass = MipsMemSimm16AsmOperand; } +def mem_simm32 : mem_generic { + let MIOperandInfo = (ops ptr_rc, simm16); + let EncoderMethod = "getMemEncoding"; + let ParserMatchClass = MipsMemSimm32AsmOperand; +} + def mem_ea : Operand { let PrintMethod = "printMemOperandEA"; let MIOperandInfo = (ops ptr_rc, simm16); @@ -1995,9 +2010,9 @@ /// Load and Store Instructions /// aligned -def LB : LoadMemory<"lb", GPR32Opnd, mem_simm16, sextloadi8, II_LB>, MMRel, +def LB : LoadMemory<"lb", GPR32Opnd, mem_simm32, sextloadi8, II_LB>, MMRel, LW_FM<0x20>; -def LBu : LoadMemory<"lbu", GPR32Opnd, mem_simm16, zextloadi8, II_LBU, +def LBu : LoadMemory<"lbu", GPR32Opnd, mem_simm32, zextloadi8, II_LBU, addrDefault>, MMRel, LW_FM<0x24>; let AdditionalPredicates = [NotInMicroMips] in { def LH : LoadMemory<"lh", GPR32Opnd, mem_simm16, sextloadi16, II_LH, Index: test/MC/Mips/micromips/invalid.s =================================================================== --- test/MC/Mips/micromips/invalid.s +++ test/MC/Mips/micromips/invalid.s @@ -121,10 +121,10 @@ xori $3, 65536 # CHECK: :[[@LINE]]:12: error: expected 16-bit unsigned immediate not $3, 4 # CHECK: :[[@LINE]]:11: error: invalid operand for instruction lb $32, 8($5) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction - lb $4, -32769($5) # CHECK: :[[@LINE]]:10: error: expected memory with 16-bit signed offset - lb $4, 32768($5) # CHECK: :[[@LINE]]:10: error: expected memory with 16-bit signed offset - lb $4, 8($32) # CHECK: :[[@LINE]]:10: error: expected memory with 16-bit signed offset + lb $4, -2147483649($5) # CHECK: :[[@LINE]]:10: error: expected memory with 32-bit signed offset + lb $4, 0x80000000($5) # CHECK: :[[@LINE]]:10: error: expected memory with 32-bit signed offset + lb $4, 8($32) # CHECK: :[[@LINE]]:10: error: expected memory with 32-bit signed offset lbu $32, 8($5) # CHECK: :[[@LINE]]:7: error: invalid operand for instruction - lbu $4, -32769($5) # CHECK: :[[@LINE]]:11: error: expected memory with 16-bit signed offset - lbu $4, 32768($5) # CHECK: :[[@LINE]]:11: error: expected memory with 16-bit signed offset - lbu $4, 8($32) # CHECK: :[[@LINE]]:11: error: expected memory with 16-bit signed offset + lbu $4, -2147483649($5) # CHECK: :[[@LINE]]:11: error: expected memory with 32-bit signed offset + lbu $4, 0x80000000($5) # CHECK: :[[@LINE]]:11: error: expected memory with 32-bit signed offset + lbu $4, 8($32) # CHECK: :[[@LINE]]:11: error: expected memory with 32-bit signed offset Index: test/MC/Mips/micromips32r6/invalid.s =================================================================== --- test/MC/Mips/micromips32r6/invalid.s +++ test/MC/Mips/micromips32r6/invalid.s @@ -254,13 +254,13 @@ xori $3, 65536 # CHECK: :[[@LINE]]:12: error: expected 16-bit unsigned immediate not $3, 4 # CHECK: :[[@LINE]]:11: error: invalid operand for instruction lb $32, 8($5) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction - lb $4, -32769($5) # CHECK: :[[@LINE]]:10: error: expected memory with 16-bit signed offset - lb $4, 32768($5) # CHECK: :[[@LINE]]:10: error: expected memory with 16-bit signed offset - lb $4, 8($32) # CHECK: :[[@LINE]]:10: error: expected memory with 16-bit signed offset + lb $4, -2147483649($5) # CHECK: :[[@LINE]]:10: error: expected memory with 32-bit signed offset + lb $4, 0x80000000($5) # CHECK: :[[@LINE]]:10: error: expected memory with 32-bit signed offset + lb $4, 8($32) # CHECK: :[[@LINE]]:10: error: expected memory with 32-bit signed offset lbu $32, 8($5) # CHECK: :[[@LINE]]:7: error: invalid operand for instruction - lbu $4, -32769($5) # CHECK: :[[@LINE]]:11: error: expected memory with 16-bit signed offset - lbu $4, 32768($5) # CHECK: :[[@LINE]]:11: error: expected memory with 16-bit signed offset - lbu $4, 8($32) # CHECK: :[[@LINE]]:11: error: expected memory with 16-bit signed offset + lbu $4, -2147483649($5) # CHECK: :[[@LINE]]:11: error: expected memory with 32-bit signed offset + lbu $4, 0x80000000($5) # CHECK: :[[@LINE]]:11: error: expected memory with 32-bit signed offset + lbu $4, 8($32) # CHECK: :[[@LINE]]:11: error: expected memory with 32-bit signed offset ldc1 $f32, 300($10) # CHECK: :[[@LINE]]:8: error: invalid operand for instruction ldc1 $f7, -32769($10) # CHECK: :[[@LINE]]:13: error: expected memory with 16-bit signed offset ldc1 $f7, 32768($10) # CHECK: :[[@LINE]]:13: error: expected memory with 16-bit signed offset Index: test/MC/Mips/mips-expansions.s =================================================================== --- test/MC/Mips/mips-expansions.s +++ test/MC/Mips/mips-expansions.s @@ -13,6 +13,24 @@ # CHECK-LE: addiu $8, $8, %lo($tmp0) # encoding: [A,A,0x08,0x25] # CHECK-LE: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16 + lb $4, 0x8000 +# CHECK-LE: lui $4, 1 # encoding: [0x01,0x00,0x04,0x3c] +# CHECK-LE: lb $4, -32768($4) # encoding: [0x00,0x80,0x84,0x80] + + lb $4, 0x20004($3) +# CHECK-LE: lui $4, 2 # encoding: [0x02,0x00,0x04,0x3c] +# CHECK-LE: addu $4, $4, $3 # encoding: [0x21,0x20,0x83,0x00] +# CHECK-LE: lb $4, 4($4) # encoding: [0x04,0x00,0x84,0x80] + + lbu $4, 0x8000 +# CHECK-LE: lui $4, 1 # encoding: [0x01,0x00,0x04,0x3c] +# CHECK-LE: lbu $4, -32768($4) # encoding: [0x00,0x80,0x84,0x90] + + lbu $4, 0x20004($3) +# CHECK-LE: lui $4, 2 # encoding: [0x02,0x00,0x04,0x3c] +# CHECK-LE: addu $4, $4, $3 # encoding: [0x21,0x20,0x83,0x00] +# CHECK-LE: lbu $4, 4($4) # encoding: [0x04,0x00,0x84,0x90] + # LW/SW and LDC1/SDC1 of symbol address, done by MipsAsmParser::expandMemInst(): .set noat lw $10, symbol($4) Index: test/MC/Mips/mips32r5/invalid.s =================================================================== --- test/MC/Mips/mips32r5/invalid.s +++ test/MC/Mips/mips32r5/invalid.s @@ -21,13 +21,13 @@ mfc2 $4, $3, -1 # CHECK: :[[@LINE]]:23: error: expected 3-bit unsigned immediate mfc2 $4, $3, 8 # CHECK: :[[@LINE]]:23: error: expected 3-bit unsigned immediate lb $32, 8($5) # CHECK: :[[@LINE]]:12: error: invalid operand for instruction - lb $4, -32769($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 32768($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset + lb $4, -2147483649($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 0x80000000($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset lbu $32, 8($5) # CHECK: :[[@LINE]]:13: error: invalid operand for instruction - lbu $4, -32769($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 32768($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset + lbu $4, -2147483649($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 0x80000000($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset ldc1 $f32, 300($10) # CHECK: :[[@LINE]]:14: error: invalid operand for instruction ldc1 $f7, -32769($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset ldc1 $f7, 32768($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset Index: test/MC/Mips/mips32r6/invalid.s =================================================================== --- test/MC/Mips/mips32r6/invalid.s +++ test/MC/Mips/mips32r6/invalid.s @@ -146,13 +146,13 @@ sync -1 # CHECK: :[[@LINE]]:14: error: expected 5-bit unsigned immediate sync 32 # CHECK: :[[@LINE]]:14: error: expected 5-bit unsigned immediate lb $32, 8($5) # CHECK: :[[@LINE]]:12: error: invalid operand for instruction - lb $4, -32769($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 32768($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset + lb $4, -2147483649($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 0x80000000($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset lbu $32, 8($5) # CHECK: :[[@LINE]]:13: error: invalid operand for instruction - lbu $4, -32769($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 32768($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset + lbu $4, -2147483649($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 0x80000000($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset ldc1 $f32, 300($10) # CHECK: :[[@LINE]]:14: error: invalid operand for instruction ldc1 $f7, -32769($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset ldc1 $f7, 32768($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset Index: test/MC/Mips/mips64r5/invalid.s =================================================================== --- test/MC/Mips/mips64r5/invalid.s +++ test/MC/Mips/mips64r5/invalid.s @@ -20,13 +20,13 @@ dmfc0 $4, $3, 8 # CHECK: :[[@LINE]]:24: error: expected 3-bit unsigned immediate sd $32, 65536($32) # CHECK: :[[@LINE]]:{{[0-9]+}}: error: invalid operand for instruction lb $32, 8($5) # CHECK: :[[@LINE]]:12: error: invalid operand for instruction - lb $4, -32769($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 32768($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset + lb $4, -2147483649($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 0x80000000($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset lbu $32, 8($5) # CHECK: :[[@LINE]]:13: error: invalid operand for instruction - lbu $4, -32769($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 32768($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset + lbu $4, -2147483649($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 0x80000000($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset ldc1 $f32, 300($10) # CHECK: :[[@LINE]]:14: error: invalid operand for instruction ldc1 $f7, -32769($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset ldc1 $f7, 32768($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset Index: test/MC/Mips/mips64r6/invalid.s =================================================================== --- test/MC/Mips/mips64r6/invalid.s +++ test/MC/Mips/mips64r6/invalid.s @@ -195,13 +195,13 @@ dsrlv $2, $4, 2 # CHECK: :[[@LINE]]:{{[0-9]+}}: error: invalid operand for instruction dsrlv $32, $32, $32 # CHECK: :[[@LINE]]:{{[0-9]+}}: error: invalid operand for instruction lb $32, 8($5) # CHECK: :[[@LINE]]:12: error: invalid operand for instruction - lb $4, -32769($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 32768($5) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset - lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 16-bit signed offset + lb $4, -2147483649($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 0x80000000($5) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset + lb $4, 8($32) # CHECK: :[[@LINE]]:16: error: expected memory with 32-bit signed offset lbu $32, 8($5) # CHECK: :[[@LINE]]:13: error: invalid operand for instruction - lbu $4, -32769($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 32768($5) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset - lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 16-bit signed offset + lbu $4, -2147483649($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 0x80000000($5) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset + lbu $4, 8($32) # CHECK: :[[@LINE]]:17: error: expected memory with 32-bit signed offset ldc1 $f32, 300($10) # CHECK: :[[@LINE]]:14: error: invalid operand for instruction ldc1 $f7, -32769($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset ldc1 $f7, 32768($10) # CHECK: :[[@LINE]]:19: error: expected memory with 16-bit signed offset