From bcb83e5b6c8e074e73986cb641801ecbedd6e4ed Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 20 Jan 2010 07:41:15 +0000 Subject: [PATCH] eliminate some uses of AsmPrinter::EmitIntXXX git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93996 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 9 ++++----- lib/CodeGen/AsmPrinter/DIE.cpp | 15 +++++++++------ lib/CodeGen/AsmPrinter/DwarfException.cpp | 15 ++++++--------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index bb786df9e1a..4c5e079f03b 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -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 diff --git a/lib/CodeGen/AsmPrinter/DIE.cpp b/lib/CodeGen/AsmPrinter/DIE.cpp index ff7994ad051..a62f14d09cb 100644 --- a/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/lib/CodeGen/AsmPrinter/DIE.cpp @@ -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. diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp index 01c32647740..615be0e1c79 100644 --- a/lib/CodeGen/AsmPrinter/DwarfException.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp @@ -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); -- 2.34.1