Make the big switch: Change MCSectionMachO to represent a section *semantically*
instead of syntactically as a string.  This means that it keeps track of the 
segment, section, flags, etc directly and asmprints them in the right format.
This also includes parsing and validation support for llvm-mc and 
"attribute(section)", so we should now start getting errors about invalid 
section attributes from the compiler instead of the assembler on darwin.

Still todo: 
1) Uniquing of darwin mcsections
2) Move all the Darwin stuff out to MCSectionMachO.[cpp|h]
3) there are a few FIXMEs, for example what is the syntax to get the
   S_GB_ZEROFILL segment type?



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78547 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/ARM/ctors_dtors.ll b/test/CodeGen/ARM/ctors_dtors.ll
index 8ed98d9..714ca61 100644
--- a/test/CodeGen/ARM/ctors_dtors.ll
+++ b/test/CodeGen/ARM/ctors_dtors.ll
@@ -1,9 +1,9 @@
-; RUN: llvm-as <  %s | llc -mtriple=arm-apple-darwin | FileCheck %s -check-prefix=DARWIN
-; RUN: llvm-as  < %s | llc -mtriple=arm-linux-gnu | FileCheck %s -check-prefix=ELF
+; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin  | FileCheck %s -check-prefix=DARWIN
+; RUN: llvm-as < %s | llc -mtriple=arm-linux-gnu     | FileCheck %s -check-prefix=ELF
 ; RUN: llvm-as < %s | llc -mtriple=arm-linux-gnueabi | FileCheck %s -check-prefix=GNUEABI
 
-; DARWIN: .mod_init_func
-; DARWIN: .mod_term_func
+; DARWIN: .section	__DATA,__mod_init_func,mod_init_funcs
+; DARWIN: .section	__DATA,__mod_term_func,mod_term_funcs
 
 ; ELF: .section .ctors,"aw",%progbits
 ; ELF: .section .dtors,"aw",%progbits
diff --git a/test/CodeGen/ARM/stubs.ll b/test/CodeGen/ARM/stubs.ll
index 7c9cc23..baf6b7e 100644
--- a/test/CodeGen/ARM/stubs.ll
+++ b/test/CodeGen/ARM/stubs.ll
@@ -39,7 +39,7 @@
 ; PIC: L_exact_log2$slp:
 ; PIC: .long	L_exact_log2$lazy_ptr-(L_exact_log2$scv+8)
 
-; PIC: .lazy_symbol_pointer
+; PIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
 ; PIC: L_exact_log2$lazy_ptr:
 ; PIC: .indirect_symbol _exact_log2
 ; PIC: .long	dyld_stub_binding_helper
@@ -55,7 +55,7 @@
 ; DYNAMIC: L_exact_log2$slp:
 ; DYNAMIC: .long	L_exact_log2$lazy_ptr
 
-; DYNAMIC: .lazy_symbol_pointer
+; DYNAMIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
 ; DYNAMIC: L_exact_log2$lazy_ptr:
 ; DYNAMIC: .indirect_symbol _exact_log2
 ; DYNAMIC: .long	dyld_stub_binding_helper
diff --git a/test/CodeGen/PowerPC/available-externally.ll b/test/CodeGen/PowerPC/available-externally.ll
index e78d6a0..6c06529 100644
--- a/test/CodeGen/PowerPC/available-externally.ll
+++ b/test/CodeGen/PowerPC/available-externally.ll
@@ -44,7 +44,7 @@
 ; PIC: mtctr r12
 ; PIC: bctr
 
-; PIC: .lazy_symbol_pointer
+; PIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
 ; PIC: L_exact_log2$lazy_ptr:
 ; PIC: .indirect_symbol _exact_log2
 ; PIC: .long dyld_stub_binding_helper
@@ -60,7 +60,7 @@
 ; DYNAMIC: mtctr r12
 ; DYNAMIC: bctr
 
-; DYNAMIC: .lazy_symbol_pointer
+; DYNAMIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
 ; DYNAMIC: L_exact_log2$lazy_ptr:
 ; DYNAMIC: .indirect_symbol _exact_log2
 ; DYNAMIC: .long dyld_stub_binding_helper
diff --git a/test/CodeGen/X86/2009-01-27-NullStrings.ll b/test/CodeGen/X86/2009-01-27-NullStrings.ll
index b0c27d8..229d726 100644
--- a/test/CodeGen/X86/2009-01-27-NullStrings.ll
+++ b/test/CodeGen/X86/2009-01-27-NullStrings.ll
@@ -1,38 +1,7 @@
-; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin | grep {\\.cstring} | count 1
-	%struct.A = type {  }
-	%struct.NSString = type opaque
-	%struct.__builtin_CFString = type { i32*, i32, i8*, i32 }
-	%struct._objc_module = type { i32, i32, i8*, %struct._objc_symtab* }
-	%struct._objc_symtab = type { i32, %struct.objc_selector**, i16, i16 }
-	%struct.objc_object = type opaque
-	%struct.objc_selector = type opaque
-@"\01L_unnamed_cfstring_0" = internal constant %struct.__builtin_CFString { i32* getelementptr ([0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr ([1 x i8]* @"\01LC", i32 0, i32 0), i32 0 }, section "__DATA, __cfstring"		; <%struct.__builtin_CFString*> [#uses=1]
-@__CFConstantStringClassReference = external global [0 x i32]		; <[0 x i32]*> [#uses=1]
-@"\01LC" = internal constant [1 x i8] zeroinitializer		; <[1 x i8]*> [#uses=1]
-@"\01L_OBJC_SELECTOR_REFERENCES_0" = internal global %struct.objc_selector* bitcast ([6 x i8]* @"\01L_OBJC_METH_VAR_NAME_0" to %struct.objc_selector*), section "__OBJC,__message_refs,literal_pointers,no_dead_strip", align 4		; <%struct.objc_selector**> [#uses=2]
-@"\01L_OBJC_SYMBOLS" = internal global %struct._objc_symtab zeroinitializer, section "__OBJC,__symbols,regular,no_dead_strip", align 4		; <%struct._objc_symtab*> [#uses=2]
-@"\01L_OBJC_METH_VAR_NAME_0" = internal global [6 x i8] c"bork:\00", section "__TEXT,__cstring,cstring_literals", align 1		; <[6 x i8]*> [#uses=2]
-@"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] zeroinitializer, section "__OBJC, __image_info,regular"		; <[2 x i32]*> [#uses=1]
-@"\01L_OBJC_CLASS_NAME_0" = internal global [1 x i8] zeroinitializer, section "__TEXT,__cstring,cstring_literals", align 1		; <[1 x i8]*> [#uses=1]
-@"\01L_OBJC_MODULES" = internal global %struct._objc_module { i32 7, i32 16, i8* getelementptr ([1 x i8]* @"\01L_OBJC_CLASS_NAME_0", i32 0, i32 0), %struct._objc_symtab* @"\01L_OBJC_SYMBOLS" }, section "__OBJC,__module_info,regular,no_dead_strip", align 4		; <%struct._objc_module*> [#uses=1]
-@llvm.used = appending global [6 x i8*] [ i8* bitcast (%struct.objc_selector** @"\01L_OBJC_SELECTOR_REFERENCES_0" to i8*), i8* bitcast (%struct._objc_symtab* @"\01L_OBJC_SYMBOLS" to i8*), i8* getelementptr ([6 x i8]* @"\01L_OBJC_METH_VAR_NAME_0", i32 0, i32 0), i8* bitcast ([2 x i32]* @"\01L_OBJC_IMAGE_INFO" to i8*), i8* getelementptr ([1 x i8]* @"\01L_OBJC_CLASS_NAME_0", i32 0, i32 0), i8* bitcast (%struct._objc_module* @"\01L_OBJC_MODULES" to i8*) ], section "llvm.metadata"		; <[6 x i8*]*> [#uses=0]
+; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin | FileCheck %s
+; CHECK: .section __TEXT,__cstring,cstring_literals
 
-define void @func(%struct.A* %a) nounwind {
-entry:
-	%a_addr = alloca %struct.A*		; <%struct.A**> [#uses=2]
-	%a.0 = alloca %struct.objc_object*		; <%struct.objc_object**> [#uses=2]
-	%"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]
-	store %struct.A* %a, %struct.A** %a_addr
-	%0 = load %struct.A** %a_addr, align 4		; <%struct.A*> [#uses=1]
-	%1 = bitcast %struct.A* %0 to %struct.objc_object*		; <%struct.objc_object*> [#uses=1]
-	store %struct.objc_object* %1, %struct.objc_object** %a.0, align 4
-	%2 = load %struct.objc_selector** @"\01L_OBJC_SELECTOR_REFERENCES_0", align 4		; <%struct.objc_selector*> [#uses=1]
-	%3 = load %struct.objc_object** %a.0, align 4		; <%struct.objc_object*> [#uses=1]
-	call void bitcast (%struct.objc_object* (%struct.objc_object*, %struct.objc_selector*, ...)* @objc_msgSend to void (%struct.objc_object*, %struct.objc_selector*, %struct.NSString*)*)(%struct.objc_object* %3, %struct.objc_selector* %2, %struct.NSString* bitcast (%struct.__builtin_CFString* @"\01L_unnamed_cfstring_0" to %struct.NSString*)) nounwind
-	br label %return
+@x = internal constant [1 x i8] zeroinitializer		; <[1 x i8]*> [#uses=1]
 
-return:		; preds = %entry
-	ret void
-}
+@y = global [1 x i8]* @x
 
-declare %struct.objc_object* @objc_msgSend(%struct.objc_object*, %struct.objc_selector*, ...)
diff --git a/test/CodeGen/X86/global-sections.ll b/test/CodeGen/X86/global-sections.ll
index 7d39a02..0fcb17f 100644
--- a/test/CodeGen/X86/global-sections.ll
+++ b/test/CodeGen/X86/global-sections.ll
@@ -28,7 +28,7 @@
 ; int * const G3 = &G1;
 @G3 = constant i32* @G1
 
-; DARWIN: .const_data
+; DARWIN: .section        __DATA,__const
 ; DARWIN: .globl _G3
 ; DARWIN: _G3:
 ; DARWIN:     .long _G1
@@ -37,7 +37,7 @@
 ; _Complex long long const G4 = 34;
 @G4 = constant {i64,i64} { i64 34, i64 0 }
 
-; DARWIN: .const
+; DARWIN: .section        __TEXT,__const
 ; DARWIN: _G4:
 ; DARWIN:     .long 34
 
@@ -50,7 +50,7 @@
 ; LINUX: G5:
 ; LINUX:    .long 47
 
-; DARWIN: .data
+; DARWIN: .section        __DATA,__data
 ; DARWIN: .globl _G5
 ; DARWIN: _G5:
 ; DARWIN:    .long 47
@@ -88,7 +88,7 @@
 
 @G7 = constant [10 x i8] c"abcdefghi\00"
 
-; DARWIN:	.cstring
+; DARWIN:	__TEXT,__cstring,cstring_literals
 ; DARWIN:	.globl _G7
 ; DARWIN: _G7:
 ; DARWIN:	.asciz	"abcdefghi"
@@ -111,7 +111,7 @@
 
 @G9 = constant [4 x i32] [ i32 1, i32 2, i32 3, i32 0 ]
 
-; DARWIN:	.const
+; DARWIN:	.section        __TEXT,__const
 ; DARWIN:	.globl _G9
 ; DARWIN: _G9: