From 09d1a7a6cbcaf171c23c6171badee17c1de736cf Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Thu, 3 Oct 2019 12:08:26 +0000 Subject: [PATCH] [mips] Push `fixup_Mips_LO16` fixup for `jialc` and `jic` instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373591 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp | 7 +++++-- test/MC/Mips/micromips32r6/relocations.s | 10 ++++++++++ test/MC/Mips/mips32r6/relocations.s | 10 ++++++++++ test/MC/Mips/mips64r6/relocations.s | 10 ++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp b/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp index 759a7fdb32b..142e9cebb79 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp @@ -485,8 +485,11 @@ getJumpOffset16OpValue(const MCInst &MI, unsigned OpNo, assert(MO.isExpr() && "getJumpOffset16OpValue expects only expressions or an immediate"); - // TODO: Push fixup. - return 0; + const MCExpr *Expr = MO.getExpr(); + Mips::Fixups FixupKind = + isMicroMips(STI) ? Mips::fixup_MICROMIPS_LO16 : Mips::fixup_Mips_LO16; + Fixups.push_back(MCFixup::create(0, Expr, MCFixupKind(FixupKind))); + return 0; } /// getJumpTargetOpValue - Return binary encoding of the jump diff --git a/test/MC/Mips/micromips32r6/relocations.s b/test/MC/Mips/micromips32r6/relocations.s index 7e8f3f6107e..615b445a0fa 100644 --- a/test/MC/Mips/micromips32r6/relocations.s +++ b/test/MC/Mips/micromips32r6/relocations.s @@ -26,6 +26,12 @@ # CHECK-FIXUP: bnezc $3, bar # encoding: [0xa0,0b011AAAAA,A,A] # CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: value: bar-4, kind: fixup_MICROMIPS_PC21_S1 +# CHECK-FIXUP: jialc $5, bar # encoding: [0x80,0x05,A,A] +# CHECK-FIXUP: # fixup A - offset: 0, +# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_LO16 +# CHECK-FIXUP: jic $5, bar # encoding: [0xa0,0x05,A,A] +# CHECK-FIXUP: # fixup A - offset: 0, +# CHECK-FIXUP: value: bar, kind: fixup_MICROMIPS_LO16 #------------------------------------------------------------------------------ # Check that the appropriate relocations were created. #------------------------------------------------------------------------------ @@ -37,6 +43,8 @@ # CHECK-ELF: 0x10 R_MICROMIPS_PC19_S2 bar 0x0 # CHECK-ELF: 0x14 R_MICROMIPS_PC21_S1 bar 0x0 # CHECK-ELF: 0x18 R_MICROMIPS_PC21_S1 bar 0x0 +# CHECK-ELF: 0x1C R_MICROMIPS_LO16 bar 0x0 +# CHECK-ELF: 0x20 R_MICROMIPS_LO16 bar 0x0 # CHECK-ELF: ] balc bar @@ -46,3 +54,5 @@ lwpc $2,bar beqzc $3, bar bnezc $3, bar + jialc $5, bar + jic $5, bar diff --git a/test/MC/Mips/mips32r6/relocations.s b/test/MC/Mips/mips32r6/relocations.s index 3f42ee8f471..8095fb156ec 100644 --- a/test/MC/Mips/mips32r6/relocations.s +++ b/test/MC/Mips/mips32r6/relocations.s @@ -40,6 +40,12 @@ # CHECK-FIXUP: lwpc $2, bar # encoding: [0xec,0b01001AAA,A,A] # CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: value: bar, kind: fixup_MIPS_PC19_S2 +# CHECK-FIXUP: jialc $5, bar # encoding: [0xf8,0x05,A,A] +# CHECK-FIXUP: # fixup A - offset: 0, +# CHECK-FIXUP: value: bar, kind: fixup_Mips_LO16 +# CHECK-FIXUP: jic $5, bar # encoding: [0xd8,0x05,A,A] +# CHECK-FIXUP: # fixup A - offset: 0, +# CHECK-FIXUP: value: bar, kind: fixup_Mips_LO16 #------------------------------------------------------------------------------ # Check that the appropriate relocations were created. #------------------------------------------------------------------------------ @@ -55,6 +61,8 @@ # CHECK-ELF: 0x20 R_MIPS_PCLO16 bar 0x0 # CHECK-ELF: 0x24 R_MIPS_PC19_S2 bar 0x0 # CHECK-ELF: 0x28 R_MIPS_PC19_S2 bar 0x0 +# CHECK-ELF: 0x2C R_MIPS_LO16 bar 0x0 +# CHECK-ELF: 0x30 R_MIPS_LO16 bar 0x0 # CHECK-ELF: ] addiupc $2,bar @@ -68,3 +76,5 @@ addiu $2, $2, %pcrel_lo(bar) lapc $2,bar lwpc $2,bar + jialc $5, bar + jic $5, bar diff --git a/test/MC/Mips/mips64r6/relocations.s b/test/MC/Mips/mips64r6/relocations.s index 4f4efda07c6..5e70f44b96e 100644 --- a/test/MC/Mips/mips64r6/relocations.s +++ b/test/MC/Mips/mips64r6/relocations.s @@ -47,6 +47,12 @@ # CHECK-FIXUP: lwupc $2, bar # encoding: [0xec,0b01010AAA,A,A] # CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: value: bar, kind: fixup_MIPS_PC19_S2 +# CHECK-FIXUP: jialc $5, bar # encoding: [0xf8,0x05,A,A] +# CHECK-FIXUP: # fixup A - offset: 0, +# CHECK-FIXUP: value: bar, kind: fixup_Mips_LO16 +# CHECK-FIXUP: jic $5, bar # encoding: [0xd8,0x05,A,A] +# CHECK-FIXUP: # fixup A - offset: 0, +# CHECK-FIXUP: value: bar, kind: fixup_Mips_LO16 #------------------------------------------------------------------------------ # Check that the appropriate relocations were created. #------------------------------------------------------------------------------ @@ -64,6 +70,8 @@ # CHECK-ELF: 0x28 R_MIPS_PC18_S3/R_MIPS_NONE/R_MIPS_NONE bar 0x0 # CHECK-ELF: 0x2C R_MIPS_PC19_S2/R_MIPS_NONE/R_MIPS_NONE bar 0x0 # CHECK-ELF: 0x30 R_MIPS_PC19_S2/R_MIPS_NONE/R_MIPS_NONE bar 0x0 +# CHECK-ELF: 0x34 R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE bar 0x0 +# CHECK-ELF: 0x38 R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE bar 0x0 # CHECK-ELF: ] addiupc $2,bar @@ -79,3 +87,5 @@ ldpc $2,bar lwpc $2,bar lwupc $2,bar + jialc $5, bar + jic $5, bar -- 2.50.0