LLVM API Documentation

X86TargetAsmInfo.cpp

Go to the documentation of this file.
00001 //===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the declarations of the X86TargetAsmInfo properties.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "X86TargetAsmInfo.h"
00015 #include "X86TargetMachine.h"
00016 #include "llvm/ADT/Triple.h"
00017 #include "llvm/Support/CommandLine.h"
00018 using namespace llvm;
00019 
00020 enum AsmWriterFlavorTy {
00021   // Note: This numbering has to match the GCC assembler dialects for inline
00022   // asm alternatives to work right.
00023   ATT = 0, Intel = 1
00024 };
00025 
00026 static cl::opt<AsmWriterFlavorTy>
00027 AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
00028   cl::desc("Choose style of code to emit from X86 backend:"),
00029   cl::values(clEnumValN(ATT,   "att",   "Emit AT&T-style assembly"),
00030              clEnumValN(Intel, "intel", "Emit Intel-style assembly"),
00031              clEnumValEnd));
00032 
00033 
00034 static const char *const x86_asm_table[] = {
00035   "{si}", "S",
00036   "{di}", "D",
00037   "{ax}", "a",
00038   "{cx}", "c",
00039   "{memory}", "memory",
00040   "{flags}", "",
00041   "{dirflag}", "",
00042   "{fpsr}", "",
00043   "{cc}", "cc",
00044   0,0};
00045 
00046 X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const Triple &Triple) {
00047   AsmTransCBE = x86_asm_table;
00048   AssemblerDialect = AsmWriterFlavor;
00049     
00050   bool is64Bit = Triple.getArch() == Triple::x86_64;
00051 
00052   TextAlignFillValue = 0x90;
00053 
00054   if (!is64Bit)
00055     Data64bitsDirective = 0;       // we can't emit a 64-bit unit
00056 
00057   // Leopard and above support aligned common symbols.
00058   COMMDirectiveTakesAlignment = Triple.getDarwinMajorNumber() >= 9;
00059 
00060   if (is64Bit) {
00061     PersonalityPrefix = "";
00062     PersonalitySuffix = "+4@GOTPCREL";
00063   } else {
00064     PersonalityPrefix = "L";
00065     PersonalitySuffix = "$non_lazy_ptr";
00066   }
00067 
00068   CommentString = "##";
00069   PCSymbol = ".";
00070 
00071   SupportsDebugInformation = true;
00072   DwarfUsesInlineInfoSection = true;
00073 
00074   // Exceptions handling
00075   ExceptionsType = ExceptionHandling::Dwarf;
00076   AbsoluteEHSectionOffsets = false;
00077 }
00078 
00079 X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const Triple &Triple) {
00080   AsmTransCBE = x86_asm_table;
00081   AssemblerDialect = AsmWriterFlavor;
00082 
00083   PrivateGlobalPrefix = ".L";
00084   WeakRefDirective = "\t.weak\t";
00085   SetDirective = "\t.set\t";
00086   PCSymbol = ".";
00087 
00088   // Set up DWARF directives
00089   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
00090 
00091   // Debug Information
00092   AbsoluteDebugSectionOffsets = true;
00093   SupportsDebugInformation = true;
00094 
00095   // Exceptions handling
00096   ExceptionsType = ExceptionHandling::Dwarf;
00097   AbsoluteEHSectionOffsets = false;
00098 
00099   // On Linux we must declare when we can use a non-executable stack.
00100   if (Triple.getOS() == Triple::Linux)
00101     NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
00102 }
00103 
00104 X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const Triple &Triple) {
00105   AsmTransCBE = x86_asm_table;
00106   AssemblerDialect = AsmWriterFlavor;
00107 }
00108 
00109 
00110 X86WinTargetAsmInfo::X86WinTargetAsmInfo(const Triple &Triple) {
00111   AsmTransCBE = x86_asm_table;
00112   AssemblerDialect = AsmWriterFlavor;
00113 
00114   GlobalPrefix = "_";
00115   CommentString = ";";
00116 
00117   PrivateGlobalPrefix = "$";
00118   AlignDirective = "\tALIGN\t";
00119   ZeroDirective = "\tdb\t";
00120   ZeroDirectiveSuffix = " dup(0)";
00121   AsciiDirective = "\tdb\t";
00122   AscizDirective = 0;
00123   Data8bitsDirective = "\tdb\t";
00124   Data16bitsDirective = "\tdw\t";
00125   Data32bitsDirective = "\tdd\t";
00126   Data64bitsDirective = "\tdq\t";
00127   HasDotTypeDotSizeDirective = false;
00128   HasSingleParameterDotFile = false;
00129 
00130   AlignmentIsInBytes = true;
00131 }