[llvm] r333407 - [mips] Emit R_MICROMIPS_HIGHER / R_MICROMIPS_HIGHEST relocations
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Tue May 29 03:27:45 PDT 2018
Author: atanasyan
Date: Tue May 29 03:27:44 2018
New Revision: 333407
URL: http://llvm.org/viewvc/llvm-project?rev=333407&view=rev
Log:
[mips] Emit R_MICROMIPS_HIGHER / R_MICROMIPS_HIGHEST relocations
Emit R_MICROMIPS_HIGHER / R_MICROMIPS_HIGHEST relocations for %higher()
and %highest() expressions in case of microMIPS. These relocations do
exactly the same things as R_MIPS_HIGHER / R_MIPS_HIGHEST, but for
consistency it's better to write microMIPS variants.
Differential Revision: http://reviews.llvm.org/D47219
Modified:
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
llvm/trunk/test/MC/Mips/relocation.s
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp?rev=333407&r1=333406&r2=333407&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp Tue May 29 03:27:44 2018
@@ -108,10 +108,12 @@ static unsigned adjustFixupValue(const M
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 @@ getFixupKindInfo(MCFixupKind Kind) const
{ "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 @@ getFixupKindInfo(MCFixupKind Kind) const
{ "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 },
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp?rev=333407&r1=333406&r2=333407&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp Tue May 29 03:27:44 2018
@@ -382,6 +382,10 @@ unsigned MipsELFObjectWriter::getRelocTy
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!");
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h?rev=333407&r1=333406&r2=333407&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h Tue May 29 03:27:44 2018
@@ -110,11 +110,13 @@ namespace Mips {
// 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,
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp?rev=333407&r1=333406&r2=333407&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp Tue May 29 03:27:44 2018
@@ -664,10 +664,12 @@ getExprOpValue(const MCExpr *Expr, Small
: 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)))
Modified: llvm/trunk/test/MC/Mips/relocation.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/relocation.s?rev=333407&r1=333406&r2=333407&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/relocation.s (original)
+++ llvm/trunk/test/MC/Mips/relocation.s Tue May 29 03:27:44 2018
@@ -318,7 +318,7 @@ foo_mm:
// 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 @@ foo_mm:
// 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:
More information about the llvm-commits
mailing list