2009-08-23 04:48:53 +08:00
|
|
|
//===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
|
2006-09-08 06:05:02 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-09-08 06:05:02 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-08-23 04:48:53 +08:00
|
|
|
// This file contains the declarations of the X86MCAsmInfo properties.
|
2006-09-08 06:05:02 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-08-23 04:48:53 +08:00
|
|
|
#include "X86MCAsmInfo.h"
|
2015-09-16 00:17:27 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2011-04-29 00:09:09 +08:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2009-08-12 07:01:09 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2006-09-08 06:05:02 +08:00
|
|
|
using namespace llvm;
|
2009-08-12 07:01:09 +08:00
|
|
|
|
|
|
|
enum AsmWriterFlavorTy {
|
|
|
|
// Note: This numbering has to match the GCC assembler dialects for inline
|
|
|
|
// asm alternatives to work right.
|
|
|
|
ATT = 0, Intel = 1
|
|
|
|
};
|
|
|
|
|
2017-12-01 08:53:10 +08:00
|
|
|
static cl::opt<AsmWriterFlavorTy> AsmWriterFlavor(
|
|
|
|
"x86-asm-syntax", cl::init(ATT), cl::Hidden,
|
|
|
|
cl::desc("Choose style of code to emit from X86 backend:"),
|
|
|
|
cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
|
|
|
|
clEnumValN(Intel, "intel", "Emit Intel-style assembly")));
|
2009-08-12 07:01:09 +08:00
|
|
|
|
2012-09-25 07:06:27 +08:00
|
|
|
static cl::opt<bool>
|
2016-05-04 05:03:41 +08:00
|
|
|
MarkedJTDataRegions("mark-data-regions", cl::init(true),
|
2012-09-25 07:06:27 +08:00
|
|
|
cl::desc("Mark code section jump table data regions."),
|
|
|
|
cl::Hidden);
|
2009-08-12 07:01:09 +08:00
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86MCAsmInfoDarwin::anchor() { }
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
|
|
|
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
2011-07-15 10:09:41 +08:00
|
|
|
if (is64Bit)
|
2017-04-18 01:41:25 +08:00
|
|
|
CodePointerSize = CalleeSaveStackSlotSize = 8;
|
2011-07-15 10:09:41 +08:00
|
|
|
|
2009-08-12 07:01:09 +08:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2011-07-08 06:54:12 +08:00
|
|
|
|
2008-07-09 21:20:48 +08:00
|
|
|
TextAlignFillValue = 0x90;
|
2009-07-24 16:24:36 +08:00
|
|
|
|
2008-07-09 21:20:48 +08:00
|
|
|
if (!is64Bit)
|
2014-04-25 13:30:21 +08:00
|
|
|
Data64bitsDirective = nullptr; // we can't emit a 64-bit unit
|
2009-07-14 02:48:39 +08:00
|
|
|
|
2010-02-17 09:38:01 +08:00
|
|
|
// Use ## as a comment string so that .s files generated by llvm can go
|
2010-02-17 09:55:54 +08:00
|
|
|
// 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.
|
2008-07-09 21:20:48 +08:00
|
|
|
CommentString = "##";
|
|
|
|
|
|
|
|
SupportsDebugInformation = true;
|
2012-09-25 07:06:27 +08:00
|
|
|
UseDataRegionDirectives = MarkedJTDataRegions;
|
2008-07-09 21:20:48 +08:00
|
|
|
|
|
|
|
// Exceptions handling
|
2011-05-01 23:44:13 +08:00
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
2013-12-11 05:37:41 +08:00
|
|
|
|
|
|
|
// old assembler lacks some directives
|
|
|
|
// FIXME: this should really be a check on the assembler characteristics
|
|
|
|
// rather than OS version
|
2015-09-16 00:17:27 +08:00
|
|
|
if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
|
2013-12-11 05:37:41 +08:00
|
|
|
HasWeakDefCanBeHiddenDirective = false;
|
2014-01-08 18:22:54 +08:00
|
|
|
|
2014-07-22 23:47:09 +08:00
|
|
|
// 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;
|
2014-02-13 22:44:26 +08:00
|
|
|
|
|
|
|
UseIntegratedAssembler = true;
|
2008-07-09 21:20:48 +08:00
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
|
|
|
|
: X86MCAsmInfoDarwin(Triple) {
|
|
|
|
}
|
2011-04-29 00:09:09 +08:00
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86ELFMCAsmInfo::anchor() { }
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
|
|
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
|
|
|
bool isX32 = T.getEnvironment() == Triple::GNUX32;
|
2013-01-23 02:02:49 +08:00
|
|
|
|
|
|
|
// 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.
|
2017-04-18 01:41:25 +08:00
|
|
|
CodePointerSize = (is64Bit && !isX32) ? 8 : 4;
|
2013-01-23 02:02:49 +08:00
|
|
|
|
|
|
|
// OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
|
|
|
|
CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
|
2011-07-15 10:09:41 +08:00
|
|
|
|
2009-08-12 07:01:09 +08:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2008-07-09 21:28:49 +08:00
|
|
|
|
2010-02-26 02:07:10 +08:00
|
|
|
TextAlignFillValue = 0x90;
|
|
|
|
|
2008-07-09 21:20:48 +08:00
|
|
|
// Debug Information
|
|
|
|
SupportsDebugInformation = true;
|
|
|
|
|
|
|
|
// Exceptions handling
|
2011-04-15 23:11:06 +08:00
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
|
|
|
|
2014-02-13 22:44:26 +08:00
|
|
|
// Always enable the integrated assembler by default.
|
|
|
|
// Clang also enabled it when the OS is Solaris but that is redundant here.
|
|
|
|
UseIntegratedAssembler = true;
|
2010-01-23 15:21:06 +08:00
|
|
|
}
|
2008-07-09 21:20:48 +08:00
|
|
|
|
2011-07-15 10:09:41 +08:00
|
|
|
const MCExpr *
|
|
|
|
X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym,
|
|
|
|
unsigned Encoding,
|
|
|
|
MCStreamer &Streamer) const {
|
|
|
|
MCContext &Context = Streamer.getContext();
|
|
|
|
const MCExpr *Res =
|
2015-05-30 09:25:56 +08:00
|
|
|
MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Context);
|
|
|
|
const MCExpr *Four = MCConstantExpr::create(4, Context);
|
|
|
|
return MCBinaryExpr::createAdd(Res, Four, Context);
|
2011-07-15 10:09:41 +08:00
|
|
|
}
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86MCAsmInfoMicrosoft::anchor() { }
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple) {
|
|
|
|
if (Triple.getArch() == Triple::x86_64) {
|
2011-11-30 02:00:06 +08:00
|
|
|
PrivateGlobalPrefix = ".L";
|
2014-12-04 08:06:57 +08:00
|
|
|
PrivateLabelPrefix = ".L";
|
2017-04-18 01:41:25 +08:00
|
|
|
CodePointerSize = 8;
|
2014-09-02 07:48:39 +08:00
|
|
|
WinEHEncodingType = WinEH::EncodingType::Itanium;
|
2015-05-30 01:00:57 +08:00
|
|
|
} 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;
|
2014-06-25 20:41:52 +08:00
|
|
|
}
|
2011-11-30 02:00:06 +08:00
|
|
|
|
2015-05-06 01:44:16 +08:00
|
|
|
ExceptionsType = ExceptionHandling::WinEH;
|
|
|
|
|
2011-11-30 02:00:06 +08:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
|
|
|
|
|
|
|
TextAlignFillValue = 0x90;
|
2013-10-19 04:46:28 +08:00
|
|
|
|
|
|
|
AllowAtInName = true;
|
2014-02-13 22:44:26 +08:00
|
|
|
|
|
|
|
UseIntegratedAssembler = true;
|
2011-11-30 02:00:06 +08:00
|
|
|
}
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86MCAsmInfoGNUCOFF::anchor() { }
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple) {
|
|
|
|
assert(Triple.isOSWindows() && "Windows is the only supported COFF target");
|
|
|
|
if (Triple.getArch() == Triple::x86_64) {
|
2010-12-07 10:43:45 +08:00
|
|
|
PrivateGlobalPrefix = ".L";
|
2014-12-04 08:06:57 +08:00
|
|
|
PrivateLabelPrefix = ".L";
|
2017-04-18 01:41:25 +08:00
|
|
|
CodePointerSize = 8;
|
2014-09-02 07:48:39 +08:00
|
|
|
WinEHEncodingType = WinEH::EncodingType::Itanium;
|
2015-01-24 02:49:01 +08:00
|
|
|
ExceptionsType = ExceptionHandling::WinEH;
|
2014-06-25 20:41:52 +08:00
|
|
|
} else {
|
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
2014-04-08 23:28:50 +08:00
|
|
|
}
|
2010-08-21 13:58:13 +08:00
|
|
|
|
2009-08-12 07:01:09 +08:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2010-02-26 02:07:10 +08:00
|
|
|
|
|
|
|
TextAlignFillValue = 0x90;
|
2012-04-07 10:24:20 +08:00
|
|
|
|
2014-02-13 22:44:26 +08:00
|
|
|
UseIntegratedAssembler = true;
|
2010-02-16 18:25:04 +08:00
|
|
|
}
|