diff options
Diffstat (limited to 'include/llvm/MC')
-rw-r--r-- | include/llvm/MC/EDInstInfo.h | 29 | ||||
-rw-r--r-- | include/llvm/MC/MCAsmInfo.h | 11 | ||||
-rw-r--r-- | include/llvm/MC/MCContext.h | 27 | ||||
-rw-r--r-- | include/llvm/MC/MCDisassembler.h | 12 | ||||
-rw-r--r-- | include/llvm/MC/MCObjectWriter.h | 2 | ||||
-rw-r--r-- | include/llvm/MC/MCParser/AsmParser.h | 15 | ||||
-rw-r--r-- | include/llvm/MC/MCParser/MCAsmLexer.h | 2 | ||||
-rw-r--r-- | include/llvm/MC/MCSectionELF.h | 43 | ||||
-rw-r--r-- | include/llvm/MC/MCSectionMachO.h | 24 |
9 files changed, 98 insertions, 67 deletions
diff --git a/include/llvm/MC/EDInstInfo.h b/include/llvm/MC/EDInstInfo.h new file mode 100644 index 000000000000..dded25521a27 --- /dev/null +++ b/include/llvm/MC/EDInstInfo.h @@ -0,0 +1,29 @@ +//===-- llvm/MC/EDInstInfo.h - EDis instruction info ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#ifndef EDINSTINFO_H +#define EDINSTINFO_H + +#include "llvm/System/DataTypes.h" + +namespace llvm { + +#define EDIS_MAX_OPERANDS 13 +#define EDIS_MAX_SYNTAXES 2 + +struct EDInstInfo { + uint8_t instructionType; + uint8_t numOperands; + uint8_t operandTypes[EDIS_MAX_OPERANDS]; + uint8_t operandFlags[EDIS_MAX_OPERANDS]; + const char operandOrders[EDIS_MAX_SYNTAXES][EDIS_MAX_OPERANDS]; +}; + +} // namespace llvm + +#endif diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 33def8618990..f57f6426e0ac 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -97,7 +97,11 @@ namespace llvm { /// AllowNameToStartWithDigit - This is true if the assembler allows symbol /// names to start with a digit (e.g., "0x0021"). This defaults to false. bool AllowNameToStartWithDigit; - + + /// AllowPeriodsInName - This is true if the assembler allows periods in + /// symbol names. This defaults to true. + bool AllowPeriodsInName; + //===--- Data Emission Directives -------------------------------------===// /// ZeroDirective - this should be set to the directive used to get some @@ -280,7 +284,7 @@ namespace llvm { /// getNonexecutableStackSection - Targets can implement this method to /// specify a section to switch to if the translation unit doesn't have any /// trampolines that require an executable stack. - virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const { + virtual const MCSection *getNonexecutableStackSection(MCContext &Ctx) const{ return 0; } @@ -341,6 +345,9 @@ namespace llvm { bool doesAllowNameToStartWithDigit() const { return AllowNameToStartWithDigit; } + bool doesAllowPeriodsInName() const { + return AllowPeriodsInName; + } const char *getZeroDirective() const { return ZeroDirective; } diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 968d55f214c7..4434341f5295 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -10,6 +10,7 @@ #ifndef LLVM_MC_MCCONTEXT_H #define LLVM_MC_MCCONTEXT_H +#include "llvm/MC/SectionKind.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Allocator.h" @@ -21,6 +22,7 @@ namespace llvm { class MCSymbol; class StringRef; class Twine; + class MCSectionMachO; /// MCContext - Context object for machine code objects. This class owns all /// of the sections that it creates. @@ -47,6 +49,8 @@ namespace llvm { /// We use a bump pointer allocator to avoid the need to track all allocated /// objects. BumpPtrAllocator Allocator; + + void *MachOUniquingMap, *ELFUniquingMap; public: explicit MCContext(const MCAsmInfo &MAI); ~MCContext(); @@ -72,6 +76,29 @@ namespace llvm { MCSymbol *LookupSymbol(StringRef Name) const; /// @} + + /// @name Section Managment + /// @{ + + /// getMachOSection - Return the MCSection for the specified mach-o section. + /// This requires the operands to be valid. + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, + unsigned TypeAndAttributes, + unsigned Reserved2, + SectionKind K); + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, + unsigned TypeAndAttributes, + SectionKind K) { + return getMachOSection(Segment, Section, TypeAndAttributes, 0, K); + } + + const MCSection *getELFSection(StringRef Section, unsigned Type, + unsigned Flags, SectionKind Kind, + bool IsExplicit = false); + + /// @} void *Allocate(unsigned Size, unsigned Align = 8) { return Allocator.Allocate(Size, Align); diff --git a/include/llvm/MC/MCDisassembler.h b/include/llvm/MC/MCDisassembler.h index ffa0e419cc52..dfb8ed5e8a10 100644 --- a/include/llvm/MC/MCDisassembler.h +++ b/include/llvm/MC/MCDisassembler.h @@ -16,6 +16,8 @@ namespace llvm { class MCInst; class MemoryObject; class raw_ostream; + +struct EDInstInfo; /// MCDisassembler - Superclass for all disassemblers. Consumes a memory region /// and provides an array of assembly instructions. @@ -43,7 +45,15 @@ public: const MemoryObject ®ion, uint64_t address, raw_ostream &vStream) const = 0; -}; + + /// getEDInfo - Returns the enhanced insturction information corresponding to + /// the disassembler. + /// + /// @return - An array of instruction information, with one entry for + /// each MCInst opcode this disassembler returns. + /// NULL if there is no info for this target. + virtual EDInstInfo *getEDInfo() const { return (EDInstInfo*)0; } +}; } // namespace llvm diff --git a/include/llvm/MC/MCObjectWriter.h b/include/llvm/MC/MCObjectWriter.h index f70a3d1851ea..522ee77826f8 100644 --- a/include/llvm/MC/MCObjectWriter.h +++ b/include/llvm/MC/MCObjectWriter.h @@ -49,7 +49,7 @@ protected: // Can only create subclasses. public: virtual ~MCObjectWriter(); - bool isLittleEndian() { return IsLittleEndian; } + bool isLittleEndian() const { return IsLittleEndian; } raw_ostream &getStream() { return OS; } diff --git a/include/llvm/MC/MCParser/AsmParser.h b/include/llvm/MC/MCParser/AsmParser.h index 23f4a1fb72a2..7a78906733af 100644 --- a/include/llvm/MC/MCParser/AsmParser.h +++ b/include/llvm/MC/MCParser/AsmParser.h @@ -14,7 +14,6 @@ #ifndef ASMPARSER_H #define ASMPARSER_H -#include <vector> #include "llvm/MC/MCParser/AsmLexer.h" #include "llvm/MC/MCParser/AsmCond.h" #include "llvm/MC/MCParser/MCAsmParser.h" @@ -22,6 +21,7 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/ADT/StringMap.h" +#include <vector> namespace llvm { class AsmCond; @@ -50,10 +50,6 @@ private: AsmCond TheCondState; std::vector<AsmCond> TheCondStack; - // FIXME: Figure out where this should leave, the code is a copy of that which - // is also used by TargetLoweringObjectFile. - mutable void *SectionUniquingMap; - /// DirectiveMap - This is a table handlers for directives. Each handler is /// invoked after the directive identifier is read and is responsible for /// parsing and validating the rest of the directive. The handler is passed @@ -97,13 +93,6 @@ public: private: MCSymbol *CreateSymbol(StringRef Name); - // FIXME: See comment on SectionUniquingMap. - const MCSection *getMachOSection(const StringRef &Segment, - const StringRef &Section, - unsigned TypeAndAttributes, - unsigned Reserved2, - SectionKind Kind) const; - bool ParseStatement(); bool TokError(const char *Msg); @@ -113,8 +102,6 @@ private: /// EnterIncludeFile - Enter the specified file. This returns true on failure. bool EnterIncludeFile(const std::string &Filename); - bool ParseConditionalAssemblyDirectives(StringRef Directive, - SMLoc DirectiveLoc); void EatToEndOfStatement(); bool ParseAssignment(const StringRef &Name); diff --git a/include/llvm/MC/MCParser/MCAsmLexer.h b/include/llvm/MC/MCParser/MCAsmLexer.h index 043c36330862..075b69b628a5 100644 --- a/include/llvm/MC/MCParser/MCAsmLexer.h +++ b/include/llvm/MC/MCParser/MCAsmLexer.h @@ -42,7 +42,7 @@ public: Plus, Minus, Tilde, Slash, // '/' LParen, RParen, LBrac, RBrac, LCurly, RCurly, - Star, Comma, Dollar, Equal, EqualEqual, + Star, Dot, Comma, Dollar, Equal, EqualEqual, Pipe, PipePipe, Caret, Amp, AmpAmp, Exclaim, ExclaimEqual, Percent, Hash, diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h index e550cd2c1111..7054668eb14e 100644 --- a/include/llvm/MC/MCSectionELF.h +++ b/include/llvm/MC/MCSectionELF.h @@ -36,16 +36,14 @@ class MCSectionELF : public MCSection { /// explicit section specified. bool IsExplicit; -protected: +private: + friend class MCContext; MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K, bool isExplicit) : MCSection(K), SectionName(Section), Type(type), Flags(flags), IsExplicit(isExplicit) {} + ~MCSectionELF(); public: - - static MCSectionELF *Create(StringRef Section, unsigned Type, - unsigned Flags, SectionKind K, bool isExplicit, - MCContext &Ctx); /// ShouldOmitSectionDirective - Decides whether a '.section' directive /// should be printed before the section name @@ -153,40 +151,33 @@ public: // This section holds Thread-Local Storage. SHF_TLS = 0x400U, + + + // Start of target-specific flags. + + /// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped + /// together by the linker to form the constant pool and the cp register is + /// set to the start of the constant pool by the boot code. + XCORE_SHF_CP_SECTION = 0x800U, - /// FIRST_TARGET_DEP_FLAG - This is the first flag that subclasses are - /// allowed to specify. - FIRST_TARGET_DEP_FLAG = 0x800U, - - /// TARGET_INDEP_SHF - This is the bitmask for all the target independent - /// section flags. Targets can define their own target flags above these. - /// If they do that, they should implement their own MCSectionELF subclasses - /// and implement the virtual method hooks below to handle printing needs. - TARGET_INDEP_SHF = FIRST_TARGET_DEP_FLAG-1U + /// XCORE_SHF_DP_SECTION - All sections with the "d" flag are grouped + /// together by the linker to form the data section and the dp register is + /// set to the start of the section by the boot code. + XCORE_SHF_DP_SECTION = 0x1000U }; StringRef getSectionName() const { return SectionName; } unsigned getType() const { return Type; } unsigned getFlags() const { return Flags; } - virtual void PrintSwitchToSection(const MCAsmInfo &MAI, - raw_ostream &OS) const; + void PrintSwitchToSection(const MCAsmInfo &MAI, + raw_ostream &OS) const; /// isBaseAddressKnownZero - We know that non-allocatable sections (like /// debug info) have a base of zero. virtual bool isBaseAddressKnownZero() const { return (getFlags() & SHF_ALLOC) == 0; } - - /// PrintTargetSpecificSectionFlags - Targets that define their own - /// MCSectionELF subclasses with target specific section flags should - /// implement this method if they end up adding letters to the attributes - /// list. - virtual void PrintTargetSpecificSectionFlags(const MCAsmInfo &MAI, - raw_ostream &OS) const { - } - - }; } // end namespace llvm diff --git a/include/llvm/MC/MCSectionMachO.h b/include/llvm/MC/MCSectionMachO.h index 5839c281ed6f..f3bc8edd84ef 100644 --- a/include/llvm/MC/MCSectionMachO.h +++ b/include/llvm/MC/MCSectionMachO.h @@ -34,30 +34,10 @@ class MCSectionMachO : public MCSection { unsigned Reserved2; MCSectionMachO(StringRef Segment, StringRef Section, - unsigned TAA, unsigned reserved2, SectionKind K) - : MCSection(K), TypeAndAttributes(TAA), Reserved2(reserved2) { - assert(Segment.size() <= 16 && Section.size() <= 16 && - "Segment or section string too long"); - for (unsigned i = 0; i != 16; ++i) { - if (i < Segment.size()) - SegmentName[i] = Segment[i]; - else - SegmentName[i] = 0; - - if (i < Section.size()) - SectionName[i] = Section[i]; - else - SectionName[i] = 0; - } - } + unsigned TAA, unsigned reserved2, SectionKind K); + friend class MCContext; public: - static MCSectionMachO *Create(StringRef Segment, - StringRef Section, - unsigned TypeAndAttributes, - unsigned Reserved2, - SectionKind K, MCContext &Ctx); - /// These are the section type and attributes fields. A MachO section can /// have only one Type, but can have any of the attributes specified. enum { |