[all-commits] [llvm/llvm-project] c177db: Move X86-specific MCSymbolRefExpr::VariantKind to ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Mar 20 20:29:10 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c177dbe484b8844874e096dc825fa9a9a1dc1e6b
      https://github.com/llvm/llvm-project/commit/c177dbe484b8844874e096dc825fa9a9a1dc1e6b
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-03-20 (Thu, 20 Mar 2025)

  Changed paths:
    M llvm/include/llvm/MC/MCExpr.h
    M llvm/lib/MC/ELFObjectWriter.cpp
    M llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimization.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86MCExpr.h
    M llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFTargetStreamer.cpp
    M llvm/lib/Target/X86/X86ISelLoweringCall.cpp
    M llvm/lib/Target/X86/X86MCInstLower.cpp
    M llvm/lib/Target/X86/X86TargetObjectFile.cpp
    M llvm/lib/Target/X86/X86TargetObjectFile.h

  Log Message:
  -----------
  Move X86-specific MCSymbolRefExpr::VariantKind to X86MCExpr::Specifier

Move target-specific members outside of MCSymbolRefExpr::VariantKind
(a legacy interface I am eliminating). Most changes are mechanic,
except:

* ELFObjectWriter::shouldRelocateWithSymbol
* The legacy generic code uses `ELFObjectWriter::fixSymbolsInTLSFixups`
  to set `STT_TLS` (and use an unnecessary expression walk). The better
  way is to do this in `getRelocType`, which I have done for
  AArch64, PowerPC, and RISC-V.

In the future, we should encode expressions with a relocation specifier
as X86MCExpr and use MCValue::RefKind to hold the specifier of the
relocatable expression.
https://maskray.me/blog/2025-03-16-relocation-generation-in-assemblers

While here, rename "Modifier' to "Specifier":

> "Relocation modifier", though concise, suggests adjustments happen during the linker's relocation step rather than the assembler's expression evaluation. I landed on "relocation specifier" as the winner. It's clear, aligns with Arm and IBM’s usage, and fits the assembler's role seamlessly.

Pull Request: https://github.com/llvm/llvm-project/pull/132149



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list