[PATCH] D28688: MC: Introduce the ABS8 symbol modifier.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 11:41:20 PST 2017
I was thinking that we might introduce an @REL8 modifier that would be used
like this:
cmpq $(foo at REL8 - .), %rdi
Peter
On Mon, Jan 30, 2017 at 11:03 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:
> I think this is fine, but any thoughts on how we would we handle
> R_X86_64_PC8 if we ever needed to?
>
> Cheers,
> Rafael
>
> Peter Collingbourne via Phabricator via llvm-commits
> <llvm-commits at lists.llvm.org> writes:
>
> > pcc created this revision.
> > pcc added reviewers: RKSimon, craig.topper, majnemer.
> > pcc added a subscriber: llvm-commits.
> >
> > @ABS8 can be applied to symbols which appear as immediate operands to
> > instructions that have a 8-bit immediate form for that operand. It causes
> > the assembler to use the 8-bit form and an 8-bit relocation (e.g. R_386_8
> > or R_X86_64_8) for the symbol.
> >
> >
> > https://reviews.llvm.org/D28688
> >
> > Files:
> > llvm/docs/Extensions.rst
> > llvm/include/llvm/MC/MCExpr.h
> > llvm/lib/MC/MCAssembler.cpp
> > llvm/lib/MC/MCExpr.cpp
> > llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
> > llvm/test/MC/X86/abs8.s
> >
> > Index: llvm/test/MC/X86/abs8.s
> > ===================================================================
> > --- /dev/null
> > +++ llvm/test/MC/X86/abs8.s
> > @@ -0,0 +1,8 @@
> > +// RUN: llvm-mc -filetype=obj %s -o - -triple i686-pc-linux |
> llvm-objdump -d -r - | FileCheck --check-prefix=32 %s
> > +// RUN: llvm-mc -filetype=obj %s -o - -triple x86_64-pc-linux |
> llvm-objdump -d -r - | FileCheck --check-prefix=64 %s
> > +
> > +// 32: 0: 83 ff 00 cmpl $0, %edi
> > +// 32: 00000002: R_386_8 foo
> > +// 64: 0: 83 ff 00 cmpl $0, %edi
> > +// 64: 0000000000000002: R_X86_64_8 foo+0
> > +cmp $foo at ABS8, %edi
> > Index: llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
> > ===================================================================
> > --- llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
> > +++ llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
> > @@ -96,6 +96,7 @@
> > default:
> > llvm_unreachable("Unimplemented");
> > case MCSymbolRefExpr::VK_None:
> > + case MCSymbolRefExpr::VK_ABS8:
> > switch (Type) {
> > case RT64_64:
> > return IsPCRel ? ELF::R_X86_64_PC64 : ELF::R_X86_64_64;
> > @@ -219,6 +220,7 @@
> > default:
> > llvm_unreachable("Unimplemented");
> > case MCSymbolRefExpr::VK_None:
> > + case MCSymbolRefExpr::VK_ABS8:
> > switch (Type) {
> > case RT32_32:
> > return IsPCRel ? ELF::R_386_PC32 : ELF::R_386_32;
> > Index: llvm/lib/MC/MCExpr.cpp
> > ===================================================================
> > --- llvm/lib/MC/MCExpr.cpp
> > +++ llvm/lib/MC/MCExpr.cpp
> > @@ -205,6 +205,7 @@
> > case VK_SECREL: return "SECREL32";
> > case VK_SIZE: return "SIZE";
> > case VK_WEAKREF: return "WEAKREF";
> > + case VK_ABS8: return "ABS8";
> > case VK_ARM_NONE: return "none";
> > case VK_ARM_GOT_PREL: return "GOT_PREL";
> > case VK_ARM_TARGET1: return "target1";
> > @@ -314,6 +315,7 @@
> > .Case("imgrel", VK_COFF_IMGREL32)
> > .Case("secrel32", VK_SECREL)
> > .Case("size", VK_SIZE)
> > + .Case("abs8", VK_ABS8)
> > .Case("l", VK_PPC_LO)
> > .Case("h", VK_PPC_HI)
> > .Case("ha", VK_PPC_HA)
> > Index: llvm/lib/MC/MCAssembler.cpp
> > ===================================================================
> > --- llvm/lib/MC/MCAssembler.cpp
> > +++ llvm/lib/MC/MCAssembler.cpp
> > @@ -741,6 +741,10 @@
> > MCValue Target;
> > uint64_t Value;
> > bool Resolved = evaluateFixup(Layout, Fixup, DF, Target, Value);
> > + if (Target.getSymA() &&
> > + Target.getSymA()->getKind() == MCSymbolRefExpr::VK_ABS8 &&
> > + Fixup.getKind() == FK_Data_1)
> > + return false;
> > return getBackend().fixupNeedsRelaxationAdvanced(Fixup, Resolved,
> Value, DF,
> > Layout);
> > }
> > Index: llvm/include/llvm/MC/MCExpr.h
> > ===================================================================
> > --- llvm/include/llvm/MC/MCExpr.h
> > +++ llvm/include/llvm/MC/MCExpr.h
> > @@ -190,6 +190,7 @@
> > VK_SECREL,
> > VK_SIZE, // symbol at SIZE
> > VK_WEAKREF, // The link between the symbols in .weakref foo, bar
> > + VK_ABS8,
> >
> > VK_ARM_NONE,
> > VK_ARM_GOT_PREL,
> > Index: llvm/docs/Extensions.rst
> > ===================================================================
> > --- llvm/docs/Extensions.rst
> > +++ llvm/docs/Extensions.rst
> > @@ -207,6 +207,17 @@
> > Target Specific Behaviour
> > =========================
> >
> > +X86
> > +---
> > +
> > +Relocations
> > +^^^^^^^^^^^
> > +
> > +``@ABS8`` can be applied to symbols which appear as immediate operands
> to
> > +instructions that have a 8-bit immediate form for that operand. It
> causes
> > +the assembler to use the 8-bit form and an 8-bit relocation (e.g.
> ``R_386_8``
> > +or ``R_X86_64_8``) for the symbol.
> > +
> > Windows on ARM
> > --------------
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
--
--
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170130/23ad57c5/attachment.html>
More information about the llvm-commits
mailing list