mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +00:00
Factor out label difference creation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82282 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -74,6 +74,25 @@ unsigned DwarfException::SizeOfEncodedValue(unsigned Encoding) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// CreateLabelDiff - Emit a label and subtract it from the expression we
|
||||||
|
/// already have. This is equivalent to emitting "foo - .", but we have to emit
|
||||||
|
/// the label for "." directly.
|
||||||
|
const MCExpr *DwarfException::CreateLabelDiff(const MCExpr *ExprRef,
|
||||||
|
const char *LabelName,
|
||||||
|
unsigned Index) {
|
||||||
|
SmallString<64> Name;
|
||||||
|
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
|
||||||
|
<< LabelName << Asm->getFunctionNumber()
|
||||||
|
<< "_" << Index;
|
||||||
|
MCSymbol *DotSym = Asm->OutContext.GetOrCreateSymbol(Name.str());
|
||||||
|
Asm->OutStreamer.EmitLabel(DotSym);
|
||||||
|
|
||||||
|
return MCBinaryExpr::CreateSub(ExprRef,
|
||||||
|
MCSymbolRefExpr::Create(DotSym,
|
||||||
|
Asm->OutContext),
|
||||||
|
Asm->OutContext);
|
||||||
|
}
|
||||||
|
|
||||||
/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that
|
/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that
|
||||||
/// is shared among many Frame Description Entries. There is at least one CIE
|
/// is shared among many Frame Description Entries. There is at least one CIE
|
||||||
/// in every non-empty .debug_frame section.
|
/// in every non-empty .debug_frame section.
|
||||||
@@ -176,23 +195,9 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
|
|||||||
|
|
||||||
// If there is a personality, we need to indicate the function's location.
|
// If there is a personality, we need to indicate the function's location.
|
||||||
if (PersonalityRef) {
|
if (PersonalityRef) {
|
||||||
// If the reference to the personality function symbol is not already
|
if (!IsPersonalityPCRel)
|
||||||
// pc-relative, then we need to subtract our current address from it. Do
|
PersonalityRef = CreateLabelDiff(PersonalityRef, "personalityref_addr",
|
||||||
// this by emitting a label and subtracting it from the expression we
|
Index);
|
||||||
// already have. This is equivalent to emitting "foo - .", but we have to
|
|
||||||
// emit the label for "." directly.
|
|
||||||
if (!IsPersonalityPCRel) {
|
|
||||||
SmallString<64> Name;
|
|
||||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
|
|
||||||
<< "personalityref_addr" << Asm->getFunctionNumber() << "_" << Index;
|
|
||||||
MCSymbol *DotSym = Asm->OutContext.GetOrCreateSymbol(Name.str());
|
|
||||||
Asm->OutStreamer.EmitLabel(DotSym);
|
|
||||||
|
|
||||||
PersonalityRef =
|
|
||||||
MCBinaryExpr::CreateSub(PersonalityRef,
|
|
||||||
MCSymbolRefExpr::Create(DotSym,Asm->OutContext),
|
|
||||||
Asm->OutContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
O << MAI->getData32bitsDirective();
|
O << MAI->getData32bitsDirective();
|
||||||
PersonalityRef->print(O, MAI);
|
PersonalityRef->print(O, MAI);
|
||||||
@@ -912,24 +917,8 @@ void DwarfException::EmitExceptionTable() {
|
|||||||
IsTypeInfoIndirect,
|
IsTypeInfoIndirect,
|
||||||
IsTypeInfoPCRel);
|
IsTypeInfoPCRel);
|
||||||
|
|
||||||
if (!IsTypeInfoPCRel) {
|
if (!IsTypeInfoPCRel)
|
||||||
// If the reference to the type info symbol is not already
|
TypeInfoRef = CreateLabelDiff(TypeInfoRef, "typeinforef_addr", Index);
|
||||||
// pc-relative, then we need to subtract our current address from it.
|
|
||||||
// Do this by emitting a label and subtracting it from the expression
|
|
||||||
// we already have. This is equivalent to emitting "foo - .", but we
|
|
||||||
// have to emit the label for "." directly.
|
|
||||||
SmallString<64> Name;
|
|
||||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
|
|
||||||
<< "typeinforef_addr" << Asm->getFunctionNumber() << "_" << Index;
|
|
||||||
MCSymbol *DotSym = Asm->OutContext.GetOrCreateSymbol(Name.str());
|
|
||||||
Asm->OutStreamer.EmitLabel(DotSym);
|
|
||||||
|
|
||||||
TypeInfoRef =
|
|
||||||
MCBinaryExpr::CreateSub(TypeInfoRef,
|
|
||||||
MCSymbolRefExpr::Create(DotSym,
|
|
||||||
Asm->OutContext),
|
|
||||||
Asm->OutContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
O << MAI->getData32bitsDirective();
|
O << MAI->getData32bitsDirective();
|
||||||
TypeInfoRef->print(O, MAI);
|
TypeInfoRef->print(O, MAI);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace llvm {
|
|||||||
struct LandingPadInfo;
|
struct LandingPadInfo;
|
||||||
class MachineModuleInfo;
|
class MachineModuleInfo;
|
||||||
class MCAsmInfo;
|
class MCAsmInfo;
|
||||||
|
class MCExpr;
|
||||||
class Timer;
|
class Timer;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
|
||||||
@@ -168,6 +169,11 @@ class VISIBILITY_HIDDEN DwarfException : public Dwarf {
|
|||||||
const SmallVectorImpl<unsigned> &FirstActions);
|
const SmallVectorImpl<unsigned> &FirstActions);
|
||||||
void EmitExceptionTable();
|
void EmitExceptionTable();
|
||||||
|
|
||||||
|
/// CreateLabelDiff - Emit a label and subtract it from the expression we
|
||||||
|
/// already have. This is equivalent to emitting "foo - .", but we have to
|
||||||
|
/// emit the label for "." directly.
|
||||||
|
const MCExpr *CreateLabelDiff(const MCExpr *ExprRef, const char *LabelName,
|
||||||
|
unsigned Index);
|
||||||
public:
|
public:
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Main entry points.
|
// Main entry points.
|
||||||
|
|||||||
Reference in New Issue
Block a user