//
//===----------------------------------------------------------------------===//
+#include "MachO.h"
+#include "MachOWriter.h"
#include "MachOCodeEmitter.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
+#include "llvm/CodeGen/MachineRelocation.h"
#include "llvm/Target/TargetAsmInfo.h"
+#include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/OutputBuffer.h"
#include <vector>
//===----------------------------------------------------------------------===//
namespace llvm {
-
+
+MachOCodeEmitter::MachOCodeEmitter(MachOWriter &mow, MachOSection &mos) :
+ ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) {
+ is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
+ isLittleEndian = TM.getTargetData()->isLittleEndian();
+ TAI = TM.getTargetAsmInfo();
+}
+
/// startFunction - This callback is invoked when a new machine function is
/// about to be emitted.
// Create symbol for function entry
const GlobalValue *FuncV = MF.getFunction();
- MachOSym FnSym(FuncV, MOW.Mang->getValueName(FuncV), MOS->Index, TAI);
+ MachOSym FnSym(FuncV, MOW.Mang->getMangledName(FuncV), MOS->Index, TAI);
FnSym.n_value = getCurrentPCOffset();
// add it to the symtab.
// FIXME: This should be a set or something that uniques
MOW.PendingGlobals.push_back(MR.getGlobalValue());
} else {
- assert(0 && "Unhandled relocation type");
+ llvm_unreachable("Unhandled relocation type");
}
MOS->addRelocation(MR);
}
for (unsigned j = 0; j < Size; ++j)
SecDataOut.outbyte(0);
- MachOWriter::InitMem(CP[i].Val.ConstVal, CPLocations[i], TM.getTargetData(), Sec);
+ MachOWriter::InitMem(CP[i].Val.ConstVal, CPLocations[i],
+ TM.getTargetData(), Sec);
}
}