123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 |
- #pragma once
- #ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-parameter"
- #endif
- #ifndef LLVM_MC_MCASMINFO_H
- #define LLVM_MC_MCASMINFO_H
- #include "llvm/ADT/StringRef.h"
- #include "llvm/MC/MCDirectives.h"
- #include "llvm/MC/MCTargetOptions.h"
- #include <vector>
- namespace llvm {
- class MCContext;
- class MCCFIInstruction;
- class MCExpr;
- class MCSection;
- class MCStreamer;
- class MCSubtargetInfo;
- class MCSymbol;
- namespace WinEH {
- enum class EncodingType {
- Invalid,
- Alpha,
- Alpha64,
- ARM,
- CE,
- Itanium,
- X86,
- MIPS = Alpha,
- };
- }
- namespace LCOMM {
- enum LCOMMType { NoAlignment, ByteAlignment, Log2Alignment };
- }
- class MCAsmInfo {
- public:
-
- enum AsmCharLiteralSyntax {
- ACLS_Unknown,
-
- ACLS_SingleQuotePrefix,
-
- };
- protected:
-
-
-
-
- unsigned CodePointerSize = 4;
-
-
- unsigned CalleeSaveStackSlotSize = 4;
-
- bool IsLittleEndian = true;
-
- bool StackGrowsUp = false;
-
-
- bool HasSubsectionsViaSymbols = false;
-
-
- bool HasMachoZeroFillDirective = false;
-
-
- bool HasMachoTBSSDirective = false;
-
-
-
- bool HasCOFFAssociativeComdats = false;
-
-
- bool HasCOFFComdatConstants = false;
-
-
- bool HasVisibilityOnlyWithLinkage = false;
-
-
- unsigned MaxInstLength = 4;
-
-
- unsigned MinInstAlignment = 1;
-
-
- bool DollarIsPC = false;
-
-
- bool DotIsPC = true;
-
-
- bool StarIsPC = false;
-
-
- const char *SeparatorString;
-
-
- StringRef CommentString;
-
-
- bool RestrictCommentStringToStartOfStatement = false;
-
-
-
-
-
-
- bool AllowAdditionalComments = true;
-
-
- bool EmitGNUAsmStartIndentationMarker = true;
-
- const char *LabelSuffix;
-
- bool EmitLabelsInUpperCase = false;
-
- bool UseAssignmentForEHBegin = false;
-
- bool NeedsLocalForSize = false;
-
-
-
- StringRef PrivateGlobalPrefix;
-
-
- StringRef PrivateLabelPrefix;
-
-
-
-
- StringRef LinkerPrivateGlobalPrefix;
-
-
- const char *InlineAsmStart;
- const char *InlineAsmEnd;
-
-
-
- const char *Code16Directive;
- const char *Code32Directive;
- const char *Code64Directive;
-
- unsigned AssemblerDialect = 0;
-
-
- bool AllowAtInName = false;
-
-
-
-
-
- bool AllowQuestionAtStartOfIdentifier = false;
-
-
-
-
-
- bool AllowDollarAtStartOfIdentifier = false;
-
-
-
-
-
- bool AllowAtAtStartOfIdentifier = false;
-
-
-
-
-
- bool AllowHashAtStartOfIdentifier = false;
-
-
- bool SupportsQuotedNames = true;
-
-
-
- bool UseDataRegionDirectives = false;
-
-
- bool UseDotAlignForAlignment = false;
-
- bool HasLEB128Directives = true;
-
-
-
-
-
- const char *ZeroDirective;
-
-
-
- bool ZeroDirectiveSupportsNonZeroValue = true;
-
-
-
- const char *AsciiDirective;
-
-
-
- const char *AscizDirective;
-
-
-
- const char *ByteListDirective = nullptr;
-
-
-
- const char *PlainStringDirective = nullptr;
-
-
-
- AsmCharLiteralSyntax CharacterLiteralSyntax = ACLS_Unknown;
-
-
-
-
- const char *Data8bitsDirective;
- const char *Data16bitsDirective;
- const char *Data32bitsDirective;
- const char *Data64bitsDirective;
-
- bool SupportsSignedData = true;
-
-
-
- const char *GPRel64Directive = nullptr;
-
-
-
- const char *GPRel32Directive = nullptr;
-
-
-
- const char *DTPRel32Directive = nullptr;
- const char *DTPRel64Directive = nullptr;
- const char *TPRel32Directive = nullptr;
- const char *TPRel64Directive = nullptr;
-
-
-
- bool SunStyleELFSectionSwitchSyntax = false;
-
-
-
- bool UsesELFSectionDirectiveForBSS = false;
- bool NeedsDwarfSectionOffsetDirective = false;
-
-
-
-
-
- bool AlignmentIsInBytes = true;
-
-
- unsigned TextAlignFillValue = 0;
-
-
-
- const char *GlobalDirective;
-
-
-
-
-
- bool SetDirectiveSuppressesReloc = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool HasAggressiveSymbolFolding = true;
-
-
- bool COMMDirectiveAlignmentIsInBytes = true;
-
-
- LCOMM::LCOMMType LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
-
-
- bool HasBasenameOnlyForFileDirective = true;
-
-
-
-
- bool HasPairedDoubleQuoteStringConstants = false;
-
-
- bool HasFunctionAlignment = true;
-
-
- bool HasDotTypeDotSizeDirective = true;
-
-
- bool HasSingleParameterDotFile = true;
-
-
- bool HasFourStringsDotFile = false;
-
-
- bool HasIdentDirective = false;
-
-
- bool HasNoDeadStrip = false;
-
-
- bool HasAltEntry = false;
-
- const char *WeakDirective;
-
-
- const char *WeakRefDirective = nullptr;
-
-
- bool HasWeakDefDirective = false;
-
-
- bool HasWeakDefCanBeHiddenDirective = false;
-
-
-
- bool AvoidWeakIfComdat = false;
-
-
- MCSymbolAttr HiddenVisibilityAttr = MCSA_Hidden;
-
-
- MCSymbolAttr ExportedVisibilityAttr = MCSA_Exported;
-
-
- MCSymbolAttr HiddenDeclarationVisibilityAttr = MCSA_Hidden;
-
-
- MCSymbolAttr ProtectedVisibilityAttr = MCSA_Protected;
- MCSymbolAttr MemtagAttr = MCSA_Memtag;
-
-
-
- bool SupportsDebugInformation = false;
-
- ExceptionHandling ExceptionsType = ExceptionHandling::None;
-
-
- bool UsesCFIForDebug = false;
-
- WinEH::EncodingType WinEHEncodingType = WinEH::EncodingType::Invalid;
-
-
- bool DwarfUsesRelocationsAcrossSections = true;
-
-
- bool DwarfFDESymbolsUseAbsDiff = false;
-
-
- bool UsesDwarfFileAndLocDirectives = true;
-
-
- bool EnableDwarfFileDirectoryDefault = true;
-
-
- bool DwarfSectionSizeRequired = true;
-
-
- bool DwarfRegNumForCFI = false;
-
-
- bool UseParensForSymbolVariant = false;
-
-
- bool UseParensForDollarSignNames = true;
-
-
- bool SupportsExtendedDwarfLocDirective = true;
-
- std::vector<MCCFIInstruction> InitialFrameState;
-
-
-
-
-
- std::pair<int, int> BinutilsVersion = {2, 26};
-
-
-
-
-
- bool UseIntegratedAssembler;
-
- bool ParseInlineAsmUsingAsmParser;
-
- bool PreserveAsmComments;
-
- DebugCompressionType CompressDebugSections = DebugCompressionType::None;
-
-
- bool UseLogicalShr = true;
-
-
- bool RelaxELFRelocations = true;
-
-
- bool HasMipsExpressions = false;
-
- bool UseMotorolaIntegers = false;
-
- bool NeedsFunctionDescriptors = false;
- public:
- explicit MCAsmInfo();
- virtual ~MCAsmInfo();
-
- unsigned getCodePointerSize() const { return CodePointerSize; }
-
-
- unsigned getCalleeSaveStackSlotSize() const {
- return CalleeSaveStackSlotSize;
- }
-
- bool isLittleEndian() const { return IsLittleEndian; }
-
- bool isStackGrowthDirectionUp() const { return StackGrowsUp; }
- bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
-
- const char *getData8bitsDirective() const { return Data8bitsDirective; }
- const char *getData16bitsDirective() const { return Data16bitsDirective; }
- const char *getData32bitsDirective() const { return Data32bitsDirective; }
- const char *getData64bitsDirective() const { return Data64bitsDirective; }
- bool supportsSignedData() const { return SupportsSignedData; }
- const char *getGPRel64Directive() const { return GPRel64Directive; }
- const char *getGPRel32Directive() const { return GPRel32Directive; }
- const char *getDTPRel64Directive() const { return DTPRel64Directive; }
- const char *getDTPRel32Directive() const { return DTPRel32Directive; }
- const char *getTPRel64Directive() const { return TPRel64Directive; }
- const char *getTPRel32Directive() const { return TPRel32Directive; }
-
-
-
- virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const {
- return nullptr;
- }
-
-
-
-
- virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const;
- virtual const MCExpr *getExprForPersonalitySymbol(const MCSymbol *Sym,
- unsigned Encoding,
- MCStreamer &Streamer) const;
- virtual const MCExpr *getExprForFDESymbol(const MCSymbol *Sym,
- unsigned Encoding,
- MCStreamer &Streamer) const;
-
- virtual bool isAcceptableChar(char C) const;
-
-
- virtual bool isValidUnquotedName(StringRef Name) const;
-
-
-
-
-
-
-
- virtual bool shouldOmitSectionDirective(StringRef SectionName) const;
- bool usesSunStyleELFSectionSwitchSyntax() const {
- return SunStyleELFSectionSwitchSyntax;
- }
- bool usesELFSectionDirectiveForBSS() const {
- return UsesELFSectionDirectiveForBSS;
- }
- bool needsDwarfSectionOffsetDirective() const {
- return NeedsDwarfSectionOffsetDirective;
- }
-
- bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; }
- bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; }
- bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
- bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
- bool hasVisibilityOnlyWithLinkage() const {
- return HasVisibilityOnlyWithLinkage;
- }
-
-
- virtual unsigned getMaxInstLength(const MCSubtargetInfo *STI = nullptr) const {
- return MaxInstLength;
- }
- unsigned getMinInstAlignment() const { return MinInstAlignment; }
- bool getDollarIsPC() const { return DollarIsPC; }
- bool getDotIsPC() const { return DotIsPC; }
- bool getStarIsPC() const { return StarIsPC; }
- const char *getSeparatorString() const { return SeparatorString; }
-
-
- unsigned getCommentColumn() const { return 40; }
- StringRef getCommentString() const { return CommentString; }
- bool getRestrictCommentStringToStartOfStatement() const {
- return RestrictCommentStringToStartOfStatement;
- }
- bool shouldAllowAdditionalComments() const { return AllowAdditionalComments; }
- bool getEmitGNUAsmStartIndentationMarker() const {
- return EmitGNUAsmStartIndentationMarker;
- }
- const char *getLabelSuffix() const { return LabelSuffix; }
- bool shouldEmitLabelsInUpperCase() const { return EmitLabelsInUpperCase; }
- bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
- bool needsLocalForSize() const { return NeedsLocalForSize; }
- StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }
- StringRef getPrivateLabelPrefix() const { return PrivateLabelPrefix; }
- bool hasLinkerPrivateGlobalPrefix() const {
- return !LinkerPrivateGlobalPrefix.empty();
- }
- StringRef getLinkerPrivateGlobalPrefix() const {
- if (hasLinkerPrivateGlobalPrefix())
- return LinkerPrivateGlobalPrefix;
- return getPrivateGlobalPrefix();
- }
- const char *getInlineAsmStart() const { return InlineAsmStart; }
- const char *getInlineAsmEnd() const { return InlineAsmEnd; }
- const char *getCode16Directive() const { return Code16Directive; }
- const char *getCode32Directive() const { return Code32Directive; }
- const char *getCode64Directive() const { return Code64Directive; }
- unsigned getAssemblerDialect() const { return AssemblerDialect; }
- bool doesAllowAtInName() const { return AllowAtInName; }
- void setAllowAtInName(bool V) { AllowAtInName = V; }
- bool doesAllowQuestionAtStartOfIdentifier() const {
- return AllowQuestionAtStartOfIdentifier;
- }
- bool doesAllowAtAtStartOfIdentifier() const {
- return AllowAtAtStartOfIdentifier;
- }
- bool doesAllowDollarAtStartOfIdentifier() const {
- return AllowDollarAtStartOfIdentifier;
- }
- bool doesAllowHashAtStartOfIdentifier() const {
- return AllowHashAtStartOfIdentifier;
- }
- bool supportsNameQuoting() const { return SupportsQuotedNames; }
- bool doesSupportDataRegionDirectives() const {
- return UseDataRegionDirectives;
- }
- bool useDotAlignForAlignment() const {
- return UseDotAlignForAlignment;
- }
- bool hasLEB128Directives() const { return HasLEB128Directives; }
- const char *getZeroDirective() const { return ZeroDirective; }
- bool doesZeroDirectiveSupportNonZeroValue() const {
- return ZeroDirectiveSupportsNonZeroValue;
- }
- const char *getAsciiDirective() const { return AsciiDirective; }
- const char *getAscizDirective() const { return AscizDirective; }
- const char *getByteListDirective() const { return ByteListDirective; }
- const char *getPlainStringDirective() const { return PlainStringDirective; }
- AsmCharLiteralSyntax characterLiteralSyntax() const {
- return CharacterLiteralSyntax;
- }
- bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; }
- unsigned getTextAlignFillValue() const { return TextAlignFillValue; }
- const char *getGlobalDirective() const { return GlobalDirective; }
- bool doesSetDirectiveSuppressReloc() const {
- return SetDirectiveSuppressesReloc;
- }
- bool hasAggressiveSymbolFolding() const { return HasAggressiveSymbolFolding; }
- bool getCOMMDirectiveAlignmentIsInBytes() const {
- return COMMDirectiveAlignmentIsInBytes;
- }
- LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const {
- return LCOMMDirectiveAlignmentType;
- }
- bool hasBasenameOnlyForFileDirective() const {
- return HasBasenameOnlyForFileDirective;
- }
- bool hasPairedDoubleQuoteStringConstants() const {
- return HasPairedDoubleQuoteStringConstants;
- }
- bool hasFunctionAlignment() const { return HasFunctionAlignment; }
- bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; }
- bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; }
- bool hasFourStringsDotFile() const { return HasFourStringsDotFile; }
- bool hasIdentDirective() const { return HasIdentDirective; }
- bool hasNoDeadStrip() const { return HasNoDeadStrip; }
- bool hasAltEntry() const { return HasAltEntry; }
- const char *getWeakDirective() const { return WeakDirective; }
- const char *getWeakRefDirective() const { return WeakRefDirective; }
- bool hasWeakDefDirective() const { return HasWeakDefDirective; }
- bool hasWeakDefCanBeHiddenDirective() const {
- return HasWeakDefCanBeHiddenDirective;
- }
- bool avoidWeakIfComdat() const { return AvoidWeakIfComdat; }
- MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr; }
- MCSymbolAttr getExportedVisibilityAttr() const { return ExportedVisibilityAttr; }
- MCSymbolAttr getHiddenDeclarationVisibilityAttr() const {
- return HiddenDeclarationVisibilityAttr;
- }
- MCSymbolAttr getProtectedVisibilityAttr() const {
- return ProtectedVisibilityAttr;
- }
- MCSymbolAttr getMemtagAttr() const { return MemtagAttr; }
- bool doesSupportDebugInformation() const { return SupportsDebugInformation; }
- ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; }
- WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; }
- void setExceptionsType(ExceptionHandling EH) {
- ExceptionsType = EH;
- }
- bool doesUseCFIForDebug() const { return UsesCFIForDebug; }
-
-
- bool usesCFIForEH() const {
- return (ExceptionsType == ExceptionHandling::DwarfCFI ||
- ExceptionsType == ExceptionHandling::ARM || usesWindowsCFI());
- }
- bool usesWindowsCFI() const {
- return ExceptionsType == ExceptionHandling::WinEH &&
- (WinEHEncodingType != WinEH::EncodingType::Invalid &&
- WinEHEncodingType != WinEH::EncodingType::X86);
- }
- bool doesDwarfUseRelocationsAcrossSections() const {
- return DwarfUsesRelocationsAcrossSections;
- }
- bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; }
- bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; }
- bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; }
- bool useParensForDollarSignNames() const {
- return UseParensForDollarSignNames;
- }
- bool supportsExtendedDwarfLocDirective() const {
- return SupportsExtendedDwarfLocDirective;
- }
- bool usesDwarfFileAndLocDirectives() const {
- return UsesDwarfFileAndLocDirectives;
- }
- bool needsDwarfSectionSizeInHeader() const {
- return DwarfSectionSizeRequired;
- }
- bool enableDwarfFileDirectoryDefault() const {
- return EnableDwarfFileDirectoryDefault;
- }
- void addInitialFrameState(const MCCFIInstruction &Inst);
- const std::vector<MCCFIInstruction> &getInitialFrameState() const {
- return InitialFrameState;
- }
- void setBinutilsVersion(std::pair<int, int> Value) {
- BinutilsVersion = Value;
- }
-
- bool useIntegratedAssembler() const { return UseIntegratedAssembler; }
-
- bool parseInlineAsmUsingAsmParser() const {
- return ParseInlineAsmUsingAsmParser;
- }
- bool binutilsIsAtLeast(int Major, int Minor) const {
- return BinutilsVersion >= std::make_pair(Major, Minor);
- }
-
- virtual void setUseIntegratedAssembler(bool Value) {
- UseIntegratedAssembler = Value;
- }
-
- virtual void setParseInlineAsmUsingAsmParser(bool Value) {
- ParseInlineAsmUsingAsmParser = Value;
- }
-
- bool preserveAsmComments() const { return PreserveAsmComments; }
-
- virtual void setPreserveAsmComments(bool Value) {
- PreserveAsmComments = Value;
- }
- DebugCompressionType compressDebugSections() const {
- return CompressDebugSections;
- }
- void setCompressDebugSections(DebugCompressionType CompressDebugSections) {
- this->CompressDebugSections = CompressDebugSections;
- }
- bool shouldUseLogicalShr() const { return UseLogicalShr; }
- bool canRelaxRelocations() const { return RelaxELFRelocations; }
- void setRelaxELFRelocations(bool V) { RelaxELFRelocations = V; }
- bool hasMipsExpressions() const { return HasMipsExpressions; }
- bool needsFunctionDescriptors() const { return NeedsFunctionDescriptors; }
- bool shouldUseMotorolaIntegers() const { return UseMotorolaIntegers; }
- };
- }
- #endif
- #ifdef __GNUC__
- #pragma GCC diagnostic pop
- #endif
|