#include "JITDwarfEmitter.h"
#include "llvm/Function.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/CodeGen/MachineCodeEmitter.h"
+#include "llvm/CodeGen/JITCodeEmitter.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
-#include "llvm/Target/TargetAsmInfo.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
-
using namespace llvm;
-JITDwarfEmitter::JITDwarfEmitter(JIT& theJit) : Jit(theJit) {}
+JITDwarfEmitter::JITDwarfEmitter(JIT& theJit) : MMI(0), Jit(theJit) {}
unsigned char* JITDwarfEmitter::EmitDwarfTable(MachineFunction& F,
- MachineCodeEmitter& mce,
+ JITCodeEmitter& jce,
unsigned char* StartFunction,
- unsigned char* EndFunction) {
+ unsigned char* EndFunction,
+ unsigned char* &EHFramePtr) {
+ assert(MMI && "MachineModuleInfo not registered!");
+
const TargetMachine& TM = F.getTarget();
TD = TM.getTargetData();
- needsIndirectEncoding = TM.getTargetAsmInfo()->getNeedsIndirectEncoding();
stackGrowthDirection = TM.getFrameInfo()->getStackGrowthDirection();
RI = TM.getRegisterInfo();
- MCE = &mce;
+ JCE = &jce;
unsigned char* ExceptionTable = EmitExceptionTable(&F, StartFunction,
EndFunction);
unsigned char* Result = 0;
- unsigned char* EHFramePtr = 0;
const std::vector<Function *> Personalities = MMI->getPersonalities();
EHFramePtr = EmitCommonEHFrame(Personalities[MMI->getPersonalityIndex()]);
Result = EmitEHFrame(Personalities[MMI->getPersonalityIndex()], EHFramePtr,
StartFunction, EndFunction, ExceptionTable);
-
+
return Result;
}
}
intptr_t LabelPtr = 0;
- if (LabelID) LabelPtr = MCE->getLabelAddress(LabelID);
+ if (LabelID) LabelPtr = JCE->getLabelAddress(LabelID);
const MachineLocation &Dst = Move.getDestination();
const MachineLocation &Src = Move.getSource();
// Advance row if new location.
if (BaseLabelPtr && LabelID && (BaseLabelID != LabelID || !IsLocal)) {
- MCE->emitByte(dwarf::DW_CFA_advance_loc4);
- if (PointerSize == 8) {
- MCE->emitInt64(LabelPtr - BaseLabelPtr);
- } else {
- MCE->emitInt32(LabelPtr - BaseLabelPtr);
- }
+ JCE->emitByte(dwarf::DW_CFA_advance_loc4);
+ JCE->emitInt32(LabelPtr - BaseLabelPtr);
BaseLabelID = LabelID;
BaseLabelPtr = LabelPtr;
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
if (!Src.isReg()) {
if (Src.getReg() == MachineLocation::VirtualFP) {
- MCE->emitByte(dwarf::DW_CFA_def_cfa_offset);
+ JCE->emitByte(dwarf::DW_CFA_def_cfa_offset);
} else {
- MCE->emitByte(dwarf::DW_CFA_def_cfa);
- MCE->emitULEB128Bytes(RI->getDwarfRegNum(Src.getReg(), true));
+ JCE->emitByte(dwarf::DW_CFA_def_cfa);
+ JCE->emitULEB128Bytes(RI->getDwarfRegNum(Src.getReg(), true));
}
- int Offset = -Src.getOffset();
-
- MCE->emitULEB128Bytes(Offset);
+ JCE->emitULEB128Bytes(-Src.getOffset());
} else {
- assert(0 && "Machine move no supported yet.");
+ llvm_unreachable("Machine move not supported yet.");
}
} else if (Src.isReg() &&
Src.getReg() == MachineLocation::VirtualFP) {
if (Dst.isReg()) {
- MCE->emitByte(dwarf::DW_CFA_def_cfa_register);
- MCE->emitULEB128Bytes(RI->getDwarfRegNum(Dst.getReg(), true));
+ JCE->emitByte(dwarf::DW_CFA_def_cfa_register);
+ JCE->emitULEB128Bytes(RI->getDwarfRegNum(Dst.getReg(), true));
} else {
- assert(0 && "Machine move no supported yet.");
+ llvm_unreachable("Machine move not supported yet.");
}
} else {
unsigned Reg = RI->getDwarfRegNum(Src.getReg(), true);
int Offset = Dst.getOffset() / stackGrowth;
if (Offset < 0) {
- MCE->emitByte(dwarf::DW_CFA_offset_extended_sf);
- MCE->emitULEB128Bytes(Reg);
- MCE->emitSLEB128Bytes(Offset);
+ JCE->emitByte(dwarf::DW_CFA_offset_extended_sf);
+ JCE->emitULEB128Bytes(Reg);
+ JCE->emitSLEB128Bytes(Offset);
} else if (Reg < 64) {
- MCE->emitByte(dwarf::DW_CFA_offset + Reg);
- MCE->emitULEB128Bytes(Offset);
+ JCE->emitByte(dwarf::DW_CFA_offset + Reg);
+ JCE->emitULEB128Bytes(Offset);
} else {
- MCE->emitByte(dwarf::DW_CFA_offset_extended);
- MCE->emitULEB128Bytes(Reg);
- MCE->emitULEB128Bytes(Offset);
+ JCE->emitByte(dwarf::DW_CFA_offset_extended);
+ JCE->emitULEB128Bytes(Reg);
+ JCE->emitULEB128Bytes(Offset);
}
}
}
unsigned char* JITDwarfEmitter::EmitExceptionTable(MachineFunction* MF,
unsigned char* StartFunction,
unsigned char* EndFunction) const {
+ assert(MMI && "MachineModuleInfo not registered!");
+
// Map all labels and get rid of any dead landing pads.
MMI->TidyLandingPads();
for(std::vector<unsigned>::const_iterator I = FilterIds.begin(),
E = FilterIds.end(); I != E; ++I) {
FilterOffsets.push_back(Offset);
- Offset -= TargetAsmInfo::getULEB128Size(*I);
+ Offset -= MCAsmInfo::getULEB128Size(*I);
}
// Compute the actions table and gather the first action index for each
const unsigned SizePrevIds = LandingPads[i-1]->TypeIds.size();
assert(Actions.size());
PrevAction = &Actions.back();
- SizeAction = TargetAsmInfo::getSLEB128Size(PrevAction->NextAction) +
- TargetAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
+ SizeAction = MCAsmInfo::getSLEB128Size(PrevAction->NextAction) +
+ MCAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
for (unsigned j = NumShared; j != SizePrevIds; ++j) {
- SizeAction -= TargetAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
+ SizeAction -= MCAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
SizeAction += -PrevAction->NextAction;
PrevAction = PrevAction->Previous;
}
int TypeID = TypeIds[I];
assert(-1-TypeID < (int)FilterOffsets.size() && "Unknown filter id!");
int ValueForTypeID = TypeID < 0 ? FilterOffsets[-1 - TypeID] : TypeID;
- unsigned SizeTypeID = TargetAsmInfo::getSLEB128Size(ValueForTypeID);
+ unsigned SizeTypeID = MCAsmInfo::getSLEB128Size(ValueForTypeID);
int NextAction = SizeAction ? -(SizeAction + SizeTypeID) : 0;
- SizeAction = SizeTypeID + TargetAsmInfo::getSLEB128Size(NextAction);
+ SizeAction = SizeTypeID + MCAsmInfo::getSLEB128Size(NextAction);
SizeSiteActions += SizeAction;
ActionEntry Action = {ValueForTypeID, NextAction, PrevAction};
sizeof(int32_t) + // Site length.
sizeof(int32_t)); // Landing pad.
for (unsigned i = 0, e = CallSites.size(); i < e; ++i)
- SizeSites += TargetAsmInfo::getULEB128Size(CallSites[i].Action);
+ SizeSites += MCAsmInfo::getULEB128Size(CallSites[i].Action);
unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize();
unsigned TypeOffset = sizeof(int8_t) + // Call site format
// Call-site table length
- TargetAsmInfo::getULEB128Size(SizeSites) +
+ MCAsmInfo::getULEB128Size(SizeSites) +
SizeSites + SizeActions + SizeTypes;
- unsigned TotalSize = sizeof(int8_t) + // LPStart format
- sizeof(int8_t) + // TType format
- TargetAsmInfo::getULEB128Size(TypeOffset) + // TType base offset
- TypeOffset;
-
- unsigned SizeAlign = (4 - TotalSize) & 3;
-
// Begin the exception table.
- MCE->emitAlignment(4);
- for (unsigned i = 0; i != SizeAlign; ++i) {
- MCE->emitByte(0);
- // Asm->EOL("Padding");
- }
-
- unsigned char* DwarfExceptionTable = (unsigned char*)MCE->getCurrentPCValue();
+ JCE->emitAlignmentWithFill(4, 0);
+ // Asm->EOL("Padding");
+
+ unsigned char* DwarfExceptionTable = (unsigned char*)JCE->getCurrentPCValue();
// Emit the header.
- MCE->emitByte(dwarf::DW_EH_PE_omit);
+ JCE->emitByte(dwarf::DW_EH_PE_omit);
// Asm->EOL("LPStart format (DW_EH_PE_omit)");
- MCE->emitByte(dwarf::DW_EH_PE_absptr);
+ JCE->emitByte(dwarf::DW_EH_PE_absptr);
// Asm->EOL("TType format (DW_EH_PE_absptr)");
- MCE->emitULEB128Bytes(TypeOffset);
+ JCE->emitULEB128Bytes(TypeOffset);
// Asm->EOL("TType base offset");
- MCE->emitByte(dwarf::DW_EH_PE_udata4);
+ JCE->emitByte(dwarf::DW_EH_PE_udata4);
// Asm->EOL("Call site format (DW_EH_PE_udata4)");
- MCE->emitULEB128Bytes(SizeSites);
+ JCE->emitULEB128Bytes(SizeSites);
// Asm->EOL("Call-site table length");
// Emit the landing pad site information.
if (!S.BeginLabel) {
BeginLabelPtr = (intptr_t)StartFunction;
- if (TD->getPointerSize() == sizeof(int32_t))
- MCE->emitInt32(0);
- else
- MCE->emitInt64(0);
+ JCE->emitInt32(0);
} else {
- BeginLabelPtr = MCE->getLabelAddress(S.BeginLabel);
- if (TD->getPointerSize() == sizeof(int32_t))
- MCE->emitInt32(BeginLabelPtr - (intptr_t)StartFunction);
- else
- MCE->emitInt64(BeginLabelPtr - (intptr_t)StartFunction);
+ BeginLabelPtr = JCE->getLabelAddress(S.BeginLabel);
+ JCE->emitInt32(BeginLabelPtr - (intptr_t)StartFunction);
}
// Asm->EOL("Region start");
if (!S.EndLabel) {
EndLabelPtr = (intptr_t)EndFunction;
- if (TD->getPointerSize() == sizeof(int32_t))
- MCE->emitInt32((intptr_t)EndFunction - BeginLabelPtr);
- else
- MCE->emitInt64((intptr_t)EndFunction - BeginLabelPtr);
+ JCE->emitInt32((intptr_t)EndFunction - BeginLabelPtr);
} else {
- EndLabelPtr = MCE->getLabelAddress(S.EndLabel);
- if (TD->getPointerSize() == sizeof(int32_t))
- MCE->emitInt32(EndLabelPtr - BeginLabelPtr);
- else
- MCE->emitInt64(EndLabelPtr - BeginLabelPtr);
+ EndLabelPtr = JCE->getLabelAddress(S.EndLabel);
+ JCE->emitInt32(EndLabelPtr - BeginLabelPtr);
}
//Asm->EOL("Region length");
if (!S.PadLabel) {
- if (TD->getPointerSize() == sizeof(int32_t))
- MCE->emitInt32(0);
- else
- MCE->emitInt64(0);
+ JCE->emitInt32(0);
} else {
- unsigned PadLabelPtr = MCE->getLabelAddress(S.PadLabel);
- if (TD->getPointerSize() == sizeof(int32_t))
- MCE->emitInt32(PadLabelPtr - (intptr_t)StartFunction);
- else
- MCE->emitInt64(PadLabelPtr - (intptr_t)StartFunction);
+ unsigned PadLabelPtr = JCE->getLabelAddress(S.PadLabel);
+ JCE->emitInt32(PadLabelPtr - (intptr_t)StartFunction);
}
// Asm->EOL("Landing pad");
- MCE->emitULEB128Bytes(S.Action);
+ JCE->emitULEB128Bytes(S.Action);
// Asm->EOL("Action");
}
for (unsigned I = 0, N = Actions.size(); I != N; ++I) {
ActionEntry &Action = Actions[I];
- MCE->emitSLEB128Bytes(Action.ValueForTypeID);
+ JCE->emitSLEB128Bytes(Action.ValueForTypeID);
//Asm->EOL("TypeInfo index");
- MCE->emitSLEB128Bytes(Action.NextAction);
+ JCE->emitSLEB128Bytes(Action.NextAction);
//Asm->EOL("Next action");
}
GlobalVariable *GV = TypeInfos[M - 1];
if (GV) {
- if (TD->getPointerSize() == sizeof(int32_t)) {
- MCE->emitInt32((intptr_t)Jit.getOrEmitGlobalVariable(GV));
- } else {
- MCE->emitInt64((intptr_t)Jit.getOrEmitGlobalVariable(GV));
- }
+ if (TD->getPointerSize() == sizeof(int32_t))
+ JCE->emitInt32((intptr_t)Jit.getOrEmitGlobalVariable(GV));
+ else
+ JCE->emitInt64((intptr_t)Jit.getOrEmitGlobalVariable(GV));
} else {
if (TD->getPointerSize() == sizeof(int32_t))
- MCE->emitInt32(0);
+ JCE->emitInt32(0);
else
- MCE->emitInt64(0);
+ JCE->emitInt64(0);
}
// Asm->EOL("TypeInfo");
}
// Emit the filter typeids.
for (unsigned j = 0, M = FilterIds.size(); j < M; ++j) {
unsigned TypeID = FilterIds[j];
- MCE->emitULEB128Bytes(TypeID);
+ JCE->emitULEB128Bytes(TypeID);
//Asm->EOL("Filter TypeInfo index");
}
-
- MCE->emitAlignment(4);
+
+ JCE->emitAlignmentWithFill(4, 0);
return DwarfExceptionTable;
}
int stackGrowth = stackGrowthDirection == TargetFrameInfo::StackGrowsUp ?
PointerSize : -PointerSize;
- unsigned char* StartCommonPtr = (unsigned char*)MCE->getCurrentPCValue();
+ unsigned char* StartCommonPtr = (unsigned char*)JCE->getCurrentPCValue();
// EH Common Frame header
- MCE->allocateSpace(PointerSize, 0);
- unsigned char* FrameCommonBeginPtr = (unsigned char*)MCE->getCurrentPCValue();
- MCE->emitInt32((int)0);
- MCE->emitByte(dwarf::DW_CIE_VERSION);
- MCE->emitString(Personality ? "zPLR" : "zR");
- MCE->emitULEB128Bytes(1);
- MCE->emitSLEB128Bytes(stackGrowth);
- MCE->emitByte(RI->getDwarfRegNum(RI->getRARegister(), true));
-
+ JCE->allocateSpace(4, 0);
+ unsigned char* FrameCommonBeginPtr = (unsigned char*)JCE->getCurrentPCValue();
+ JCE->emitInt32((int)0);
+ JCE->emitByte(dwarf::DW_CIE_VERSION);
+ JCE->emitString(Personality ? "zPLR" : "zR");
+ JCE->emitULEB128Bytes(1);
+ JCE->emitSLEB128Bytes(stackGrowth);
+ JCE->emitByte(RI->getDwarfRegNum(RI->getRARegister(), true));
+
if (Personality) {
- MCE->emitULEB128Bytes(7);
-
- // Direct encoding, because we use the function pointer.
- MCE->emitByte(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
+ // Augmentation Size: 3 small ULEBs of one byte each, and the personality
+ // function which size is PointerSize.
+ JCE->emitULEB128Bytes(3 + PointerSize);
- if (PointerSize == 8)
- MCE->emitInt64((intptr_t)Jit.getPointerToGlobal(Personality) -
- MCE->getCurrentPCValue());
- else
- MCE->emitInt32((intptr_t)Jit.getPointerToGlobal(Personality) -
- MCE->getCurrentPCValue());
-
- MCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
- MCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
-
+ // We set the encoding of the personality as direct encoding because we use
+ // the function pointer. The encoding is not relative because the current
+ // PC value may be bigger than the personality function pointer.
+ if (PointerSize == 4) {
+ JCE->emitByte(dwarf::DW_EH_PE_sdata4);
+ JCE->emitInt32(((intptr_t)Jit.getPointerToGlobal(Personality)));
+ } else {
+ JCE->emitByte(dwarf::DW_EH_PE_sdata8);
+ JCE->emitInt64(((intptr_t)Jit.getPointerToGlobal(Personality)));
+ }
+
+ JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
+ JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
} else {
- MCE->emitULEB128Bytes(1);
- MCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
+ JCE->emitULEB128Bytes(1);
+ JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
}
std::vector<MachineMove> Moves;
RI->getInitialFrameState(Moves);
EmitFrameMoves(0, Moves);
- MCE->emitAlignment(4);
-
- MCE->emitAt((uintptr_t*)StartCommonPtr,
- (uintptr_t)((unsigned char*)MCE->getCurrentPCValue() -
- FrameCommonBeginPtr));
+
+ JCE->emitAlignmentWithFill(PointerSize, dwarf::DW_CFA_nop);
+
+ JCE->emitInt32At((uintptr_t*)StartCommonPtr,
+ (uintptr_t)((unsigned char*)JCE->getCurrentPCValue() -
+ FrameCommonBeginPtr));
return StartCommonPtr;
}
unsigned PointerSize = TD->getPointerSize();
// EH frame header.
- unsigned char* StartEHPtr = (unsigned char*)MCE->getCurrentPCValue();
- MCE->allocateSpace(PointerSize, 0);
- unsigned char* FrameBeginPtr = (unsigned char*)MCE->getCurrentPCValue();
+ unsigned char* StartEHPtr = (unsigned char*)JCE->getCurrentPCValue();
+ JCE->allocateSpace(4, 0);
+ unsigned char* FrameBeginPtr = (unsigned char*)JCE->getCurrentPCValue();
// FDE CIE Offset
- if (PointerSize == 8) {
- MCE->emitInt64(FrameBeginPtr - StartCommonPtr);
- MCE->emitInt64(StartFunction - (unsigned char*)MCE->getCurrentPCValue());
- MCE->emitInt64(EndFunction - StartFunction);
- } else {
- MCE->emitInt32(FrameBeginPtr - StartCommonPtr);
- MCE->emitInt32(StartFunction - (unsigned char*)MCE->getCurrentPCValue());
- MCE->emitInt32(EndFunction - StartFunction);
- }
+ JCE->emitInt32(FrameBeginPtr - StartCommonPtr);
+ JCE->emitInt32(StartFunction - (unsigned char*)JCE->getCurrentPCValue());
+ JCE->emitInt32(EndFunction - StartFunction);
// If there is a personality and landing pads then point to the language
// specific data area in the exception table.
- if (MMI->getPersonalityIndex()) {
- MCE->emitULEB128Bytes(4);
+ if (Personality) {
+ JCE->emitULEB128Bytes(PointerSize == 4 ? 4 : 8);
- if (!MMI->getLandingPads().empty()) {
- if (PointerSize == 8)
- MCE->emitInt64(ExceptionTable - (unsigned char*)MCE->getCurrentPCValue());
+ if (PointerSize == 4) {
+ if (!MMI->getLandingPads().empty())
+ JCE->emitInt32(ExceptionTable-(unsigned char*)JCE->getCurrentPCValue());
else
- MCE->emitInt32(ExceptionTable - (unsigned char*)MCE->getCurrentPCValue());
- } else if (PointerSize == 8) {
- MCE->emitInt64((int)0);
+ JCE->emitInt32((int)0);
} else {
- MCE->emitInt32((int)0);
+ if (!MMI->getLandingPads().empty())
+ JCE->emitInt64(ExceptionTable-(unsigned char*)JCE->getCurrentPCValue());
+ else
+ JCE->emitInt64((int)0);
}
} else {
- MCE->emitULEB128Bytes(0);
+ JCE->emitULEB128Bytes(0);
}
// Indicate locations of function specific callee saved registers in
// frame.
EmitFrameMoves((intptr_t)StartFunction, MMI->getFrameMoves());
-
- MCE->emitAlignment(4);
-
+
+ JCE->emitAlignmentWithFill(PointerSize, dwarf::DW_CFA_nop);
+
// Indicate the size of the table
- MCE->emitAt((uintptr_t*)StartEHPtr,
- (uintptr_t)((unsigned char*)MCE->getCurrentPCValue() -
- StartEHPtr));
-
+ JCE->emitInt32At((uintptr_t*)StartEHPtr,
+ (uintptr_t)((unsigned char*)JCE->getCurrentPCValue() -
+ StartEHPtr));
+
// Double zeroes for the unwind runtime
if (PointerSize == 8) {
- MCE->emitInt64(0);
- MCE->emitInt64(0);
+ JCE->emitInt64(0);
+ JCE->emitInt64(0);
} else {
- MCE->emitInt32(0);
- MCE->emitInt32(0);
+ JCE->emitInt32(0);
+ JCE->emitInt32(0);
}
-
return StartEHPtr;
}
unsigned JITDwarfEmitter::GetDwarfTableSizeInBytes(MachineFunction& F,
- MachineCodeEmitter& mce,
+ JITCodeEmitter& jce,
unsigned char* StartFunction,
unsigned char* EndFunction) {
const TargetMachine& TM = F.getTarget();
TD = TM.getTargetData();
- needsIndirectEncoding = TM.getTargetAsmInfo()->getNeedsIndirectEncoding();
stackGrowthDirection = TM.getFrameInfo()->getStackGrowthDirection();
RI = TM.getRegisterInfo();
- MCE = &mce;
+ JCE = &jce;
unsigned FinalSize = 0;
FinalSize += GetExceptionTableSizeInBytes(&F);
const std::vector<Function *> Personalities = MMI->getPersonalities();
- FinalSize += GetCommonEHFrameSizeInBytes(Personalities[MMI->getPersonalityIndex()]);
+ FinalSize +=
+ GetCommonEHFrameSizeInBytes(Personalities[MMI->getPersonalityIndex()]);
+
+ FinalSize += GetEHFrameSizeInBytes(Personalities[MMI->getPersonalityIndex()],
+ StartFunction);
- FinalSize += GetEHFrameSizeInBytes(Personalities[MMI->getPersonalityIndex()], StartFunction);
-
return FinalSize;
}
FinalSize += 3 * PointerSize;
// If there is a personality and landing pads then point to the language
// specific data area in the exception table.
- if (MMI->getPersonalityIndex()) {
- FinalSize += TargetAsmInfo::getULEB128Size(4);
+ if (Personality) {
+ FinalSize += MCAsmInfo::getULEB128Size(4);
FinalSize += PointerSize;
} else {
- FinalSize += TargetAsmInfo::getULEB128Size(0);
+ FinalSize += MCAsmInfo::getULEB128Size(0);
}
// Indicate locations of function specific callee saved registers in
FinalSize += 4;
FinalSize += 1;
FinalSize += Personality ? 5 : 3; // "zPLR" or "zR"
- FinalSize += TargetAsmInfo::getULEB128Size(1);
- FinalSize += TargetAsmInfo::getSLEB128Size(stackGrowth);
+ FinalSize += MCAsmInfo::getULEB128Size(1);
+ FinalSize += MCAsmInfo::getSLEB128Size(stackGrowth);
FinalSize += 1;
if (Personality) {
- FinalSize += TargetAsmInfo::getULEB128Size(7);
+ FinalSize += MCAsmInfo::getULEB128Size(7);
// Encoding
FinalSize+= 1;
//Personality
FinalSize += PointerSize;
- FinalSize += TargetAsmInfo::getULEB128Size(dwarf::DW_EH_PE_pcrel);
- FinalSize += TargetAsmInfo::getULEB128Size(dwarf::DW_EH_PE_pcrel);
+ FinalSize += MCAsmInfo::getULEB128Size(dwarf::DW_EH_PE_pcrel);
+ FinalSize += MCAsmInfo::getULEB128Size(dwarf::DW_EH_PE_pcrel);
} else {
- FinalSize += TargetAsmInfo::getULEB128Size(1);
- FinalSize += TargetAsmInfo::getULEB128Size(dwarf::DW_EH_PE_pcrel);
+ FinalSize += MCAsmInfo::getULEB128Size(1);
+ FinalSize += MCAsmInfo::getULEB128Size(dwarf::DW_EH_PE_pcrel);
}
std::vector<MachineMove> Moves;
}
intptr_t LabelPtr = 0;
- if (LabelID) LabelPtr = MCE->getLabelAddress(LabelID);
+ if (LabelID) LabelPtr = JCE->getLabelAddress(LabelID);
const MachineLocation &Dst = Move.getDestination();
const MachineLocation &Src = Move.getSource();
} else {
++FinalSize;
unsigned RegNum = RI->getDwarfRegNum(Src.getReg(), true);
- FinalSize += TargetAsmInfo::getULEB128Size(RegNum);
+ FinalSize += MCAsmInfo::getULEB128Size(RegNum);
}
int Offset = -Src.getOffset();
- FinalSize += TargetAsmInfo::getULEB128Size(Offset);
+ FinalSize += MCAsmInfo::getULEB128Size(Offset);
} else {
- assert(0 && "Machine move no supported yet.");
+ llvm_unreachable("Machine move no supported yet.");
}
} else if (Src.isReg() &&
Src.getReg() == MachineLocation::VirtualFP) {
if (Dst.isReg()) {
++FinalSize;
unsigned RegNum = RI->getDwarfRegNum(Dst.getReg(), true);
- FinalSize += TargetAsmInfo::getULEB128Size(RegNum);
+ FinalSize += MCAsmInfo::getULEB128Size(RegNum);
} else {
- assert(0 && "Machine move no supported yet.");
+ llvm_unreachable("Machine move no supported yet.");
}
} else {
unsigned Reg = RI->getDwarfRegNum(Src.getReg(), true);
if (Offset < 0) {
++FinalSize;
- FinalSize += TargetAsmInfo::getULEB128Size(Reg);
- FinalSize += TargetAsmInfo::getSLEB128Size(Offset);
+ FinalSize += MCAsmInfo::getULEB128Size(Reg);
+ FinalSize += MCAsmInfo::getSLEB128Size(Offset);
} else if (Reg < 64) {
++FinalSize;
- FinalSize += TargetAsmInfo::getULEB128Size(Offset);
+ FinalSize += MCAsmInfo::getULEB128Size(Offset);
} else {
++FinalSize;
- FinalSize += TargetAsmInfo::getULEB128Size(Reg);
- FinalSize += TargetAsmInfo::getULEB128Size(Offset);
+ FinalSize += MCAsmInfo::getULEB128Size(Reg);
+ FinalSize += MCAsmInfo::getULEB128Size(Offset);
}
}
}
for(std::vector<unsigned>::const_iterator I = FilterIds.begin(),
E = FilterIds.end(); I != E; ++I) {
FilterOffsets.push_back(Offset);
- Offset -= TargetAsmInfo::getULEB128Size(*I);
+ Offset -= MCAsmInfo::getULEB128Size(*I);
}
// Compute the actions table and gather the first action index for each
const unsigned SizePrevIds = LandingPads[i-1]->TypeIds.size();
assert(Actions.size());
PrevAction = &Actions.back();
- SizeAction = TargetAsmInfo::getSLEB128Size(PrevAction->NextAction) +
- TargetAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
+ SizeAction = MCAsmInfo::getSLEB128Size(PrevAction->NextAction) +
+ MCAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
for (unsigned j = NumShared; j != SizePrevIds; ++j) {
- SizeAction -= TargetAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
+ SizeAction -= MCAsmInfo::getSLEB128Size(PrevAction->ValueForTypeID);
SizeAction += -PrevAction->NextAction;
PrevAction = PrevAction->Previous;
}
int TypeID = TypeIds[I];
assert(-1-TypeID < (int)FilterOffsets.size() && "Unknown filter id!");
int ValueForTypeID = TypeID < 0 ? FilterOffsets[-1 - TypeID] : TypeID;
- unsigned SizeTypeID = TargetAsmInfo::getSLEB128Size(ValueForTypeID);
+ unsigned SizeTypeID = MCAsmInfo::getSLEB128Size(ValueForTypeID);
int NextAction = SizeAction ? -(SizeAction + SizeTypeID) : 0;
- SizeAction = SizeTypeID + TargetAsmInfo::getSLEB128Size(NextAction);
+ SizeAction = SizeTypeID + MCAsmInfo::getSLEB128Size(NextAction);
SizeSiteActions += SizeAction;
ActionEntry Action = {ValueForTypeID, NextAction, PrevAction};
sizeof(int32_t) + // Site length.
sizeof(int32_t)); // Landing pad.
for (unsigned i = 0, e = CallSites.size(); i < e; ++i)
- SizeSites += TargetAsmInfo::getULEB128Size(CallSites[i].Action);
+ SizeSites += MCAsmInfo::getULEB128Size(CallSites[i].Action);
unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize();
unsigned TypeOffset = sizeof(int8_t) + // Call site format
// Call-site table length
- TargetAsmInfo::getULEB128Size(SizeSites) +
+ MCAsmInfo::getULEB128Size(SizeSites) +
SizeSites + SizeActions + SizeTypes;
unsigned TotalSize = sizeof(int8_t) + // LPStart format
sizeof(int8_t) + // TType format
- TargetAsmInfo::getULEB128Size(TypeOffset) + // TType base offset
+ MCAsmInfo::getULEB128Size(TypeOffset) + // TType base offset
TypeOffset;
unsigned SizeAlign = (4 - TotalSize) & 3;
// Asm->EOL("Landing pad");
FinalSize += PointerSize;
- FinalSize += TargetAsmInfo::getULEB128Size(S.Action);
+ FinalSize += MCAsmInfo::getULEB128Size(S.Action);
// Asm->EOL("Action");
}
ActionEntry &Action = Actions[I];
//Asm->EOL("TypeInfo index");
- FinalSize += TargetAsmInfo::getSLEB128Size(Action.ValueForTypeID);
+ FinalSize += MCAsmInfo::getSLEB128Size(Action.ValueForTypeID);
//Asm->EOL("Next action");
- FinalSize += TargetAsmInfo::getSLEB128Size(Action.NextAction);
+ FinalSize += MCAsmInfo::getSLEB128Size(Action.NextAction);
}
// Emit the type ids.
// Emit the filter typeids.
for (unsigned j = 0, M = FilterIds.size(); j < M; ++j) {
unsigned TypeID = FilterIds[j];
- FinalSize += TargetAsmInfo::getULEB128Size(TypeID);
+ FinalSize += MCAsmInfo::getULEB128Size(TypeID);
//Asm->EOL("Filter TypeInfo index");
}