CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
239 lines
7.9 KiB
C++
239 lines
7.9 KiB
C++
//===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains the declarations of the X86MCAsmInfo properties.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "X86MCAsmInfo.h"
|
|
#include "llvm/MC/MCExpr.h"
|
|
#include "llvm/MC/MCStreamer.h"
|
|
#include "llvm/Support/CommandLine.h"
|
|
#include "llvm/TargetParser/Triple.h"
|
|
using namespace llvm;
|
|
|
|
enum AsmWriterFlavorTy {
|
|
// Note: This numbering has to match the GCC assembler dialects for inline
|
|
// asm alternatives to work right.
|
|
ATT = 0, Intel = 1
|
|
};
|
|
|
|
static cl::opt<AsmWriterFlavorTy> X86AsmSyntax(
|
|
"x86-asm-syntax", cl::init(ATT), cl::Hidden,
|
|
cl::desc("Select the assembly style for input"),
|
|
cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
|
|
clEnumValN(Intel, "intel", "Emit Intel-style assembly")));
|
|
|
|
static cl::opt<bool>
|
|
MarkedJTDataRegions("mark-data-regions", cl::init(true),
|
|
cl::desc("Mark code section jump table data regions."),
|
|
cl::Hidden);
|
|
|
|
const MCAsmInfo::AtSpecifier atSpecifiers[] = {
|
|
{X86::S_ABS8, "ABS8"},
|
|
{X86::S_DTPOFF, "DTPOFF"},
|
|
{X86::S_DTPREL, "DTPREL"},
|
|
{X86::S_GOT, "GOT"},
|
|
{X86::S_GOTENT, "GOTENT"},
|
|
{X86::S_GOTNTPOFF, "GOTNTPOFF"},
|
|
{X86::S_GOTOFF, "GOTOFF"},
|
|
{X86::S_GOTPCREL, "GOTPCREL"},
|
|
{X86::S_GOTPCREL_NORELAX, "GOTPCREL_NORELAX"},
|
|
{X86::S_GOTREL, "GOTREL"},
|
|
{X86::S_GOTTPOFF, "GOTTPOFF"},
|
|
{X86::S_INDNTPOFF, "INDNTPOFF"},
|
|
{MCSymbolRefExpr::VK_COFF_IMGREL32, "IMGREL"},
|
|
{X86::S_NTPOFF, "NTPOFF"},
|
|
{X86::S_PCREL, "PCREL"},
|
|
{X86::S_PLT, "PLT"},
|
|
{X86::S_PLTOFF, "PLTOFF"},
|
|
{X86::S_COFF_SECREL, "SECREL32"},
|
|
{X86::S_SIZE, "SIZE"},
|
|
{X86::S_TLSCALL, "tlscall"},
|
|
{X86::S_TLSDESC, "tlsdesc"},
|
|
{X86::S_TLSGD, "TLSGD"},
|
|
{X86::S_TLSLD, "TLSLD"},
|
|
{X86::S_TLSLDM, "TLSLDM"},
|
|
{X86::S_TLVP, "TLVP"},
|
|
{X86::S_TLVPPAGE, "TLVPPAGE"},
|
|
{X86::S_TLVPPAGEOFF, "TLVPPAGEOFF"},
|
|
{X86::S_TPOFF, "TPOFF"},
|
|
};
|
|
|
|
void X86MCAsmInfoDarwin::anchor() { }
|
|
|
|
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T,
|
|
const MCTargetOptions &Options)
|
|
: MCAsmInfoDarwin(Options) {
|
|
bool is64Bit = T.isX86_64();
|
|
if (is64Bit)
|
|
CodePointerSize = CalleeSaveStackSlotSize = 8;
|
|
|
|
AssemblerDialect = X86AsmSyntax;
|
|
|
|
if (!is64Bit)
|
|
Data64bitsDirective = nullptr; // we can't emit a 64-bit unit
|
|
|
|
// Use ## as a comment string so that .s files generated by llvm can go
|
|
// through the GCC preprocessor without causing an error. This is needed
|
|
// because "clang foo.s" runs the C preprocessor, which is usually reserved
|
|
// for .S files on other systems. Perhaps this is because the file system
|
|
// wasn't always case preserving or something.
|
|
CommentString = "##";
|
|
|
|
SupportsDebugInformation = true;
|
|
UseDataRegionDirectives = MarkedJTDataRegions;
|
|
|
|
// Exceptions handling
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
|
|
|
// old assembler lacks some directives
|
|
// FIXME: this should really be a check on the assembler characteristics
|
|
// rather than OS version
|
|
if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
|
|
HasWeakDefCanBeHiddenDirective = false;
|
|
|
|
// Assume ld64 is new enough that the abs-ified FDE relocs may be used
|
|
// (actually, must, since otherwise the non-extern relocations we produce
|
|
// overwhelm ld64's tiny little mind and it fails).
|
|
DwarfFDESymbolsUseAbsDiff = true;
|
|
|
|
initializeAtSpecifiers(atSpecifiers);
|
|
}
|
|
|
|
X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple,
|
|
const MCTargetOptions &Options)
|
|
: X86MCAsmInfoDarwin(Triple, Options) {}
|
|
|
|
void X86ELFMCAsmInfo::anchor() { }
|
|
|
|
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T,
|
|
const MCTargetOptions &Options)
|
|
: MCAsmInfoELF(Options) {
|
|
bool is64Bit = T.isX86_64();
|
|
bool isX32 = T.isX32();
|
|
|
|
// For ELF, x86-64 pointer size depends on the ABI.
|
|
// For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
|
|
// with the x32 ABI, pointer size remains the default 4.
|
|
CodePointerSize = (is64Bit && !isX32) ? 8 : 4;
|
|
|
|
// OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
|
|
CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
|
|
|
|
AssemblerDialect = X86AsmSyntax;
|
|
|
|
// Debug Information
|
|
SupportsDebugInformation = true;
|
|
|
|
// Exceptions handling
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
|
|
|
initializeAtSpecifiers(atSpecifiers);
|
|
}
|
|
|
|
const MCExpr *
|
|
X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym,
|
|
unsigned Encoding,
|
|
MCStreamer &Streamer) const {
|
|
MCContext &Context = Streamer.getContext();
|
|
const MCExpr *Res = MCSymbolRefExpr::create(Sym, X86::S_GOTPCREL, Context);
|
|
const MCExpr *Four = MCConstantExpr::create(4, Context);
|
|
return MCBinaryExpr::createAdd(Res, Four, Context);
|
|
}
|
|
|
|
void X86MCAsmInfoMicrosoft::anchor() { }
|
|
|
|
X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple,
|
|
const MCTargetOptions &Options)
|
|
: MCAsmInfoMicrosoft(Options) {
|
|
if (Triple.isX86_64()) {
|
|
InternalSymbolPrefix = ".L";
|
|
CodePointerSize = 8;
|
|
WinEHEncodingType = WinEH::EncodingType::Itanium;
|
|
} else {
|
|
// 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just
|
|
// a place holder that the Windows EHStreamer looks for to suppress CFI
|
|
// output. In particular, usesWindowsCFI() returns false.
|
|
WinEHEncodingType = WinEH::EncodingType::X86;
|
|
}
|
|
|
|
ExceptionsType = ExceptionHandling::WinEH;
|
|
|
|
AssemblerDialect = X86AsmSyntax;
|
|
|
|
AllowAtInName = true;
|
|
|
|
initializeAtSpecifiers(atSpecifiers);
|
|
}
|
|
|
|
void X86MCAsmInfoMicrosoftMASM::anchor() { }
|
|
|
|
X86MCAsmInfoMicrosoftMASM::X86MCAsmInfoMicrosoftMASM(
|
|
const Triple &Triple, const MCTargetOptions &Options)
|
|
: X86MCAsmInfoMicrosoft(Triple, Options) {
|
|
DollarIsPC = true;
|
|
SeparatorString = "\n";
|
|
CommentString = ";";
|
|
AllowAdditionalComments = false;
|
|
AllowQuestionAtStartOfIdentifier = true;
|
|
AllowDollarAtStartOfIdentifier = true;
|
|
AllowAtAtStartOfIdentifier = true;
|
|
}
|
|
|
|
static bool isValidX86UnquotedName(const MCAsmInfo &MAI, StringRef Name) {
|
|
if (!MAI.MCAsmInfo::isValidUnquotedName(Name))
|
|
return false;
|
|
// Only Intel-syntax output needs to avoid register/keyword collisions; AT&T
|
|
// disambiguates registers with '%' and doesn't treat `byte`, `ptr`, etc. as
|
|
// keywords.
|
|
if (MAI.getOutputAssemblerDialect() == 0)
|
|
return true;
|
|
return !MAI.getReservedIdentifiers().contains(
|
|
CachedHashStringRef(Name.lower()));
|
|
}
|
|
|
|
bool X86MCAsmInfoDarwin::isValidUnquotedName(StringRef Name) const {
|
|
return isValidX86UnquotedName(*this, Name);
|
|
}
|
|
|
|
bool X86ELFMCAsmInfo::isValidUnquotedName(StringRef Name) const {
|
|
return isValidX86UnquotedName(*this, Name);
|
|
}
|
|
|
|
bool X86MCAsmInfoMicrosoft::isValidUnquotedName(StringRef Name) const {
|
|
return isValidX86UnquotedName(*this, Name);
|
|
}
|
|
|
|
bool X86MCAsmInfoGNUCOFF::isValidUnquotedName(StringRef Name) const {
|
|
return isValidX86UnquotedName(*this, Name);
|
|
}
|
|
|
|
void X86MCAsmInfoGNUCOFF::anchor() { }
|
|
|
|
X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple,
|
|
const MCTargetOptions &Options)
|
|
: MCAsmInfoGNUCOFF(Options) {
|
|
assert((Triple.isOSWindows() || Triple.isUEFI()) &&
|
|
"Windows and UEFI are the only supported COFF targets");
|
|
if (Triple.isX86_64()) {
|
|
InternalSymbolPrefix = ".L";
|
|
CodePointerSize = 8;
|
|
WinEHEncodingType = WinEH::EncodingType::Itanium;
|
|
ExceptionsType = ExceptionHandling::WinEH;
|
|
} else {
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
|
}
|
|
|
|
AssemblerDialect = X86AsmSyntax;
|
|
|
|
AllowAtInName = true;
|
|
|
|
initializeAtSpecifiers(atSpecifiers);
|
|
}
|