OSDN Git Service

Merge with LLVM upstream 2011/10/20 (r142530)
[android-x86/external-llvm.git] / lib / CodeGen / AsmPrinter / AsmPrinter.cpp
index 8ac4fb6..c9de6d2 100644 (file)
 
 #define DEBUG_TYPE "asm-printer"
 #include "llvm/CodeGen/AsmPrinter.h"
-#include "DwarfDebug.h"
-#include "DwarfException.h"
+#ifndef ANDROID_TARGET_BUILD
+#   include "DwarfDebug.h"
+#   include "DwarfException.h"
+#endif // ANDROID_TARGET_BUILD
 #include "llvm/Module.h"
 #include "llvm/CodeGen/GCMetadataPrinter.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
@@ -46,6 +48,7 @@
 #include "llvm/Support/Format.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Timer.h"
+#include <ctype.h>
 using namespace llvm;
 
 static const char *DWARFGroupName = "DWARF Emission";
@@ -186,6 +189,7 @@ bool AsmPrinter::doInitialization(Module &M) {
     OutStreamer.AddBlankLine();
   }
 
+#ifndef ANDROID_TARGET_BUILD
   if (MAI->doesSupportDebugInformation())
     DD = new DwarfDebug(this, &M);
 
@@ -203,6 +207,9 @@ bool AsmPrinter::doInitialization(Module &M) {
     DE = new Win64Exception(this);
     return false;
   }
+#else
+  return false;
+#endif // ANDROID_TARGET_BUILD
 
   llvm_unreachable("Unknown exception type.");
 }
@@ -459,6 +466,7 @@ void AsmPrinter::EmitFunctionHeader() {
   }
 
   // Emit pre-function debug and/or EH information.
+#ifndef ANDROID_TARGET_BUILD
   if (DE) {
     NamedRegionTimer T(EHTimerName, DWARFGroupName, TimePassesIsEnabled);
     DE->BeginFunction(MF);
@@ -467,6 +475,7 @@ void AsmPrinter::EmitFunctionHeader() {
     NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled);
     DD->beginFunction(MF);
   }
+#endif // ANDROID_TARGET_BUILD
 }
 
 /// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
@@ -474,8 +483,10 @@ void AsmPrinter::EmitFunctionHeader() {
 void AsmPrinter::EmitFunctionEntryLabel() {
   // The function label could have already been emitted if two symbols end up
   // conflicting due to asm renaming.  Detect this and emit an error.
-  if (CurrentFnSym->isUndefined())
+  if (CurrentFnSym->isUndefined()) {
+    OutStreamer.ForceCodeRegion();
     return OutStreamer.EmitLabel(CurrentFnSym);
+  }
 
   report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
                      "' label emitted multiple times to assembly file");
@@ -660,14 +671,16 @@ void AsmPrinter::EmitFunctionBody() {
       if (!II->isLabel() && !II->isImplicitDef() && !II->isKill() &&
           !II->isDebugValue()) {
         HasAnyRealCode = true;
+      
         ++EmittedInsts;
       }
-
+#ifndef ANDROID_TARGET_BUILD
       if (ShouldPrintDebugScopes) {
         NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled);
         DD->beginInstruction(II);
       }
-
+#endif // ANDROID_TARGET_BUILD
+      
       if (isVerbose())
         EmitComments(*II, OutStreamer.GetCommentOS());
 
@@ -702,11 +715,13 @@ void AsmPrinter::EmitFunctionBody() {
         EmitInstruction(II);
         break;
       }
-
+      
+#ifndef ANDROID_TARGET_BUILD
       if (ShouldPrintDebugScopes) {
         NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled);
         DD->endInstruction(II);
       }
+#endif // ANDROID_TARGET_BUILD
     }
   }
 
@@ -749,6 +764,7 @@ void AsmPrinter::EmitFunctionBody() {
   }
 
   // Emit post-function debug information.
+#ifndef ANDROID_TARGET_BUILD
   if (DD) {
     NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled);
     DD->endFunction(MF);
@@ -757,6 +773,7 @@ void AsmPrinter::EmitFunctionBody() {
     NamedRegionTimer T(EHTimerName, DWARFGroupName, TimePassesIsEnabled);
     DE->EndFunction();
   }
+#endif // ANDROID_TARGET_BUILD
   MMI->EndFunction();
 
   // Print out jump tables referenced by the function.
@@ -840,6 +857,7 @@ bool AsmPrinter::doFinalization(Module &M) {
   }
 
   // Finalize debug and EH information.
+#ifndef ANDROID_TARGET_BUILD
   if (DE) {
     {
       NamedRegionTimer T(EHTimerName, DWARFGroupName, TimePassesIsEnabled);
@@ -854,7 +872,8 @@ bool AsmPrinter::doFinalization(Module &M) {
     }
     delete DD; DD = 0;
   }
-
+#endif // ANDROID_TARGET_BUILD
+  
   // If the target wants to know about weak references, print them all.
   if (MAI->getWeakRefDirective()) {
     // FIXME: This is not lazy, it would be nice to only print weak references
@@ -1058,6 +1077,15 @@ void AsmPrinter::EmitJumpTableInfo() {
 
   EmitAlignment(Log2_32(MJTI->getEntryAlignment(*TM.getTargetData())));
 
+  // If we know the form of the jump table, go ahead and tag it as such.
+  if (!JTInDiffSection) {
+    if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32) {
+      OutStreamer.EmitJumpTable32Region();
+    } else {
+      OutStreamer.EmitDataRegion();
+    }
+  }
+
   for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
     const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;