summaryrefslogtreecommitdiff
path: root/include/llvm/MC
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:01:22 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:01:22 +0000
commit71d5a2540a98c81f5bcaeb48805e0e2881f530ef (patch)
tree5343938942df402b49ec7300a1c25a2d4ccd5821 /include/llvm/MC
parent31bbf64f3a4974a2d6c8b3b27ad2f519caf74057 (diff)
Diffstat (limited to 'include/llvm/MC')
-rw-r--r--include/llvm/MC/ConstantPools.h10
-rw-r--r--include/llvm/MC/MCAsmBackend.h26
-rw-r--r--include/llvm/MC/MCAsmInfo.h140
-rw-r--r--include/llvm/MC/MCAsmInfoCOFF.h42
-rw-r--r--include/llvm/MC/MCAsmInfoDarwin.h16
-rw-r--r--include/llvm/MC/MCAsmInfoELF.h10
-rw-r--r--include/llvm/MC/MCAsmInfoWasm.h24
-rw-r--r--include/llvm/MC/MCAssembler.h59
-rw-r--r--include/llvm/MC/MCCodeEmitter.h15
-rw-r--r--include/llvm/MC/MCContext.h186
-rw-r--r--include/llvm/MC/MCDisassembler/MCDisassembler.h17
-rw-r--r--include/llvm/MC/MCDisassembler/MCRelocationInfo.h18
-rw-r--r--include/llvm/MC/MCDisassembler/MCSymbolizer.h16
-rw-r--r--include/llvm/MC/MCDwarf.h48
-rw-r--r--include/llvm/MC/MCELFObjectWriter.h25
-rw-r--r--include/llvm/MC/MCELFStreamer.h26
-rw-r--r--include/llvm/MC/MCExpr.h85
-rw-r--r--include/llvm/MC/MCFragment.h32
-rw-r--r--include/llvm/MC/MCInst.h30
-rw-r--r--include/llvm/MC/MCInstPrinter.h16
-rw-r--r--include/llvm/MC/MCInstrAnalysis.h11
-rw-r--r--include/llvm/MC/MCInstrItineraries.h28
-rw-r--r--include/llvm/MC/MCLabel.h12
-rw-r--r--include/llvm/MC/MCLinkerOptimizationHint.h11
-rw-r--r--include/llvm/MC/MCMachObjectWriter.h15
-rw-r--r--include/llvm/MC/MCObjectFileInfo.h5
-rw-r--r--include/llvm/MC/MCObjectStreamer.h7
-rw-r--r--include/llvm/MC/MCObjectWriter.h24
-rw-r--r--include/llvm/MC/MCParser/AsmCond.h10
-rw-r--r--include/llvm/MC/MCParser/AsmLexer.h19
-rw-r--r--include/llvm/MC/MCParser/MCAsmLexer.h30
-rw-r--r--include/llvm/MC/MCParser/MCAsmParser.h41
-rw-r--r--include/llvm/MC/MCParser/MCAsmParserExtension.h26
-rw-r--r--include/llvm/MC/MCParser/MCAsmParserUtils.h5
-rw-r--r--include/llvm/MC/MCParser/MCParsedAsmOperand.h14
-rw-r--r--include/llvm/MC/MCParser/MCTargetAsmParser.h34
-rw-r--r--include/llvm/MC/MCRegisterInfo.h58
-rw-r--r--include/llvm/MC/MCSection.h33
-rw-r--r--include/llvm/MC/MCSectionCOFF.h8
-rw-r--r--include/llvm/MC/MCSectionELF.h23
-rw-r--r--include/llvm/MC/MCSectionMachO.h3
-rw-r--r--include/llvm/MC/MCSectionWasm.h86
-rw-r--r--include/llvm/MC/MCStreamer.h41
-rw-r--r--include/llvm/MC/MCSubtargetInfo.h34
-rw-r--r--include/llvm/MC/MCSymbol.h29
-rw-r--r--include/llvm/MC/MCSymbolCOFF.h13
-rw-r--r--include/llvm/MC/MCSymbolWasm.h57
-rw-r--r--include/llvm/MC/MCTargetOptions.h40
-rw-r--r--include/llvm/MC/MCWasmObjectWriter.h85
-rw-r--r--include/llvm/MC/MCWasmStreamer.h83
-rw-r--r--include/llvm/MC/MCWinCOFFObjectWriter.h11
-rw-r--r--include/llvm/MC/MCWinCOFFStreamer.h11
-rw-r--r--include/llvm/MC/MachineLocation.h30
-rw-r--r--include/llvm/MC/StringTableBuilder.h11
-rw-r--r--include/llvm/MC/SubtargetFeature.h96
55 files changed, 1208 insertions, 677 deletions
diff --git a/include/llvm/MC/ConstantPools.h b/include/llvm/MC/ConstantPools.h
index f0c445dbe59f..643902377dd3 100644
--- a/include/llvm/MC/ConstantPools.h
+++ b/include/llvm/MC/ConstantPools.h
@@ -11,15 +11,17 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef LLVM_MC_CONSTANTPOOLS_H
#define LLVM_MC_CONSTANTPOOLS_H
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/SMLoc.h"
+#include <cstdint>
namespace llvm {
+
class MCContext;
class MCExpr;
class MCSection;
@@ -30,6 +32,7 @@ class MCSymbolRefExpr;
struct ConstantPoolEntry {
ConstantPoolEntry(MCSymbol *L, const MCExpr *Val, unsigned Sz, SMLoc Loc_)
: Label(L), Value(Val), Size(Sz), Loc(Loc_) {}
+
MCSymbol *Label;
const MCExpr *Value;
unsigned Size;
@@ -45,7 +48,7 @@ class ConstantPool {
public:
// Initialize a new empty constant pool
- ConstantPool() {}
+ ConstantPool() = default;
// Add a new entry to the constant pool in the next slot.
// \param Value is the new entry to put in the constant pool.
@@ -90,6 +93,7 @@ private:
ConstantPool *getConstantPool(MCSection *Section);
ConstantPool &getOrCreateConstantPool(MCSection *Section);
};
+
} // end namespace llvm
-#endif
+#endif // LLVM_MC_CONSTANTPOOLS_H
diff --git a/include/llvm/MC/MCAsmBackend.h b/include/llvm/MC/MCAsmBackend.h
index d4bdbcd2baa3..fb21e195b1df 100644
--- a/include/llvm/MC/MCAsmBackend.h
+++ b/include/llvm/MC/MCAsmBackend.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCAsmBackend.h - MC Asm Backend -----------------*- C++ -*-===//
+//===- llvm/MC/MCAsmBackend.h - MC Asm Backend ------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,35 +12,33 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/ErrorHandling.h"
+#include <cstdint>
namespace llvm {
+
class MCAsmLayout;
class MCAssembler;
class MCCFIInstruction;
-class MCELFObjectTargetWriter;
struct MCFixupKindInfo;
class MCFragment;
class MCInst;
-class MCRelaxableFragment;
class MCObjectWriter;
-class MCSection;
+class MCRelaxableFragment;
class MCSubtargetInfo;
class MCValue;
class raw_pwrite_stream;
/// Generic interface to target specific assembler backends.
class MCAsmBackend {
- MCAsmBackend(const MCAsmBackend &) = delete;
- void operator=(const MCAsmBackend &) = delete;
-
protected: // Can only create subclasses.
MCAsmBackend();
public:
+ MCAsmBackend(const MCAsmBackend &) = delete;
+ MCAsmBackend &operator=(const MCAsmBackend &) = delete;
virtual ~MCAsmBackend();
/// lifetime management
@@ -73,9 +71,11 @@ public:
/// Apply the \p Value for given \p Fixup into the provided data fragment, at
/// the offset specified by the fixup and following the fixup kind as
- /// appropriate.
+ /// appropriate. Errors (such as an out of range fixup value) should be
+ /// reported via \p Ctx.
virtual void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
- uint64_t Value, bool IsPCRel) const = 0;
+ uint64_t Value, bool IsPCRel,
+ MCContext &Ctx) const = 0;
/// @}
@@ -136,6 +136,6 @@ public:
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCASMBACKEND_H
diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h
index f898bf5288d6..bd2717de9960 100644
--- a/include/llvm/MC/MCAsmInfo.h
+++ b/include/llvm/MC/MCAsmInfo.h
@@ -16,20 +16,22 @@
#ifndef LLVM_MC_MCASMINFO_H
#define LLVM_MC_MCASMINFO_H
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCTargetOptions.h"
-#include <cassert>
#include <vector>
namespace llvm {
+
+class MCContext;
class MCExpr;
class MCSection;
class MCStreamer;
class MCSymbol;
-class MCContext;
namespace WinEH {
+
enum class EncodingType {
Invalid, /// Invalid
Alpha, /// Windows Alpha
@@ -40,11 +42,14 @@ enum class EncodingType {
X86, /// Windows x86, uses no CFI, just EH tables
MIPS = Alpha,
};
-}
+
+} // end namespace WinEH
namespace LCOMM {
+
enum LCOMMType { NoAlignment, ByteAlignment, Log2Alignment };
-}
+
+} // end namespace LCOMM
enum class DebugCompressionType {
DCT_None, // no compression
@@ -61,41 +66,41 @@ protected:
//
/// Pointer size in bytes. Default is 4.
- unsigned PointerSize;
+ unsigned PointerSize = 4;
/// Size of the stack slot reserved for callee-saved registers, in bytes.
/// Default is same as pointer size.
- unsigned CalleeSaveStackSlotSize;
+ unsigned CalleeSaveStackSlotSize = 4;
/// True if target is little endian. Default is true.
- bool IsLittleEndian;
+ bool IsLittleEndian = true;
/// True if target stack grow up. Default is false.
- bool StackGrowsUp;
+ bool StackGrowsUp = false;
/// True if this target has the MachO .subsections_via_symbols directive.
/// Default is false.
- bool HasSubsectionsViaSymbols;
+ bool HasSubsectionsViaSymbols = false;
/// True if this is a MachO target that supports the macho-specific .zerofill
/// directive for emitting BSS Symbols. Default is false.
- bool HasMachoZeroFillDirective;
+ bool HasMachoZeroFillDirective = false;
/// True if this is a MachO target that supports the macho-specific .tbss
/// directive for emitting thread local BSS Symbols. Default is false.
- bool HasMachoTBSSDirective;
+ bool HasMachoTBSSDirective = false;
/// This is the maximum possible length of an instruction, which is needed to
/// compute the size of an inline asm. Defaults to 4.
- unsigned MaxInstLength;
+ unsigned MaxInstLength = 4;
/// Every possible instruction length is a multiple of this value. Factored
/// out in .debug_frame and .debug_line. Defaults to 1.
- unsigned MinInstAlignment;
+ unsigned MinInstAlignment = 1;
/// The '$' token, when not referencing an identifier or constant, refers to
/// the current PC. Defaults to false.
- bool DollarIsPC;
+ bool DollarIsPC = false;
/// This string, if specified, is used to separate instructions from each
/// other when on the same line. Defaults to ';'
@@ -109,10 +114,10 @@ protected:
const char *LabelSuffix;
// Print the EH begin symbol with an assignment. Defaults to false.
- bool UseAssignmentForEHBegin;
+ bool UseAssignmentForEHBegin = false;
// Do we need to create a local symbol for .size?
- bool NeedsLocalForSize;
+ bool NeedsLocalForSize = false;
/// This prefix is used for globals like constant pool entries that are
/// completely private to the .s file and should not have names in the .o
@@ -142,20 +147,20 @@ protected:
const char *Code64Directive;
/// Which dialect of an assembler variant to use. Defaults to 0
- unsigned AssemblerDialect;
+ unsigned AssemblerDialect = 0;
/// This is true if the assembler allows @ characters in symbol names.
/// Defaults to false.
- bool AllowAtInName;
+ bool AllowAtInName = false;
/// If this is true, symbol names with invalid characters will be printed in
/// quotes.
- bool SupportsQuotedNames;
+ bool SupportsQuotedNames = true;
/// This is true if data region markers should be printed as
/// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
/// instead.
- bool UseDataRegionDirectives;
+ bool UseDataRegionDirectives = false;
//===--- Data Emission Directives -------------------------------------===//
@@ -185,13 +190,13 @@ protected:
/// If non-null, a directive that is used to emit a word which should be
/// relocated as a 64-bit GP-relative offset, e.g. .gpdword on Mips. Defaults
- /// to NULL.
- const char *GPRel64Directive;
+ /// to nullptr.
+ const char *GPRel64Directive = nullptr;
/// If non-null, a directive that is used to emit a word which should be
/// relocated as a 32-bit GP-relative offset, e.g. .gpword on Mips or .gprel32
- /// on Alpha. Defaults to NULL.
- const char *GPRel32Directive;
+ /// on Alpha. Defaults to nullptr.
+ const char *GPRel32Directive = nullptr;
/// If non-null, directives that are used to emit a word/dword which should
/// be relocated as a 32/64-bit DTP/TP-relative offset, e.g. .dtprelword/
@@ -204,14 +209,14 @@ protected:
/// This is true if this target uses "Sun Style" syntax for section switching
/// ("#alloc,#write" etc) instead of the normal ELF syntax (,"a,w") in
/// .section directives. Defaults to false.
- bool SunStyleELFSectionSwitchSyntax;
+ bool SunStyleELFSectionSwitchSyntax = false;
/// This is true if this target uses ELF '.section' directive before the
/// '.bss' one. It's used for PPC/Linux which doesn't support the '.bss'
/// directive only. Defaults to false.
- bool UsesELFSectionDirectiveForBSS;
+ bool UsesELFSectionDirectiveForBSS = false;
- bool NeedsDwarfSectionOffsetDirective;
+ bool NeedsDwarfSectionOffsetDirective = false;
//===--- Alignment Information ----------------------------------------===//
@@ -219,11 +224,11 @@ protected:
/// directives, where N is the number of bytes to align to. Otherwise, it
/// emits ".align log2(N)", e.g. 3 to align to an 8 byte boundary. Defaults
/// to true.
- bool AlignmentIsInBytes;
+ bool AlignmentIsInBytes = true;
/// If non-zero, this is used to fill the executable space created as the
/// result of a alignment directive. Defaults to 0
- unsigned TextAlignFillValue;
+ unsigned TextAlignFillValue = 0;
//===--- Global Variable Emission Directives --------------------------===//
@@ -236,7 +241,7 @@ protected:
/// uses a relocation but it can be suppressed by writing
/// a = f - g
/// .long a
- bool SetDirectiveSuppressesReloc;
+ bool SetDirectiveSuppressesReloc = false;
/// False if the assembler requires that we use
/// \code
@@ -251,98 +256,98 @@ protected:
/// \endcode
///
/// Defaults to true.
- bool HasAggressiveSymbolFolding;
+ bool HasAggressiveSymbolFolding = true;
/// True is .comm's and .lcomms optional alignment is to be specified in bytes
/// instead of log2(n). Defaults to true.
- bool COMMDirectiveAlignmentIsInBytes;
+ bool COMMDirectiveAlignmentIsInBytes = true;
/// Describes if the .lcomm directive for the target supports an alignment
/// argument and how it is interpreted. Defaults to NoAlignment.
- LCOMM::LCOMMType LCOMMDirectiveAlignmentType;
+ LCOMM::LCOMMType LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
// True if the target allows .align directives on functions. This is true for
// most targets, so defaults to true.
- bool HasFunctionAlignment;
+ bool HasFunctionAlignment = true;
/// True if the target has .type and .size directives, this is true for most
/// ELF targets. Defaults to true.
- bool HasDotTypeDotSizeDirective;
+ bool HasDotTypeDotSizeDirective = true;
/// True if the target has a single parameter .file directive, this is true
/// for ELF targets. Defaults to true.
- bool HasSingleParameterDotFile;
+ bool HasSingleParameterDotFile = true;
/// True if the target has a .ident directive, this is true for ELF targets.
/// Defaults to false.
- bool HasIdentDirective;
+ bool HasIdentDirective = false;
/// True if this target supports the MachO .no_dead_strip directive. Defaults
/// to false.
- bool HasNoDeadStrip;
+ bool HasNoDeadStrip = false;
/// True if this target supports the MachO .alt_entry directive. Defaults to
/// false.
- bool HasAltEntry;
+ bool HasAltEntry = false;
/// Used to declare a global as being a weak symbol. Defaults to ".weak".
const char *WeakDirective;
/// This directive, if non-null, is used to declare a global as being a weak
- /// undefined symbol. Defaults to NULL.
- const char *WeakRefDirective;
+ /// undefined symbol. Defaults to nullptr.
+ const char *WeakRefDirective = nullptr;
/// True if we have a directive to declare a global as being a weak defined
/// symbol. Defaults to false.
- bool HasWeakDefDirective;
+ bool HasWeakDefDirective = false;
/// True if we have a directive to declare a global as being a weak defined
/// symbol that can be hidden (unexported). Defaults to false.
- bool HasWeakDefCanBeHiddenDirective;
+ bool HasWeakDefCanBeHiddenDirective = false;
/// True if we have a .linkonce directive. This is used on cygwin/mingw.
/// Defaults to false.
- bool HasLinkOnceDirective;
+ bool HasLinkOnceDirective = false;
/// This attribute, if not MCSA_Invalid, is used to declare a symbol as having
/// hidden visibility. Defaults to MCSA_Hidden.
- MCSymbolAttr HiddenVisibilityAttr;
+ MCSymbolAttr HiddenVisibilityAttr = MCSA_Hidden;
/// This attribute, if not MCSA_Invalid, is used to declare an undefined
/// symbol as having hidden visibility. Defaults to MCSA_Hidden.
- MCSymbolAttr HiddenDeclarationVisibilityAttr;
+ MCSymbolAttr HiddenDeclarationVisibilityAttr = MCSA_Hidden;
/// This attribute, if not MCSA_Invalid, is used to declare a symbol as having
/// protected visibility. Defaults to MCSA_Protected
- MCSymbolAttr ProtectedVisibilityAttr;
+ MCSymbolAttr ProtectedVisibilityAttr = MCSA_Protected;
//===--- Dwarf Emission Directives -----------------------------------===//
/// True if target supports emission of debugging information. Defaults to
/// false.
- bool SupportsDebugInformation;
+ bool SupportsDebugInformation = false;
/// Exception handling format for the target. Defaults to None.
- ExceptionHandling ExceptionsType;
+ ExceptionHandling ExceptionsType = ExceptionHandling::None;
/// Windows exception handling data (.pdata) encoding. Defaults to Invalid.
- WinEH::EncodingType WinEHEncodingType;
+ WinEH::EncodingType WinEHEncodingType = WinEH::EncodingType::Invalid;
/// True if Dwarf2 output generally uses relocations for references to other
/// .debug_* sections.
- bool DwarfUsesRelocationsAcrossSections;
+ bool DwarfUsesRelocationsAcrossSections = true;
/// True if DWARF FDE symbol reference relocations should be replaced by an
/// absolute difference.
- bool DwarfFDESymbolsUseAbsDiff;
+ bool DwarfFDESymbolsUseAbsDiff = false;
/// True if dwarf register numbers are printed instead of symbolic register
/// names in .cfi_* directives. Defaults to false.
- bool DwarfRegNumForCFI;
+ bool DwarfRegNumForCFI = false;
/// True if target uses parens to indicate the symbol variant instead of @.
/// For example, foo(plt) instead of foo@plt. Defaults to false.
- bool UseParensForSymbolVariant;
+ bool UseParensForSymbolVariant = false;
//===--- Prologue State ----------------------------------------------===//
@@ -361,11 +366,11 @@ protected:
bool PreserveAsmComments;
/// Compress DWARF debug sections. Defaults to no compression.
- DebugCompressionType CompressDebugSections;
+ DebugCompressionType CompressDebugSections = DebugCompressionType::DCT_None;
/// True if the integrated assembler should interpret 'a >> b' constant
/// expressions as logical rather than arithmetic.
- bool UseLogicalShr;
+ bool UseLogicalShr = true;
// If true, emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL, on
// X86_64 ELF.
@@ -475,14 +480,17 @@ public:
bool needsLocalForSize() const { return NeedsLocalForSize; }
StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }
StringRef getPrivateLabelPrefix() const { return PrivateLabelPrefix; }
+
bool hasLinkerPrivateGlobalPrefix() const {
return LinkerPrivateGlobalPrefix[0] != '\0';
}
+
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; }
@@ -491,25 +499,32 @@ public:
unsigned getAssemblerDialect() const { return AssemblerDialect; }
bool doesAllowAtInName() const { return AllowAtInName; }
bool supportsNameQuoting() const { return SupportsQuotedNames; }
+
bool doesSupportDataRegionDirectives() const {
return UseDataRegionDirectives;
}
+
const char *getZeroDirective() const { return ZeroDirective; }
const char *getAsciiDirective() const { return AsciiDirective; }
const char *getAscizDirective() const { return AscizDirective; }
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 hasFunctionAlignment() const { return HasFunctionAlignment; }
bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; }
bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; }
@@ -519,22 +534,29 @@ public:
const char *getWeakDirective() const { return WeakDirective; }
const char *getWeakRefDirective() const { return WeakRefDirective; }
bool hasWeakDefDirective() const { return HasWeakDefDirective; }
+
bool hasWeakDefCanBeHiddenDirective() const {
return HasWeakDefCanBeHiddenDirective;
}
+
bool hasLinkOnceDirective() const { return HasLinkOnceDirective; }
MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr; }
+
MCSymbolAttr getHiddenDeclarationVisibilityAttr() const {
return HiddenDeclarationVisibilityAttr;
}
+
MCSymbolAttr getProtectedVisibilityAttr() const {
return ProtectedVisibilityAttr;
}
+
bool doesSupportDebugInformation() const { return SupportsDebugInformation; }
+
bool doesSupportExceptionHandling() const {
return ExceptionsType != ExceptionHandling::None;
}
+
ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; }
WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; }
@@ -558,6 +580,7 @@ public:
bool doesDwarfUseRelocationsAcrossSections() const {
return DwarfUsesRelocationsAcrossSections;
}
+
bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; }
bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; }
bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; }
@@ -600,6 +623,7 @@ public:
void setRelaxELFRelocations(bool V) { RelaxELFRelocations = V; }
bool hasMipsExpressions() const { return HasMipsExpressions; }
};
-}
-#endif
+} // end namespace llvm
+
+#endif // LLVM_MC_MCASMINFO_H
diff --git a/include/llvm/MC/MCAsmInfoCOFF.h b/include/llvm/MC/MCAsmInfoCOFF.h
index 56444f3c7cf5..01c8ae49a6fc 100644
--- a/include/llvm/MC/MCAsmInfoCOFF.h
+++ b/include/llvm/MC/MCAsmInfoCOFF.h
@@ -1,4 +1,4 @@
-//===-- MCAsmInfoCOFF.h - COFF asm properties -------------------*- C++ -*-===//
+//===- MCAsmInfoCOFF.h - COFF asm properties --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,24 +13,28 @@
#include "llvm/MC/MCAsmInfo.h"
namespace llvm {
- class MCAsmInfoCOFF : public MCAsmInfo {
- virtual void anchor();
- protected:
- explicit MCAsmInfoCOFF();
- };
-
- class MCAsmInfoMicrosoft : public MCAsmInfoCOFF {
- void anchor() override;
- protected:
- explicit MCAsmInfoMicrosoft();
- };
-
- class MCAsmInfoGNUCOFF : public MCAsmInfoCOFF {
- void anchor() override;
- protected:
- explicit MCAsmInfoGNUCOFF();
- };
-}
+class MCAsmInfoCOFF : public MCAsmInfo {
+ virtual void anchor();
+
+protected:
+ explicit MCAsmInfoCOFF();
+};
+
+class MCAsmInfoMicrosoft : public MCAsmInfoCOFF {
+ void anchor() override;
+
+protected:
+ explicit MCAsmInfoMicrosoft();
+};
+
+class MCAsmInfoGNUCOFF : public MCAsmInfoCOFF {
+ void anchor() override;
+
+protected:
+ explicit MCAsmInfoGNUCOFF();
+};
+
+} // end namespace llvm
#endif // LLVM_MC_MCASMINFOCOFF_H
diff --git a/include/llvm/MC/MCAsmInfoDarwin.h b/include/llvm/MC/MCAsmInfoDarwin.h
index d587c3ce9d54..a533d604a89e 100644
--- a/include/llvm/MC/MCAsmInfoDarwin.h
+++ b/include/llvm/MC/MCAsmInfoDarwin.h
@@ -1,4 +1,4 @@
-//===---- MCAsmInfoDarwin.h - Darwin asm properties -------------*- C++ -*-===//
+//===- MCAsmInfoDarwin.h - Darwin asm properties ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,12 +18,14 @@
#include "llvm/MC/MCAsmInfo.h"
namespace llvm {
- class MCAsmInfoDarwin : public MCAsmInfo {
- public:
- explicit MCAsmInfoDarwin();
- bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
- };
-}
+class MCAsmInfoDarwin : public MCAsmInfo {
+public:
+ explicit MCAsmInfoDarwin();
+
+ bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
+};
+
+} // end namespace llvm
#endif // LLVM_MC_MCASMINFODARWIN_H
diff --git a/include/llvm/MC/MCAsmInfoELF.h b/include/llvm/MC/MCAsmInfoELF.h
index f8bb943aac4e..f113afc9885e 100644
--- a/include/llvm/MC/MCAsmInfoELF.h
+++ b/include/llvm/MC/MCAsmInfoELF.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCAsmInfoELF.h - ELF Asm info -------------------*- C++ -*-===//
+//===- llvm/MC/MCAsmInfoELF.h - ELF Asm info --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,6 +13,7 @@
#include "llvm/MC/MCAsmInfo.h"
namespace llvm {
+
class MCAsmInfoELF : public MCAsmInfo {
virtual void anchor();
MCSection *getNonexecutableStackSection(MCContext &Ctx) const final;
@@ -20,10 +21,11 @@ class MCAsmInfoELF : public MCAsmInfo {
protected:
/// Targets which have non-executable stacks by default can set this to false
/// to disable the special section which requests a non-executable stack.
- bool UsesNonexecutableStackSection;
+ bool UsesNonexecutableStackSection = true;
MCAsmInfoELF();
};
-}
-#endif
+} // end namespace llvm
+
+#endif // LLVM_MC_MCASMINFOELF_H
diff --git a/include/llvm/MC/MCAsmInfoWasm.h b/include/llvm/MC/MCAsmInfoWasm.h
new file mode 100644
index 000000000000..bc46cfdf4c4c
--- /dev/null
+++ b/include/llvm/MC/MCAsmInfoWasm.h
@@ -0,0 +1,24 @@
+//===-- llvm/MC/MCAsmInfoWasm.h - Wasm Asm info -----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCASMINFOWASM_H
+#define LLVM_MC_MCASMINFOWASM_H
+
+#include "llvm/MC/MCAsmInfo.h"
+
+namespace llvm {
+class MCAsmInfoWasm : public MCAsmInfo {
+ virtual void anchor();
+
+protected:
+ MCAsmInfoWasm();
+};
+}
+
+#endif
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h
index 641e78994768..c29abaa03a6d 100644
--- a/include/llvm/MC/MCAssembler.h
+++ b/include/llvm/MC/MCAssembler.h
@@ -10,33 +10,35 @@
#ifndef LLVM_MC_MCASSEMBLER_H
#define LLVM_MC_MCASSEMBLER_H
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/ilist.h"
-#include "llvm/ADT/ilist_node.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCFragment.h"
-#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCLinkerOptimizationHint.h"
-#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <string>
+#include <utility>
+#include <vector>
namespace llvm {
-class raw_ostream;
+
+class MCAsmBackend;
class MCAsmLayout;
-class MCAssembler;
class MCContext;
class MCCodeEmitter;
-class MCExpr;
class MCFragment;
class MCObjectWriter;
class MCSection;
-class MCSubtargetInfo;
class MCValue;
-class MCAsmBackend;
// FIXME: This really doesn't belong here. See comments below.
struct IndirectSymbolData {
@@ -90,9 +92,6 @@ public:
} VersionMinInfoType;
private:
- MCAssembler(const MCAssembler &) = delete;
- void operator=(const MCAssembler &) = delete;
-
MCContext &Context;
MCAsmBackend &Backend;
@@ -131,9 +130,9 @@ private:
/// By default it's 0, which means bundling is disabled.
unsigned BundleAlignSize;
- unsigned RelaxAll : 1;
- unsigned SubsectionsViaSymbols : 1;
- unsigned IncrementalLinkerCompatible : 1;
+ bool RelaxAll : 1;
+ bool SubsectionsViaSymbols : 1;
+ bool IncrementalLinkerCompatible : 1;
/// ELF specific e_header flags
// It would be good if there were an MCELFAssembler class to hold this.
@@ -148,7 +147,6 @@ private:
VersionMinInfoType VersionMinInfo;
-private:
/// Evaluate a fixup to a relocatable expression and the value which should be
/// placed into the fixup.
///
@@ -201,6 +199,18 @@ private:
MCFragment &F, const MCFixup &Fixup);
public:
+ /// Construct a new assembler instance.
+ //
+ // FIXME: How are we going to parameterize this? Two obvious options are stay
+ // concrete and require clients to pass in a target like object. The other
+ // option is to make this abstract, and have targets provide concrete
+ // implementations as we do with AsmParser.
+ MCAssembler(MCContext &Context, MCAsmBackend &Backend,
+ MCCodeEmitter &Emitter, MCObjectWriter &Writer);
+ MCAssembler(const MCAssembler &) = delete;
+ MCAssembler &operator=(const MCAssembler &) = delete;
+ ~MCAssembler();
+
/// Compute the effective fragment size assuming it is laid out at the given
/// \p SectionAddress and \p FragmentOffset.
uint64_t computeFragmentSize(const MCAsmLayout &Layout,
@@ -240,17 +250,6 @@ public:
VersionMinInfo.Update = Update;
}
-public:
- /// Construct a new assembler instance.
- //
- // FIXME: How are we going to parameterize this? Two obvious options are stay
- // concrete and require clients to pass in a target like object. The other
- // option is to make this abstract, and have targets provide concrete
- // implementations as we do with AsmParser.
- MCAssembler(MCContext &Context, MCAsmBackend &Backend,
- MCCodeEmitter &Emitter, MCObjectWriter &Writer);
- ~MCAssembler();
-
/// Reuse an assembler instance
///
void reset();
@@ -425,4 +424,4 @@ uint64_t computeBundlePadding(const MCAssembler &Assembler, const MCFragment *F,
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCASSEMBLER_H
diff --git a/include/llvm/MC/MCCodeEmitter.h b/include/llvm/MC/MCCodeEmitter.h
index b6c19150c12a..f1b0b784a2df 100644
--- a/include/llvm/MC/MCCodeEmitter.h
+++ b/include/llvm/MC/MCCodeEmitter.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCCodeEmitter.h - Instruction Encoding ----------*- C++ -*-===//
+//===- llvm/MC/MCCodeEmitter.h - Instruction Encoding -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,9 +10,8 @@
#ifndef LLVM_MC_MCCODEEMITTER_H
#define LLVM_MC_MCCODEEMITTER_H
-#include "llvm/Support/Compiler.h"
-
namespace llvm {
+
class MCFixup;
class MCInst;
class MCSubtargetInfo;
@@ -21,14 +20,12 @@ template<typename T> class SmallVectorImpl;
/// MCCodeEmitter - Generic instruction encoding interface.
class MCCodeEmitter {
-private:
- MCCodeEmitter(const MCCodeEmitter &) = delete;
- void operator=(const MCCodeEmitter &) = delete;
-
protected: // Can only create subclasses.
MCCodeEmitter();
public:
+ MCCodeEmitter(const MCCodeEmitter &) = delete;
+ MCCodeEmitter &operator=(const MCCodeEmitter &) = delete;
virtual ~MCCodeEmitter();
/// Lifetime management
@@ -41,6 +38,6 @@ public:
const MCSubtargetInfo &STI) const = 0;
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCCODEEMITTER_H
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h
index f846b632f112..b3106936e27f 100644
--- a/include/llvm/MC/MCContext.h
+++ b/include/llvm/MC/MCContext.h
@@ -15,6 +15,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCSubtargetInfo.h"
@@ -23,35 +24,37 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
#include <map>
-#include <tuple>
-#include <vector> // FIXME: Shouldn't be needed.
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
namespace llvm {
+
+ class CodeViewContext;
class MCAsmInfo;
- class MCExpr;
- class MCSection;
- class MCSymbol;
- class MCSymbolELF;
class MCLabel;
- struct MCDwarfFile;
- class MCDwarfLoc;
class MCObjectFileInfo;
class MCRegisterInfo;
- class MCLineSection;
- class SMLoc;
- class MCSectionMachO;
- class MCSectionELF;
+ class MCSection;
class MCSectionCOFF;
- class CodeViewContext;
+ class MCSectionELF;
+ class MCSectionMachO;
+ class MCSectionWasm;
+ class MCSymbol;
+ class MCSymbolELF;
+ class MCSymbolWasm;
+ class SMLoc;
/// Context object for machine code objects. This class owns all of the
/// sections that it creates.
///
class MCContext {
- MCContext(const MCContext &) = delete;
- MCContext &operator=(const MCContext &) = delete;
-
public:
typedef StringMap<MCSymbol *, BumpPtrAllocator &> SymbolTable;
@@ -59,6 +62,9 @@ namespace llvm {
/// The SourceMgr for this object, if any.
const SourceMgr *SrcMgr;
+ /// The SourceMgr for inline assembly, if any.
+ SourceMgr *InlineSrcMgr;
+
/// The MCAsmInfo for this target.
const MCAsmInfo *MAI;
@@ -79,14 +85,11 @@ namespace llvm {
SpecificBumpPtrAllocator<MCSectionCOFF> COFFAllocator;
SpecificBumpPtrAllocator<MCSectionELF> ELFAllocator;
SpecificBumpPtrAllocator<MCSectionMachO> MachOAllocator;
+ SpecificBumpPtrAllocator<MCSectionWasm> WasmAllocator;
/// Bindings of names to symbols.
SymbolTable Symbols;
- /// Sections can have a corresponding symbol. This maps one to the
- /// other.
- DenseMap<const MCSection *, MCSymbol *> SectionSymbols;
-
/// A mapping from a local label number and an instance count to a symbol.
/// For example, in the assembly
/// 1:
@@ -123,7 +126,7 @@ namespace llvm {
/// Boolean toggled when .secure_log_unique / .secure_log_reset is seen to
/// catch errors if .secure_log_unique appears twice without
/// .secure_log_reset appearing between them.
- bool SecureLogUsed;
+ bool SecureLogUsed = false;
/// The compilation directory to use for DW_AT_comp_dir.
SmallString<128> CompilationDir;
@@ -139,14 +142,14 @@ namespace llvm {
/// The current dwarf line information from the last dwarf .loc directive.
MCDwarfLoc CurrentDwarfLoc;
- bool DwarfLocSeen;
+ bool DwarfLocSeen = false;
/// Generate dwarf debugging info for assembly source files.
- bool GenDwarfForAssembly;
+ bool GenDwarfForAssembly = false;
/// The current dwarf file number when generate dwarf debugging info for
/// assembly source files.
- unsigned GenDwarfFileNumber;
+ unsigned GenDwarfFileNumber = 0;
/// Sections for generating the .debug_ranges and .debug_aranges sections.
SetVector<MCSection *> SectionsForRanges;
@@ -164,25 +167,27 @@ namespace llvm {
StringRef DwarfDebugProducer;
/// The maximum version of dwarf that we should emit.
- uint16_t DwarfVersion;
+ uint16_t DwarfVersion = 4;
/// Honor temporary labels, this is useful for debugging semantic
/// differences between temporary and non-temporary labels (primarily on
/// Darwin).
- bool AllowTemporaryLabels;
+ bool AllowTemporaryLabels = true;
bool UseNamesOnTempLabels = true;
/// The Compile Unit ID that we are currently processing.
- unsigned DwarfCompileUnitID;
+ unsigned DwarfCompileUnitID = 0;
struct ELFSectionKey {
std::string SectionName;
StringRef GroupName;
unsigned UniqueID;
+
ELFSectionKey(StringRef SectionName, StringRef GroupName,
unsigned UniqueID)
: SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
}
+
bool operator<(const ELFSectionKey &Other) const {
if (SectionName != Other.SectionName)
return SectionName < Other.SectionName;
@@ -197,10 +202,12 @@ namespace llvm {
StringRef GroupName;
int SelectionKey;
unsigned UniqueID;
+
COFFSectionKey(StringRef SectionName, StringRef GroupName,
int SelectionKey, unsigned UniqueID)
: SectionName(SectionName), GroupName(GroupName),
SelectionKey(SelectionKey), UniqueID(UniqueID) {}
+
bool operator<(const COFFSectionKey &Other) const {
if (SectionName != Other.SectionName)
return SectionName < Other.SectionName;
@@ -212,17 +219,35 @@ namespace llvm {
}
};
+ struct WasmSectionKey {
+ std::string SectionName;
+ StringRef GroupName;
+ unsigned UniqueID;
+ WasmSectionKey(StringRef SectionName, StringRef GroupName,
+ unsigned UniqueID)
+ : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
+ }
+ bool operator<(const WasmSectionKey &Other) const {
+ if (SectionName != Other.SectionName)
+ return SectionName < Other.SectionName;
+ if (GroupName != Other.GroupName)
+ return GroupName < Other.GroupName;
+ return UniqueID < Other.UniqueID;
+ }
+ };
+
StringMap<MCSectionMachO *> MachOUniquingMap;
std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
- StringMap<bool> ELFRelSecNames;
+ std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
+ StringMap<bool> RelSecNames;
SpecificBumpPtrAllocator<MCSubtargetInfo> MCSubtargetAllocator;
/// Do automatic reset in destructor
bool AutoReset;
- bool HadError;
+ bool HadError = false;
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
bool CanBeUnnamed);
@@ -232,14 +257,25 @@ namespace llvm {
MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
unsigned Instance);
+ MCSectionELF *createELFSectionImpl(StringRef Section, unsigned Type,
+ unsigned Flags, SectionKind K,
+ unsigned EntrySize,
+ const MCSymbolELF *Group,
+ unsigned UniqueID,
+ const MCSymbolELF *Associated);
+
public:
explicit MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI,
const MCObjectFileInfo *MOFI,
const SourceMgr *Mgr = nullptr, bool DoAutoReset = true);
+ MCContext(const MCContext &) = delete;
+ MCContext &operator=(const MCContext &) = delete;
~MCContext();
const SourceMgr *getSourceManager() const { return SrcMgr; }
+ void setInlineSourceManager(SourceMgr *SM) { InlineSrcMgr = SM; }
+
const MCAsmInfo *getAsmInfo() const { return MAI; }
const MCRegisterInfo *getRegisterInfo() const { return MRI; }
@@ -288,8 +324,6 @@ namespace llvm {
/// \param Name - The symbol name, which must be unique across all symbols.
MCSymbol *getOrCreateSymbol(const Twine &Name);
- MCSymbolELF *getOrCreateSectionSymbol(const MCSectionELF &Section);
-
/// Gets a symbol that will be defined to the final stack offset of a local
/// variable after codegen.
///
@@ -340,25 +374,13 @@ namespace llvm {
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags) {
- return getELFSection(Section, Type, Flags, nullptr);
- }
-
- MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
- unsigned Flags, const char *BeginSymName) {
- return getELFSection(Section, Type, Flags, 0, "", BeginSymName);
+ return getELFSection(Section, Type, Flags, 0, "");
}
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const Twine &Group) {
- return getELFSection(Section, Type, Flags, EntrySize, Group, nullptr);
- }
-
- MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
- unsigned Flags, unsigned EntrySize,
- const Twine &Group, const char *BeginSymName) {
- return getELFSection(Section, Type, Flags, EntrySize, Group, ~0,
- BeginSymName);
+ return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
}
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
@@ -371,13 +393,12 @@ namespace llvm {
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const Twine &Group, unsigned UniqueID,
- const char *BeginSymName);
+ const MCSymbolELF *Associated);
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const MCSymbolELF *Group, unsigned UniqueID,
- const char *BeginSymName,
- const MCSectionELF *Associated);
+ const MCSymbolELF *Associated);
/// Get a section with the provided group identifier. This section is
/// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
@@ -390,7 +411,7 @@ namespace llvm {
MCSectionELF *createELFRelSection(const Twine &Name, unsigned Type,
unsigned Flags, unsigned EntrySize,
const MCSymbolELF *Group,
- const MCSectionELF *Associated);
+ const MCSectionELF *RelInfoSection);
void renameELFSection(MCSectionELF *Section, StringRef Name);
@@ -416,6 +437,54 @@ namespace llvm {
getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym,
unsigned UniqueID = GenericSectionID);
+ MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
+ unsigned Flags) {
+ return getWasmSection(Section, Type, Flags, nullptr);
+ }
+
+ MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
+ unsigned Flags, const char *BeginSymName) {
+ return getWasmSection(Section, Type, Flags, "", BeginSymName);
+ }
+
+ MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
+ unsigned Flags, const Twine &Group) {
+ return getWasmSection(Section, Type, Flags, Group, nullptr);
+ }
+
+ MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
+ unsigned Flags, const Twine &Group,
+ const char *BeginSymName) {
+ return getWasmSection(Section, Type, Flags, Group, ~0, BeginSymName);
+ }
+
+ MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
+ unsigned Flags, const Twine &Group,
+ unsigned UniqueID) {
+ return getWasmSection(Section, Type, Flags, Group, UniqueID, nullptr);
+ }
+
+ MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
+ unsigned Flags, const Twine &Group,
+ unsigned UniqueID, const char *BeginSymName);
+
+ MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
+ unsigned Flags, const MCSymbolWasm *Group,
+ unsigned UniqueID, const char *BeginSymName);
+
+ /// Get a section with the provided group identifier. This section is
+ /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
+ /// describes the type of the section and \p Flags are used to further
+ /// configure this named section.
+ MCSectionWasm *getWasmNamedSection(const Twine &Prefix, const Twine &Suffix,
+ unsigned Type, unsigned Flags);
+
+ MCSectionWasm *createWasmRelSection(const Twine &Name, unsigned Type,
+ unsigned Flags,
+ const MCSymbolWasm *Group);
+
+ void renameWasmSection(MCSectionWasm *Section, StringRef Name);
+
// Create and save a copy of STI and return a reference to the copy.
MCSubtargetInfo &getSubtargetCopy(const MCSubtargetInfo &STI);
@@ -463,6 +532,7 @@ namespace llvm {
const SmallVectorImpl<MCDwarfFile> &getMCDwarfFiles(unsigned CUID = 0) {
return getMCDwarfLineTable(CUID).getMCDwarfFiles();
}
+
const SmallVectorImpl<std::string> &getMCDwarfDirs(unsigned CUID = 0) {
return getMCDwarfLineTable(CUID).getMCDwarfDirs();
}
@@ -473,10 +543,13 @@ namespace llvm {
return true;
return false;
}
+
unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
+
void setDwarfCompileUnitID(unsigned CUIndex) {
DwarfCompileUnitID = CUIndex;
}
+
void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir) {
getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
}
@@ -496,6 +569,7 @@ namespace llvm {
CurrentDwarfLoc.setDiscriminator(Discriminator);
DwarfLocSeen = true;
}
+
void clearDwarfLocSeen() { DwarfLocSeen = false; }
bool getDwarfLocSeen() { return DwarfLocSeen; }
@@ -504,20 +578,25 @@ namespace llvm {
bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
+
void setGenDwarfFileNumber(unsigned FileNumber) {
GenDwarfFileNumber = FileNumber;
}
+
const SetVector<MCSection *> &getGenDwarfSectionSyms() {
return SectionsForRanges;
}
+
bool addGenDwarfSection(MCSection *Sec) {
return SectionsForRanges.insert(Sec);
}
void finalizeDwarfSections(MCStreamer &MCOS);
+
const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
return MCGenDwarfLabelEntries;
}
+
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E) {
MCGenDwarfLabelEntries.push_back(E);
}
@@ -527,10 +606,12 @@ namespace llvm {
void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
+
dwarf::DwarfFormat getDwarfFormat() const {
// TODO: Support DWARF64
return dwarf::DWARF32;
}
+
void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
uint16_t getDwarfVersion() const { return DwarfVersion; }
@@ -538,15 +619,18 @@ namespace llvm {
char *getSecureLogFile() { return SecureLogFile; }
raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
- bool getSecureLogUsed() { return SecureLogUsed; }
+
void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
SecureLog = std::move(Value);
}
+
+ bool getSecureLogUsed() { return SecureLogUsed; }
void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
void *allocate(unsigned Size, unsigned Align = 8) {
return Allocator.Allocate(Size, Align);
}
+
void deallocate(void *Ptr) {}
bool hadError() { return HadError; }
@@ -632,4 +716,4 @@ inline void operator delete[](void *Ptr, llvm::MCContext &C) noexcept {
C.deallocate(Ptr);
}
-#endif
+#endif // LLVM_MC_MCCONTEXT_H
diff --git a/include/llvm/MC/MCDisassembler/MCDisassembler.h b/include/llvm/MC/MCDisassembler/MCDisassembler.h
index 9006d87abb43..5e626f186986 100644
--- a/include/llvm/MC/MCDisassembler/MCDisassembler.h
+++ b/include/llvm/MC/MCDisassembler/MCDisassembler.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCDisassembler.h - Disassembler interface -------*- C++ -*-===//
+//===- llvm/MC/MCDisassembler.h - Disassembler interface --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,20 +6,21 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_MC_MCDISASSEMBLER_MCDISASSEMBLER_H
#define LLVM_MC_MCDISASSEMBLER_MCDISASSEMBLER_H
-#include "llvm-c/Disassembler.h"
#include "llvm/MC/MCDisassembler/MCSymbolizer.h"
-#include "llvm/Support/DataTypes.h"
+#include <cstdint>
+#include <memory>
namespace llvm {
template <typename T> class ArrayRef;
+class MCContext;
class MCInst;
class MCSubtargetInfo;
class raw_ostream;
-class MCContext;
/// Superclass for all disassemblers. Consumes a memory region and provides an
/// array of assembly instructions.
@@ -54,7 +55,7 @@ public:
};
MCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx)
- : Ctx(Ctx), STI(STI), Symbolizer(), CommentStream(nullptr) {}
+ : Ctx(Ctx), STI(STI) {}
virtual ~MCDisassembler();
@@ -105,9 +106,9 @@ public:
// Marked mutable because we cache it inside the disassembler, rather than
// having to pass it around as an argument through all the autogenerated code.
- mutable raw_ostream *CommentStream;
+ mutable raw_ostream *CommentStream = nullptr;
};
-} // namespace llvm
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCDISASSEMBLER_MCDISASSEMBLER_H
diff --git a/include/llvm/MC/MCDisassembler/MCRelocationInfo.h b/include/llvm/MC/MCDisassembler/MCRelocationInfo.h
index 25334f755ee6..7836e886c303 100644
--- a/include/llvm/MC/MCDisassembler/MCRelocationInfo.h
+++ b/include/llvm/MC/MCDisassembler/MCRelocationInfo.h
@@ -1,4 +1,4 @@
-//==-- llvm/MC/MCRelocationInfo.h --------------------------------*- C++ -*-==//
+//===- llvm/MC/MCRelocationInfo.h -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,26 +16,20 @@
#ifndef LLVM_MC_MCDISASSEMBLER_MCRELOCATIONINFO_H
#define LLVM_MC_MCDISASSEMBLER_MCRELOCATIONINFO_H
-#include "llvm/Support/Compiler.h"
-
namespace llvm {
-namespace object {
-class RelocationRef;
-}
-class MCExpr;
class MCContext;
+class MCExpr;
/// \brief Create MCExprs from relocations found in an object file.
class MCRelocationInfo {
- MCRelocationInfo(const MCRelocationInfo &) = delete;
- void operator=(const MCRelocationInfo &) = delete;
-
protected:
MCContext &Ctx;
public:
MCRelocationInfo(MCContext &Ctx);
+ MCRelocationInfo(const MCRelocationInfo &) = delete;
+ MCRelocationInfo &operator=(const MCRelocationInfo &) = delete;
virtual ~MCRelocationInfo();
/// \brief Create an MCExpr for the target-specific \p VariantKind.
@@ -46,6 +40,6 @@ public:
unsigned VariantKind);
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCDISASSEMBLER_MCRELOCATIONINFO_H
diff --git a/include/llvm/MC/MCDisassembler/MCSymbolizer.h b/include/llvm/MC/MCDisassembler/MCSymbolizer.h
index 713467c0a3e7..d85cf5e066f5 100644
--- a/include/llvm/MC/MCDisassembler/MCSymbolizer.h
+++ b/include/llvm/MC/MCDisassembler/MCSymbolizer.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCSymbolizer.h - MCSymbolizer class -------------*- C++ -*-===//
+//===- llvm/MC/MCSymbolizer.h - MCSymbolizer class --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,9 +17,8 @@
#define LLVM_MC_MCDISASSEMBLER_MCSYMBOLIZER_H
#include "llvm/MC/MCDisassembler/MCRelocationInfo.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
-#include <cassert>
+#include <algorithm>
+#include <cstdint>
#include <memory>
namespace llvm {
@@ -38,9 +37,6 @@ class raw_ostream;
/// operands are actually symbolizable, and in what way. I don't think this
/// information exists right now.
class MCSymbolizer {
- MCSymbolizer(const MCSymbolizer &) = delete;
- void operator=(const MCSymbolizer &) = delete;
-
protected:
MCContext &Ctx;
std::unique_ptr<MCRelocationInfo> RelInfo;
@@ -51,6 +47,8 @@ public:
: Ctx(Ctx), RelInfo(std::move(RelInfo)) {
}
+ MCSymbolizer(const MCSymbolizer &) = delete;
+ MCSymbolizer &operator=(const MCSymbolizer &) = delete;
virtual ~MCSymbolizer();
/// \brief Try to add a symbolic operand instead of \p Value to the MCInst.
@@ -80,6 +78,6 @@ public:
uint64_t Address) = 0;
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCDISASSEMBLER_MCSYMBOLIZER_H
diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h
index 0c555d377d8b..0d69c2005cb4 100644
--- a/include/llvm/MC/MCDwarf.h
+++ b/include/llvm/MC/MCDwarf.h
@@ -16,24 +16,27 @@
#define LLVM_MC_MCDWARF_H
#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCSection.h"
-#include "llvm/Support/Dwarf.h"
+#include <cassert>
+#include <cstdint>
#include <string>
#include <utility>
#include <vector>
namespace llvm {
+
template <typename T> class ArrayRef;
-class raw_ostream;
class MCAsmBackend;
class MCContext;
class MCObjectStreamer;
class MCStreamer;
class MCSymbol;
-class SourceMgr;
+class raw_ostream;
class SMLoc;
+class SourceMgr;
/// \brief Instances of this class represent the name of the dwarf
/// .file directive and its associated dwarf file number in the MC file,
@@ -71,6 +74,7 @@ class MCDwarfLoc {
private: // MCContext manages these
friend class MCContext;
friend class MCDwarfLineEntry;
+
MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags,
unsigned isa, unsigned discriminator)
: FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa),
@@ -194,13 +198,14 @@ struct MCDwarfLineTableParams {
};
struct MCDwarfLineTableHeader {
- MCSymbol *Label;
+ MCSymbol *Label = nullptr;
SmallVector<std::string, 3> MCDwarfDirs;
SmallVector<MCDwarfFile, 3> MCDwarfFiles;
StringMap<unsigned> SourceIdMap;
StringRef CompilationDir;
- MCDwarfLineTableHeader() : Label(nullptr) {}
+ MCDwarfLineTableHeader() = default;
+
unsigned getFile(StringRef &Directory, StringRef &FileName,
unsigned FileNumber = 0);
std::pair<MCSymbol *, MCSymbol *> Emit(MCStreamer *MCOS,
@@ -212,13 +217,16 @@ struct MCDwarfLineTableHeader {
class MCDwarfDwoLineTable {
MCDwarfLineTableHeader Header;
+
public:
void setCompilationDir(StringRef CompilationDir) {
Header.CompilationDir = CompilationDir;
}
+
unsigned getFile(StringRef Directory, StringRef FileName) {
return Header.getFile(Directory, FileName);
}
+
void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params) const;
};
@@ -488,22 +496,19 @@ public:
};
struct MCDwarfFrameInfo {
- MCDwarfFrameInfo()
- : Begin(nullptr), End(nullptr), Personality(nullptr), Lsda(nullptr),
- Instructions(), CurrentCfaRegister(0), PersonalityEncoding(),
- LsdaEncoding(0), CompactUnwindEncoding(0), IsSignalFrame(false),
- IsSimple(false) {}
- MCSymbol *Begin;
- MCSymbol *End;
- const MCSymbol *Personality;
- const MCSymbol *Lsda;
+ MCDwarfFrameInfo() = default;
+
+ MCSymbol *Begin = nullptr;
+ MCSymbol *End = nullptr;
+ const MCSymbol *Personality = nullptr;
+ const MCSymbol *Lsda = nullptr;
std::vector<MCCFIInstruction> Instructions;
- unsigned CurrentCfaRegister;
- unsigned PersonalityEncoding;
- unsigned LsdaEncoding;
- uint32_t CompactUnwindEncoding;
- bool IsSignalFrame;
- bool IsSimple;
+ unsigned CurrentCfaRegister = 0;
+ unsigned PersonalityEncoding = 0;
+ unsigned LsdaEncoding = 0;
+ uint32_t CompactUnwindEncoding = 0;
+ bool IsSignalFrame = false;
+ bool IsSimple = false;
};
class MCDwarfFrameEmitter {
@@ -516,6 +521,7 @@ public:
static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta,
raw_ostream &OS);
};
+
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCDWARF_H
diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h
index 376e21821316..f22fc11f9b07 100644
--- a/include/llvm/MC/MCELFObjectWriter.h
+++ b/include/llvm/MC/MCELFObjectWriter.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCELFObjectWriter.h - ELF Object Writer ---------*- C++ -*-===//
+//===- llvm/MC/MCELFObjectWriter.h - ELF Object Writer ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,22 +11,21 @@
#define LLVM_MC_MCELFOBJECTWRITER_H
#include "llvm/ADT/Triple.h"
-#include "llvm/MC/MCValue.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/raw_ostream.h"
+#include <cstdint>
#include <vector>
namespace llvm {
+
class MCAssembler;
class MCContext;
class MCFixup;
-class MCFragment;
class MCObjectWriter;
class MCSymbol;
class MCSymbolELF;
class MCValue;
-class raw_pwrite_stream;
struct ELFRelocationEntry {
uint64_t Offset; // Where is the relocation.
@@ -47,6 +46,7 @@ struct ELFRelocationEntry {
<< ", Addend=" << Addend << ", OriginalSymbol=" << OriginalSymbol
<< ", OriginalAddend=" << OriginalAddend;
}
+
void dump() const { print(errs()); }
};
@@ -58,12 +58,12 @@ class MCELFObjectTargetWriter {
const unsigned IsN64 : 1;
protected:
-
- MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_,
- uint16_t EMachine_, bool HasRelocationAddend,
- bool IsN64=false);
+ MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_, uint16_t EMachine_,
+ bool HasRelocationAddend, bool IsN64 = false);
public:
+ virtual ~MCELFObjectTargetWriter() = default;
+
static uint8_t getOSABI(Triple::OSType OSType) {
switch (OSType) {
case Triple::CloudABI:
@@ -76,8 +76,6 @@ public:
}
}
- virtual ~MCELFObjectTargetWriter() {}
-
virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
const MCFixup &Fixup, bool IsPCRel) const = 0;
@@ -144,6 +142,7 @@ public:
MCObjectWriter *createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
raw_pwrite_stream &OS,
bool IsLittleEndian);
-} // End llvm namespace
-#endif
+} // end namespace llvm
+
+#endif // LLVM_MC_MCELFOBJECTWRITER_H
diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h
index a5c263844352..90434f34da5f 100644
--- a/include/llvm/MC/MCELFStreamer.h
+++ b/include/llvm/MC/MCELFStreamer.h
@@ -10,27 +10,24 @@
#ifndef LLVM_MC_MCELFSTREAMER_H
#define LLVM_MC_MCELFSTREAMER_H
-#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCObjectStreamer.h"
-#include "llvm/MC/SectionKind.h"
-#include "llvm/Support/DataTypes.h"
namespace llvm {
+
class MCAsmBackend;
-class MCAssembler;
class MCCodeEmitter;
class MCExpr;
class MCInst;
-class raw_ostream;
class MCELFStreamer : public MCObjectStreamer {
public:
MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
MCCodeEmitter *Emitter)
- : MCObjectStreamer(Context, TAB, OS, Emitter), SeenIdent(false) {}
+ : MCObjectStreamer(Context, TAB, OS, Emitter) {}
- ~MCELFStreamer() override;
+ ~MCELFStreamer() override = default;
/// state management
void reset() override {
@@ -44,7 +41,8 @@ public:
void InitSections(bool NoExecStack) override;
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
- void EmitLabel(MCSymbol *Symbol) override;
+ void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
+ void EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F) override;
void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
void EmitThumbFunc(MCSymbol *Func) override;
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
@@ -52,10 +50,6 @@ public:
void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) override;
- void BeginCOFFSymbolDef(const MCSymbol *Symbol) override;
- void EmitCOFFSymbolStorageClass(int StorageClass) override;
- void EmitCOFFSymbolType(int Type) override;
- void EndCOFFSymbolDef() override;
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
@@ -69,8 +63,6 @@ public:
void EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc = SMLoc()) override;
- void EmitFileDirective(StringRef Filename) override;
-
void EmitIdent(StringRef IdentString) override;
void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
@@ -91,11 +83,11 @@ private:
/// \brief Merge the content of the fragment \p EF into the fragment \p DF.
void mergeFragment(MCDataFragment *, MCDataFragment *);
- bool SeenIdent;
+ bool SeenIdent = false;
/// BundleGroups - The stack of fragments holding the bundle-locked
/// instructions.
- llvm::SmallVector<MCDataFragment *, 4> BundleGroups;
+ SmallVector<MCDataFragment *, 4> BundleGroups;
};
MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
@@ -105,4 +97,4 @@ MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCELFSTREAMER_H
diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h
index 0d1e675da459..c850abf42e2c 100644
--- a/include/llvm/MC/MCExpr.h
+++ b/include/llvm/MC/MCExpr.h
@@ -11,10 +11,11 @@
#define LLVM_MC_MCEXPR_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/SMLoc.h"
+#include <cstdint>
namespace llvm {
+
class MCAsmInfo;
class MCAsmLayout;
class MCAssembler;
@@ -43,9 +44,7 @@ public:
private:
ExprKind Kind;
-
- MCExpr(const MCExpr&) = delete;
- void operator=(const MCExpr&) = delete;
+ SMLoc Loc;
bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
@@ -56,7 +55,7 @@ private:
const SectionAddrMap *Addrs, bool InSet) const;
protected:
- explicit MCExpr(ExprKind Kind) : Kind(Kind) {}
+ explicit MCExpr(ExprKind Kind, SMLoc Loc) : Kind(Kind), Loc(Loc) {}
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
@@ -64,10 +63,14 @@ protected:
const SectionAddrMap *Addrs, bool InSet) const;
public:
+ MCExpr(const MCExpr &) = delete;
+ MCExpr &operator=(const MCExpr &) = delete;
+
/// \name Accessors
/// @{
ExprKind getKind() const { return Kind; }
+ SMLoc getLoc() const { return Loc; }
/// @}
/// \name Utility Methods
@@ -132,7 +135,7 @@ class MCConstantExpr : public MCExpr {
int64_t Value;
explicit MCConstantExpr(int64_t Value)
- : MCExpr(MCExpr::Constant), Value(Value) {}
+ : MCExpr(MCExpr::Constant, SMLoc()), Value(Value) {}
public:
/// \name Construction
@@ -191,6 +194,8 @@ public:
VK_SIZE, // symbol@SIZE
VK_WEAKREF, // The link between the symbols in .weakref foo, bar
+ VK_X86_ABS8,
+
VK_ARM_NONE,
VK_ARM_GOT_PREL,
VK_ARM_TARGET1,
@@ -265,6 +270,7 @@ public:
VK_Hexagon_IE_GOT,
VK_WebAssembly_FUNCTION, // Function table index, rather than virtual addr
+ VK_WebAssembly_TYPEINDEX,// Type table index
VK_AMDGPU_GOTPCREL32_LO, // symbol@gotpcrel32@lo
VK_AMDGPU_GOTPCREL32_HI, // symbol@gotpcrel32@hi
@@ -289,7 +295,7 @@ private:
const MCSymbol *Symbol;
explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
- const MCAsmInfo *MAI);
+ const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
public:
/// \name Construction
@@ -300,7 +306,7 @@ public:
}
static const MCSymbolRefExpr *create(const MCSymbol *Symbol, VariantKind Kind,
- MCContext &Ctx);
+ MCContext &Ctx, SMLoc Loc = SMLoc());
static const MCSymbolRefExpr *create(StringRef Name, VariantKind Kind,
MCContext &Ctx);
@@ -345,26 +351,30 @@ private:
Opcode Op;
const MCExpr *Expr;
- MCUnaryExpr(Opcode Op, const MCExpr *Expr)
- : MCExpr(MCExpr::Unary), Op(Op), Expr(Expr) {}
+ MCUnaryExpr(Opcode Op, const MCExpr *Expr, SMLoc Loc)
+ : MCExpr(MCExpr::Unary, Loc), Op(Op), Expr(Expr) {}
public:
/// \name Construction
/// @{
static const MCUnaryExpr *create(Opcode Op, const MCExpr *Expr,
- MCContext &Ctx);
- static const MCUnaryExpr *createLNot(const MCExpr *Expr, MCContext &Ctx) {
- return create(LNot, Expr, Ctx);
+ MCContext &Ctx, SMLoc Loc = SMLoc());
+
+ static const MCUnaryExpr *createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
+ return create(LNot, Expr, Ctx, Loc);
}
- static const MCUnaryExpr *createMinus(const MCExpr *Expr, MCContext &Ctx) {
- return create(Minus, Expr, Ctx);
+
+ static const MCUnaryExpr *createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
+ return create(Minus, Expr, Ctx, Loc);
}
- static const MCUnaryExpr *createNot(const MCExpr *Expr, MCContext &Ctx) {
- return create(Not, Expr, Ctx);
+
+ static const MCUnaryExpr *createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
+ return create(Not, Expr, Ctx, Loc);
}
- static const MCUnaryExpr *createPlus(const MCExpr *Expr, MCContext &Ctx) {
- return create(Plus, Expr, Ctx);
+
+ static const MCUnaryExpr *createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
+ return create(Plus, Expr, Ctx, Loc);
}
/// @}
@@ -417,87 +427,108 @@ private:
Opcode Op;
const MCExpr *LHS, *RHS;
- MCBinaryExpr(Opcode Op, const MCExpr *LHS, const MCExpr *RHS)
- : MCExpr(MCExpr::Binary), Op(Op), LHS(LHS), RHS(RHS) {}
+ MCBinaryExpr(Opcode Op, const MCExpr *LHS, const MCExpr *RHS,
+ SMLoc Loc = SMLoc())
+ : MCExpr(MCExpr::Binary, Loc), Op(Op), LHS(LHS), RHS(RHS) {}
public:
/// \name Construction
/// @{
static const MCBinaryExpr *create(Opcode Op, const MCExpr *LHS,
- const MCExpr *RHS, MCContext &Ctx);
+ const MCExpr *RHS, MCContext &Ctx,
+ SMLoc Loc = SMLoc());
+
static const MCBinaryExpr *createAdd(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Add, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createAnd(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(And, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createDiv(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Div, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createEQ(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(EQ, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createGT(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(GT, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createGTE(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(GTE, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createLAnd(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(LAnd, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createLOr(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(LOr, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createLT(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(LT, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createLTE(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(LTE, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createMod(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Mod, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createMul(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Mul, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createNE(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(NE, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createOr(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Or, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createShl(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Shl, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createAShr(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(AShr, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createLShr(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(LShr, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createSub(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Sub, LHS, RHS, Ctx);
}
+
static const MCBinaryExpr *createXor(const MCExpr *LHS, const MCExpr *RHS,
MCContext &Ctx) {
return create(Xor, LHS, RHS, Ctx);
@@ -530,9 +561,11 @@ public:
/// MCExprs are bump pointer allocated and not destructed.
class MCTargetExpr : public MCExpr {
virtual void anchor();
+
protected:
- MCTargetExpr() : MCExpr(Target) {}
- virtual ~MCTargetExpr() {}
+ MCTargetExpr() : MCExpr(Target, SMLoc()) {}
+ virtual ~MCTargetExpr() = default;
+
public:
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
@@ -550,4 +583,4 @@ public:
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCEXPR_H
diff --git a/include/llvm/MC/MCFragment.h b/include/llvm/MC/MCFragment.h
index edb740f36d91..fc8257f90a9f 100644
--- a/include/llvm/MC/MCFragment.h
+++ b/include/llvm/MC/MCFragment.h
@@ -10,25 +10,26 @@
#ifndef LLVM_MC_MCFRAGMENT_H
#define LLVM_MC_MCFRAGMENT_H
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/ilist.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/ilist_node.h"
-#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCInst.h"
+#include "llvm/Support/SMLoc.h"
+#include <cstdint>
+#include <utility>
namespace llvm {
+
class MCSection;
-class MCSymbol;
class MCSubtargetInfo;
+class MCSymbol;
class MCFragment : public ilist_node_with_parent<MCFragment, MCSection> {
friend class MCAsmLayout;
- MCFragment() = delete;
- MCFragment(const MCFragment &) = delete;
- void operator=(const MCFragment &) = delete;
-
public:
enum FragmentType : uint8_t {
FT_Align,
@@ -86,6 +87,10 @@ protected:
~MCFragment();
public:
+ MCFragment() = delete;
+ MCFragment(const MCFragment &) = delete;
+ MCFragment &operator=(const MCFragment &) = delete;
+
/// Destroys the current fragment.
///
/// This must be used instead of delete as MCFragment is non-virtual.
@@ -131,7 +136,8 @@ public:
class MCDummyFragment : public MCFragment {
public:
explicit MCDummyFragment(MCSection *Sec)
- : MCFragment(FT_Dummy, false, 0, Sec){};
+ : MCFragment(FT_Dummy, false, 0, Sec) {}
+
static bool classof(const MCFragment *F) { return F->getKind() == FT_Dummy; }
};
@@ -271,7 +277,6 @@ public:
};
class MCAlignFragment : public MCFragment {
-
/// Alignment - The alignment to ensure, in bytes.
unsigned Alignment;
@@ -319,7 +324,6 @@ public:
};
class MCFillFragment : public MCFragment {
-
/// Value to use for filling bytes.
uint8_t Value;
@@ -339,7 +343,6 @@ public:
};
class MCOrgFragment : public MCFragment {
-
/// Offset - The offset this fragment should start at.
const MCExpr *Offset;
@@ -371,7 +374,6 @@ public:
};
class MCLEBFragment : public MCFragment {
-
/// Value - The value this fragment should contain.
const MCExpr *Value;
@@ -404,7 +406,6 @@ public:
};
class MCDwarfLineAddrFragment : public MCFragment {
-
/// LineDelta - the value of the difference between the two line numbers
/// between two .loc dwarf directives.
int64_t LineDelta;
@@ -441,7 +442,6 @@ public:
};
class MCDwarfCallFrameFragment : public MCFragment {
-
/// AddrDelta - The expression for the difference of the two symbols that
/// make up the address delta between two .cfi_* dwarf directives.
const MCExpr *AddrDelta;
@@ -561,4 +561,4 @@ public:
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCFRAGMENT_H
diff --git a/include/llvm/MC/MCInst.h b/include/llvm/MC/MCInst.h
index 4688b5f2b6e9..702279659371 100644
--- a/include/llvm/MC/MCInst.h
+++ b/include/llvm/MC/MCInst.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCInst.h - MCInst class -------------------------*- C++ -*-===//
+//===- llvm/MC/MCInst.h - MCInst class --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,15 +18,17 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/DataTypes.h"
#include "llvm/Support/SMLoc.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
namespace llvm {
-class raw_ostream;
-class MCAsmInfo;
-class MCInstPrinter;
+
class MCExpr;
class MCInst;
+class MCInstPrinter;
+class raw_ostream;
/// \brief Instances of this class represent operands of the MCInst class.
/// This is a simple discriminated union.
@@ -39,7 +41,7 @@ class MCOperand {
kExpr, ///< Relocatable immediate operand.
kInst ///< Sub-instruction operand.
};
- MachineOperandType Kind;
+ MachineOperandType Kind = kInvalid;
union {
unsigned RegVal;
@@ -50,7 +52,7 @@ class MCOperand {
};
public:
- MCOperand() : Kind(kInvalid), FPImmVal(0.0) {}
+ MCOperand() : FPImmVal(0.0) {}
bool isValid() const { return Kind != kInvalid; }
bool isReg() const { return Kind == kRegister; }
@@ -75,6 +77,7 @@ public:
assert(isImm() && "This is not an immediate");
return ImmVal;
}
+
void setImm(int64_t Val) {
assert(isImm() && "This is not an immediate");
ImmVal = Val;
@@ -94,6 +97,7 @@ public:
assert(isExpr() && "This is not an expression");
return ExprVal;
}
+
void setExpr(const MCExpr *Val) {
assert(isExpr() && "This is not an expression");
ExprVal = Val;
@@ -103,6 +107,7 @@ public:
assert(isInst() && "This is not a sub-instruction");
return InstVal;
}
+
void setInst(const MCInst *Val) {
assert(isInst() && "This is not a sub-instruction");
InstVal = Val;
@@ -114,24 +119,28 @@ public:
Op.RegVal = Reg;
return Op;
}
+
static MCOperand createImm(int64_t Val) {
MCOperand Op;
Op.Kind = kImmediate;
Op.ImmVal = Val;
return Op;
}
+
static MCOperand createFPImm(double Val) {
MCOperand Op;
Op.Kind = kFPImmediate;
Op.FPImmVal = Val;
return Op;
}
+
static MCOperand createExpr(const MCExpr *Val) {
MCOperand Op;
Op.Kind = kExpr;
Op.ExprVal = Val;
return Op;
}
+
static MCOperand createInst(const MCInst *Val) {
MCOperand Op;
Op.Kind = kInst;
@@ -148,12 +157,12 @@ template <> struct isPodLike<MCOperand> { static const bool value = true; };
/// \brief Instances of this class represent a single low-level machine
/// instruction.
class MCInst {
- unsigned Opcode;
+ unsigned Opcode = 0;
SMLoc Loc;
SmallVector<MCOperand, 8> Operands;
public:
- MCInst() : Opcode(0) {}
+ MCInst() = default;
void setOpcode(unsigned Op) { Opcode = Op; }
unsigned getOpcode() const { return Opcode; }
@@ -176,6 +185,7 @@ public:
const_iterator begin() const { return Operands.begin(); }
iterator end() { return Operands.end(); }
const_iterator end() const { return Operands.end(); }
+
iterator insert(iterator I, const MCOperand &Op) {
return Operands.insert(I, Op);
}
@@ -202,4 +212,4 @@ inline raw_ostream& operator<<(raw_ostream &OS, const MCInst &MI) {
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCINST_H
diff --git a/include/llvm/MC/MCInstPrinter.h b/include/llvm/MC/MCInstPrinter.h
index 320b280cc756..069403074b31 100644
--- a/include/llvm/MC/MCInstPrinter.h
+++ b/include/llvm/MC/MCInstPrinter.h
@@ -16,12 +16,12 @@
namespace llvm {
template <typename T> class ArrayRef;
-class MCInst;
-class raw_ostream;
class MCAsmInfo;
+class MCInst;
class MCInstrInfo;
class MCRegisterInfo;
class MCSubtargetInfo;
+class raw_ostream;
class StringRef;
/// Convert `Bytes' to a hex string and output to `OS'
@@ -43,28 +43,26 @@ protected:
/// \brief A stream that comments can be emitted to if desired. Each comment
/// must end with a newline. This will be null if verbose assembly emission
/// is disable.
- raw_ostream *CommentStream;
+ raw_ostream *CommentStream = nullptr;
const MCAsmInfo &MAI;
const MCInstrInfo &MII;
const MCRegisterInfo &MRI;
/// True if we are printing marked up assembly.
- bool UseMarkup;
+ bool UseMarkup = false;
/// True if we are printing immediates as hex.
- bool PrintImmHex;
+ bool PrintImmHex = false;
/// Which style to use for printing hexadecimal values.
- HexStyle::Style PrintHexStyle;
+ HexStyle::Style PrintHexStyle = HexStyle::C;
/// Utility function for printing annotations.
void printAnnotation(raw_ostream &OS, StringRef Annot);
public:
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
- const MCRegisterInfo &mri)
- : CommentStream(nullptr), MAI(mai), MII(mii), MRI(mri), UseMarkup(false),
- PrintImmHex(false), PrintHexStyle(HexStyle::C) {}
+ const MCRegisterInfo &mri) : MAI(mai), MII(mii), MRI(mri) {}
virtual ~MCInstPrinter();
diff --git a/include/llvm/MC/MCInstrAnalysis.h b/include/llvm/MC/MCInstrAnalysis.h
index 8f5159e9e1c8..dd3e1df477b4 100644
--- a/include/llvm/MC/MCInstrAnalysis.h
+++ b/include/llvm/MC/MCInstrAnalysis.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks ------*- C++ -*-===//
+//===- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,18 +18,19 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
+#include <cstdint>
namespace llvm {
class MCInstrAnalysis {
protected:
friend class Target;
+
const MCInstrInfo *Info;
public:
MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
-
- virtual ~MCInstrAnalysis() {}
+ virtual ~MCInstrAnalysis() = default;
virtual bool isBranch(const MCInst &Inst) const {
return Info->get(Inst.getOpcode()).isBranch();
@@ -66,6 +67,6 @@ public:
uint64_t &Target) const;
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCINSTRANALYSIS_H
diff --git a/include/llvm/MC/MCInstrItineraries.h b/include/llvm/MC/MCInstrItineraries.h
index 1fb276a302b9..4443dd113715 100644
--- a/include/llvm/MC/MCInstrItineraries.h
+++ b/include/llvm/MC/MCInstrItineraries.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCInstrItineraries.h - Scheduling ---------------*- C++ -*-===//
+//===- llvm/MC/MCInstrItineraries.h - Scheduling ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -88,7 +88,6 @@ struct InstrStage {
}
};
-
//===----------------------------------------------------------------------===//
/// An itinerary represents the scheduling information for an instruction.
/// This includes a set of stages occupied by the instruction and the pipeline
@@ -102,23 +101,20 @@ struct InstrItinerary {
unsigned LastOperandCycle; ///< Index of last + 1 operand rd/wr
};
-
//===----------------------------------------------------------------------===//
/// Itinerary data supplied by a subtarget to be used by a target.
///
class InstrItineraryData {
public:
- MCSchedModel SchedModel; ///< Basic machine properties.
- const InstrStage *Stages; ///< Array of stages selected
- const unsigned *OperandCycles; ///< Array of operand cycles selected
- const unsigned *Forwardings; ///< Array of pipeline forwarding paths
- const InstrItinerary *Itineraries; ///< Array of itineraries selected
-
- /// Ctors.
- InstrItineraryData() : SchedModel(MCSchedModel::GetDefaultSchedModel()),
- Stages(nullptr), OperandCycles(nullptr),
- Forwardings(nullptr), Itineraries(nullptr) {}
-
+ MCSchedModel SchedModel =
+ MCSchedModel::GetDefaultSchedModel(); ///< Basic machine properties.
+ const InstrStage *Stages = nullptr; ///< Array of stages selected
+ const unsigned *OperandCycles = nullptr; ///< Array of operand cycles selected
+ const unsigned *Forwardings = nullptr; ///< Array of pipeline forwarding paths
+ const InstrItinerary *Itineraries =
+ nullptr; ///< Array of itineraries selected
+
+ InstrItineraryData() = default;
InstrItineraryData(const MCSchedModel &SM, const InstrStage *S,
const unsigned *OS, const unsigned *F)
: SchedModel(SM), Stages(S), OperandCycles(OS), Forwardings(F),
@@ -234,6 +230,6 @@ public:
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCINSTRITINERARIES_H
diff --git a/include/llvm/MC/MCLabel.h b/include/llvm/MC/MCLabel.h
index a12473fdad02..b6579fd654ab 100644
--- a/include/llvm/MC/MCLabel.h
+++ b/include/llvm/MC/MCLabel.h
@@ -14,10 +14,8 @@
#ifndef LLVM_MC_MCLABEL_H
#define LLVM_MC_MCLABEL_H
-#include "llvm/Support/Compiler.h"
-
namespace llvm {
-class MCContext;
+
class raw_ostream;
/// \brief Instances of this class represent a label name in the MC file,
@@ -29,12 +27,13 @@ class MCLabel {
private: // MCContext creates and uniques these.
friend class MCContext;
+
MCLabel(unsigned instance) : Instance(instance) {}
+public:
MCLabel(const MCLabel &) = delete;
- void operator=(const MCLabel &) = delete;
+ MCLabel &operator=(const MCLabel &) = delete;
-public:
/// \brief Get the current instance of this Directional Local Label.
unsigned getInstance() const { return Instance; }
@@ -52,6 +51,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const MCLabel &Label) {
Label.print(OS);
return OS;
}
+
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCLABEL_H
diff --git a/include/llvm/MC/MCLinkerOptimizationHint.h b/include/llvm/MC/MCLinkerOptimizationHint.h
index 200bb93f64c8..0c3525bbeda6 100644
--- a/include/llvm/MC/MCLinkerOptimizationHint.h
+++ b/include/llvm/MC/MCLinkerOptimizationHint.h
@@ -21,13 +21,14 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <cstdint>
namespace llvm {
-// Forward declarations.
+class MachObjectWriter;
class MCAsmLayout;
class MCSymbol;
-class MachObjectWriter;
/// Linker Optimization Hint Type.
enum MCLOHType {
@@ -133,7 +134,7 @@ public:
class MCLOHContainer {
/// Keep track of the emit size of all the LOHs.
- mutable uint64_t EmitSize;
+ mutable uint64_t EmitSize = 0;
/// Keep track of all LOH directives.
SmallVector<MCLOHDirective, 32> Directives;
@@ -141,7 +142,7 @@ class MCLOHContainer {
public:
typedef SmallVectorImpl<MCLOHDirective> LOHDirectives;
- MCLOHContainer() : EmitSize(0) {}
+ MCLOHContainer() = default;
/// Const accessor to the directives.
const LOHDirectives &getDirectives() const {
@@ -183,4 +184,4 @@ typedef MCLOHContainer::LOHDirectives MCLOHDirectives;
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCLINKEROPTIMIZATIONHINT_H
diff --git a/include/llvm/MC/MCMachObjectWriter.h b/include/llvm/MC/MCMachObjectWriter.h
index 1a685dbd608e..b93638f86408 100644
--- a/include/llvm/MC/MCMachObjectWriter.h
+++ b/include/llvm/MC/MCMachObjectWriter.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCMachObjectWriter.h - Mach Object Writer -------*- C++ -*-===//
+//===- llvm/MC/MCMachObjectWriter.h - Mach Object Writer --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,12 +11,15 @@
#define LLVM_MC_MCMACHOBJECTWRITER_H
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/StringTableBuilder.h"
-#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MachO.h"
+#include <cstdint>
+#include <memory>
+#include <string>
#include <vector>
namespace llvm {
@@ -95,8 +98,8 @@ class MachObjectWriter : public MCObjectWriter {
: Sym(Sym), MRE(MRE) {}
};
- llvm::DenseMap<const MCSection *, std::vector<RelAndSymbol>> Relocations;
- llvm::DenseMap<const MCSection *, unsigned> IndirectSymBase;
+ DenseMap<const MCSection *, std::vector<RelAndSymbol>> Relocations;
+ DenseMap<const MCSection *, unsigned> IndirectSymBase;
SectionAddrMap SectionAddress;
@@ -271,6 +274,6 @@ MCObjectWriter *createMachObjectWriter(MCMachObjectTargetWriter *MOTW,
raw_pwrite_stream &OS,
bool IsLittleEndian);
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCMACHOBJECTWRITER_H
diff --git a/include/llvm/MC/MCObjectFileInfo.h b/include/llvm/MC/MCObjectFileInfo.h
index 9aa8812c7bb3..8b2a1261b220 100644
--- a/include/llvm/MC/MCObjectFileInfo.h
+++ b/include/llvm/MC/MCObjectFileInfo.h
@@ -129,7 +129,7 @@ protected:
/// it'll go here.
MCSection *TLSExtraDataSection;
- /// Section directive for Thread Local data. ELF, MachO and COFF.
+ /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
MCSection *TLSDataSection; // Defaults to ".tdata".
/// Section directive for Thread Local uninitialized data.
@@ -338,7 +338,7 @@ public:
return EHFrameSection;
}
- enum Environment { IsMachO, IsELF, IsCOFF };
+ enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
Environment getObjectFileType() const { return Env; }
bool isPositionIndependent() const { return PositionIndependent; }
@@ -353,6 +353,7 @@ private:
void initMachOMCObjectFileInfo(const Triple &T);
void initELFMCObjectFileInfo(const Triple &T);
void initCOFFMCObjectFileInfo(const Triple &T);
+ void initWasmMCObjectFileInfo(const Triple &T);
public:
const Triple &getTargetTriple() const { return TT; }
diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h
index f9111b7f47ea..7c1189e46ab2 100644
--- a/include/llvm/MC/MCObjectStreamer.h
+++ b/include/llvm/MC/MCObjectStreamer.h
@@ -89,7 +89,8 @@ public:
/// \name MCStreamer Interface
/// @{
- void EmitLabel(MCSymbol *Symbol) override;
+ void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
+ virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F);
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
void EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc = SMLoc()) override;
@@ -97,7 +98,8 @@ public:
void EmitSLEB128Value(const MCExpr *Value) override;
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
- void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo& STI) override;
+ void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
+ bool = false) override;
/// \brief Emit an instruction to a special fragment, because this instruction
/// can change its size during relaxation.
@@ -152,6 +154,7 @@ public:
SMLoc Loc = SMLoc()) override;
void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
SMLoc Loc = SMLoc()) override;
+ void EmitFileDirective(StringRef Filename) override;
void FinishImpl() override;
diff --git a/include/llvm/MC/MCObjectWriter.h b/include/llvm/MC/MCObjectWriter.h
index 0ecebe42a0b9..86bcbb6861d7 100644
--- a/include/llvm/MC/MCObjectWriter.h
+++ b/include/llvm/MC/MCObjectWriter.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCObjectWriter.h - Object File Writer Interface -*- C++ -*-===//
+//===- llvm/MC/MCObjectWriter.h - Object File Writer Interface --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,13 +11,15 @@
#define LLVM_MC_MCOBJECTWRITER_H
#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Endian.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
+#include <cstdint>
namespace llvm {
+
class MCAsmLayout;
class MCAssembler;
class MCFixup;
@@ -38,15 +40,12 @@ class MCValue;
/// The object writer also contains a number of helper methods for writing
/// binary data to the output stream.
class MCObjectWriter {
- MCObjectWriter(const MCObjectWriter &) = delete;
- void operator=(const MCObjectWriter &) = delete;
-
raw_pwrite_stream *OS;
protected:
unsigned IsLittleEndian : 1;
-protected: // Can only create subclasses.
+ // Can only create subclasses.
MCObjectWriter(raw_pwrite_stream &OS, bool IsLittleEndian)
: OS(&OS), IsLittleEndian(IsLittleEndian) {}
@@ -55,6 +54,8 @@ protected: // Can only create subclasses.
}
public:
+ MCObjectWriter(const MCObjectWriter &) = delete;
+ MCObjectWriter &operator=(const MCObjectWriter &) = delete;
virtual ~MCObjectWriter();
/// lifetime management
@@ -108,11 +109,6 @@ public:
bool InSet,
bool IsPCRel) const;
- /// True if this symbol (which is a variable) is weak. This is not
- /// just STB_WEAK, but more generally whether or not we can evaluate
- /// past it.
- virtual bool isWeak(const MCSymbol &Sym) const;
-
/// Write the object file.
///
/// This routine is called by the assembler after layout and relaxation is
@@ -199,6 +195,6 @@ public:
/// @}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCOBJECTWRITER_H
diff --git a/include/llvm/MC/MCParser/AsmCond.h b/include/llvm/MC/MCParser/AsmCond.h
index a918b5600ed5..8e7bfc521556 100644
--- a/include/llvm/MC/MCParser/AsmCond.h
+++ b/include/llvm/MC/MCParser/AsmCond.h
@@ -28,13 +28,13 @@ public:
ElseCond // inside else conditional
};
- ConditionalAssemblyType TheCond;
- bool CondMet;
- bool Ignore;
+ ConditionalAssemblyType TheCond = NoCond;
+ bool CondMet = false;
+ bool Ignore = false;
- AsmCond() : TheCond(NoCond), CondMet(false), Ignore(false) {}
+ AsmCond() = default;
};
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_ASMCOND_H
diff --git a/include/llvm/MC/MCParser/AsmLexer.h b/include/llvm/MC/MCParser/AsmLexer.h
index 029598c013d3..207183a69b0e 100644
--- a/include/llvm/MC/MCParser/AsmLexer.h
+++ b/include/llvm/MC/MCParser/AsmLexer.h
@@ -16,25 +16,22 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCParser/MCAsmLexer.h"
-#include "llvm/Support/DataTypes.h"
#include <string>
namespace llvm {
-class MemoryBuffer;
+
class MCAsmInfo;
/// AsmLexer - Lexer class for assembly files.
class AsmLexer : public MCAsmLexer {
const MCAsmInfo &MAI;
- const char *CurPtr;
+ const char *CurPtr = nullptr;
StringRef CurBuf;
- bool IsAtStartOfLine;
- bool IsAtStartOfStatement;
- bool IsParsingMSInlineAsm;
- bool IsPeeking;
- void operator=(const AsmLexer&) = delete;
- AsmLexer(const AsmLexer&) = delete;
+ bool IsAtStartOfLine = true;
+ bool IsAtStartOfStatement = true;
+ bool IsParsingMSInlineAsm = false;
+ bool IsPeeking = false;
protected:
/// LexToken - Read the next token and return its code.
@@ -42,6 +39,8 @@ protected:
public:
AsmLexer(const MCAsmInfo &MAI);
+ AsmLexer(const AsmLexer &) = delete;
+ AsmLexer &operator=(const AsmLexer &) = delete;
~AsmLexer() override;
void setBuffer(StringRef Buf, const char *ptr = nullptr);
@@ -74,4 +73,4 @@ private:
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_ASMLEXER_H
diff --git a/include/llvm/MC/MCParser/MCAsmLexer.h b/include/llvm/MC/MCParser/MCAsmLexer.h
index 56da6f85c199..7ddc7722e512 100644
--- a/include/llvm/MC/MCParser/MCAsmLexer.h
+++ b/include/llvm/MC/MCParser/MCAsmLexer.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCAsmLexer.h - Abstract Asm Lexer Interface -----*- C++ -*-===//
+//===- llvm/MC/MCAsmLexer.h - Abstract Asm Lexer Interface ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,10 +14,12 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
#include "llvm/Support/SMLoc.h"
-#include <utility>
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <string>
namespace llvm {
@@ -76,7 +78,7 @@ private:
APInt IntVal;
public:
- AsmToken() {}
+ AsmToken() = default;
AsmToken(TokenKind Kind, StringRef Str, APInt IntVal)
: Kind(Kind), Str(Str), IntVal(std::move(IntVal)) {}
AsmToken(TokenKind Kind, StringRef Str, int64_t IntVal = 0)
@@ -132,7 +134,7 @@ public:
/// it is lexed.
class AsmCommentConsumer {
public:
- virtual ~AsmCommentConsumer() {};
+ virtual ~AsmCommentConsumer() = default;
/// Callback function for when a comment is lexed. Loc is the start of the
/// comment text (excluding the comment-start marker). CommentText is the text
@@ -152,14 +154,12 @@ class MCAsmLexer {
SMLoc ErrLoc;
std::string Err;
- MCAsmLexer(const MCAsmLexer &) = delete;
- void operator=(const MCAsmLexer &) = delete;
protected: // Can only create subclasses.
- const char *TokStart;
- bool SkipSpace;
+ const char *TokStart = nullptr;
+ bool SkipSpace = true;
bool AllowAtInIdentifier;
- bool IsAtStartOfStatement;
- AsmCommentConsumer *CommentConsumer;
+ bool IsAtStartOfStatement = true;
+ AsmCommentConsumer *CommentConsumer = nullptr;
MCAsmLexer();
@@ -171,6 +171,8 @@ protected: // Can only create subclasses.
}
public:
+ MCAsmLexer(const MCAsmLexer &) = delete;
+ MCAsmLexer &operator=(const MCAsmLexer &) = delete;
virtual ~MCAsmLexer();
/// Consume the next token from the input stream and return it.
@@ -255,6 +257,6 @@ public:
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_MCASMLEXER_H
diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h
index eb85a3a30963..6763374185ec 100644
--- a/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/include/llvm/MC/MCParser/MCAsmParser.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCAsmParser.h - Abstract Asm Parser Interface ---*- C++ -*-===//
+//===- llvm/MC/MCAsmParser.h - Abstract Asm Parser Interface ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,16 +10,21 @@
#ifndef LLVM_MC_MCPARSER_MCASMPARSER_H
#define LLVM_MC_MCPARSER_MCASMPARSER_H
-#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
-#include "llvm/MC/MCParser/AsmLexer.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/MC/MCParser/MCAsmLexer.h"
+#include "llvm/Support/SMLoc.h"
+#include <cstdint>
+#include <string>
+#include <utility>
namespace llvm {
+
class MCAsmInfo;
-class MCAsmLexer;
class MCAsmParserExtension;
class MCContext;
class MCExpr;
@@ -27,10 +32,7 @@ class MCInstPrinter;
class MCInstrInfo;
class MCStreamer;
class MCTargetAsmParser;
-class SMLoc;
-class SMRange;
class SourceMgr;
-class Twine;
class InlineAsmIdentifierInfo {
public:
@@ -51,12 +53,12 @@ public:
class MCAsmParserSemaCallback {
public:
virtual ~MCAsmParserSemaCallback();
+
virtual void *LookupInlineAsmIdentifier(StringRef &LineBuf,
InlineAsmIdentifierInfo &Info,
bool IsUnevaluatedContext) = 0;
virtual StringRef LookupInlineAsmLabel(StringRef Identifier, SourceMgr &SM,
SMLoc Location, bool Create) = 0;
-
virtual bool LookupInlineAsmField(StringRef Base, StringRef Member,
unsigned &Offset) = 0;
};
@@ -76,22 +78,21 @@ public:
};
private:
- MCAsmParser(const MCAsmParser &) = delete;
- void operator=(const MCAsmParser &) = delete;
-
- MCTargetAsmParser *TargetParser;
+ MCTargetAsmParser *TargetParser = nullptr;
unsigned ShowParsedOperands : 1;
protected: // Can only create subclasses.
MCAsmParser();
- bool HadError;
+ bool HadError = false;
SmallVector<MCPendingError, 1> PendingErrors;
/// Flag tracking whether any errors have been encountered.
public:
+ MCAsmParser(const MCAsmParser &) = delete;
+ MCAsmParser &operator=(const MCAsmParser &) = delete;
virtual ~MCAsmParser();
virtual void addDirectiveHandler(StringRef Directive,
@@ -186,12 +187,12 @@ public:
bool parseEOL(const Twine &ErrMsg);
- bool parseMany(std::function<bool()> parseOne, bool hasComma = true);
+ bool parseMany(function_ref<bool()> parseOne, bool hasComma = true);
bool parseIntToken(int64_t &V, const Twine &ErrMsg);
- bool check(bool P, const llvm::Twine &Msg);
- bool check(bool P, SMLoc Loc, const llvm::Twine &Msg);
+ bool check(bool P, const Twine &Msg);
+ bool check(bool P, SMLoc Loc, const Twine &Msg);
/// \brief Parse an identifier or string (as a quoted identifier) and set \p
/// Res to the identifier contents.
@@ -258,8 +259,8 @@ public:
/// \brief Create an MCAsmParser instance.
MCAsmParser *createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &,
- const MCAsmInfo &);
+ const MCAsmInfo &, unsigned CB = 0);
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_MCASMPARSER_H
diff --git a/include/llvm/MC/MCParser/MCAsmParserExtension.h b/include/llvm/MC/MCParser/MCAsmParserExtension.h
index dabda0ab9485..ffb8d7a4a26a 100644
--- a/include/llvm/MC/MCParser/MCAsmParserExtension.h
+++ b/include/llvm/MC/MCParser/MCAsmParserExtension.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCAsmParserExtension.h - Asm Parser Hooks -------*- C++ -*-===//
+//===- llvm/MC/MCAsmParserExtension.h - Asm Parser Hooks --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,20 +10,20 @@
#ifndef LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H
#define LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/Support/SMLoc.h"
namespace llvm {
+
class Twine;
/// \brief Generic interface for extending the MCAsmParser,
/// which is implemented by target and object file assembly parser
/// implementations.
class MCAsmParserExtension {
- MCAsmParserExtension(const MCAsmParserExtension &) = delete;
- void operator=(const MCAsmParserExtension &) = delete;
-
MCAsmParser *Parser;
protected:
@@ -38,9 +38,11 @@ protected:
return (Obj->*Handler)(Directive, DirectiveLoc);
}
- bool BracketExpressionsSupported;
+ bool BracketExpressionsSupported = false;
public:
+ MCAsmParserExtension(const MCAsmParserExtension &) = delete;
+ MCAsmParserExtension &operator=(const MCAsmParserExtension &) = delete;
virtual ~MCAsmParserExtension();
/// \brief Initialize the extension for parsing using the given \p Parser.
@@ -65,15 +67,19 @@ public:
SourceMgr &getSourceManager() { return getParser().getSourceManager(); }
MCStreamer &getStreamer() { return getParser().getStreamer(); }
+
bool Warning(SMLoc L, const Twine &Msg) {
return getParser().Warning(L, Msg);
}
+
bool Error(SMLoc L, const Twine &Msg, SMRange Range = SMRange()) {
return getParser().Error(L, Msg, Range);
}
+
void Note(SMLoc L, const Twine &Msg) {
getParser().Note(L, Msg);
}
+
bool TokError(const Twine &Msg) {
return getParser().TokError(Msg);
}
@@ -85,7 +91,7 @@ public:
return getParser().parseToken(T, Msg);
}
- bool parseMany(std::function<bool()> parseOne, bool hasComma = true) {
+ bool parseMany(function_ref<bool()> parseOne, bool hasComma = true) {
return getParser().parseMany(parseOne, hasComma);
}
@@ -93,11 +99,11 @@ public:
return getParser().parseOptionalToken(T);
}
- bool check(bool P, const llvm::Twine &Msg) {
+ bool check(bool P, const Twine &Msg) {
return getParser().check(P, Msg);
}
- bool check(bool P, SMLoc Loc, const llvm::Twine &Msg) {
+ bool check(bool P, SMLoc Loc, const Twine &Msg) {
return getParser().check(P, Loc, Msg);
}
@@ -110,6 +116,6 @@ public:
/// @}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H
diff --git a/include/llvm/MC/MCParser/MCAsmParserUtils.h b/include/llvm/MC/MCParser/MCAsmParserUtils.h
index 9834fe96307b..84173bb9cb8e 100644
--- a/include/llvm/MC/MCParser/MCAsmParserUtils.h
+++ b/include/llvm/MC/MCParser/MCAsmParserUtils.h
@@ -1,4 +1,4 @@
-//===------ llvm/MC/MCAsmParserUtils.h - Asm Parser Utilities ---*- C++ -*-===//
+//===- llvm/MC/MCAsmParserUtils.h - Asm Parser Utilities --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -28,6 +28,7 @@ bool parseAssignmentExpression(StringRef Name, bool allow_redef,
const MCExpr *&Value);
} // namespace MCParserUtils
+
} // namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_MCASMPARSERUTILS_H
diff --git a/include/llvm/MC/MCParser/MCParsedAsmOperand.h b/include/llvm/MC/MCParser/MCParsedAsmOperand.h
index a90d280c240c..4af76ac2a858 100644
--- a/include/llvm/MC/MCParser/MCParsedAsmOperand.h
+++ b/include/llvm/MC/MCParser/MCParsedAsmOperand.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand -------*- C++ -*-===//
+//===- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,11 +10,12 @@
#ifndef LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
#define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
-#include <string>
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SMLoc.h"
+#include <string>
namespace llvm {
+
class raw_ostream;
/// MCParsedAsmOperand - This abstract class represents a source-level assembly
@@ -35,12 +36,12 @@ protected:
// lots of members and MSVC doesn't support defaulted move ops, so to avoid
// that verbosity, just rely on defaulted copy ops. It's only the Constraint
// string member that would benefit from movement anyway.
+ MCParsedAsmOperand() = default;
MCParsedAsmOperand(const MCParsedAsmOperand &RHS) = default;
MCParsedAsmOperand &operator=(const MCParsedAsmOperand &) = default;
- MCParsedAsmOperand() = default;
public:
- virtual ~MCParsedAsmOperand() {}
+ virtual ~MCParsedAsmOperand() = default;
void setConstraint(StringRef C) { Constraint = C.str(); }
StringRef getConstraint() { return Constraint; }
@@ -81,6 +82,7 @@ public:
/// print - Print a debug representation of the operand to the given stream.
virtual void print(raw_ostream &OS) const = 0;
+
/// dump - Print to the debug stream.
virtual void dump() const;
};
@@ -93,6 +95,6 @@ inline raw_ostream& operator<<(raw_ostream &OS, const MCParsedAsmOperand &MO) {
return OS;
}
-} // end namespace llvm.
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
diff --git a/include/llvm/MC/MCParser/MCTargetAsmParser.h b/include/llvm/MC/MCParser/MCTargetAsmParser.h
index 70cd60c9a112..c81a7624011f 100644
--- a/include/llvm/MC/MCParser/MCTargetAsmParser.h
+++ b/include/llvm/MC/MCParser/MCTargetAsmParser.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCTargetAsmParser.h - Target Assembly Parser ----*- C++ -*-===//
+//===- llvm/MC/MCTargetAsmParser.h - Target Assembly Parser -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,19 +10,21 @@
#ifndef LLVM_MC_MCPARSER_MCTARGETASMPARSER_H
#define LLVM_MC_MCPARSER_MCTARGETASMPARSER_H
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
#include "llvm/MC/MCTargetOptions.h"
+#include "llvm/Support/SMLoc.h"
+#include <cstdint>
#include <memory>
namespace llvm {
-class AsmToken;
+
class MCInst;
class MCParsedAsmOperand;
class MCStreamer;
class MCSubtargetInfo;
-class SMLoc;
-class StringRef;
template <typename T> class SmallVectorImpl;
typedef SmallVectorImpl<std::unique_ptr<MCParsedAsmOperand>> OperandVector;
@@ -66,6 +68,7 @@ struct AsmRewrite {
unsigned Len;
unsigned Val;
StringRef Label;
+
public:
AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len = 0, unsigned val = 0)
: Kind(kind), Loc(loc), Len(len), Val(val) {}
@@ -74,10 +77,9 @@ public:
};
struct ParseInstructionInfo {
+ SmallVectorImpl<AsmRewrite> *AsmRewrites = nullptr;
- SmallVectorImpl<AsmRewrite> *AsmRewrites;
-
- ParseInstructionInfo() : AsmRewrites(nullptr) {}
+ ParseInstructionInfo() = default;
ParseInstructionInfo(SmallVectorImpl<AsmRewrite> *rewrites)
: AsmRewrites(rewrites) {}
};
@@ -99,9 +101,6 @@ public:
FIRST_TARGET_MATCH_RESULT_TY
};
-private:
- MCTargetAsmParser(const MCTargetAsmParser &) = delete;
- void operator=(const MCTargetAsmParser &) = delete;
protected: // Can only create subclasses.
MCTargetAsmParser(MCTargetOptions const &, const MCSubtargetInfo &STI);
@@ -109,10 +108,10 @@ protected: // Can only create subclasses.
MCSubtargetInfo &copySTI();
/// AvailableFeatures - The current set of available features.
- uint64_t AvailableFeatures;
+ uint64_t AvailableFeatures = 0;
/// ParsingInlineAsm - Are we parsing ms-style inline assembly?
- bool ParsingInlineAsm;
+ bool ParsingInlineAsm = false;
/// SemaCallback - The Sema callback implementation. Must be set when parsing
/// ms-style inline assembly.
@@ -125,6 +124,9 @@ protected: // Can only create subclasses.
const MCSubtargetInfo *STI;
public:
+ MCTargetAsmParser(const MCTargetAsmParser &) = delete;
+ MCTargetAsmParser &operator=(const MCTargetAsmParser &) = delete;
+
~MCTargetAsmParser() override;
const MCSubtargetInfo &getSTI() const;
@@ -229,11 +231,11 @@ public:
return nullptr;
}
- virtual void onLabelParsed(MCSymbol *Symbol) { }
+ virtual void onLabelParsed(MCSymbol *Symbol) {}
/// Ensure that all previously parsed instructions have been emitted to the
/// output streamer, if the target does not emit them immediately.
- virtual void flushPendingInstructions(MCStreamer &Out) { }
+ virtual void flushPendingInstructions(MCStreamer &Out) {}
virtual const MCExpr *createTargetUnaryExpr(const MCExpr *E,
AsmToken::TokenKind OperatorToken,
@@ -242,6 +244,6 @@ public:
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCPARSER_MCTARGETASMPARSER_H
diff --git a/include/llvm/MC/MCRegisterInfo.h b/include/llvm/MC/MCRegisterInfo.h
index 3dc88a298ff8..015d0b96d9f2 100644
--- a/include/llvm/MC/MCRegisterInfo.h
+++ b/include/llvm/MC/MCRegisterInfo.h
@@ -1,4 +1,4 @@
-//=== MC/MCRegisterInfo.h - Target Register Description ---------*- C++ -*-===//
+//===- MC/MCRegisterInfo.h - Target Register Description --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,9 +17,11 @@
#define LLVM_MC_MCREGISTERINFO_H
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/MC/LaneBitmask.h"
-#include "llvm/Support/ErrorHandling.h"
#include <cassert>
+#include <cstdint>
+#include <utility>
namespace llvm {
@@ -39,7 +41,7 @@ public:
const uint16_t RegsSize;
const uint16_t RegSetSize;
const uint16_t ID;
- const uint16_t RegSize, Alignment; // Size & Alignment of register in bytes
+ const uint16_t PhysRegSize;
const int8_t CopyCost;
const bool Allocatable;
@@ -78,13 +80,10 @@ public:
return contains(Reg1) && contains(Reg2);
}
- /// getSize - Return the size of the register in bytes, which is also the size
- /// of a stack slot allocated to hold a spilled copy of this register.
- unsigned getSize() const { return RegSize; }
-
- /// getAlignment - Return the minimum required alignment for a register of
- /// this class.
- unsigned getAlignment() const { return Alignment; }
+ /// Return the size of the physical register in bytes.
+ unsigned getPhysRegSize() const { return PhysRegSize; }
+ /// Temporary function to allow out-of-tree targets to switch.
+ unsigned getSize() const { return getPhysRegSize(); }
/// getCopyCost - Return the cost of copying a value between two registers in
/// this class. A negative number means the register class is very expensive
@@ -152,6 +151,7 @@ public:
uint16_t Offset;
uint16_t Size;
};
+
private:
const MCRegisterDesc *Desc; // Pointer to the descriptor array
unsigned NumRegs; // Number of entries in the array
@@ -191,12 +191,12 @@ public:
/// Don't use this class directly, use one of the specialized sub-classes
/// defined below.
class DiffListIterator {
- uint16_t Val;
- const MCPhysReg *List;
+ uint16_t Val = 0;
+ const MCPhysReg *List = nullptr;
protected:
/// Create an invalid iterator. Call init() to point to something useful.
- DiffListIterator() : Val(0), List(nullptr) {}
+ DiffListIterator() = default;
/// init - Point the iterator to InitVal, decoding subsequent values from
/// DiffList. The iterator will initially point to InitVal, sub-classes are
@@ -217,7 +217,6 @@ public:
}
public:
-
/// isValid - returns true if this iterator is not yet at the end.
bool isValid() const { return List; }
@@ -418,6 +417,9 @@ public:
regclass_iterator regclass_begin() const { return Classes; }
regclass_iterator regclass_end() const { return Classes+NumClasses; }
+ iterator_range<regclass_iterator> regclasses() const {
+ return make_range(regclass_begin(), regclass_end());
+ }
unsigned getNumRegClasses() const {
return (unsigned)(regclass_end()-regclass_begin());
@@ -492,6 +494,7 @@ public:
class MCSubRegIndexIterator {
MCSubRegIterator SRIter;
const uint16_t *SRIndex;
+
public:
/// Constructs an iterator that traverses subregisters and their
/// associated subregister indices.
@@ -504,6 +507,7 @@ public:
unsigned getSubReg() const {
return *SRIter;
}
+
/// Returns sub-register index of the current sub-register.
unsigned getSubRegIndex() const {
return *SRIndex;
@@ -523,7 +527,8 @@ public:
/// If IncludeSelf is set, Reg itself is included in the list.
class MCSuperRegIterator : public MCRegisterInfo::DiffListIterator {
public:
- MCSuperRegIterator() {}
+ MCSuperRegIterator() = default;
+
MCSuperRegIterator(unsigned Reg, const MCRegisterInfo *MCRI,
bool IncludeSelf = false) {
init(Reg, MCRI->DiffLists + MCRI->get(Reg).SuperRegs);
@@ -560,7 +565,8 @@ class MCRegUnitIterator : public MCRegisterInfo::DiffListIterator {
public:
/// MCRegUnitIterator - Create an iterator that traverses the register units
/// in Reg.
- MCRegUnitIterator() {}
+ MCRegUnitIterator() = default;
+
MCRegUnitIterator(unsigned Reg, const MCRegisterInfo *MCRI) {
assert(Reg && "Null register has no regunits");
// Decode the RegUnits MCRegisterDesc field.
@@ -586,8 +592,10 @@ public:
class MCRegUnitMaskIterator {
MCRegUnitIterator RUIter;
const LaneBitmask *MaskListIter;
+
public:
- MCRegUnitMaskIterator() {}
+ MCRegUnitMaskIterator() = default;
+
/// Constructs an iterator that traverses the register units and their
/// associated LaneMasks in Reg.
MCRegUnitMaskIterator(unsigned Reg, const MCRegisterInfo *MCRI)
@@ -622,10 +630,12 @@ public:
/// MCRegUnitRootIterator enumerates the root registers of a register unit.
class MCRegUnitRootIterator {
- uint16_t Reg0;
- uint16_t Reg1;
+ uint16_t Reg0 = 0;
+ uint16_t Reg1 = 0;
+
public:
- MCRegUnitRootIterator() : Reg0(0), Reg1(0) {}
+ MCRegUnitRootIterator() = default;
+
MCRegUnitRootIterator(unsigned RegUnit, const MCRegisterInfo *MCRI) {
assert(RegUnit < MCRI->getNumRegUnits() && "Invalid register unit");
Reg0 = MCRI->RegUnitRoots[RegUnit][0];
@@ -662,11 +672,11 @@ private:
MCRegUnitIterator RI;
MCRegUnitRootIterator RRI;
MCSuperRegIterator SI;
+
public:
MCRegAliasIterator(unsigned Reg, const MCRegisterInfo *MCRI,
bool IncludeSelf)
: Reg(Reg), MCRI(MCRI), IncludeSelf(IncludeSelf) {
-
// Initialize the iterators.
for (RI = MCRegUnitIterator(Reg, MCRI); RI.isValid(); ++RI) {
for (RRI = MCRegUnitRootIterator(*RI, MCRI); RRI.isValid(); ++RRI) {
@@ -681,7 +691,7 @@ public:
bool isValid() const { return RI.isValid(); }
unsigned operator*() const {
- assert (SI.isValid() && "Cannot dereference an invalid iterator.");
+ assert(SI.isValid() && "Cannot dereference an invalid iterator.");
return *SI;
}
@@ -710,6 +720,6 @@ public:
}
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCREGISTERINFO_H
diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h
index d4c31696b40f..2974d8f1b80b 100644
--- a/include/llvm/MC/MCSection.h
+++ b/include/llvm/MC/MCSection.h
@@ -14,22 +14,21 @@
#ifndef LLVM_MC_MCSECTION_H
#define LLVM_MC_MCSECTION_H
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/ilist.h"
-#include "llvm/ADT/ilist_node.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCFragment.h"
#include "llvm/MC/SectionKind.h"
-#include "llvm/Support/Compiler.h"
+#include <cassert>
+#include <utility>
namespace llvm {
+
class MCAsmInfo;
-class MCAssembler;
class MCContext;
class MCExpr;
-class MCFragment;
-class MCSection;
class MCSymbol;
class raw_ostream;
+class Triple;
template <> struct ilist_alloc_traits<MCFragment> {
static void deleteNode(MCFragment *V);
@@ -39,7 +38,7 @@ template <> struct ilist_alloc_traits<MCFragment> {
/// current translation unit. The MCContext class uniques and creates these.
class MCSection {
public:
- enum SectionVariant { SV_COFF = 0, SV_ELF, SV_MachO };
+ enum SectionVariant { SV_COFF = 0, SV_ELF, SV_MachO, SV_Wasm };
/// \brief Express the state of bundle locked groups while emitting code.
enum BundleLockStateType {
@@ -57,9 +56,6 @@ public:
typedef FragmentListType::reverse_iterator reverse_iterator;
private:
- MCSection(const MCSection &) = delete;
- void operator=(const MCSection &) = delete;
-
MCSymbol *Begin;
MCSymbol *End = nullptr;
/// The alignment requirement of this section.
@@ -77,12 +73,12 @@ private:
/// \brief We've seen a bundle_lock directive but not its first instruction
/// yet.
- unsigned BundleGroupBeforeFirstInst : 1;
+ bool BundleGroupBeforeFirstInst : 1;
/// Whether this section has had instructions emitted into it.
- unsigned HasInstructions : 1;
+ bool HasInstructions : 1;
- unsigned IsRegistered : 1;
+ bool IsRegistered : 1;
MCDummyFragment DummyFragment;
@@ -93,12 +89,16 @@ private:
SmallVector<std::pair<unsigned, MCFragment *>, 1> SubsectionFragmentMap;
protected:
- MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin);
SectionVariant Variant;
SectionKind Kind;
+
+ MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin);
~MCSection();
public:
+ MCSection(const MCSection &) = delete;
+ MCSection &operator=(const MCSection &) = delete;
+
SectionKind getKind() const { return Kind; }
SectionVariant getVariant() const { return Variant; }
@@ -169,7 +169,8 @@ public:
void dump();
- virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+ virtual void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+ raw_ostream &OS,
const MCExpr *Subsection) const = 0;
/// Return true if a .align directive should use "optimized nops" to fill
@@ -183,4 +184,4 @@ public:
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCSECTION_H
diff --git a/include/llvm/MC/MCSectionCOFF.h b/include/llvm/MC/MCSectionCOFF.h
index 7d5f9f7f3cde..24b9f8898ebb 100644
--- a/include/llvm/MC/MCSectionCOFF.h
+++ b/include/llvm/MC/MCSectionCOFF.h
@@ -16,8 +16,11 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCSection.h"
+#include "llvm/MC/SectionKind.h"
+#include <cassert>
namespace llvm {
+
class MCSymbol;
/// This represents a section on Windows
@@ -73,7 +76,8 @@ public:
void setSelection(int Selection) const;
- void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+ void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+ raw_ostream &OS,
const MCExpr *Subsection) const override;
bool UseCodeAlign() const override;
bool isVirtualSection() const override;
@@ -93,4 +97,4 @@ public:
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCSECTIONCOFF_H
diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h
index dabd787b0d45..00c289c6bd6e 100644
--- a/include/llvm/MC/MCSectionELF.h
+++ b/include/llvm/MC/MCSectionELF.h
@@ -14,12 +14,10 @@
#ifndef LLVM_MC_MCSECTIONELF_H
#define LLVM_MC_MCSECTIONELF_H
-#include "llvm/ADT/Twine.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbolELF.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/ELF.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/MC/SectionKind.h"
namespace llvm {
@@ -47,17 +45,18 @@ class MCSectionELF final : public MCSection {
const MCSymbolELF *Group;
- /// Depending on the type of the section this is sh_link or sh_info.
- const MCSectionELF *Associated;
+ /// sh_info for SHF_LINK_ORDER (can be null).
+ const MCSymbol *AssociatedSymbol;
private:
friend class MCContext;
+
MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K,
unsigned entrySize, const MCSymbolELF *group, unsigned UniqueID,
- MCSymbol *Begin, const MCSectionELF *Associated)
+ MCSymbol *Begin, const MCSymbolELF *AssociatedSymbol)
: MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group),
- Associated(Associated) {
+ AssociatedSymbol(AssociatedSymbol) {
if (Group)
Group->setIsSignature();
}
@@ -78,7 +77,8 @@ public:
void setFlags(unsigned F) { Flags = F; }
const MCSymbolELF *getGroup() const { return Group; }
- void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+ void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+ raw_ostream &OS,
const MCExpr *Subsection) const override;
bool UseCodeAlign() const override;
bool isVirtualSection() const override;
@@ -86,7 +86,8 @@ public:
bool isUnique() const { return UniqueID != ~0U; }
unsigned getUniqueID() const { return UniqueID; }
- const MCSectionELF *getAssociatedSection() const { return Associated; }
+ const MCSection *getAssociatedSection() const { return &AssociatedSymbol->getSection(); }
+ const MCSymbol *getAssociatedSymbol() const { return AssociatedSymbol; }
static bool classof(const MCSection *S) {
return S->getVariant() == SV_ELF;
@@ -95,4 +96,4 @@ public:
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCSECTIONELF_H
diff --git a/include/llvm/MC/MCSectionMachO.h b/include/llvm/MC/MCSectionMachO.h
index 658dfcda7268..3bc5408a4f75 100644
--- a/include/llvm/MC/MCSectionMachO.h
+++ b/include/llvm/MC/MCSectionMachO.h
@@ -76,7 +76,8 @@ public:
bool &TAAParsed, // Out.
unsigned &StubSize); // Out.
- void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+ void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+ raw_ostream &OS,
const MCExpr *Subsection) const override;
bool UseCodeAlign() const override;
bool isVirtualSection() const override;
diff --git a/include/llvm/MC/MCSectionWasm.h b/include/llvm/MC/MCSectionWasm.h
new file mode 100644
index 000000000000..4e19196175c0
--- /dev/null
+++ b/include/llvm/MC/MCSectionWasm.h
@@ -0,0 +1,86 @@
+//===- MCSectionWasm.h - Wasm Machine Code Sections -------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the MCSectionWasm class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCSECTIONWASM_H
+#define LLVM_MC_MCSECTIONWASM_H
+
+#include "llvm/ADT/Twine.h"
+#include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCSymbolWasm.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+
+class MCSymbol;
+
+/// This represents a section on wasm.
+class MCSectionWasm final : public MCSection {
+ /// This is the name of the section. The referenced memory is owned by
+ /// TargetLoweringObjectFileWasm's WasmUniqueMap.
+ StringRef SectionName;
+
+ /// This is the sh_type field of a section, drawn from the enums below.
+ unsigned Type;
+
+ /// This is the sh_flags field of a section, drawn from the enums below.
+ unsigned Flags;
+
+ unsigned UniqueID;
+
+ const MCSymbolWasm *Group;
+
+ // The offset of the MC function section in the wasm code section.
+ uint64_t SectionOffset;
+
+private:
+ friend class MCContext;
+ MCSectionWasm(StringRef Section, unsigned type, unsigned flags, SectionKind K,
+ const MCSymbolWasm *group, unsigned UniqueID, MCSymbol *Begin)
+ : MCSection(SV_Wasm, K, Begin), SectionName(Section), Type(type),
+ Flags(flags), UniqueID(UniqueID), Group(group), SectionOffset(0) {
+ }
+
+ void setSectionName(StringRef Name) { SectionName = Name; }
+
+public:
+ ~MCSectionWasm();
+
+ /// Decides whether a '.section' directive should be printed before the
+ /// section name
+ bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
+
+ StringRef getSectionName() const { return SectionName; }
+ unsigned getType() const { return Type; }
+ unsigned getFlags() const { return Flags; }
+ void setFlags(unsigned F) { Flags = F; }
+ const MCSymbolWasm *getGroup() const { return Group; }
+
+ void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
+ raw_ostream &OS,
+ const MCExpr *Subsection) const override;
+ bool UseCodeAlign() const override;
+ bool isVirtualSection() const override;
+
+ bool isUnique() const { return UniqueID != ~0U; }
+ unsigned getUniqueID() const { return UniqueID; }
+
+ uint64_t getSectionOffset() const { return SectionOffset; }
+ void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
+
+ static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; }
+};
+
+} // end namespace llvm
+
+#endif
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
index 41f00a24dfbf..e466b368ed34 100644
--- a/include/llvm/MC/MCStreamer.h
+++ b/include/llvm/MC/MCStreamer.h
@@ -15,17 +15,26 @@
#define LLVM_MC_MCSTREAMER_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCLinkerOptimizationHint.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCWinEH.h"
-#include "llvm/Support/DataTypes.h"
#include "llvm/Support/SMLoc.h"
+#include <cassert>
+#include <cstdint>
+#include <memory>
#include <string>
+#include <utility>
+#include <vector>
namespace llvm {
+
+class AssemblerConstantPools;
+class formatted_raw_ostream;
class MCAsmBackend;
class MCCodeEmitter;
class MCContext;
@@ -34,14 +43,11 @@ class MCInst;
class MCInstPrinter;
class MCSection;
class MCStreamer;
-class MCSymbolELF;
class MCSymbolRefExpr;
+class MCSymbolWasm;
class MCSubtargetInfo;
-class StringRef;
-class Twine;
class raw_ostream;
-class formatted_raw_ostream;
-class AssemblerConstantPools;
+class Twine;
typedef std::pair<MCSection *, const MCExpr *> MCSectionSubPair;
@@ -162,9 +168,6 @@ class MCStreamer {
MCContext &Context;
std::unique_ptr<MCTargetStreamer> TargetStreamer;
- MCStreamer(const MCStreamer &) = delete;
- MCStreamer &operator=(const MCStreamer &) = delete;
-
std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
MCDwarfFrameInfo *getCurrentDwarfFrameInfo();
void EnsureValidDwarfFrame();
@@ -205,6 +208,8 @@ protected:
virtual void EmitRawTextImpl(StringRef String);
public:
+ MCStreamer(const MCStreamer &) = delete;
+ MCStreamer &operator=(const MCStreamer &) = delete;
virtual ~MCStreamer();
void visitUsedExpr(const MCExpr &Expr);
@@ -282,6 +287,7 @@ public:
/// \brief Add explicit comment T. T is required to be a valid
/// comment in the output and does not need to be escaped.
virtual void addExplicitComment(const Twine &T);
+
/// \brief Emit added explicit comments.
virtual void emitExplicitComments();
@@ -393,7 +399,7 @@ public:
/// used in an assignment.
// FIXME: These emission are non-const because we mutate the symbol to
// add the section we're emitting it to later.
- virtual void EmitLabel(MCSymbol *Symbol);
+ virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc());
virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
@@ -483,6 +489,14 @@ public:
/// .size symbol, expression
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value);
+ /// \brief Emit an ELF .symver directive.
+ ///
+ /// This corresponds to an assembler statement such as:
+ /// .symver _start, foo@@SOME_VERSION
+ /// \param Alias - The versioned alias (i.e. "foo@@SOME_VERSION")
+ /// \param Aliasee - The aliased symbol (i.e. "_start")
+ virtual void emitELFSymverDirective(MCSymbol *Alias, const MCSymbol *Aliasee);
+
/// \brief Emit a Linker Optimization Hint (LOH) directive.
/// \param Args - Arguments of the LOH.
virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {}
@@ -822,7 +836,9 @@ public:
}
/// \brief Emit the given \p Instruction into the current section.
- virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
+ /// PrintSchedInfo == true then schedul comment should be added to output
+ virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
+ bool PrintSchedInfo = false);
/// \brief Set the bundle alignment mode from now on in the section.
/// The argument is the power of 2 to which the alignment is set. The
@@ -876,6 +892,7 @@ MCStreamer *createAsmStreamer(MCContext &Ctx,
bool isVerboseAsm, bool useDwarfDirectory,
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
MCAsmBackend *TAB, bool ShowInst);
+
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCSTREAMER_H
diff --git a/include/llvm/MC/MCSubtargetInfo.h b/include/llvm/MC/MCSubtargetInfo.h
index 5ede043fa2ee..6229db3bbcb2 100644
--- a/include/llvm/MC/MCSubtargetInfo.h
+++ b/include/llvm/MC/MCSubtargetInfo.h
@@ -1,4 +1,4 @@
-//==-- llvm/MC/MCSubtargetInfo.h - Subtarget Information ---------*- C++ -*-==//
+//===- llvm/MC/MCSubtargetInfo.h - Subtarget Information --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,13 +15,19 @@
#define LLVM_MC_MCSUBTARGETINFO_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/MC/MCInstrItineraries.h"
+#include "llvm/MC/MCSchedule.h"
#include "llvm/MC/SubtargetFeature.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
#include <string>
namespace llvm {
-
-class StringRef;
+class MachineInstr;
+class MCInst;
//===----------------------------------------------------------------------===//
///
@@ -45,10 +51,6 @@ class MCSubtargetInfo {
const unsigned *ForwardingPaths; // Forwarding paths
FeatureBitset FeatureBits; // Feature bits for current CPU + FS
- MCSubtargetInfo() = delete;
- MCSubtargetInfo &operator=(MCSubtargetInfo &&) = delete;
- MCSubtargetInfo &operator=(const MCSubtargetInfo &) = delete;
-
public:
MCSubtargetInfo(const MCSubtargetInfo &) = default;
MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
@@ -58,6 +60,11 @@ public:
const MCWriteProcResEntry *WPR, const MCWriteLatencyEntry *WL,
const MCReadAdvanceEntry *RA, const InstrStage *IS,
const unsigned *OC, const unsigned *FP);
+ MCSubtargetInfo() = delete;
+ MCSubtargetInfo &operator=(const MCSubtargetInfo &) = delete;
+ MCSubtargetInfo &operator=(MCSubtargetInfo &&) = delete;
+
+ virtual ~MCSubtargetInfo() {}
/// getTargetTriple - Return the target triple string.
const Triple &getTargetTriple() const { return TargetTriple; }
@@ -164,8 +171,17 @@ public:
auto Found = std::lower_bound(ProcDesc.begin(), ProcDesc.end(), CPU);
return Found != ProcDesc.end() && StringRef(Found->Key) == CPU;
}
+
+ /// Returns string representation of scheduler comment
+ virtual std::string getSchedInfoStr(const MachineInstr &MI) const {
+ return std::string();
+ }
+
+ virtual std::string getSchedInfoStr(MCInst const &MCI) const {
+ return std::string();
+ }
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCSUBTARGETINFO_H
diff --git a/include/llvm/MC/MCSymbol.h b/include/llvm/MC/MCSymbol.h
index 23e34b7869a5..e8432afd8627 100644
--- a/include/llvm/MC/MCSymbol.h
+++ b/include/llvm/MC/MCSymbol.h
@@ -15,18 +15,21 @@
#define LLVM_MC_MCSYMBOL_H
#include "llvm/ADT/PointerIntPair.h"
-#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCFragment.h"
-#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
namespace llvm {
+
class MCAsmInfo;
+class MCContext;
class MCExpr;
-class MCSymbol;
-class MCFragment;
class MCSection;
-class MCContext;
class raw_ostream;
/// MCSymbol - Instances of this class represent a symbol name in the MC file,
@@ -45,6 +48,7 @@ protected:
SymbolKindCOFF,
SymbolKindELF,
SymbolKindMachO,
+ SymbolKindWasm,
};
/// A symbol can contain an Offset, or Value, or be Common, but never more
@@ -97,7 +101,7 @@ protected:
/// LLVM RTTI discriminator. This is actually a SymbolKind enumerator, but is
/// unsigned to avoid sign extension and achieve better bitpacking with MSVC.
- unsigned Kind : 2;
+ unsigned Kind : 3;
/// True if we have created a relocation that uses this symbol.
mutable unsigned IsUsedInReloc : 1;
@@ -133,7 +137,7 @@ protected:
const MCExpr *Value;
};
-protected: // MCContext creates and uniques these.
+ // MCContext creates and uniques these.
friend class MCExpr;
friend class MCContext;
@@ -163,7 +167,6 @@ protected: // MCContext creates and uniques these.
MCContext &Ctx);
private:
-
void operator delete(void *);
/// \brief Placement delete - required by std, but never called.
void operator delete(void*, unsigned) {
@@ -174,8 +177,6 @@ private:
llvm_unreachable("Constructor throws?");
}
- MCSymbol(const MCSymbol &) = delete;
- void operator=(const MCSymbol &) = delete;
MCSection *getSectionPtr(bool SetUsed = true) const {
if (MCFragment *F = getFragment(SetUsed)) {
assert(F != AbsolutePseudoFragment);
@@ -195,6 +196,9 @@ private:
}
public:
+ MCSymbol(const MCSymbol &) = delete;
+ MCSymbol &operator=(const MCSymbol &) = delete;
+
/// getName - Get the symbol name.
StringRef getName() const {
if (!FragmentAndHasName.getInt())
@@ -281,6 +285,8 @@ public:
bool isMachO() const { return Kind == SymbolKindMachO; }
+ bool isWasm() const { return Kind == SymbolKindWasm; }
+
/// @}
/// \name Variable Symbols
/// @{
@@ -416,6 +422,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
Sym.print(OS, nullptr);
return OS;
}
+
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCSYMBOL_H
diff --git a/include/llvm/MC/MCSymbolCOFF.h b/include/llvm/MC/MCSymbolCOFF.h
index 2172c67981c0..7918c353dc15 100644
--- a/include/llvm/MC/MCSymbolCOFF.h
+++ b/include/llvm/MC/MCSymbolCOFF.h
@@ -6,16 +6,18 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_MC_MCSYMBOLCOFF_H
#define LLVM_MC_MCSYMBOLCOFF_H
#include "llvm/MC/MCSymbol.h"
+#include <cstdint>
namespace llvm {
-class MCSymbolCOFF : public MCSymbol {
+class MCSymbolCOFF : public MCSymbol {
/// This corresponds to the e_type field of the COFF symbol.
- mutable uint16_t Type;
+ mutable uint16_t Type = 0;
enum SymbolFlags : uint16_t {
SF_ClassMask = 0x00FF,
@@ -27,7 +29,7 @@ class MCSymbolCOFF : public MCSymbol {
public:
MCSymbolCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
- : MCSymbol(SymbolKindCOFF, Name, isTemporary), Type(0) {}
+ : MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
uint16_t getType() const {
return Type;
@@ -59,6 +61,7 @@ public:
static bool classof(const MCSymbol *S) { return S->isCOFF(); }
};
-}
-#endif
+} // end namespace llvm
+
+#endif // LLVM_MC_MCSYMBOLCOFF_H
diff --git a/include/llvm/MC/MCSymbolWasm.h b/include/llvm/MC/MCSymbolWasm.h
new file mode 100644
index 000000000000..4445be006eb0
--- /dev/null
+++ b/include/llvm/MC/MCSymbolWasm.h
@@ -0,0 +1,57 @@
+//===- MCSymbolWasm.h - ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_MC_MCSYMBOLWASM_H
+#define LLVM_MC_MCSYMBOLWASM_H
+
+#include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/Wasm.h"
+
+namespace llvm {
+class MCSymbolWasm : public MCSymbol {
+private:
+ bool IsFunction = false;
+ std::string ModuleName;
+ SmallVector<wasm::ValType, 1> Returns;
+ SmallVector<wasm::ValType, 4> Params;
+
+ /// An expression describing how to calculate the size of a symbol. If a
+ /// symbol has no size this field will be NULL.
+ const MCExpr *SymbolSize = nullptr;
+
+public:
+ // Use a module name of "env" for now, for compatibility with existing tools.
+ // This is temporary, and may change, as the ABI is not yet stable.
+ MCSymbolWasm(const StringMapEntry<bool> *Name, bool isTemporary)
+ : MCSymbol(SymbolKindWasm, Name, isTemporary),
+ ModuleName("env") {}
+ static bool classof(const MCSymbol *S) { return S->isWasm(); }
+
+ const MCExpr *getSize() const { return SymbolSize; }
+ void setSize(const MCExpr *SS) { SymbolSize = SS; }
+
+ bool isFunction() const { return IsFunction; }
+ void setIsFunction(bool isFunc) { IsFunction = isFunc; }
+
+ const StringRef getModuleName() const { return ModuleName; }
+
+ const SmallVector<wasm::ValType, 1> &getReturns() const { return Returns; }
+
+ void setReturns(SmallVectorImpl<wasm::ValType> &&Rets) {
+ Returns = std::move(Rets);
+ }
+
+ const SmallVector<wasm::ValType, 4> &getParams() const { return Params; }
+
+ void setParams(SmallVectorImpl<wasm::ValType> &&Pars) {
+ Params = std::move(Pars);
+ }
+};
+}
+
+#endif
diff --git a/include/llvm/MC/MCTargetOptions.h b/include/llvm/MC/MCTargetOptions.h
index 25642379ac9f..06f58d498030 100644
--- a/include/llvm/MC/MCTargetOptions.h
+++ b/include/llvm/MC/MCTargetOptions.h
@@ -1,4 +1,4 @@
-//===- MCTargetOptions.h - MC Target Options -------------------*- C++ -*-===//
+//===- MCTargetOptions.h - MC Target Options --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -51,12 +51,8 @@ public:
/// Preserve Comments in Assembly.
bool PreserveAsmComments : 1;
- int DwarfVersion;
+ int DwarfVersion = 0;
- /// getABIName - If this returns a non-empty string this represents the
- /// textual name of the ABI that we want the backend to use, e.g. o32, or
- /// aapcs-linux.
- StringRef getABIName() const;
std::string ABIName;
/// Additional paths to search for `.include` directives when using the
@@ -64,33 +60,13 @@ public:
std::vector<std::string> IASSearchPaths;
MCTargetOptions();
-};
-inline bool operator==(const MCTargetOptions &LHS, const MCTargetOptions &RHS) {
-#define ARE_EQUAL(X) LHS.X == RHS.X
- return (ARE_EQUAL(SanitizeAddress) &&
- ARE_EQUAL(MCRelaxAll) &&
- ARE_EQUAL(MCNoExecStack) &&
- ARE_EQUAL(MCFatalWarnings) &&
- ARE_EQUAL(MCNoWarn) &&
- ARE_EQUAL(MCNoDeprecatedWarn) &&
- ARE_EQUAL(MCSaveTempLabels) &&
- ARE_EQUAL(MCUseDwarfDirectory) &&
- ARE_EQUAL(MCIncrementalLinkerCompatible) &&
- ARE_EQUAL(MCPIECopyRelocations) &&
- ARE_EQUAL(ShowMCEncoding) &&
- ARE_EQUAL(ShowMCInst) &&
- ARE_EQUAL(AsmVerbose) &&
- ARE_EQUAL(DwarfVersion) &&
- ARE_EQUAL(ABIName) &&
- ARE_EQUAL(IASSearchPaths));
-#undef ARE_EQUAL
-}
-
-inline bool operator!=(const MCTargetOptions &LHS, const MCTargetOptions &RHS) {
- return !(LHS == RHS);
-}
+ /// getABIName - If this returns a non-empty string this represents the
+ /// textual name of the ABI that we want the backend to use, e.g. o32, or
+ /// aapcs-linux.
+ StringRef getABIName() const;
+};
} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCTARGETOPTIONS_H
diff --git a/include/llvm/MC/MCWasmObjectWriter.h b/include/llvm/MC/MCWasmObjectWriter.h
new file mode 100644
index 000000000000..6e458eaac9c8
--- /dev/null
+++ b/include/llvm/MC/MCWasmObjectWriter.h
@@ -0,0 +1,85 @@
+//===-- llvm/MC/MCWasmObjectWriter.h - Wasm Object Writer -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCWASMOBJECTWRITER_H
+#define LLVM_MC_MCWASMOBJECTWRITER_H
+
+#include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCValue.h"
+#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/raw_ostream.h"
+#include <vector>
+
+namespace llvm {
+class MCAssembler;
+class MCContext;
+class MCFixup;
+class MCFragment;
+class MCObjectWriter;
+class MCSectionWasm;
+class MCSymbol;
+class MCSymbolWasm;
+class MCValue;
+class raw_pwrite_stream;
+
+// Information about a single relocation.
+struct WasmRelocationEntry {
+ uint64_t Offset; // Where is the relocation.
+ const MCSymbolWasm *Symbol; // The symbol to relocate with.
+ uint64_t Addend; // A value to add to the symbol.
+ unsigned Type; // The type of the relocation.
+ MCSectionWasm *FixupSection;// The section the relocation is targeting.
+
+ WasmRelocationEntry(uint64_t Offset, const MCSymbolWasm *Symbol,
+ uint64_t Addend, unsigned Type,
+ MCSectionWasm *FixupSection)
+ : Offset(Offset), Symbol(Symbol), Addend(Addend), Type(Type),
+ FixupSection(FixupSection) {}
+
+ void print(raw_ostream &Out) const {
+ Out << "Off=" << Offset << ", Sym=" << Symbol << ", Addend=" << Addend
+ << ", Type=" << Type << ", FixupSection=" << FixupSection;
+ }
+ void dump() const { print(errs()); }
+};
+
+class MCWasmObjectTargetWriter {
+ const unsigned Is64Bit : 1;
+
+protected:
+ explicit MCWasmObjectTargetWriter(bool Is64Bit_);
+
+public:
+ virtual ~MCWasmObjectTargetWriter() {}
+
+ virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
+ const MCFixup &Fixup, bool IsPCRel) const = 0;
+
+ virtual bool needsRelocateWithSymbol(const MCSymbol &Sym,
+ unsigned Type) const;
+
+ virtual void sortRelocs(const MCAssembler &Asm,
+ std::vector<WasmRelocationEntry> &Relocs);
+
+ /// \name Accessors
+ /// @{
+ bool is64Bit() const { return Is64Bit; }
+ /// @}
+};
+
+/// \brief Construct a new Wasm writer instance.
+///
+/// \param MOTW - The target specific Wasm writer subclass.
+/// \param OS - The stream to write to.
+/// \returns The constructed object writer.
+MCObjectWriter *createWasmObjectWriter(MCWasmObjectTargetWriter *MOTW,
+ raw_pwrite_stream &OS);
+} // End llvm namespace
+
+#endif
diff --git a/include/llvm/MC/MCWasmStreamer.h b/include/llvm/MC/MCWasmStreamer.h
new file mode 100644
index 000000000000..bdd6f103cd44
--- /dev/null
+++ b/include/llvm/MC/MCWasmStreamer.h
@@ -0,0 +1,83 @@
+//===- MCWasmStreamer.h - MCStreamer Wasm Object File Interface -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCWASMSTREAMER_H
+#define LLVM_MC_MCWASMSTREAMER_H
+
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/MC/MCDirectives.h"
+#include "llvm/MC/MCObjectStreamer.h"
+#include "llvm/MC/SectionKind.h"
+#include "llvm/Support/DataTypes.h"
+
+namespace llvm {
+class MCAsmBackend;
+class MCAssembler;
+class MCCodeEmitter;
+class MCExpr;
+class MCInst;
+class raw_ostream;
+
+class MCWasmStreamer : public MCObjectStreamer {
+public:
+ MCWasmStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter)
+ : MCObjectStreamer(Context, TAB, OS, Emitter), SeenIdent(false) {}
+
+ ~MCWasmStreamer() override;
+
+ /// state management
+ void reset() override {
+ SeenIdent = false;
+ MCObjectStreamer::reset();
+ }
+
+ /// \name MCStreamer Interface
+ /// @{
+
+ void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
+ void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
+ void EmitThumbFunc(MCSymbol *Func) override;
+ void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
+ bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
+ void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
+ void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
+ unsigned ByteAlignment) override;
+
+ void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
+
+ void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
+ unsigned ByteAlignment) override;
+
+ void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
+ uint64_t Size = 0, unsigned ByteAlignment = 0) override;
+ void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
+ unsigned ByteAlignment = 0) override;
+ void EmitValueImpl(const MCExpr *Value, unsigned Size,
+ SMLoc Loc = SMLoc()) override;
+
+ void EmitIdent(StringRef IdentString) override;
+
+ void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
+
+ void FinishImpl() override;
+
+private:
+ void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
+ void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
+
+ /// \brief Merge the content of the fragment \p EF into the fragment \p DF.
+ void mergeFragment(MCDataFragment *, MCDataFragment *);
+
+ bool SeenIdent;
+};
+
+} // end namespace llvm
+
+#endif
diff --git a/include/llvm/MC/MCWinCOFFObjectWriter.h b/include/llvm/MC/MCWinCOFFObjectWriter.h
index e2e95c7df710..57bed213aad4 100644
--- a/include/llvm/MC/MCWinCOFFObjectWriter.h
+++ b/include/llvm/MC/MCWinCOFFObjectWriter.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCWinCOFFObjectWriter.h - Win COFF Object Writer *- C++ -*-===//
+//===- llvm/MC/MCWinCOFFObjectWriter.h - Win COFF Object Writer -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,22 +11,23 @@
#define LLVM_MC_MCWINCOFFOBJECTWRITER_H
namespace llvm {
+
class MCAsmBackend;
class MCFixup;
class MCObjectWriter;
class MCValue;
-class raw_ostream;
class raw_pwrite_stream;
class MCWinCOFFObjectTargetWriter {
virtual void anchor();
+
const unsigned Machine;
protected:
MCWinCOFFObjectTargetWriter(unsigned Machine_);
public:
- virtual ~MCWinCOFFObjectTargetWriter() {}
+ virtual ~MCWinCOFFObjectTargetWriter() = default;
unsigned getMachine() const { return Machine; }
virtual unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup,
@@ -42,6 +43,6 @@ class raw_pwrite_stream;
/// \returns The constructed object writer.
MCObjectWriter *createWinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW,
raw_pwrite_stream &OS);
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MCWINCOFFOBJECTWRITER_H
diff --git a/include/llvm/MC/MCWinCOFFStreamer.h b/include/llvm/MC/MCWinCOFFStreamer.h
index 63e44f2e67d6..84e60b85be6a 100644
--- a/include/llvm/MC/MCWinCOFFStreamer.h
+++ b/include/llvm/MC/MCWinCOFFStreamer.h
@@ -14,16 +14,15 @@
#include "llvm/MC/MCObjectStreamer.h"
namespace llvm {
+
class MCAsmBackend;
class MCContext;
class MCCodeEmitter;
-class MCExpr;
class MCInst;
class MCSection;
class MCSubtargetInfo;
class MCSymbol;
class StringRef;
-class raw_ostream;
class raw_pwrite_stream;
class MCWinCOFFStreamer : public MCObjectStreamer {
@@ -41,7 +40,7 @@ public:
/// \{
void InitSections(bool NoExecStack) override;
- void EmitLabel(MCSymbol *Symbol) override;
+ void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
void EmitThumbFunc(MCSymbol *Func) override;
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
@@ -61,7 +60,6 @@ public:
unsigned ByteAlignment) override;
void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) override;
- void EmitFileDirective(StringRef Filename) override;
void EmitIdent(StringRef IdentString) override;
void EmitWinEHHandlerData() override;
void FinishImpl() override;
@@ -70,12 +68,13 @@ public:
protected:
const MCSymbol *CurSymbol;
+
void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override;
private:
void Error(const Twine &Msg) const;
};
-}
-#endif
+} // end namespace llvm
+#endif // LLVM_MC_MCWINCOFFSTREAMER_H
diff --git a/include/llvm/MC/MachineLocation.h b/include/llvm/MC/MachineLocation.h
index 4b5cf4357793..f4fc6ee2fd19 100644
--- a/include/llvm/MC/MachineLocation.h
+++ b/include/llvm/MC/MachineLocation.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MachineLocation.h -------------------------------*- C++ -*-===//
+//===- llvm/MC/MachineLocation.h --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,35 +12,31 @@
// explicitly passing an offset to the constructor.
//===----------------------------------------------------------------------===//
-
#ifndef LLVM_MC_MACHINELOCATION_H
#define LLVM_MC_MACHINELOCATION_H
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
+#include <cstdint>
namespace llvm {
- class MCSymbol;
class MachineLocation {
private:
- bool IsRegister; // True if location is a register.
- unsigned Register; // gcc/gdb register number.
- int Offset; // Displacement if not register.
+ bool IsRegister = false; // True if location is a register.
+ unsigned Register = 0; // gcc/gdb register number.
+ int Offset = 0; // Displacement if not register.
+
public:
enum : uint32_t {
// The target register number for an abstract frame pointer. The value is
// an arbitrary value that doesn't collide with any real target register.
VirtualFP = ~0U
};
- MachineLocation()
- : IsRegister(false), Register(0), Offset(0) {}
+
+ MachineLocation() = default;
/// Create a direct register location.
- explicit MachineLocation(unsigned R)
- : IsRegister(true), Register(R), Offset(0) {}
+ explicit MachineLocation(unsigned R) : IsRegister(true), Register(R) {}
/// Create a register-indirect location with an offset.
- MachineLocation(unsigned R, int O)
- : IsRegister(false), Register(R), Offset(O) {}
+ MachineLocation(unsigned R, int O) : Register(R), Offset(O) {}
bool operator==(const MachineLocation &Other) const {
return IsRegister == Other.IsRegister && Register == Other.Register &&
@@ -56,12 +52,14 @@ public:
void setIsRegister(bool Is) { IsRegister = Is; }
void setRegister(unsigned R) { Register = R; }
void setOffset(int O) { Offset = O; }
+
/// Make this location a direct register location.
void set(unsigned R) {
IsRegister = true;
Register = R;
Offset = 0;
}
+
/// Make this location a register-indirect+offset location.
void set(unsigned R, int O) {
IsRegister = false;
@@ -74,6 +72,6 @@ inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
return !(LHS == RHS);
}
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_MACHINELOCATION_H
diff --git a/include/llvm/MC/StringTableBuilder.h b/include/llvm/MC/StringTableBuilder.h
index 7da444f7bfb1..0df3fcd63723 100644
--- a/include/llvm/MC/StringTableBuilder.h
+++ b/include/llvm/MC/StringTableBuilder.h
@@ -1,4 +1,4 @@
-//===-- StringTableBuilder.h - String table building utility ------*- C++ -*-=//
+//===- StringTableBuilder.h - String table building utility -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,9 +12,12 @@
#include "llvm/ADT/CachedHashString.h"
#include "llvm/ADT/DenseMap.h"
-#include <cassert>
+#include "llvm/ADT/StringRef.h"
+#include <cstddef>
+#include <cstdint>
namespace llvm {
+
class raw_ostream;
/// \brief Utility for building string tables with deduplicated suffixes.
@@ -67,6 +70,6 @@ private:
bool isFinalized() const { return Finalized; }
};
-} // end llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_STRINGTABLEBUILDER_H
diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h
index ed4abd772821..cb036671b752 100644
--- a/include/llvm/MC/SubtargetFeature.h
+++ b/include/llvm/MC/SubtargetFeature.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/SubtargetFeature.h - CPU characteristics --------*- C++ -*-===//
+//===- llvm/MC/SubtargetFeature.h - CPU characteristics ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,126 +7,124 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines and manages user or tool specified CPU characteristics.
-// The intent is to be able to package specific features that should or should
-// not be used on a specific target processor. A tool, such as llc, could, as
-// as example, gather chip info from the command line, a long with features
-// that should be used on that chip.
+/// \file Defines and manages user or tool specified CPU characteristics.
+/// The intent is to be able to package specific features that should or should
+/// not be used on a specific target processor. A tool, such as llc, could, as
+/// as example, gather chip info from the command line, a long with features
+/// that should be used on that chip.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_MC_SUBTARGETFEATURE_H
#define LLVM_MC_SUBTARGETFEATURE_H
-#include "llvm/ADT/Triple.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/StringRef.h"
#include <bitset>
+#include <initializer_list>
+#include <string>
#include <vector>
namespace llvm {
+
template <typename T> class ArrayRef;
- class raw_ostream;
- class StringRef;
+class raw_ostream;
+class Triple;
-// A container class for subtarget features.
-// This is convenient because std::bitset does not have a constructor
-// with an initializer list of set bits.
-const unsigned MAX_SUBTARGET_FEATURES = 128;
+const unsigned MAX_SUBTARGET_FEATURES = 192;
+/// Container class for subtarget features.
+/// This is convenient because std::bitset does not have a constructor
+/// with an initializer list of set bits.
class FeatureBitset : public std::bitset<MAX_SUBTARGET_FEATURES> {
public:
// Cannot inherit constructors because it's not supported by VC++..
- FeatureBitset() : bitset() {}
+ FeatureBitset() = default;
FeatureBitset(const bitset<MAX_SUBTARGET_FEATURES>& B) : bitset(B) {}
- FeatureBitset(std::initializer_list<unsigned> Init) : bitset() {
+ FeatureBitset(std::initializer_list<unsigned> Init) {
for (auto I : Init)
set(I);
}
};
//===----------------------------------------------------------------------===//
-///
-/// SubtargetFeatureKV - Used to provide key value pairs for feature and
-/// CPU bit flags.
-//
+
+/// Used to provide key value pairs for feature and CPU bit flags.
struct SubtargetFeatureKV {
- const char *Key; // K-V key string
- const char *Desc; // Help descriptor
- FeatureBitset Value; // K-V integer value
- FeatureBitset Implies; // K-V bit mask
+ const char *Key; ///< K-V key string
+ const char *Desc; ///< Help descriptor
+ FeatureBitset Value; ///< K-V integer value
+ FeatureBitset Implies; ///< K-V bit mask
- // Compare routine for std::lower_bound
+ /// Compare routine for std::lower_bound
bool operator<(StringRef S) const {
return StringRef(Key) < S;
}
- // Compare routine for std::is_sorted.
+ /// Compare routine for std::is_sorted.
bool operator<(const SubtargetFeatureKV &Other) const {
return StringRef(Key) < StringRef(Other.Key);
}
};
//===----------------------------------------------------------------------===//
-///
-/// SubtargetInfoKV - Used to provide key value pairs for CPU and arbitrary
-/// pointers.
-//
+
+/// Used to provide key value pairs for CPU and arbitrary pointers.
struct SubtargetInfoKV {
- const char *Key; // K-V key string
- const void *Value; // K-V pointer value
+ const char *Key; ///< K-V key string
+ const void *Value; ///< K-V pointer value
- // Compare routine for std::lower_bound
+ /// Compare routine for std::lower_bound
bool operator<(StringRef S) const {
return StringRef(Key) < S;
}
};
//===----------------------------------------------------------------------===//
+
+/// Manages the enabling and disabling of subtarget specific features.
///
-/// SubtargetFeatures - Manages the enabling and disabling of subtarget
-/// specific features. Features are encoded as a string of the form
+/// Features are encoded as a string of the form
/// "+attr1,+attr2,-attr3,...,+attrN"
/// A comma separates each feature from the next (all lowercase.)
/// Each of the remaining features is prefixed with + or - indicating whether
/// that feature should be enabled or disabled contrary to the cpu
/// specification.
-///
-
class SubtargetFeatures {
- std::vector<std::string> Features; // Subtarget features as a vector
+ std::vector<std::string> Features; ///< Subtarget features as a vector
+
public:
explicit SubtargetFeatures(StringRef Initial = "");
- /// Features string accessors.
+ /// Returns features as a string.
std::string getString() const;
- /// Adding Features.
+ /// Adds Features.
void AddFeature(StringRef String, bool Enable = true);
- /// ToggleFeature - Toggle a feature and update the feature bits.
+ /// Toggles a feature and update the feature bits.
static void ToggleFeature(FeatureBitset &Bits, StringRef String,
ArrayRef<SubtargetFeatureKV> FeatureTable);
- /// Apply the feature flag and update the feature bits.
+ /// Applies the feature flag and update the feature bits.
static void ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature,
ArrayRef<SubtargetFeatureKV> FeatureTable);
- /// Get feature bits of a CPU.
+ /// Returns feature bits of a CPU.
FeatureBitset getFeatureBits(StringRef CPU,
- ArrayRef<SubtargetFeatureKV> CPUTable,
- ArrayRef<SubtargetFeatureKV> FeatureTable);
+ ArrayRef<SubtargetFeatureKV> CPUTable,
+ ArrayRef<SubtargetFeatureKV> FeatureTable);
- /// Print feature string.
+ /// Prints feature string.
void print(raw_ostream &OS) const;
- // Dump feature info.
+ // Dumps feature info.
void dump() const;
/// Adds the default features for the specified target triple.
void getDefaultSubtargetFeatures(const Triple& Triple);
};
-} // End namespace llvm
+} // end namespace llvm
-#endif
+#endif // LLVM_MC_SUBTARGETFEATURE_H