More data/parsing support for tls directives. Add a few more testcases
authorEric Christopher <echristo@apple.com>
Mon, 17 May 2010 22:53:55 +0000 (22:53 +0000)
committerEric Christopher <echristo@apple.com>
Mon, 17 May 2010 22:53:55 +0000 (22:53 +0000)
and cleanup comments as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103985 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
include/llvm/MC/MCSectionMachO.h
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/directive_tbss.s
test/MC/AsmParser/directive_tdata.s [new file with mode: 0644]
test/MC/AsmParser/directive_thread_init_func.s [new file with mode: 0644]
test/MC/AsmParser/directive_tlv.s [new file with mode: 0644]

index e106a417ff7d27d0b9dc10172ff6a30d77385f9d..3aaab88612249fbb70273b9b86d4be2eb0d14f06 100644 (file)
@@ -84,19 +84,23 @@ public:
 
 
 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
-  /// TLSDataSection - Section directive for Thread Local data.
+  /// TLSDataSection - Section for thread local data.
   ///
   const MCSection *TLSDataSection;        // Defaults to ".tdata".
 
-  /// TLSBSSSection - Section directive for Thread Local uninitialized data.
+  /// TLSBSSSection - Section for thread local uninitialized data.
   ///
   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
   
-  /// TLSTLVSection - Section directive for Thread Local structure infomation.
+  /// TLSTLVSection - Section for thread local structure infomation.
   /// Contains the source code name of the variable, visibility and a pointer
   /// to the initial value (.tdata or .tbss).
   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
   
+  /// TLSThreadInitSection - Section for thread local data initialization
+  /// functions.
+  const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
+  
   const MCSection *CStringSection;
   const MCSection *UStringSection;
   const MCSection *TextCoalSection;
index c149926a19278738313cb8b578c79339cdad9c60..2d9d1333dbe23a9d917447a397902ac781501780 100644 (file)
@@ -98,7 +98,7 @@ public:
     S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14U,
     /// S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local
     /// variable initialization pointers to functions.
-    S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15,
+    S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15U,
 
     LAST_KNOWN_SECTION_TYPE = S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
     
index 5bb33c2e35743492df6403adb055df6d8b17fa8f..837681985859450dc27a6ec87546eaf7105d31eb 100644 (file)
@@ -475,6 +475,12 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
     = getContext().getMachOSection("__DATA", "__thread_vars",
                                    MCSectionMachO::S_THREAD_LOCAL_VARIABLES,
                                    SectionKind::getDataRel());
+                                   
+  TLSThreadInitSection
+    = getContext().getMachOSection("__DATA", "__thread_init",
+                          MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
+                          SectionKind::getDataRel());
+                                   
   CStringSection // .cstring
     = getContext().getMachOSection("__TEXT", "__cstring", 
                                    MCSectionMachO::S_CSTRING_LITERALS,
index c4916731ef01092b7e2e02d66c92aab59b6f9b8b..2a60a67e1ba4a3fde70b2f9bab2496cc6a5567ba 100644 (file)
@@ -623,6 +623,16 @@ bool AsmParser::ParseStatement() {
       return ParseDirectiveSectionSwitch("__OBJC", "__selector_strs",
                                          MCSectionMachO::S_CSTRING_LITERALS);
     
+    if (IDVal == ".tdata")
+      return ParseDirectiveSectionSwitch("__DATA", "__thread_data",
+                                        MCSectionMachO::S_THREAD_LOCAL_REGULAR);
+    if (IDVal == ".tlv")
+      return ParseDirectiveSectionSwitch("__DATA", "__thread_vars",
+                                      MCSectionMachO::S_THREAD_LOCAL_VARIABLES);
+    if (IDVal == ".thread_init_func")
+      return ParseDirectiveSectionSwitch("__DATA", "__thread_init",
+                        MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS);
+    
     // Assembler features
     if (IDVal == ".set")
       return ParseDirectiveSet();
index 38d3a3e1fcf28ac58ee86c881d4209226aaf81fc..62d7123017240c3dc726dcf22b476e96bb06306a 100644 (file)
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -triple i386-unknown-darwin %s | FileCheck %s
+# RUN: llvm-mc -triple x86_64-unknown-darwin %s | FileCheck %s
 
 # CHECK: .tbss _a$tlv$init, 4
 # CHECK: .tbss _b$tlv$init, 4, 3
diff --git a/test/MC/AsmParser/directive_tdata.s b/test/MC/AsmParser/directive_tdata.s
new file mode 100644 (file)
index 0000000..240bef0
--- /dev/null
@@ -0,0 +1,9 @@
+# RUN: llvm-mc -triple x86_64-unknown-darwin %s | FileCheck %s
+
+# CHECK:       __DATA,__thread_data,thread_local_regular
+# CHECK:       _a$tlv$init:
+# CHECK:       .quad 4
+
+       .tdata
+_a$tlv$init:
+       .quad 4
diff --git a/test/MC/AsmParser/directive_thread_init_func.s b/test/MC/AsmParser/directive_thread_init_func.s
new file mode 100644 (file)
index 0000000..4abd5bf
--- /dev/null
@@ -0,0 +1,7 @@
+# RUN: llvm-mc -triple x86_64-unknown-darwin %s | FileCheck %s
+
+# CHECK: __DATA,__thread_init,thread_local_init_function_pointers
+# CHECK: .quad 0
+
+.thread_init_func
+       .quad 0
diff --git a/test/MC/AsmParser/directive_tlv.s b/test/MC/AsmParser/directive_tlv.s
new file mode 100644 (file)
index 0000000..c4b3e10
--- /dev/null
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -triple x86_64-unknown-darwin %s | FileCheck %s
+
+# CHECK:       __DATA,__thread_vars,thread_local_variables
+# CHECK:       .globl _a
+# CHECK:       _a:
+# CHECK:       .quad 0
+
+       .tlv
+.globl _a
+_a:
+       .quad 0
+       .quad 0
+       .quad 0