[llvm-commits] [llvm] r118288 - in /llvm/trunk: include/llvm/MC/MachObjectWriter.h lib/MC/MachObjectWriter.cpp lib/Target/ARM/ARMAsmBackend.cpp lib/Target/X86/X86AsmBackend.cpp
Jim Grosbach
grosbach at apple.com
Fri Nov 5 11:48:58 PDT 2010
Author: grosbach
Date: Fri Nov 5 13:48:58 2010
New Revision: 118288
URL: http://llvm.org/viewvc/llvm-project?rev=118288&view=rev
Log:
Allow targets to specify the MachO CPUType/CPUSubtype information.
Modified:
llvm/trunk/include/llvm/MC/MachObjectWriter.h
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp
llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
Modified: llvm/trunk/include/llvm/MC/MachObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MachObjectWriter.h?rev=118288&r1=118287&r2=118288&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MachObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MachObjectWriter.h Fri Nov 5 13:48:58 2010
@@ -25,7 +25,8 @@
void *Impl;
public:
- MachObjectWriter(raw_ostream &OS, bool Is64Bit, bool IsLittleEndian = true);
+ MachObjectWriter(raw_ostream &OS, bool Is64Bit, uint32_t CPUType,
+ uint32_t CPUSubtype, bool IsLittleEndian = true);
virtual ~MachObjectWriter();
virtual void ExecutePostLayoutBinding(MCAssembler &Asm);
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=118288&r1=118287&r2=118288&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Fri Nov 5 13:48:58 2010
@@ -290,9 +290,14 @@
unsigned Is64Bit : 1;
+ uint32_t CPUType;
+ uint32_t CPUSubtype;
+
public:
- MachObjectWriterImpl(MachObjectWriter *_Writer, bool _Is64Bit)
- : Writer(_Writer), OS(Writer->getStream()), Is64Bit(_Is64Bit) {
+ MachObjectWriterImpl(MachObjectWriter *_Writer, bool _Is64Bit,
+ uint32_t _CPUType, uint32_t _CPUSubtype)
+ : Writer(_Writer), OS(Writer->getStream()), Is64Bit(_Is64Bit),
+ CPUType(_CPUType), CPUSubtype(_CPUSubtype) {
}
void Write8(uint8_t Value) { Writer->Write8(Value); }
@@ -319,10 +324,9 @@
Write32(Is64Bit ? Header_Magic64 : Header_Magic32);
- // FIXME: Support cputype.
- Write32(Is64Bit ? MachO::CPUTypeX86_64 : MachO::CPUTypeI386);
- // FIXME: Support cpusubtype.
- Write32(MachO::CPUSubType_I386_ALL);
+ Write32(CPUType);
+ Write32(CPUSubtype);
+
Write32(HFT_Object);
Write32(NumLoadCommands); // Object files have a single load command, the
// segment.
@@ -1329,10 +1333,12 @@
MachObjectWriter::MachObjectWriter(raw_ostream &OS,
bool Is64Bit,
+ uint32_t CPUType,
+ uint32_t CPUSubtype,
bool IsLittleEndian)
: MCObjectWriter(OS, IsLittleEndian)
{
- Impl = new MachObjectWriterImpl(this, Is64Bit);
+ Impl = new MachObjectWriterImpl(this, Is64Bit, CPUType, CPUSubtype);
}
MachObjectWriter::~MachObjectWriter() {
Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=118288&r1=118287&r2=118288&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Fri Nov 5 13:48:58 2010
@@ -20,6 +20,7 @@
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MachObjectWriter.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/MachO.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetRegistry.h"
@@ -128,7 +129,9 @@
}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return new MachObjectWriter(OS, /*Is64Bit=*/false);
+ // FIXME: Subtarget info should be derived. Force v7 for now.
+ return new MachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeARM,
+ MachO::CPUSubType_ARM_V7);
}
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=118288&r1=118287&r2=118288&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Fri Nov 5 13:48:58 2010
@@ -21,6 +21,7 @@
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MachObjectWriter.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/MachO.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetRegistry.h"
@@ -396,7 +397,8 @@
}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return new MachObjectWriter(OS, /*Is64Bit=*/false);
+ return new MachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeI386,
+ MachO::CPUSubType_I386_ALL);
}
};
@@ -412,7 +414,8 @@
}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return new MachObjectWriter(OS, /*Is64Bit=*/true);
+ return new MachObjectWriter(OS, /*Is64Bit=*/true, MachO::CPUTypeX86_64,
+ MachO::CPUSubType_I386_ALL);
}
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
More information about the llvm-commits
mailing list