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"
|
2009-08-12 15:22:17 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2010-04-09 05:26:26 +08:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2011-04-29 00:09:09 +08:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
2010-01-23 15:21:06 +08:00
|
|
|
#include "llvm/MC/MCSectionELF.h"
|
2011-04-29 00:09:09 +08:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2009-08-12 07:01:09 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2011-01-23 12:28:49 +08:00
|
|
|
#include "llvm/Support/ELF.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
|
|
|
|
};
|
|
|
|
|
|
|
|
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-25 07:06:27 +08: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-12 07:01:09 +08:00
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86MCAsmInfoDarwin::anchor() { }
|
|
|
|
|
2011-07-15 10:09:41 +08:00
|
|
|
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
|
|
|
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
|
|
|
if (is64Bit)
|
2013-01-23 02:02:49 +08:00
|
|
|
PointerSize = 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)
|
|
|
|
Data64bitsDirective = 0; // 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 = "##";
|
|
|
|
PCSymbol = ".";
|
|
|
|
|
|
|
|
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;
|
2008-07-09 21:20:48 +08:00
|
|
|
}
|
|
|
|
|
2011-04-29 00:09:09 +08:00
|
|
|
X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
|
|
|
|
: X86MCAsmInfoDarwin(Triple) {
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86ELFMCAsmInfo::anchor() { }
|
|
|
|
|
2010-03-11 08:06:19 +08:00
|
|
|
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
2013-01-23 02:02:49 +08: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 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
|
|
|
PrivateGlobalPrefix = ".L";
|
|
|
|
WeakRefDirective = "\t.weak\t";
|
|
|
|
PCSymbol = ".";
|
|
|
|
|
|
|
|
// Set up DWARF directives
|
|
|
|
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
|
|
|
|
|
|
|
// Debug Information
|
|
|
|
SupportsDebugInformation = true;
|
|
|
|
|
|
|
|
// Exceptions handling
|
2011-04-15 23:11:06 +08:00
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
|
|
|
|
2012-08-07 04:52:18 +08: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 08:06:19 +08:00
|
|
|
Data64bitsDirective = 0;
|
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 =
|
|
|
|
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Context);
|
|
|
|
const MCExpr *Four = MCConstantExpr::Create(4, Context);
|
|
|
|
return MCBinaryExpr::CreateAdd(Res, Four, Context);
|
|
|
|
}
|
|
|
|
|
2010-04-09 05:26:26 +08:00
|
|
|
const MCSection *X86ELFMCAsmInfo::
|
|
|
|
getNonexecutableStackSection(MCContext &Ctx) const {
|
2011-01-23 12:28:49 +08:00
|
|
|
return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS,
|
2010-11-11 11:40:25 +08:00
|
|
|
0, SectionKind::getMetadata());
|
2008-07-09 21:20:48 +08:00
|
|
|
}
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86MCAsmInfoMicrosoft::anchor() { }
|
|
|
|
|
2011-11-30 02:00:06 +08:00
|
|
|
X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple) {
|
|
|
|
if (Triple.getArch() == Triple::x86_64) {
|
|
|
|
GlobalPrefix = "";
|
|
|
|
PrivateGlobalPrefix = ".L";
|
|
|
|
}
|
|
|
|
|
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
|
|
|
|
|
|
|
TextAlignFillValue = 0x90;
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void X86MCAsmInfoGNUCOFF::anchor() { }
|
|
|
|
|
2011-11-30 02:00:06 +08:00
|
|
|
X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple) {
|
2010-12-07 10:43:45 +08:00
|
|
|
if (Triple.getArch() == Triple::x86_64) {
|
2010-08-21 13:58:13 +08:00
|
|
|
GlobalPrefix = "";
|
2010-12-07 10:43:45 +08:00
|
|
|
PrivateGlobalPrefix = ".L";
|
|
|
|
}
|
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
|
|
|
|
|
|
|
// Exceptions handling
|
|
|
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
2010-02-16 18:25:04 +08:00
|
|
|
}
|