[llvm-branch-commits] [llvm-branch] r100831 - in /llvm/branches/Apple/Morbo: include/llvm/MC/ lib/CodeGen/AsmPrinter/ lib/CodeGen/SelectionDAG/ lib/MC/ lib/Target/X86/AsmPrinter/ test/CodeGen/ARM/ test/CodeGen/Alpha/ test/CodeGen/CellSPU/ test/CodeGen/MBlaze/ test/CodeGen/MSP430/ test/CodeGen/Mips/ test/CodeGen/PowerPC/ test/CodeGen/SPARC/ test/CodeGen/SystemZ/ test/CodeGen/Thumb/ test/CodeGen/X86/ test/CodeGen/XCore/

Dale Johannesen dalej at apple.com
Thu Apr 8 17:12:40 PDT 2010


Author: johannes
Date: Thu Apr  8 19:12:40 2010
New Revision: 100831

URL: http://llvm.org/viewvc/llvm-project?rev=100831&view=rev
Log:
--- Merging r100596 into '.':
U    lib/CodeGen/AsmPrinter/AsmPrinter.cpp
U    lib/CodeGen/SelectionDAG/FastISel.cpp
U    lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
--- Merging r100688 into '.':
A    test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll
A    test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll
100596 did not apply cleanly because some MC modifications have not been
brought into Morbo.  This patch brings in EmitRawText and changes a few
spots in 100596 to work with the older API.


Added:
    llvm/branches/Apple/Morbo/test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll
    llvm/branches/Apple/Morbo/test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll
      - copied unchanged from r100688, llvm/trunk/test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll
Modified:
    llvm/branches/Apple/Morbo/include/llvm/MC/MCStreamer.h
    llvm/branches/Apple/Morbo/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/branches/Apple/Morbo/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/branches/Apple/Morbo/lib/MC/MCAsmStreamer.cpp
    llvm/branches/Apple/Morbo/lib/MC/MCStreamer.cpp
    llvm/branches/Apple/Morbo/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp

Modified: llvm/branches/Apple/Morbo/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/MC/MCStreamer.h?rev=100831&r1=100830&r2=100831&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/MC/MCStreamer.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/MC/MCStreamer.h Thu Apr  8 19:12:40 2010
@@ -66,6 +66,10 @@
     /// all.
     virtual bool isVerboseAsm() const { return false; }
 
+    /// hasRawTextSupport - Return true if this asm streamer supports emitting
+    /// unformatted text to the .s file with EmitRawText.
+    virtual bool hasRawTextSupport() const { return false; }
+
     /// AddComment - Add a comment that can be emitted to the generated .s
     /// file if applicable as a QoI issue to make the output of the compiler
     /// more readable.  This only affects the MCAsmStreamer, and only when
@@ -278,6 +282,12 @@
     /// section.
     virtual void EmitInstruction(const MCInst &Inst) = 0;
 
+    /// EmitRawText - If this file is backed by a assembly streamer, this dumps
+    /// the specified string in the output .s file.  This capability is
+    /// indicated by the hasRawTextSupport() predicate.  By default this aborts.
+    virtual void EmitRawText(StringRef String);
+    void EmitRawText(const Twine &String);
+    
     /// Finish - Finish emission of machine code and flush any output.
     virtual void Finish() = 0;
   };

Modified: llvm/branches/Apple/Morbo/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=100831&r1=100830&r2=100831&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Apr  8 19:12:40 2010
@@ -391,6 +391,65 @@
 
 
 
+/// EmitDebugValueComment - This method handles the target-independent form
+/// of DBG_VALUE, returning true if it was able to do so.  A false return
+/// means the target will need to handle MI in EmitInstruction.
+static bool EmitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
+  char buf[100];
+  std::string Str =  "\t";
+  Str += AP.MAI->getCommentString();
+  Str += "DEBUG_VALUE: ";
+  // This code handles only the 3-operand target-independent form.
+  if (MI->getNumOperands() != 3)
+    return false;
+
+  // cast away const; DIetc do not take const operands for some reason.
+  DIVariable V((MDNode*)(MI->getOperand(2).getMetadata()));
+  Str += V.getName();
+  Str += " <- ";
+
+  // Register or immediate value. Register 0 means undef.
+  if (MI->getOperand(0).isFPImm()) {
+    APFloat APF = APFloat(MI->getOperand(0).getFPImm()->getValueAPF());
+    if (MI->getOperand(0).getFPImm()->getType()->isFloatTy()) {
+      sprintf(buf, "%e", APF.convertToFloat());
+      Str += buf;
+    } else if (MI->getOperand(0).getFPImm()->getType()->isDoubleTy()) {
+      sprintf(buf, "%e", APF.convertToDouble());
+      Str += buf;
+    } else {
+      // There is no good way to print long double.  Convert a copy to
+      // double.  Ah well, it's only a comment.
+      bool ignored;
+      APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
+                  &ignored);
+      Str += "(long double) ";
+      sprintf(buf, "%e", APF.convertToDouble());
+      Str += buf;
+    }
+  } else if (MI->getOperand(0).isImm()) {
+    sprintf(buf, "%lld", MI->getOperand(0).getImm());
+    Str += buf;
+  } else if (MI->getOperand(0).isReg()) {
+    if (MI->getOperand(0).getReg() == 0) {
+      // Suppress offset, it is not meaningful here.
+      Str += "undef";
+      // NOTE: Want this comment at start of line, don't emit with AddComment.
+      AP.OutStreamer.EmitRawText(Twine(Str));
+      return true;
+    }
+    Str += AP.TM.getRegisterInfo()->getName(MI->getOperand(0).getReg());
+  } else
+    llvm_unreachable("Unknown operand type");
+
+  Str += '+';
+  sprintf(buf, "%lld", MI->getOperand(1).getImm());
+  Str += buf;
+  // NOTE: Want this comment at start of line, don't emit with AddComment.
+  AP.OutStreamer.EmitRawText(Twine(Str));
+  return true;
+}
+
 /// EmitFunctionBody - This method emits the body and trailer for a
 /// function.
 void AsmPrinter::EmitFunctionBody() {
@@ -426,6 +485,12 @@
       case TargetOpcode::INLINEASM:
         printInlineAsm(II);
         break;
+      case TargetOpcode::DBG_VALUE:
+        if (VerboseAsm) {
+          if (!EmitDebugValueComment(II, *this))
+            EmitInstruction(II);
+        }
+        break;
       case TargetOpcode::IMPLICIT_DEF:
         printImplicitDef(II);
         break;
@@ -1163,7 +1228,7 @@
   
   if (CFP->getType()->isX86_FP80Ty()) {
     // all long double variants are printed as hex
-    // api needed to prevent premature destruction
+    // API needed to prevent premature destruction
     APInt API = CFP->getValueAPF().bitcastToAPInt();
     const uint64_t *p = API.getRawData();
     if (AP.VerboseAsm) {
@@ -1193,8 +1258,8 @@
   
   assert(CFP->getType()->isPPC_FP128Ty() &&
          "Floating point constant type not handled");
-  // All long double variants are printed as hex api needed to prevent
-  // premature destruction.
+  // All long double variants are printed as hex
+  // API needed to prevent premature destruction.
   APInt API = CFP->getValueAPF().bitcastToAPInt();
   const uint64_t *p = API.getRawData();
   if (AP.TM.getTargetData()->isBigEndian()) {

Modified: llvm/branches/Apple/Morbo/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=100831&r1=100830&r2=100831&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/SelectionDAG/FastISel.cpp Thu Apr  8 19:12:40 2010
@@ -333,6 +333,8 @@
     Value *Address = DI->getAddress();
     if (!Address)
       return true;
+    if (isa<UndefValue>(Address))
+      return true;
     AllocaInst *AI = dyn_cast<AllocaInst>(Address);
     // Don't handle byval struct arguments or VLAs, for example.
     if (!AI) break;
@@ -349,7 +351,7 @@
     return true;
   }
   case Intrinsic::dbg_value: {
-    // This requires target support, but right now X86 is the only Fast target.
+    // This form of DBG_VALUE is target-independent.
     DbgValueInst *DI = cast<DbgValueInst>(I);
     const TargetInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE);
     Value *V = DI->getValue();

Modified: llvm/branches/Apple/Morbo/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/MC/MCAsmStreamer.cpp?rev=100831&r1=100830&r2=100831&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/MC/MCAsmStreamer.cpp Thu Apr  8 19:12:40 2010
@@ -68,6 +68,9 @@
   /// all.
   virtual bool isVerboseAsm() const { return IsVerboseAsm; }
 
+  /// hasRawTextSupport - We support EmitRawText.
+  virtual bool hasRawTextSupport() const { return true; }
+
   /// AddComment - Add a comment that can be emitted to the generated .s
   /// file if applicable as a QoI issue to make the output of the compiler
   /// more readable.  This only affects the MCAsmStreamer, and only when
@@ -144,6 +147,11 @@
 
   virtual void EmitInstruction(const MCInst &Inst);
   
+  /// EmitRawText - If this file is backed by a assembly streamer, this dumps
+  /// the specified string in the output .s file.  This capability is
+  /// indicated by the hasRawTextSupport() predicate.
+  virtual void EmitRawText(StringRef String);
+  
   virtual void Finish();
   
   /// @}
@@ -647,6 +655,16 @@
   EmitEOL();
 }
 
+/// EmitRawText - If this file is backed by a assembly streamer, this dumps
+/// the specified string in the output .s file.  This capability is
+/// indicated by the hasRawTextSupport() predicate.
+void MCAsmStreamer::EmitRawText(StringRef String) {
+  if (!String.empty() && String.back() == '\n')
+    String = String.substr(0, String.size()-1);
+  OS << String;
+  EmitEOL();
+}
+
 void MCAsmStreamer::Finish() {
   OS.flush();
 }

Modified: llvm/branches/Apple/Morbo/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/MC/MCStreamer.cpp?rev=100831&r1=100830&r2=100831&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/MC/MCStreamer.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/MC/MCStreamer.cpp Thu Apr  8 19:12:40 2010
@@ -10,6 +10,8 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
 using namespace llvm;
 
 MCStreamer::MCStreamer(MCContext &_Context) : Context(_Context), CurSection(0) {
@@ -44,3 +46,18 @@
   for (uint64_t i = 0, e = NumBytes; i != e; ++i)
     EmitValue(E, 1, AddrSpace);
 }
+
+/// EmitRawText - If this file is backed by a assembly streamer, this dumps
+/// the specified string in the output .s file.  This capability is
+/// indicated by the hasRawTextSupport() predicate.
+void MCStreamer::EmitRawText(StringRef String) {
+  errs() << "EmitRawText called on an MCStreamer that doesn't support it, "
+  " something must not be fully mc'ized\n";
+  abort();
+}
+
+void MCStreamer::EmitRawText(const Twine &T) {
+  SmallString<128> Str;
+  T.toVector(Str);
+  EmitRawText(Str.str());
+}

Modified: llvm/branches/Apple/Morbo/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=100831&r1=100830&r2=100831&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Thu Apr  8 19:12:40 2010
@@ -326,70 +326,30 @@
   }
 }
 
-
-
 void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
   X86MCInstLower MCInstLowering(OutContext, Mang, *this);
   switch (MI->getOpcode()) {
-  case TargetOpcode::DBG_VALUE: {
-    // FIXME: if this is implemented for another target before it goes
-    // away completely, the common part should be moved into AsmPrinter.
-    if (!VerboseAsm)
-      return;
-    O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: ";
+  case X86::DBG_VALUE: {
+    // Only the target-dependent form of DBG_VALUE should get here.
+    // Referencing the offset and metadata as NOps-2 and NOps-1 is
+    // probably portable to other targets; frame pointer location is not.
     unsigned NOps = MI->getNumOperands();
+    assert(NOps==7);
+    O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: ";
     // cast away const; DIetc do not take const operands for some reason.
     DIVariable V((MDNode*)(MI->getOperand(NOps-1).getMetadata()));
     O << V.getName();
     O << " <- ";
-    if (NOps==3) {
-      // Register or immediate value. Register 0 means undef.
-      assert(MI->getOperand(0).getType()==MachineOperand::MO_Register ||
-             MI->getOperand(0).getType()==MachineOperand::MO_Immediate ||
-             MI->getOperand(0).getType()==MachineOperand::MO_FPImmediate);
-      if (MI->getOperand(0).getType()==MachineOperand::MO_Register &&
-          MI->getOperand(0).getReg()==0) {
-        // Suppress offset in this case, it is not meaningful.
-        O << "undef";
-        OutStreamer.AddBlankLine();
-        return;
-      } else if (MI->getOperand(0).getType()==MachineOperand::MO_FPImmediate) {
-        // This is more naturally done in printOperand, but since the only use
-        // of such an operand is in this comment and that is temporary (and it's
-        // ugly), we prefer to keep this localized.
-        // The include of Type.h may be removable when this code is.
-        if (MI->getOperand(0).getFPImm()->getType()->isFloatTy() ||
-            MI->getOperand(0).getFPImm()->getType()->isDoubleTy())
-          MI->getOperand(0).print(O, &TM);
-        else {
-          // There is no good way to print long double.  Convert a copy to
-          // double.  Ah well, it's only a comment.
-          bool ignored;
-          APFloat APF = APFloat(MI->getOperand(0).getFPImm()->getValueAPF());
-          APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
-                      &ignored);
-          O << "(long double) " << APF.convertToDouble();
-        }
-      } else
-        printOperand(MI, 0);
-    } else {
-      if (MI->getOperand(0).getType()==MachineOperand::MO_Register &&
-          MI->getOperand(0).getReg()==0) {
-        // Suppress offset in this case, it is not meaningful.
-        O << "undef";
-        OutStreamer.AddBlankLine();
-        return;
-      }
-      // Frame address.  Currently handles register +- offset only.
-      assert(MI->getOperand(0).getType()==MachineOperand::MO_Register);
-      assert(MI->getOperand(3).getType()==MachineOperand::MO_Immediate);
-      O << '['; printOperand(MI, 0); O << '+'; printOperand(MI, 3); O << ']';
-    }
+    // Frame address.  Currently handles register +- offset only.
+    assert(MI->getOperand(0).isReg() && MI->getOperand(3).isImm());
+    O << '['; printOperand(MI, 0); O << '+'; printOperand(MI, 3);
+    O << ']';
     O << "+";
     printOperand(MI, NOps-2);
-    OutStreamer.AddBlankLine();
+    O << '\n';
     return;
   }
+
   case X86::MOVPC32r: {
     MCInst TmpInst;
     // This is a pseudo op for a two instruction sequence with a label, which





More information about the llvm-branch-commits mailing list