#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSectionELF.h"
-#include "llvm/Target/TargetAsmInfo.h"
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetELFWriterInfo.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/Support/Mangler.h"
-#include "llvm/Support/Streams.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Mangler.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
isLittleEndian(TM.getTargetData()->isLittleEndian()),
ElfHdr(isLittleEndian, is64Bit) {
- TAI = TM.getTargetAsmInfo();
+ MAI = TM.getMCAsmInfo();
TEW = TM.getELFWriterInfo();
// Create the object code emitter object for this target.
ELFWriter::~ELFWriter() {
delete ElfCE;
delete &OutContext;
+
+ while(!SymbolList.empty()) {
+ delete SymbolList.back();
+ SymbolList.pop_back();
+ }
+
+ while(!PrivateSyms.empty()) {
+ delete PrivateSyms.back();
+ PrivateSyms.pop_back();
+ }
+
+ while(!SectionList.empty()) {
+ delete SectionList.back();
+ SectionList.pop_back();
+ }
+
+ // Release the name mangler object.
+ delete Mang; Mang = 0;
}
// doInitialization - Emit the file header and all of the global variables for
unsigned Size = TD->getTypeAllocSize(GVar->getInitializer()->getType());
GblSym->Size = Size;
- if (S->IsCommon()) { // Symbol must go to a common section
+ if (S->HasCommonSymbols()) { // Symbol must go to a common section
GblSym->SectionIdx = ELFSection::SHN_COMMON;
// A new linkonce section is created for each global in the
return;
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
APInt Val = CFP->getValueAPF().bitcastToAPInt();
- if (CFP->getType() == Type::DoubleTy)
+ if (CFP->getType()->isDoubleTy())
GblS.emitWord64(Val.getZExtValue());
- else if (CFP->getType() == Type::FloatTy)
+ else if (CFP->getType()->isFloatTy())
GblS.emitWord32(Val.getZExtValue());
- else if (CFP->getType() == Type::X86_FP80Ty) {
- unsigned PadSize = TD->getTypeAllocSize(Type::X86_FP80Ty)-
- TD->getTypeStoreSize(Type::X86_FP80Ty);
+ else if (CFP->getType()->isX86_FP80Ty()) {
+ unsigned PadSize = TD->getTypeAllocSize(CFP->getType())-
+ TD->getTypeStoreSize(CFP->getType());
GblS.emitWordFP80(Val.getRawData(), PadSize);
- } else if (CFP->getType() == Type::PPC_FP128Ty)
+ } else if (CFP->getType()->isPPC_FP128Ty())
llvm_unreachable("PPC_FP128Ty global emission not implemented");
return;
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
}
case Instruction::IntToPtr: {
Constant *Op = CE->getOperand(0);
- Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(), false/*ZExt*/);
+ Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(CV->getContext()),
+ false/*ZExt*/);
return ResolveConstantExpr(Op);
}
case Instruction::PtrToInt: {
SymbolList.push_back(ELFSym::getExtSym(*I));
// Emit non-executable stack note
- if (TAI->getNonexecutableStackDirective())
+ if (MAI->getNonexecutableStackDirective())
getNonExecStackSection();
// Emit a symbol for each section created until now, skip null section
// Dump the sections and section table to the .o file.
OutputSectionsAndSectionTable();
- // We are done with the abstract symbols.
- SymbolList.clear();
- SectionList.clear();
- NumSections = 0;
-
- // Release the name mangler object.
- delete Mang; Mang = 0;
return false;
}
// Emit all of sections to the file and build the section header table.
for (ELFSectionIter I=SectionList.begin(), E=SectionList.end(); I != E; ++I) {
ELFSection &S = *(*I);
- DOUT << "SectionIdx: " << S.SectionIdx << ", Name: " << S.getName()
- << ", Size: " << S.Size << ", Offset: " << S.Offset
- << ", SectionData Size: " << S.size() << "\n";
+ DEBUG(errs() << "SectionIdx: " << S.SectionIdx << ", Name: " << S.getName()
+ << ", Size: " << S.Size << ", Offset: " << S.Offset
+ << ", SectionData Size: " << S.size() << "\n");
// Align FileOff to whatever the alignment restrictions of the section are.
if (S.size()) {