2009-08-22 20:48:53 +00:00
|
|
|
//===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
|
2006-09-07 22:05:02 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-09-07 22:05:02 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-08-22 20:48:53 +00:00
|
|
|
// This file contains the declarations of the X86MCAsmInfo properties.
|
2006-09-07 22:05:02 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-08-22 20:48:53 +00:00
|
|
|
#include "X86MCAsmInfo.h"
|
2009-08-12 07:22:17 +00:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2010-04-08 21:26:26 +00:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2011-04-28 16:09:09 +00:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
2010-01-23 07:21:06 +00:00
|
|
|
#include "llvm/MC/MCSectionELF.h"
|
2011-04-28 16:09:09 +00:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2009-08-11 23:01:09 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2011-01-23 04:28:49 +00:00
|
|
|
#include "llvm/Support/ELF.h"
|
2006-09-07 22:05:02 +00:00
|
|
|
using namespace llvm;
|
2009-08-11 23:01:09 +00:00
|
|
|
|
|
|
|
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>
|
|
|
|
AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
|
|
|
|
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"),
|
|
|
|
clEnumValEnd));
|
|
|
|
|
2012-09-24 23:06:27 +00:00
|
|
|
static cl::opt<bool>
|
|
|
|
MarkedJTDataRegions("mark-data-regions", cl::init(false),
|
|
|
|
cl::desc("Mark code section jump table data regions."),
|
|
|
|
cl::Hidden);
|
2009-08-11 23:01:09 +00:00
|
|
|
|
2011-12-20 02:50:00 +00:00
|
|
|
void X86MCAsmInfoDarwin::anchor() { }
|
|
|
|
|
2011-07-15 02:09:41 +00:00
|
|
|
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
|
|
|
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
|
|
|
if (is64Bit)
|
2013-01-22 18:02:49 +00:00
|
|
|
PointerSize = CalleeSaveStackSlotSize = 8;
|
2011-07-15 02:09:41 +00:00
|
|
|
|
2009-08-11 23:01:09 +00:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2011-07-07 22:54:12 +00:00
|
|
|
|
2008-07-09 13:20:48 +00:00
|
|
|
TextAlignFillValue = 0x90;
|
2009-07-24 08:24:36 +00:00
|
|
|
|
2008-07-09 13:20:48 +00:00
|
|
|
if (!is64Bit)
|
|
|
|
Data64bitsDirective = 0; // we can't emit a 64-bit unit
|
2009-07-13 18:48:39 +00:00
|
|
|
|
2010-02-17 01:38:01 +00:00
|
|
|
// Use ## as a comment string so that .s files generated by llvm can go
|
2010-02-17 01:55:54 +00: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 13:20:48 +00:00
|
|
|
CommentString = "##";
|
|
|
|
|
|
|
|
SupportsDebugInformation = true;
|
2012-09-24 23:06:27 +00:00
|
|
|
UseDataRegionDirectives = MarkedJTDataRegions;
|
2008-07-09 13:20:48 +00:00
|
|
|
|
|
|
|
// Exceptions handling
|
2011-05-01 15:44:13 +00:00
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
2008-07-09 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-04-28 16:09:09 +00:00
|
|
|
X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
|
|
|
|
: X86MCAsmInfoDarwin(Triple) {
|
|
|
|
}
|
|
|
|
|
2011-12-20 02:50:00 +00:00
|
|
|
void X86ELFMCAsmInfo::anchor() { }
|
|
|
|
|
2010-03-11 00:06:19 +00:00
|
|
|
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
2013-01-22 18:02:49 +00:00
|
|
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
|
|
|
bool isX32 = T.getEnvironment() == Triple::GNUX32;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
PointerSize = (is64Bit && !isX32) ? 8 : 4;
|
|
|
|
|
|
|
|
// OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
|
|
|
|
CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
|
2011-07-15 02:09:41 +00:00
|
|
|
|
2009-08-11 23:01:09 +00:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2008-07-09 13:28:49 +00:00
|
|
|
|
2010-02-25 18:07:10 +00:00
|
|
|
TextAlignFillValue = 0x90;
|
|
|
|
|
2008-07-09 13:20:48 +00:00
|
|
|
// Set up DWARF directives
|
|
|
|
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
|
|
|
|
|
|
|
// Debug Information
|
|
|
|
SupportsDebugInformation = true;
|
|
|
|
|
|
|
|
// Exceptions handling
|
2011-04-15 15:11:06 +00:00
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
|
|
|
|
2012-08-06 20:52:18 +00:00
|
|
|
// OpenBSD and Bitrig have buggy support for .quad in 32-bit mode, just split
|
|
|
|
// into two .words.
|
|
|
|
if ((T.getOS() == Triple::OpenBSD || T.getOS() == Triple::Bitrig) &&
|
|
|
|
T.getArch() == Triple::x86)
|
2010-03-11 00:06:19 +00:00
|
|
|
Data64bitsDirective = 0;
|
2010-01-23 07:21:06 +00:00
|
|
|
}
|
2008-07-09 13:20:48 +00:00
|
|
|
|
2011-07-15 02:09:41 +00:00
|
|
|
const MCExpr *
|
|
|
|
X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym,
|
|
|
|
unsigned Encoding,
|
|
|
|
MCStreamer &Streamer) const {
|
|
|
|
MCContext &Context = Streamer.getContext();
|
|
|
|
const MCExpr *Res =
|
|
|
|
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Context);
|
|
|
|
const MCExpr *Four = MCConstantExpr::Create(4, Context);
|
|
|
|
return MCBinaryExpr::CreateAdd(Res, Four, Context);
|
|
|
|
}
|
|
|
|
|
2010-04-08 21:26:26 +00:00
|
|
|
const MCSection *X86ELFMCAsmInfo::
|
|
|
|
getNonexecutableStackSection(MCContext &Ctx) const {
|
2011-01-23 04:28:49 +00:00
|
|
|
return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS,
|
2010-11-11 03:40:25 +00:00
|
|
|
0, SectionKind::getMetadata());
|
2008-07-09 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-12-20 02:50:00 +00:00
|
|
|
void X86MCAsmInfoMicrosoft::anchor() { }
|
|
|
|
|
2011-11-29 18:00:06 +00:00
|
|
|
X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple) {
|
|
|
|
if (Triple.getArch() == Triple::x86_64) {
|
2013-11-28 17:00:49 +00:00
|
|
|
GlobalPrefix = '\0';
|
2011-11-29 18:00:06 +00:00
|
|
|
PrivateGlobalPrefix = ".L";
|
2013-12-09 20:44:48 +00:00
|
|
|
HasMicrosoftFastStdCallMangling = false;
|
2011-11-29 18:00:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
|
|
|
|
|
|
|
TextAlignFillValue = 0x90;
|
2013-10-18 20:46:28 +00:00
|
|
|
|
|
|
|
AllowAtInName = true;
|
2011-11-29 18:00:06 +00:00
|
|
|
}
|
|
|
|
|
2011-12-20 02:50:00 +00:00
|
|
|
void X86MCAsmInfoGNUCOFF::anchor() { }
|
|
|
|
|
2011-11-29 18:00:06 +00:00
|
|
|
X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple) {
|
2010-12-07 02:43:45 +00:00
|
|
|
if (Triple.getArch() == Triple::x86_64) {
|
2013-11-28 17:00:49 +00:00
|
|
|
GlobalPrefix = '\0';
|
2010-12-07 02:43:45 +00:00
|
|
|
PrivateGlobalPrefix = ".L";
|
2013-12-09 20:44:48 +00:00
|
|
|
HasMicrosoftFastStdCallMangling = false;
|
2010-12-07 02:43:45 +00:00
|
|
|
}
|
2010-08-21 05:58:13 +00:00
|
|
|
|
2009-08-11 23:01:09 +00:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2010-02-25 18:07:10 +00:00
|
|
|
|
|
|
|
TextAlignFillValue = 0x90;
|
2012-04-07 02:24:20 +00:00
|
|
|
|
|
|
|
// Exceptions handling
|
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
2010-02-16 10:25:04 +00:00
|
|
|
}
|