diff options
author | Bill Wendling <isanbard@gmail.com> | 2007-01-18 01:23:11 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2007-01-18 01:23:11 +0000 |
commit | c904a5b925ce9981ad7501b14ee39cbc8795e23c (patch) | |
tree | 01dc4a2700cdae4e7837bb9a57b7c16b115b2abe /lib/CodeGen/MachOWriter.cpp | |
parent | b266ccd0f41b3ac9d9ad733e73204d9177c12e9f (diff) |
Have the OutputBuffer take the is64Bit and isLittleEndian booleans.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachOWriter.cpp')
-rw-r--r-- | lib/CodeGen/MachOWriter.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index 29c070b371..64e11010b3 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -53,6 +53,10 @@ namespace llvm { /// Target machine description. TargetMachine &TM; + /// is64Bit/isLittleEndian - This information is inferred from the target + /// machine directly, indicating what header values and flags to set. + bool is64Bit, isLittleEndian; + /// Relocations - These are the relocations that the function needs, as /// emitted. std::vector<MachineRelocation> Relocations; @@ -75,7 +79,10 @@ namespace llvm { std::vector<intptr_t> MBBLocations; public: - MachOCodeEmitter(MachOWriter &mow) : MOW(mow), TM(MOW.TM) {} + MachOCodeEmitter(MachOWriter &mow) : MOW(mow), TM(MOW.TM) { + is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; + isLittleEndian = TM.getTargetData()->isLittleEndian(); + } virtual void startFunction(MachineFunction &F); virtual bool finishFunction(MachineFunction &F); @@ -230,7 +237,7 @@ void MachOCodeEmitter::emitConstantPool(MachineConstantPool *MCP) { unsigned Size = TM.getTargetData()->getTypeSize(Ty); MachOWriter::MachOSection *Sec = MOW.getConstSection(Ty); - OutputBuffer SecDataOut(TM, Sec->SectionData); + OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); CPLocations.push_back(Sec->SectionData.size()); CPSections.push_back(Sec->Index); @@ -261,7 +268,7 @@ void MachOCodeEmitter::emitJumpTables(MachineJumpTableInfo *MJTI) { MachOWriter::MachOSection *Sec = MOW.getJumpTableSection(); unsigned TextSecIndex = MOW.getTextSection()->Index; - OutputBuffer SecDataOut(TM, Sec->SectionData); + OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); for (unsigned i = 0, e = JT.size(); i != e; ++i) { // For each jump table, record its offset from the start of the section, @@ -309,7 +316,7 @@ void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) { // Reserve space in the .bss section for this symbol while maintaining the // desired section alignment, which must be at least as much as required by // this symbol. - OutputBuffer SecDataOut(TM, Sec->SectionData); + OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); if (Align) { uint64_t OrigSize = Sec->size; @@ -451,7 +458,7 @@ void MachOWriter::EmitHeaderAndLoadCommands() { // Step #3: write the header to the file // Local alias to shortenify coming code. DataBuffer &FH = Header.HeaderData; - OutputBuffer FHOut(TM, FH); + OutputBuffer FHOut(FH, is64Bit, isLittleEndian); FHOut.outword(Header.magic); FHOut.outword(Header.cputype); @@ -638,7 +645,7 @@ void MachOWriter::BufferSymbolAndStringTable() { // Write out a leading zero byte when emitting string table, for n_strx == 0 // which means an empty string. - OutputBuffer StrTOut(TM, StrT); + OutputBuffer StrTOut(StrT, is64Bit, isLittleEndian); StrTOut.outbyte(0); // The order of the string table is: @@ -656,7 +663,7 @@ void MachOWriter::BufferSymbolAndStringTable() { } } - OutputBuffer SymTOut(TM, SymT); + OutputBuffer SymTOut(SymT, is64Bit, isLittleEndian); for (std::vector<MachOSym>::iterator I = SymbolTable.begin(), E = SymbolTable.end(); I != E; ++I) { |