eliminate some uses of AsmPrinter::EmitIntXXX
authorChris Lattner <sabre@nondot.org>
Wed, 20 Jan 2010 07:41:15 +0000 (07:41 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 20 Jan 2010 07:41:15 +0000 (07:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93996 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DIE.cpp
lib/CodeGen/AsmPrinter/DwarfException.cpp

index bb786df9e1a6954c26dff95af77666d5d58c0834..4c5e079f03be2a928ddb75e602efe98a48af9e09 100644 (file)
@@ -1086,8 +1086,7 @@ static void EmitGlobalConstantArray(const ConstantArray *CA, unsigned AddrSpace,
 
 static void EmitGlobalConstantVector(const ConstantVector *CV,
                                      unsigned AddrSpace, AsmPrinter &AP) {
-  const VectorType *VTy = CV->getType();
-  for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
+  for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
     AP.EmitGlobalConstant(CV->getOperand(i), AddrSpace);
 }
 
@@ -1099,16 +1098,16 @@ static void EmitGlobalConstantStruct(const ConstantStruct *CS,
   const StructLayout *Layout = TD->getStructLayout(CS->getType());
   uint64_t SizeSoFar = 0;
   for (unsigned i = 0, e = CS->getNumOperands(); i != e; ++i) {
-    const Constant *field = CS->getOperand(i);
+    const Constant *Field = CS->getOperand(i);
 
     // Check if padding is needed and insert one or more 0s.
-    uint64_t FieldSize = TD->getTypeAllocSize(field->getType());
+    uint64_t FieldSize = TD->getTypeAllocSize(Field->getType());
     uint64_t PadSize = ((i == e-1 ? Size : Layout->getElementOffset(i+1))
                         - Layout->getElementOffset(i)) - FieldSize;
     SizeSoFar += FieldSize + PadSize;
 
     // Now print the actual field value.
-    AP.EmitGlobalConstant(field, AddrSpace);
+    AP.EmitGlobalConstant(Field, AddrSpace);
 
     // Insert padding - this may include padding to increase the size of the
     // current field up to the ABI size (if the struct is not packed) as well
index ff7994ad051d53bd5cef04bea03d14871eff4b0c..a62f14d09cb4b2ec572177c196335fe5e3bee78e 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Support/Debug.h"
@@ -186,20 +187,22 @@ void DIEValue::dump() {
 ///
 void DIEInteger::EmitValue(Dwarf *D, unsigned Form) const {
   const AsmPrinter *Asm = D->getAsm();
+  unsigned Size = ~0U;
   switch (Form) {
   case dwarf::DW_FORM_flag:  // Fall thru
   case dwarf::DW_FORM_ref1:  // Fall thru
-  case dwarf::DW_FORM_data1: Asm->EmitInt8(Integer);         break;
+  case dwarf::DW_FORM_data1: Size = 1; break;
   case dwarf::DW_FORM_ref2:  // Fall thru
-  case dwarf::DW_FORM_data2: Asm->EmitInt16(Integer);        break;
+  case dwarf::DW_FORM_data2: Size = 2; break;
   case dwarf::DW_FORM_ref4:  // Fall thru
-  case dwarf::DW_FORM_data4: Asm->EmitInt32(Integer);        break;
+  case dwarf::DW_FORM_data4: Size = 4; break;
   case dwarf::DW_FORM_ref8:  // Fall thru
-  case dwarf::DW_FORM_data8: Asm->EmitInt64(Integer);        break;
-  case dwarf::DW_FORM_udata: Asm->EmitULEB128Bytes(Integer); break;
-  case dwarf::DW_FORM_sdata: Asm->EmitSLEB128Bytes(Integer); break;
+  case dwarf::DW_FORM_data8: Size = 8; break;
+  case dwarf::DW_FORM_udata: Asm->EmitULEB128Bytes(Integer); return;
+  case dwarf::DW_FORM_sdata: Asm->EmitSLEB128Bytes(Integer); return;
   default: llvm_unreachable("DIE Value form not supported yet");
   }
+  Asm->OutStreamer.EmitIntValue(Integer, Size, 0/*addrspace*/);
 }
 
 /// SizeOf - Determine size of integer value in bytes.
index 01c32647740fdb11980eb491b8a741e39ca2bf03..615be0e1c796e8b69110a1f1d76b9b3b8f6562cd 100644 (file)
@@ -119,7 +119,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
 
   // EH frame header.
   EmitLabel("eh_frame_common_begin", Index);
-  Asm->EmitInt32((int)0);
+  Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
   Asm->EOL("CIE Identifier Tag");
   Asm->EmitInt8(dwarf::DW_CIE_VERSION);
   Asm->EOL("CIE Version");
@@ -281,7 +281,6 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
     // If there is a personality and landing pads then point to the language
     // specific data area in the exception table.
     if (MMI->getPersonalities()[0] != NULL) {
-      bool is4Byte = TD->getPointerSize() == sizeof(int32_t);
 
       if (Asm->TM.getLSDAEncoding() != DwarfLSDAEncoding::EightByte) {
         Asm->EmitULEB128Bytes(4);
@@ -290,18 +289,16 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
         if (EHFrameInfo.hasLandingPads)
           EmitReference("exception", EHFrameInfo.Number, true, true);
         else
-          Asm->EmitInt32((int)0);
+          Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
       } else {
-        Asm->EmitULEB128Bytes(is4Byte ? 4 : 8);
+        Asm->EmitULEB128Bytes(TD->getPointerSize());
         Asm->EOL("Augmentation size");
 
         if (EHFrameInfo.hasLandingPads) {
           EmitReference("exception", EHFrameInfo.Number, true, false);
         } else {
-          if (is4Byte)
-            Asm->EmitInt32((int)0);
-          else
-            Asm->EmitInt64((int)0);
+          Asm->OutStreamer.EmitIntValue(0, TD->getPointerSize(),
+                                        0/*addrspace*/);
         }
       }
 
@@ -885,7 +882,7 @@ void DwarfException::EmitExceptionTable() {
       // Offset of the landing pad, counted in 16-byte bundles relative to the
       // @LPStart address.
       if (!S.PadLabel)
-        Asm->EmitInt32(0);
+        Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
       else
         EmitSectionOffset("label", "eh_func_begin", S.PadLabel, SubprogramCount,
                           true, true);