Index: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -108,10 +108,12 @@ Value = ((Value + 0x8000) >> 16) & 0xffff; break; case Mips::fixup_Mips_HIGHER: + case Mips::fixup_MICROMIPS_HIGHER: // Get the 3rd 16-bits. Value = ((Value + 0x80008000LL) >> 32) & 0xffff; break; case Mips::fixup_Mips_HIGHEST: + case Mips::fixup_MICROMIPS_HIGHEST: // Get the 4th 16-bits. Value = ((Value + 0x800080008000LL) >> 48) & 0xffff; break; @@ -339,7 +341,9 @@ { "fixup_Mips_GOT_OFST", 0, 16, 0 }, { "fixup_Mips_GOT_DISP", 0, 16, 0 }, { "fixup_Mips_HIGHER", 0, 16, 0 }, + { "fixup_MICROMIPS_HIGHER", 0, 16, 0 }, { "fixup_Mips_HIGHEST", 0, 16, 0 }, + { "fixup_MICROMIPS_HIGHEST", 0, 16, 0 }, { "fixup_Mips_GOT_HI16", 0, 16, 0 }, { "fixup_Mips_GOT_LO16", 0, 16, 0 }, { "fixup_Mips_CALL_HI16", 0, 16, 0 }, @@ -413,7 +417,9 @@ { "fixup_Mips_GOT_OFST", 16, 16, 0 }, { "fixup_Mips_GOT_DISP", 16, 16, 0 }, { "fixup_Mips_HIGHER", 16, 16, 0 }, + { "fixup_MICROMIPS_HIGHER", 16, 16, 0 }, { "fixup_Mips_HIGHEST", 16, 16, 0 }, + { "fixup_MICROMIPS_HIGHEST",16, 16, 0 }, { "fixup_Mips_GOT_HI16", 16, 16, 0 }, { "fixup_Mips_GOT_LO16", 16, 16, 0 }, { "fixup_Mips_CALL_HI16", 16, 16, 0 }, Index: lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -382,6 +382,10 @@ return ELF::R_MICROMIPS_TLS_TPREL_LO16; case Mips::fixup_MICROMIPS_SUB: return ELF::R_MICROMIPS_SUB; + case Mips::fixup_MICROMIPS_HIGHER: + return ELF::R_MICROMIPS_HIGHER; + case Mips::fixup_MICROMIPS_HIGHEST: + return ELF::R_MICROMIPS_HIGHEST; } llvm_unreachable("invalid fixup kind!"); Index: lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h +++ lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h @@ -110,11 +110,13 @@ // resulting in - R_MIPS_GOT_DISP fixup_Mips_GOT_DISP, - // resulting in - R_MIPS_GOT_HIGHER + // resulting in - R_MIPS_HIGHER/R_MICROMIPS_HIGHER fixup_Mips_HIGHER, + fixup_MICROMIPS_HIGHER, - // resulting in - R_MIPS_HIGHEST + // resulting in - R_MIPS_HIGHEST/R_MICROMIPS_HIGHEST fixup_Mips_HIGHEST, + fixup_MICROMIPS_HIGHEST, // resulting in - R_MIPS_GOT_HI16 fixup_Mips_GOT_HI16, Index: lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp +++ lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp @@ -664,10 +664,12 @@ : Mips::fixup_Mips_LO16; break; case MipsMCExpr::MEK_HIGHEST: - FixupKind = Mips::fixup_Mips_HIGHEST; + FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HIGHEST + : Mips::fixup_Mips_HIGHEST; break; case MipsMCExpr::MEK_HIGHER: - FixupKind = Mips::fixup_Mips_HIGHER; + FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HIGHER + : Mips::fixup_Mips_HIGHER; break; case MipsMCExpr::MEK_HI: // Check for %hi(%neg(%gp_rel(X))) Index: test/MC/Mips/relocation.s =================================================================== --- test/MC/Mips/relocation.s +++ test/MC/Mips/relocation.s @@ -318,7 +318,7 @@ // ENCLE: addiu $2, $2, %lo(bar) # encoding: [0x42'A',0x30'A',0x00,0x00] // FIXUP: # fixup A - offset: 0, value: %lo(bar), kind: fixup_MICROMIPS_LO16 -// DATA-NEXT: 0010: 30430000 30420004 30430001 30420034 +// DATA-NEXT: 0010: 30430000 30420004 30430001 3042003C addiu $2, $3, %got(baz) // RELOC: R_MICROMIPS_GOT16 .text // ENCBE: addiu $2, $3, %got(baz) # encoding: [0x30,0x43,A,A] // The placement of the 'A' annotations is incorrect. They use 32-bit little endian instead of 2x 16-bit little endian. @@ -377,11 +377,21 @@ // ENCLE: addiu $2, $2, %lo(bar) # encoding: [0x42'A',0x30'A',0x00,0x00] // FIXUP: # fixup A - offset: 0, value: %lo(bar), kind: fixup_MICROMIPS_LO16 -// DATA-NEXT: 0040: 30430000 00000000 00000000 00000000 +// DATA-NEXT: 0040: 30430000 41A50000 41A50000 00000000 addiu $2, $3, %gottprel(foo) // RELOC: R_MICROMIPS_TLS_GOTTPREL foo // ENCBE: addiu $2, $3, %gottprel(foo) # encoding: [0x30,0x43,A,A] // ENCLE: addiu $2, $3, %gottprel(foo) # encoding: [0x43'A',0x30'A',0x00,0x00] // FIXUP: # fixup A - offset: 0, value: %gottprel(foo), kind: fixup_MICROMIPS_GOTTPREL + lui $5, %higher(foo) // RELOC: R_MICROMIPS_HIGHER foo + // ENCBE: lui $5, %higher(foo) # encoding: [0x41,0xa5,A,A] + // ENCLE: lui $5, %higher(foo) # encoding: [0xa5'A',0x41'A',0x00,0x00] + // FIXUP: # fixup A - offset: 0, value: %higher(foo), kind: fixup_MICROMIPS_HIGHER + + lui $5, %highest(foo) // RELOC: R_MICROMIPS_HIGHEST foo + // ENCBE: lui $5, %highest(foo) # encoding: [0x41,0xa5,A,A] + // ENCLE: lui $5, %highest(foo) # encoding: [0xa5'A',0x41'A',0x00,0x00] + // FIXUP: # fixup A - offset: 0, value: %highest(foo), kind: fixup_MICROMIPS_HIGHEST + .space 65520, 0 long_mm: