eliminate some uses of AsmPrinter::EmitIntXXX

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93996 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-20 07:41:15 +00:00
parent 2ab47098f8
commit bcb83e5b6c
3 changed files with 19 additions and 20 deletions

View 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

View 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.

View 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);