mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-05 13:09:10 +00:00
2c3a4641a7
Mips16 is really a processor decoding mode (ala thumb 1) and in the same program, mips16 and mips32 functions can exist and can call each other. If a jal type instruction encounters an address with the lower bit set, then the processor switches to mips16 mode (if it is not already in it). If the lower bit is not set, then it switches to mips32 mode. The linker knows which functions are mips16 and which are mips32. When relocation is performed on code labels, this lower order bit is set if the code label is a mips16 code label. In general this works just fine, however when creating exception handling tables and dwarf, there are cases where you don't want this lower order bit added in. This has been traditionally distinguished in gas assembly source by using a different syntax for the label. lab1: ; this will cause the lower order bit to be added lab2=. ; this will not cause the lower order bit to be added In some cases, it does not matter because in dwarf and debug tables the difference of two labels is used and in that case the lower order bits subtract each other out. To fix this, I have added to mcstreamer the notion of a debuglabel. The default is for label and debug label to be the same. So calling EmitLabel and EmitDebugLabel produce the same result. For various reasons, there is only one set of labels that needs to be modified for the mips exceptions to work. These are the "$eh_func_beginXXX" labels. Mips overrides the debug label suffix from ":" to "=." . This initial patch fixes exceptions. More changes most likely will be needed to DwarfCFException to make all of this work for actual debugging. These changes will be to emit debug labels in some places where a simple label is emitted now. Some historical discussion on this from gcc can be found at: http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00623.html http://gcc.gnu.org/ml/gcc-patches/2008-11/msg01273.html git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170279 91177308-0d34-0410-b5e6-96231b3b80d8
142 lines
4.2 KiB
C++
142 lines
4.2 KiB
C++
//===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines target asm properties related what form asm statements
|
|
// should take.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
|
#include "llvm/MC/MCContext.h"
|
|
#include "llvm/MC/MCExpr.h"
|
|
#include "llvm/MC/MCStreamer.h"
|
|
#include "llvm/Support/DataTypes.h"
|
|
#include "llvm/Support/Dwarf.h"
|
|
#include <cctype>
|
|
#include <cstring>
|
|
using namespace llvm;
|
|
|
|
MCAsmInfo::MCAsmInfo() {
|
|
PointerSize = 4;
|
|
IsLittleEndian = true;
|
|
StackGrowsUp = false;
|
|
HasSubsectionsViaSymbols = false;
|
|
HasMachoZeroFillDirective = false;
|
|
HasMachoTBSSDirective = false;
|
|
HasStaticCtorDtorReferenceInStaticMode = false;
|
|
LinkerRequiresNonEmptyDwarfLines = false;
|
|
MaxInstLength = 4;
|
|
PCSymbol = "$";
|
|
SeparatorString = ";";
|
|
CommentColumn = 40;
|
|
CommentString = "#";
|
|
LabelSuffix = ":";
|
|
DebugLabelSuffix = ":";
|
|
GlobalPrefix = "";
|
|
PrivateGlobalPrefix = ".";
|
|
LinkerPrivateGlobalPrefix = "";
|
|
InlineAsmStart = "APP";
|
|
InlineAsmEnd = "NO_APP";
|
|
Code16Directive = ".code16";
|
|
Code32Directive = ".code32";
|
|
Code64Directive = ".code64";
|
|
AssemblerDialect = 0;
|
|
AllowQuotesInName = false;
|
|
AllowNameToStartWithDigit = false;
|
|
AllowPeriodsInName = true;
|
|
AllowUTF8 = true;
|
|
UseDataRegionDirectives = false;
|
|
ZeroDirective = "\t.zero\t";
|
|
AsciiDirective = "\t.ascii\t";
|
|
AscizDirective = "\t.asciz\t";
|
|
Data8bitsDirective = "\t.byte\t";
|
|
Data16bitsDirective = "\t.short\t";
|
|
Data32bitsDirective = "\t.long\t";
|
|
Data64bitsDirective = "\t.quad\t";
|
|
SunStyleELFSectionSwitchSyntax = false;
|
|
UsesELFSectionDirectiveForBSS = false;
|
|
AlignDirective = "\t.align\t";
|
|
AlignmentIsInBytes = true;
|
|
TextAlignFillValue = 0;
|
|
GPRel64Directive = 0;
|
|
GPRel32Directive = 0;
|
|
GlobalDirective = "\t.globl\t";
|
|
HasSetDirective = true;
|
|
HasAggressiveSymbolFolding = true;
|
|
COMMDirectiveAlignmentIsInBytes = true;
|
|
LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
|
|
HasDotTypeDotSizeDirective = true;
|
|
HasSingleParameterDotFile = true;
|
|
HasNoDeadStrip = false;
|
|
HasSymbolResolver = false;
|
|
WeakRefDirective = 0;
|
|
WeakDefDirective = 0;
|
|
LinkOnceDirective = 0;
|
|
HiddenVisibilityAttr = MCSA_Hidden;
|
|
HiddenDeclarationVisibilityAttr = MCSA_Hidden;
|
|
ProtectedVisibilityAttr = MCSA_Protected;
|
|
HasLEB128 = false;
|
|
SupportsDebugInformation = false;
|
|
ExceptionsType = ExceptionHandling::None;
|
|
DwarfUsesInlineInfoSection = false;
|
|
DwarfSectionOffsetDirective = 0;
|
|
DwarfUsesRelocationsAcrossSections = true;
|
|
DwarfRegNumForCFI = false;
|
|
HasMicrosoftFastStdCallMangling = false;
|
|
}
|
|
|
|
MCAsmInfo::~MCAsmInfo() {
|
|
}
|
|
|
|
|
|
unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
|
|
unsigned Size = 0;
|
|
do {
|
|
Value >>= 7;
|
|
Size += sizeof(int8_t);
|
|
} while (Value);
|
|
return Size;
|
|
}
|
|
|
|
unsigned MCAsmInfo::getSLEB128Size(int Value) {
|
|
unsigned Size = 0;
|
|
int Sign = Value >> (8 * sizeof(Value) - 1);
|
|
bool IsMore;
|
|
|
|
do {
|
|
unsigned Byte = Value & 0x7f;
|
|
Value >>= 7;
|
|
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
|
|
Size += sizeof(int8_t);
|
|
} while (IsMore);
|
|
return Size;
|
|
}
|
|
|
|
const MCExpr *
|
|
MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
|
|
unsigned Encoding,
|
|
MCStreamer &Streamer) const {
|
|
return getExprForFDESymbol(Sym, Encoding, Streamer);
|
|
}
|
|
|
|
const MCExpr *
|
|
MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
|
|
unsigned Encoding,
|
|
MCStreamer &Streamer) const {
|
|
if (!(Encoding & dwarf::DW_EH_PE_pcrel))
|
|
return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
|
|
|
|
MCContext &Context = Streamer.getContext();
|
|
const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
|
|
MCSymbol *PCSym = Context.CreateTempSymbol();
|
|
Streamer.EmitLabel(PCSym);
|
|
const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
|
|
return MCBinaryExpr::CreateSub(Res, PC, Context);
|
|
}
|