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"
|
2006-09-07 22:05:02 +00:00
|
|
|
#include "X86TargetMachine.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"
|
2010-01-23 07:21:06 +00:00
|
|
|
#include "llvm/MC/MCSectionELF.h"
|
2009-08-11 23:01:09 +00:00
|
|
|
#include "llvm/Support/CommandLine.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));
|
|
|
|
|
|
|
|
|
2009-08-11 21:57:08 +00:00
|
|
|
static const char *const x86_asm_table[] = {
|
2008-09-25 21:00:33 +00:00
|
|
|
"{si}", "S",
|
|
|
|
"{di}", "D",
|
|
|
|
"{ax}", "a",
|
|
|
|
"{cx}", "c",
|
|
|
|
"{memory}", "memory",
|
|
|
|
"{flags}", "",
|
|
|
|
"{dirflag}", "",
|
|
|
|
"{fpsr}", "",
|
|
|
|
"{cc}", "cc",
|
|
|
|
0,0};
|
|
|
|
|
2010-01-20 06:34:14 +00:00
|
|
|
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
|
2009-08-11 21:57:08 +00:00
|
|
|
AsmTransCBE = x86_asm_table;
|
2009-08-11 23:01:09 +00:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2009-08-11 21:57:08 +00:00
|
|
|
|
2009-08-12 07:22:17 +00:00
|
|
|
bool is64Bit = Triple.getArch() == Triple::x86_64;
|
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 = "##";
|
|
|
|
PCSymbol = ".";
|
|
|
|
|
|
|
|
SupportsDebugInformation = true;
|
2009-04-13 17:02:03 +00:00
|
|
|
DwarfUsesInlineInfoSection = true;
|
2008-07-09 13:20:48 +00:00
|
|
|
|
2010-12-01 16:59:34 +00:00
|
|
|
// Disable debugging information for older targets that do not support
|
|
|
|
// .loc and are broken by regressions in .debug_line entries.
|
|
|
|
if (Triple.getOS() == Triple::Darwin) {
|
|
|
|
switch (Triple.getDarwinMajorNumber()) {
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
SupportsDebugInformation = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-09 13:20:48 +00:00
|
|
|
// Exceptions handling
|
2009-08-11 00:09:57 +00:00
|
|
|
ExceptionsType = ExceptionHandling::Dwarf;
|
2008-07-09 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-03-11 00:06:19 +00:00
|
|
|
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
2009-08-11 21:57:08 +00:00
|
|
|
AsmTransCBE = x86_asm_table;
|
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
|
|
|
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
|
2009-08-11 00:09:57 +00:00
|
|
|
ExceptionsType = ExceptionHandling::Dwarf;
|
2010-03-11 00:06:19 +00:00
|
|
|
|
|
|
|
// OpenBSD has buggy support for .quad in 32-bit mode, just split into two
|
|
|
|
// .words.
|
|
|
|
if (T.getOS() == Triple::OpenBSD && T.getArch() == Triple::x86)
|
|
|
|
Data64bitsDirective = 0;
|
2010-01-23 07:21:06 +00:00
|
|
|
}
|
2008-07-09 13:20:48 +00:00
|
|
|
|
2010-04-08 21:26:26 +00:00
|
|
|
const MCSection *X86ELFMCAsmInfo::
|
|
|
|
getNonexecutableStackSection(MCContext &Ctx) const {
|
|
|
|
return Ctx.getELFSection(".note.GNU-stack", MCSectionELF::SHT_PROGBITS,
|
2010-11-11 03:40:25 +00:00
|
|
|
0, SectionKind::getMetadata());
|
2008-07-09 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 06:34:14 +00:00
|
|
|
X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) {
|
2010-08-21 05:58:13 +00:00
|
|
|
if (Triple.getArch() == Triple::x86_64)
|
|
|
|
GlobalPrefix = "";
|
|
|
|
|
2009-08-11 21:57:08 +00:00
|
|
|
AsmTransCBE = x86_asm_table;
|
2009-08-11 23:01:09 +00:00
|
|
|
AssemblerDialect = AsmWriterFlavor;
|
2010-02-25 18:07:10 +00:00
|
|
|
|
|
|
|
TextAlignFillValue = 0x90;
|
2010-02-16 10:25:04 +00:00
|
|
|
}
|