This situation can occur:
[oota-llvm.git] / lib / Target / X86 / X86TargetAsmInfo.cpp
index acc13ba1070091ee26cbe0eba4648bed85c70f92..887c13dcc767866ee5789621d0b0173d2ea44315 100644 (file)
@@ -25,7 +25,8 @@
 using namespace llvm;
 using namespace llvm::dwarf;
 
-static const char* x86_asm_table[] = {"{si}", "S",
+static const char *const x86_asm_table[] = {
+                                      "{si}", "S",
                                       "{di}", "D",
                                       "{ax}", "a",
                                       "{cx}", "c",
@@ -65,6 +66,7 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     ReadOnlySection = "\t.const\n";
     LCOMMDirective = "\t.lcomm\t";
     SwitchToSectionDirective = "\t.section ";
+    StringConstantPrefix = "\1LC";
     COMMDirectiveTakesAlignment = false;
     HasDotTypeDotSizeDirective = false;
     if (TM.getRelocationModel() == Reloc::Static) {
@@ -82,14 +84,16 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
       PersonalitySuffix = "$non_lazy_ptr";
     }
     NeedsIndirectEncoding = true;
-    InlineAsmStart = "# InlineAsm Start";
-    InlineAsmEnd = "# InlineAsm End";
+    InlineAsmStart = "## InlineAsm Start";
+    InlineAsmEnd = "## InlineAsm End";
+    CommentString = "##";
     SetDirective = "\t.set";
     PCSymbol = ".";
     UsedDirective = "\t.no_dead_strip\t";
     WeakDefDirective = "\t.weak_definition ";
     WeakRefDirective = "\t.weak_reference ";
     HiddenDirective = "\t.private_extern ";
+    ProtectedDirective = "\t.globl\t";
     
     // In non-PIC modes, emit a special label before jump tables so that the
     // linker can perform more accurate dead code stripping.
@@ -117,8 +121,6 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     GlobalEHDirective = "\t.globl\t";
     SupportsWeakOmittedEHFrame = false;
     AbsoluteEHSectionOffsets = false;
-    if (Subtarget->is64Bit())
-      ShortenEHDataOn64Bit = true;
     DwarfEHFrameSection =
     ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
     DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
@@ -226,6 +228,10 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     SectionEndDirectiveSuffix = "\tends\n";
   }
 
+  // On Linux we must declare when we can use a non-executable stack.
+  if (Subtarget->isLinux())
+    NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
+
   AssemblerDialect = Subtarget->getAsmFlavor();
 }
 
@@ -251,7 +257,7 @@ bool X86TargetAsmInfo::LowerToBSwap(CallInst *CI) const {
   Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);
   
   Value *Op = CI->getOperand(1);
-  Op = new CallInst(Int, Op, CI->getName(), CI);
+  Op = CallInst::Create(Int, Op, CI->getName(), CI);
   
   CI->replaceAllUsesWith(Op);
   CI->eraseFromParent();
@@ -313,15 +319,15 @@ bool X86TargetAsmInfo::ExpandInlineAsm(CallInst *CI) const {
 /// format used for encoding pointers in exception handling data. Reason is
 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
 /// if the symbol can be relocated.
-unsigned X86TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
+unsigned X86TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
                                                  bool Global) const {
   const X86Subtarget *Subtarget = &X86TM->getSubtarget<X86Subtarget>();
 
   switch (Subtarget->TargetType) {
   case X86Subtarget::isDarwin:
-   if (Reason == 2 && Global)
+   if (Reason == DwarfEncoding::Functions && Global)
      return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
-   else if (Reason == 1 || !Global)
+   else if (Reason == DwarfEncoding::CodeLabels || !Global)
      return DW_EH_PE_pcrel;
    else
      return DW_EH_PE_absptr;
@@ -343,7 +349,8 @@ unsigned X86TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
         // - code model is medium and we're emitting externally visible symbols or
         //   any code symbols
         if (CM == CodeModel::Small ||
-            (CM == CodeModel::Medium && (Global || Reason)))
+            (CM == CodeModel::Medium && (Global ||
+                                         Reason != DwarfEncoding::Data)))
           Format = DW_EH_PE_sdata4;
         else
           Format = DW_EH_PE_sdata8;
@@ -356,7 +363,7 @@ unsigned X86TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
     } else {
       if (Subtarget->is64Bit() &&
           (CM == CodeModel::Small ||
-           (CM == CodeModel::Medium && Reason)))
+           (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
         return DW_EH_PE_udata4;
       else
         return DW_EH_PE_absptr;