aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/MC
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-12-01 14:51:49 -0800
committerStephen Hines <srhines@google.com>2014-12-02 16:08:10 -0800
commit37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch)
tree8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /include/llvm/MC
parentd2327b22152ced7bc46dc629fc908959e8a52d03 (diff)
downloadexternal_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'include/llvm/MC')
-rw-r--r--include/llvm/MC/ConstantPools.h24
-rw-r--r--include/llvm/MC/MCAnalysis/MCAtom.h199
-rw-r--r--include/llvm/MC/MCAnalysis/MCFunction.h142
-rw-r--r--include/llvm/MC/MCAnalysis/MCModule.h134
-rw-r--r--include/llvm/MC/MCAnalysis/MCModuleYAML.h40
-rw-r--r--include/llvm/MC/MCAsmBackend.h4
-rw-r--r--include/llvm/MC/MCAsmInfo.h60
-rw-r--r--include/llvm/MC/MCAsmInfoELF.h3
-rw-r--r--include/llvm/MC/MCAssembler.h74
-rw-r--r--include/llvm/MC/MCContext.h13
-rw-r--r--include/llvm/MC/MCDisassembler.h31
-rw-r--r--include/llvm/MC/MCDwarf.h8
-rw-r--r--include/llvm/MC/MCELF.h4
-rw-r--r--include/llvm/MC/MCELFObjectWriter.h4
-rw-r--r--include/llvm/MC/MCELFStreamer.h13
-rw-r--r--include/llvm/MC/MCExpr.h50
-rw-r--r--include/llvm/MC/MCInstPrinter.h2
-rw-r--r--include/llvm/MC/MCInstrDesc.h46
-rw-r--r--include/llvm/MC/MCInstrItineraries.h59
-rw-r--r--include/llvm/MC/MCLinkerOptimizationHint.h2
-rw-r--r--include/llvm/MC/MCMachObjectWriter.h6
-rw-r--r--include/llvm/MC/MCObjectDisassembler.h174
-rw-r--r--include/llvm/MC/MCObjectFileInfo.h9
-rw-r--r--include/llvm/MC/MCObjectStreamer.h13
-rw-r--r--include/llvm/MC/MCObjectSymbolizer.h83
-rw-r--r--include/llvm/MC/MCParser/AsmLexer.h2
-rw-r--r--include/llvm/MC/MCParser/MCAsmLexer.h43
-rw-r--r--include/llvm/MC/MCParser/MCAsmParser.h73
-rw-r--r--include/llvm/MC/MCParser/MCAsmParserExtension.h9
-rw-r--r--include/llvm/MC/MCRegisterInfo.h13
-rw-r--r--include/llvm/MC/MCSchedule.h57
-rw-r--r--include/llvm/MC/MCSectionCOFF.h6
-rw-r--r--include/llvm/MC/MCStreamer.h76
-rw-r--r--include/llvm/MC/MCSubtargetInfo.h14
-rw-r--r--include/llvm/MC/MCTargetAsmParser.h43
-rw-r--r--include/llvm/MC/MCTargetOptions.h4
-rw-r--r--include/llvm/MC/MCWin64EH.h104
-rw-r--r--include/llvm/MC/MCWinCOFFStreamer.h8
-rw-r--r--include/llvm/MC/MCWinEH.h84
-rw-r--r--include/llvm/MC/StringTableBuilder.h16
-rw-r--r--include/llvm/MC/SubtargetFeature.h8
41 files changed, 577 insertions, 1180 deletions
diff --git a/include/llvm/MC/ConstantPools.h b/include/llvm/MC/ConstantPools.h
index 2819b75..1fc0332 100644
--- a/include/llvm/MC/ConstantPools.h
+++ b/include/llvm/MC/ConstantPools.h
@@ -12,20 +12,31 @@
//===----------------------------------------------------------------------===//
-#ifndef LLVM_MC_CONSTANTPOOL_H
-#define LLVM_MC_CONSTANTPOOL_H
+#ifndef LLVM_MC_CONSTANTPOOLS_H
+#define LLVM_MC_CONSTANTPOOLS_H
+#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
+
namespace llvm {
class MCContext;
class MCExpr;
class MCSection;
class MCStreamer;
class MCSymbol;
+
+struct ConstantPoolEntry {
+ ConstantPoolEntry(MCSymbol *L, const MCExpr *Val, unsigned Sz)
+ : Label(L), Value(Val), Size(Sz) {}
+ MCSymbol *Label;
+ const MCExpr *Value;
+ unsigned Size;
+};
+
// A class to keep track of assembler-generated constant pools that are use to
// implement the ldr-pseudo.
class ConstantPool {
- typedef SmallVector<std::pair<MCSymbol *, const MCExpr *>, 4> EntryVecTy;
+ typedef SmallVector<ConstantPoolEntry, 4> EntryVecTy;
EntryVecTy Entries;
public:
@@ -34,9 +45,11 @@ public:
// Add a new entry to the constant pool in the next slot.
// \param Value is the new entry to put in the constant pool.
+ // \param Size is the size in bytes of the entry
//
// \returns a MCExpr that references the newly inserted value
- const MCExpr *addEntry(const MCExpr *Value, MCContext &Context);
+ const MCExpr *addEntry(const MCExpr *Value, MCContext &Context,
+ unsigned Size);
// Emit the contents of the constant pool using the provided streamer.
void emitEntries(MCStreamer &Streamer);
@@ -69,7 +82,8 @@ public:
void emitAll(MCStreamer &Streamer);
void emitForCurrentSection(MCStreamer &Streamer);
- const MCExpr *addEntry(MCStreamer &Streamer, const MCExpr *Expr);
+ const MCExpr *addEntry(MCStreamer &Streamer, const MCExpr *Expr,
+ unsigned Size);
private:
ConstantPool *getConstantPool(const MCSection *Section);
diff --git a/include/llvm/MC/MCAnalysis/MCAtom.h b/include/llvm/MC/MCAnalysis/MCAtom.h
deleted file mode 100644
index 33f3431..0000000
--- a/include/llvm/MC/MCAnalysis/MCAtom.h
+++ /dev/null
@@ -1,199 +0,0 @@
-//===-- MCAtom.h ------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the declaration of the MCAtom class, which is used to
-// represent a contiguous region in a decoded object that is uniformly data or
-// instructions.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MC_MCANALYSIS_MCATOM_H
-#define LLVM_MC_MCANALYSIS_MCATOM_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/MC/MCInst.h"
-#include "llvm/Support/DataTypes.h"
-#include <vector>
-
-namespace llvm {
-
-class MCModule;
-
-class MCAtom;
-class MCTextAtom;
-class MCDataAtom;
-
-/// \brief Represents a contiguous range of either instructions (a TextAtom)
-/// or data (a DataAtom). Address ranges are expressed as _closed_ intervals.
-class MCAtom {
- virtual void anchor();
-public:
- virtual ~MCAtom() {}
-
- enum AtomKind { TextAtom, DataAtom };
- AtomKind getKind() const { return Kind; }
-
- /// \brief Get the start address of the atom.
- uint64_t getBeginAddr() const { return Begin; }
- /// \brief Get the end address, i.e. the last one inside the atom.
- uint64_t getEndAddr() const { return End; }
-
- /// \name Atom modification methods:
- /// When modifying a TextAtom, keep instruction boundaries in mind.
- /// For instance, split must me given the start address of an instruction.
- /// @{
-
- /// \brief Splits the atom in two at a given address.
- /// \param SplitPt Address at which to start a new atom, splitting this one.
- /// \returns The newly created atom starting at \p SplitPt.
- virtual MCAtom *split(uint64_t SplitPt) = 0;
-
- /// \brief Truncates an atom, discarding everything after \p TruncPt.
- /// \param TruncPt Last byte address to be contained in this atom.
- virtual void truncate(uint64_t TruncPt) = 0;
- /// @}
-
- /// \name Naming:
- ///
- /// This is mostly for display purposes, and may contain anything that hints
- /// at what the atom contains: section or symbol name, BB start address, ..
- /// @{
- StringRef getName() const { return Name; }
- void setName(StringRef NewName) { Name = NewName.str(); }
- /// @}
-
-protected:
- const AtomKind Kind;
- std::string Name;
- MCModule *Parent;
- uint64_t Begin, End;
-
- friend class MCModule;
- MCAtom(AtomKind K, MCModule *P, uint64_t B, uint64_t E)
- : Kind(K), Name("(unknown)"), Parent(P), Begin(B), End(E) { }
-
- /// \name Atom remapping helpers
- /// @{
-
- /// \brief Remap the atom, using the given range, updating Begin/End.
- /// One or both of the bounds can remain the same, but overlapping with other
- /// atoms in the module is still forbidden.
- void remap(uint64_t NewBegin, uint64_t NewEnd);
-
- /// \brief Remap the atom to prepare for a truncation at TruncPt.
- /// Equivalent to:
- /// \code
- /// // Bound checks
- /// remap(Begin, TruncPt);
- /// \endcode
- void remapForTruncate(uint64_t TruncPt);
-
- /// \brief Remap the atom to prepare for a split at SplitPt.
- /// The bounds for the resulting atoms are returned in {L,R}{Begin,End}.
- /// The current atom is truncated to \p LEnd.
- void remapForSplit(uint64_t SplitPt,
- uint64_t &LBegin, uint64_t &LEnd,
- uint64_t &RBegin, uint64_t &REnd);
- /// @}
-};
-
-/// \name Text atom
-/// @{
-
-/// \brief An entry in an MCTextAtom: a disassembled instruction.
-/// NOTE: Both the Address and Size field are actually redundant when taken in
-/// the context of the text atom, and may better be exposed in an iterator
-/// instead of stored in the atom, which would replace this class.
-class MCDecodedInst {
-public:
- MCInst Inst;
- uint64_t Address;
- uint64_t Size;
- MCDecodedInst(const MCInst &Inst, uint64_t Address, uint64_t Size)
- : Inst(Inst), Address(Address), Size(Size) {}
-};
-
-/// \brief An atom consisting of disassembled instructions.
-class MCTextAtom : public MCAtom {
-private:
- typedef std::vector<MCDecodedInst> InstListTy;
- InstListTy Insts;
-
- /// \brief The address of the next appended instruction, i.e., the
- /// address immediately after the last instruction in the atom.
- uint64_t NextInstAddress;
-public:
- /// Append an instruction, expanding the atom if necessary.
- void addInst(const MCInst &Inst, uint64_t Size);
-
- /// \name Instruction list access
- /// @{
- typedef InstListTy::const_iterator const_iterator;
- const_iterator begin() const { return Insts.begin(); }
- const_iterator end() const { return Insts.end(); }
-
- const MCDecodedInst &back() const { return Insts.back(); }
- const MCDecodedInst &at(size_t n) const { return Insts.at(n); }
- size_t size() const { return Insts.size(); }
- /// @}
-
- /// \name Atom type specific split/truncate logic.
- /// @{
- MCTextAtom *split(uint64_t SplitPt) override;
- void truncate(uint64_t TruncPt) override;
- /// @}
-
- // Class hierarchy.
- static bool classof(const MCAtom *A) { return A->getKind() == TextAtom; }
-private:
- friend class MCModule;
- // Private constructor - only callable by MCModule
- MCTextAtom(MCModule *P, uint64_t Begin, uint64_t End)
- : MCAtom(TextAtom, P, Begin, End), NextInstAddress(Begin) {}
-};
-/// @}
-
-/// \name Data atom
-/// @{
-
-/// \brief An entry in an MCDataAtom.
-// NOTE: This may change to a more complex type in the future.
-typedef uint8_t MCData;
-
-/// \brief An atom consising of a sequence of bytes.
-class MCDataAtom : public MCAtom {
- std::vector<MCData> Data;
-
-public:
- /// Append a data entry, expanding the atom if necessary.
- void addData(const MCData &D);
-
- /// Get a reference to the data in this atom.
- ArrayRef<MCData> getData() const { return Data; }
-
- /// \name Atom type specific split/truncate logic.
- /// @{
- MCDataAtom *split(uint64_t SplitPt) override;
- void truncate(uint64_t TruncPt) override;
- /// @}
-
- // Class hierarchy.
- static bool classof(const MCAtom *A) { return A->getKind() == DataAtom; }
-private:
- friend class MCModule;
- // Private constructor - only callable by MCModule
- MCDataAtom(MCModule *P, uint64_t Begin, uint64_t End)
- : MCAtom(DataAtom, P, Begin, End) {
- Data.reserve(End + 1 - Begin);
- }
-};
-
-}
-
-#endif
diff --git a/include/llvm/MC/MCAnalysis/MCFunction.h b/include/llvm/MC/MCAnalysis/MCFunction.h
deleted file mode 100644
index 44fa450..0000000
--- a/include/llvm/MC/MCAnalysis/MCFunction.h
+++ /dev/null
@@ -1,142 +0,0 @@
-//===-- MCFunction.h --------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the data structures to hold a CFG reconstructed from
-// machine code.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MC_MCANALYSIS_MCFUNCTION_H
-#define LLVM_MC_MCANALYSIS_MCFUNCTION_H
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/MC/MCInst.h"
-#include <memory>
-#include <string>
-#include <vector>
-
-namespace llvm {
-
-class MCFunction;
-class MCModule;
-class MCTextAtom;
-
-/// \brief Basic block containing a sequence of disassembled instructions.
-/// The basic block is backed by an MCTextAtom, which holds the instructions,
-/// and the address range it covers.
-/// Create a basic block using MCFunction::createBlock.
-class MCBasicBlock {
- const MCTextAtom *Insts;
-
- // MCFunction owns the basic block.
- MCFunction *Parent;
- friend class MCFunction;
- MCBasicBlock(const MCTextAtom &Insts, MCFunction *Parent);
-
- /// \name Predecessors/Successors, to represent the CFG.
- /// @{
- typedef std::vector<const MCBasicBlock *> BasicBlockListTy;
- BasicBlockListTy Successors;
- BasicBlockListTy Predecessors;
- /// @}
-public:
-
- /// \brief Get the backing MCTextAtom, containing the instruction sequence.
- const MCTextAtom *getInsts() const { return Insts; }
-
- /// \name Get the owning MCFunction.
- /// @{
- const MCFunction *getParent() const { return Parent; }
- MCFunction *getParent() { return Parent; }
- /// @}
-
- /// MC CFG access: Predecessors/Successors.
- /// @{
- typedef BasicBlockListTy::const_iterator succ_const_iterator;
- succ_const_iterator succ_begin() const { return Successors.begin(); }
- succ_const_iterator succ_end() const { return Successors.end(); }
-
- typedef BasicBlockListTy::const_iterator pred_const_iterator;
- pred_const_iterator pred_begin() const { return Predecessors.begin(); }
- pred_const_iterator pred_end() const { return Predecessors.end(); }
-
- void addSuccessor(const MCBasicBlock *MCBB);
- bool isSuccessor(const MCBasicBlock *MCBB) const;
-
- void addPredecessor(const MCBasicBlock *MCBB);
- bool isPredecessor(const MCBasicBlock *MCBB) const;
-
- /// \brief Split block, mirrorring NewAtom = Insts->split(..).
- /// This moves all successors to \p SplitBB, and
- /// adds a fallthrough to it.
- /// \p SplitBB The result of splitting Insts, a basic block directly following
- /// this basic block.
- void splitBasicBlock(MCBasicBlock *SplitBB);
- /// @}
-};
-
-/// \brief Represents a function in machine code, containing MCBasicBlocks.
-/// MCFunctions are created by MCModule.
-class MCFunction {
- MCFunction (const MCFunction&) LLVM_DELETED_FUNCTION;
- MCFunction& operator=(const MCFunction&) LLVM_DELETED_FUNCTION;
-
- std::string Name;
- MCModule *ParentModule;
- typedef std::vector<std::unique_ptr<MCBasicBlock>> BasicBlockListTy;
- BasicBlockListTy Blocks;
-
- // MCModule owns the function.
- friend class MCModule;
- MCFunction(StringRef Name, MCModule *Parent);
-
-public:
- /// \brief Create an MCBasicBlock backed by Insts and add it to this function.
- /// \param Insts Sequence of straight-line code backing the basic block.
- /// \returns The newly created basic block.
- MCBasicBlock &createBlock(const MCTextAtom &Insts);
-
- StringRef getName() const { return Name; }
-
- /// \name Get the owning MC Module.
- /// @{
- const MCModule *getParent() const { return ParentModule; }
- MCModule *getParent() { return ParentModule; }
- /// @}
-
- /// \name Access to the function's basic blocks. No ordering is enforced,
- /// except that the first block is the entry block.
- /// @{
- /// \brief Get the entry point basic block.
- const MCBasicBlock *getEntryBlock() const { return front(); }
- MCBasicBlock *getEntryBlock() { return front(); }
-
- bool empty() const { return Blocks.empty(); }
-
- typedef BasicBlockListTy::const_iterator const_iterator;
- typedef BasicBlockListTy:: iterator iterator;
- const_iterator begin() const { return Blocks.begin(); }
- iterator begin() { return Blocks.begin(); }
- const_iterator end() const { return Blocks.end(); }
- iterator end() { return Blocks.end(); }
-
- const MCBasicBlock* front() const { return Blocks.front().get(); }
- MCBasicBlock* front() { return Blocks.front().get(); }
- const MCBasicBlock* back() const { return Blocks.back().get(); }
- MCBasicBlock* back() { return Blocks.back().get(); }
-
- /// \brief Find the basic block, if any, that starts at \p StartAddr.
- const MCBasicBlock *find(uint64_t StartAddr) const;
- MCBasicBlock *find(uint64_t StartAddr);
- /// @}
-};
-
-}
-
-#endif
diff --git a/include/llvm/MC/MCAnalysis/MCModule.h b/include/llvm/MC/MCAnalysis/MCModule.h
deleted file mode 100644
index cf7e2c0..0000000
--- a/include/llvm/MC/MCAnalysis/MCModule.h
+++ /dev/null
@@ -1,134 +0,0 @@
-//===-- MCModule.h - MCModule class -----------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the declaration of the MCModule class, which is used to
-// represent a complete, disassembled object file or executable.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MC_MCANALYSIS_MCMODULE_H
-#define LLVM_MC_MCANALYSIS_MCMODULE_H
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
-#include <memory>
-#include <vector>
-
-namespace llvm {
-
-class MCAtom;
-class MCBasicBlock;
-class MCDataAtom;
-class MCFunction;
-class MCObjectDisassembler;
-class MCTextAtom;
-
-/// \brief A completely disassembled object file or executable.
-/// It comprises a list of MCAtom's, each representing a contiguous range of
-/// either instructions or data.
-/// An MCModule is created using MCObjectDisassembler::buildModule.
-class MCModule {
- /// \name Atom tracking
- /// @{
-
- /// \brief Atoms in this module, sorted by begin address.
- /// FIXME: This doesn't handle overlapping atoms (which happen when a basic
- /// block starts in the middle of an instruction of another basic block.)
- typedef std::vector<MCAtom*> AtomListTy;
- AtomListTy Atoms;
-
- // For access to map/remap.
- friend class MCAtom;
-
- /// \brief Remap \p Atom to the given range, and update its Begin/End fields.
- /// \param Atom An atom belonging to this module.
- /// An atom should always use this method to update its bounds, because this
- /// enables the owning MCModule to keep track of its atoms.
- void remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd);
-
- /// \brief Insert an atom in the module, using its Begin and End addresses.
- void map(MCAtom *NewAtom);
- /// @}
-
- /// \name Basic block tracking
- /// @{
- typedef std::vector<MCBasicBlock*> BBsByAtomTy;
- BBsByAtomTy BBsByAtom;
-
- // For access to basic block > atom tracking.
- friend class MCBasicBlock;
- friend class MCTextAtom;
-
- /// \brief Keep track of \p BBBackedByAtom as being backed by \p Atom.
- /// This is used to update succs/preds when \p Atom is split.
- void trackBBForAtom(const MCTextAtom *Atom, MCBasicBlock *BBBackedByAtom);
- void splitBasicBlocksForAtom(const MCTextAtom *TA, const MCTextAtom *NewTA);
- /// @}
-
- /// \name Function tracking
- /// @{
- typedef std::vector<std::unique_ptr<MCFunction>> FunctionListTy;
- FunctionListTy Functions;
- /// @}
-
- /// The address of the entrypoint function.
- uint64_t Entrypoint;
-
- MCModule (const MCModule &) LLVM_DELETED_FUNCTION;
- MCModule& operator=(const MCModule &) LLVM_DELETED_FUNCTION;
-
- // MCObjectDisassembler creates MCModules.
- friend class MCObjectDisassembler;
-
-public:
- MCModule();
- ~MCModule();
-
- /// \name Create a new MCAtom covering the specified offset range.
- /// @{
- MCTextAtom *createTextAtom(uint64_t Begin, uint64_t End);
- MCDataAtom *createDataAtom(uint64_t Begin, uint64_t End);
- /// @}
-
- /// \name Access to the owned atom list, ordered by begin address.
- /// @{
- const MCAtom *findAtomContaining(uint64_t Addr) const;
- MCAtom *findAtomContaining(uint64_t Addr);
- const MCAtom *findFirstAtomAfter(uint64_t Addr) const;
- MCAtom *findFirstAtomAfter(uint64_t Addr);
-
- typedef AtomListTy::const_iterator const_atom_iterator;
- typedef AtomListTy:: iterator atom_iterator;
- const_atom_iterator atom_begin() const { return Atoms.begin(); }
- atom_iterator atom_begin() { return Atoms.begin(); }
- const_atom_iterator atom_end() const { return Atoms.end(); }
- atom_iterator atom_end() { return Atoms.end(); }
- /// @}
-
- /// \brief Create a new MCFunction.
- MCFunction *createFunction(StringRef Name);
-
- /// \name Access to the owned function list.
- /// @{
- typedef FunctionListTy::const_iterator const_func_iterator;
- typedef FunctionListTy:: iterator func_iterator;
- const_func_iterator func_begin() const { return Functions.begin(); }
- func_iterator func_begin() { return Functions.begin(); }
- const_func_iterator func_end() const { return Functions.end(); }
- func_iterator func_end() { return Functions.end(); }
- /// @}
-
- /// \brief Get the address of the entrypoint function, or 0 if there is none.
- uint64_t getEntrypoint() const { return Entrypoint; }
-};
-
-}
-
-#endif
diff --git a/include/llvm/MC/MCAnalysis/MCModuleYAML.h b/include/llvm/MC/MCAnalysis/MCModuleYAML.h
deleted file mode 100644
index 4856277..0000000
--- a/include/llvm/MC/MCAnalysis/MCModuleYAML.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//===- MCModuleYAML.h - MCModule YAMLIO implementation ----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// \brief This file declares classes for handling the YAML representation
-/// of MCModule.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MC_MCANALYSIS_MCMODULEYAML_H
-#define LLVM_MC_MCANALYSIS_MCMODULEYAML_H
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/MC/MCAnalysis/MCModule.h"
-#include "llvm/Support/raw_ostream.h"
-
-namespace llvm {
-
-class MCInstrInfo;
-class MCRegisterInfo;
-
-/// \brief Dump a YAML representation of the MCModule \p MCM to \p OS.
-/// \returns The empty string on success, an error message on failure.
-StringRef mcmodule2yaml(raw_ostream &OS, const MCModule &MCM,
- const MCInstrInfo &MII, const MCRegisterInfo &MRI);
-
-/// \brief Creates a new module and returns it in \p MCM.
-/// \returns The empty string on success, an error message on failure.
-StringRef yaml2mcmodule(std::unique_ptr<MCModule> &MCM, StringRef YamlContent,
- const MCInstrInfo &MII, const MCRegisterInfo &MRI);
-
-} // end namespace llvm
-
-#endif
diff --git a/include/llvm/MC/MCAsmBackend.h b/include/llvm/MC/MCAsmBackend.h
index 82b65fd..15a956b 100644
--- a/include/llvm/MC/MCAsmBackend.h
+++ b/include/llvm/MC/MCAsmBackend.h
@@ -1,4 +1,4 @@
-//===-- llvm/MC/MCAsmBack.h - MC Asm Backend --------------------*- C++ -*-===//
+//===-- llvm/MC/MCAsmBackend.h - MC Asm Backend -----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -146,7 +146,7 @@ public:
/// \brief Generate the compact unwind encoding for the CFI instructions.
virtual uint32_t
- generateCompactUnwindEncoding(ArrayRef<MCCFIInstruction>) const {
+ generateCompactUnwindEncoding(ArrayRef<MCCFIInstruction>) const {
return 0;
}
};
diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h
index 06e473d..4f38aac 100644
--- a/include/llvm/MC/MCAsmInfo.h
+++ b/include/llvm/MC/MCAsmInfo.h
@@ -31,22 +31,22 @@ class MCContext;
namespace WinEH {
enum class EncodingType {
- ET_Invalid, /// Invalid
- ET_Alpha, /// Windows Alpha
- ET_Alpha64, /// Windows AXP64
- ET_ARM, /// Windows NT (Windows on ARM)
- ET_CE, /// Windows CE ARM, PowerPC, SH3, SH4
- ET_Itanium, /// Windows x64, Windows Itanium (IA-64)
- ET_MIPS = ET_Alpha,
+ Invalid, /// Invalid
+ Alpha, /// Windows Alpha
+ Alpha64, /// Windows AXP64
+ ARM, /// Windows NT (Windows on ARM)
+ CE, /// Windows CE ARM, PowerPC, SH3, SH4
+ Itanium, /// Windows x64, Windows Itanium (IA-64)
+ MIPS = Alpha,
};
}
enum class ExceptionHandling {
- None, /// No exception support
- DwarfCFI, /// DWARF-like instruction based exceptions
- SjLj, /// setjmp/longjmp based exceptions
- ARM, /// ARM EHABI
- WinEH, /// Windows Exception Handling
+ None, /// No exception support
+ DwarfCFI, /// DWARF-like instruction based exceptions
+ SjLj, /// setjmp/longjmp based exceptions
+ ARM, /// ARM EHABI
+ ItaniumWinEH, /// Itanium EH built on Windows unwind info (.pdata and .xdata)
};
namespace LCOMM {
@@ -87,16 +87,11 @@ protected:
bool HasMachoTBSSDirective;
/// True if the compiler should emit a ".reference .constructors_used" or
- /// ".reference .destructors_used" directive after the a static ctor/dtor
+ /// ".reference .destructors_used" directive after the static ctor/dtor
/// list. This directive is only emitted in Static relocation model. Default
/// is false.
bool HasStaticCtorDtorReferenceInStaticMode;
- /// True if the linker has a bug and requires that the debug_line section be
- /// of a minimum size. In practice such a linker requires a non-empty line
- /// sequence if a file is present. Default to false.
- bool LinkerRequiresNonEmptyDwarfLines;
-
/// 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;
@@ -223,8 +218,12 @@ protected:
/// This is the directive used to declare a global entity. Defaults to NULL.
const char *GlobalDirective;
- /// True if the assembler supports the .set directive. Defaults to true.
- bool HasSetDirective;
+ /// True if the expression
+ /// .long f - g
+ /// uses an relocation but it can be supressed by writting
+ /// a = f - g
+ /// .long a
+ bool SetDirectiveSuppressesReloc;
/// False if the assembler requires that we use
/// \code
@@ -295,9 +294,6 @@ protected:
//===--- Dwarf Emission Directives -----------------------------------===//
- /// True if target asm supports leb128 directives. Defaults to false.
- bool HasLEB128;
-
/// True if target supports emission of debugging information. Defaults to
/// false.
bool SupportsDebugInformation;
@@ -404,9 +400,6 @@ public:
bool hasStaticCtorDtorReferenceInStaticMode() const {
return HasStaticCtorDtorReferenceInStaticMode;
}
- bool getLinkerRequiresNonEmptyDwarfLines() const {
- return LinkerRequiresNonEmptyDwarfLines;
- }
unsigned getMaxInstLength() const { return MaxInstLength; }
unsigned getMinInstAlignment() const { return MinInstAlignment; }
bool getDollarIsPC() const { return DollarIsPC; }
@@ -445,7 +438,9 @@ public:
bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; }
unsigned getTextAlignFillValue() const { return TextAlignFillValue; }
const char *getGlobalDirective() const { return GlobalDirective; }
- bool hasSetDirective() const { return HasSetDirective; }
+ bool doesSetDirectiveSuppressesReloc() const {
+ return SetDirectiveSuppressesReloc;
+ }
bool hasAggressiveSymbolFolding() const { return HasAggressiveSymbolFolding; }
bool getCOMMDirectiveAlignmentIsInBytes() const {
return COMMDirectiveAlignmentIsInBytes;
@@ -471,19 +466,22 @@ public:
MCSymbolAttr getProtectedVisibilityAttr() const {
return ProtectedVisibilityAttr;
}
- bool hasLEB128() const { return HasLEB128; }
bool doesSupportDebugInformation() const { return SupportsDebugInformation; }
bool doesSupportExceptionHandling() const {
return ExceptionsType != ExceptionHandling::None;
}
ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; }
WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; }
- bool isExceptionHandlingDwarf() const {
+
+ /// Return true if the exception handling type uses the language-specific data
+ /// area (LSDA) format specified by the Itanium C++ ABI.
+ bool usesItaniumLSDAForExceptions() const {
return (ExceptionsType == ExceptionHandling::DwarfCFI ||
ExceptionsType == ExceptionHandling::ARM ||
- // Windows handler data still uses DWARF LSDA encoding.
- ExceptionsType == ExceptionHandling::WinEH);
+ // This Windows EH type uses the Itanium LSDA encoding.
+ ExceptionsType == ExceptionHandling::ItaniumWinEH);
}
+
bool doesDwarfUseRelocationsAcrossSections() const {
return DwarfUsesRelocationsAcrossSections;
}
diff --git a/include/llvm/MC/MCAsmInfoELF.h b/include/llvm/MC/MCAsmInfoELF.h
index 27fea84..7bd2460 100644
--- a/include/llvm/MC/MCAsmInfoELF.h
+++ b/include/llvm/MC/MCAsmInfoELF.h
@@ -15,6 +15,9 @@
namespace llvm {
class MCAsmInfoELF : public MCAsmInfo {
virtual void anchor();
+ const MCSection *
+ getNonexecutableStackSection(MCContext &Ctx) const override final;
+
protected:
MCAsmInfoELF();
};
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h
index 1cb34c2..681a317 100644
--- a/include/llvm/MC/MCAssembler.h
+++ b/include/llvm/MC/MCAssembler.h
@@ -11,6 +11,7 @@
#define LLVM_MC_MCASSEMBLER_H
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/ilist.h"
@@ -593,7 +594,10 @@ private:
unsigned Alignment;
/// \brief Keeping track of bundle-locked state.
- BundleLockStateType BundleLockState;
+ BundleLockStateType BundleLockState;
+
+ /// \brief Current nesting depth of bundle_lock directives.
+ unsigned BundleLockNestingDepth;
/// \brief We've seen a bundle_lock directive but not its first instruction
/// yet.
@@ -665,9 +669,7 @@ public:
return BundleLockState;
}
- void setBundleLockState(BundleLockStateType NewState) {
- BundleLockState = NewState;
- }
+ void setBundleLockState(BundleLockStateType NewState);
bool isBundleGroupBeforeFirstInst() const {
return BundleGroupBeforeFirstInst;
@@ -684,34 +686,27 @@ public:
// FIXME: Same concerns as with SectionData.
class MCSymbolData : public ilist_node<MCSymbolData> {
-public:
const MCSymbol *Symbol;
- /// Fragment - The fragment this symbol's value is relative to, if any.
- MCFragment *Fragment;
+ /// Fragment - The fragment this symbol's value is relative to, if any. Also
+ /// stores if this symbol is visible outside this translation unit (bit 0) or
+ /// if it is private extern (bit 1).
+ PointerIntPair<MCFragment *, 2> Fragment;
- /// Offset - The offset to apply to the fragment address to form this symbol's
- /// value.
- uint64_t Offset;
+ union {
+ /// Offset - The offset to apply to the fragment address to form this
+ /// symbol's value.
+ uint64_t Offset;
- /// IsExternal - True if this symbol is visible outside this translation
- /// unit.
- unsigned IsExternal : 1;
-
- /// IsPrivateExtern - True if this symbol is private extern.
- unsigned IsPrivateExtern : 1;
-
- /// CommonSize - The size of the symbol, if it is 'common', or 0.
- //
- // FIXME: Pack this in with other fields? We could put it in offset, since a
- // common symbol can never get a definition.
- uint64_t CommonSize;
+ /// CommonSize - The size of the symbol, if it is 'common'.
+ uint64_t CommonSize;
+ };
/// SymbolSize - 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;
- /// CommonAlign - The alignment of the symbol, if it is 'common'.
+ /// CommonAlign - The alignment of the symbol, if it is 'common', or -1.
//
// FIXME: Pack this in with other fields?
unsigned CommonAlign;
@@ -734,30 +729,41 @@ public:
const MCSymbol &getSymbol() const { return *Symbol; }
- MCFragment *getFragment() const { return Fragment; }
- void setFragment(MCFragment *Value) { Fragment = Value; }
+ MCFragment *getFragment() const { return Fragment.getPointer(); }
+ void setFragment(MCFragment *Value) { Fragment.setPointer(Value); }
- uint64_t getOffset() const { return Offset; }
- void setOffset(uint64_t Value) { Offset = Value; }
+ uint64_t getOffset() const {
+ assert(!isCommon());
+ return Offset;
+ }
+ void setOffset(uint64_t Value) {
+ assert(!isCommon());
+ Offset = Value;
+ }
/// @}
/// @name Symbol Attributes
/// @{
- bool isExternal() const { return IsExternal; }
- void setExternal(bool Value) { IsExternal = Value; }
+ bool isExternal() const { return Fragment.getInt() & 1; }
+ void setExternal(bool Value) {
+ Fragment.setInt((Fragment.getInt() & ~1) | unsigned(Value));
+ }
- bool isPrivateExtern() const { return IsPrivateExtern; }
- void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
+ bool isPrivateExtern() const { return Fragment.getInt() & 2; }
+ void setPrivateExtern(bool Value) {
+ Fragment.setInt((Fragment.getInt() & ~2) | (unsigned(Value) << 1));
+ }
/// isCommon - Is this a 'common' symbol.
- bool isCommon() const { return CommonSize != 0; }
+ bool isCommon() const { return CommonAlign != -1U; }
/// setCommon - Mark this symbol as being 'common'.
///
/// \param Size - The size of the symbol.
/// \param Align - The alignment of the symbol.
void setCommon(uint64_t Size, unsigned Align) {
+ assert(getOffset() == 0);
CommonSize = Size;
CommonAlign = Align;
}
@@ -910,7 +916,6 @@ private:
unsigned BundleAlignSize;
unsigned RelaxAll : 1;
- unsigned NoExecStack : 1;
unsigned SubsectionsViaSymbols : 1;
/// ELF specific e_header flags
@@ -1056,9 +1061,6 @@ public:
bool getRelaxAll() const { return RelaxAll; }
void setRelaxAll(bool Value) { RelaxAll = Value; }
- bool getNoExecStack() const { return NoExecStack; }
- void setNoExecStack(bool Value) { NoExecStack = Value; }
-
bool isBundlingEnabled() const {
return BundleAlignSize != 0;
}
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h
index eb0340f..f209448 100644
--- a/include/llvm/MC/MCContext.h
+++ b/include/llvm/MC/MCContext.h
@@ -73,6 +73,10 @@ namespace llvm {
/// Symbols - Bindings of names to symbols.
SymbolTable Symbols;
+ /// ELF sections can have a corresponding symbol. This maps one to the
+ /// other.
+ DenseMap<const MCSectionELF*, MCSymbol*> SectionSymbols;
+
/// A maping from a local label number and an instance count to a symbol.
/// For example, in the assembly
/// 1:
@@ -231,6 +235,8 @@ namespace llvm {
MCSymbol *GetOrCreateSymbol(StringRef Name);
MCSymbol *GetOrCreateSymbol(const Twine &Name);
+ MCSymbol *getOrCreateSectionSymbol(const MCSectionELF &Section);
+
/// LookupSymbol - Get the symbol for \p Name, or null.
MCSymbol *LookupSymbol(StringRef Name) const;
MCSymbol *LookupSymbol(const Twine &Name) const;
@@ -284,6 +290,13 @@ namespace llvm {
const MCSectionCOFF *getCOFFSection(StringRef Section);
+ /// Gets or creates a section equivalent to Sec that is associated with the
+ /// section containing KeySym. For example, to create a debug info section
+ /// associated with an inline function, pass the normal debug info section
+ /// as Sec and the function symbol as KeySym.
+ const MCSectionCOFF *getAssociativeCOFFSection(const MCSectionCOFF *Sec,
+ const MCSymbol *KeySym);
+
/// @}
/// @name Dwarf Management
diff --git a/include/llvm/MC/MCDisassembler.h b/include/llvm/MC/MCDisassembler.h
index 9d441bb..d6b0a30 100644
--- a/include/llvm/MC/MCDisassembler.h
+++ b/include/llvm/MC/MCDisassembler.h
@@ -10,6 +10,7 @@
#define LLVM_MC_MCDISASSEMBLER_H
#include "llvm-c/Disassembler.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/MC/MCRelocationInfo.h"
#include "llvm/MC/MCSymbolizer.h"
#include "llvm/Support/DataTypes.h"
@@ -18,12 +19,11 @@ namespace llvm {
class MCInst;
class MCSubtargetInfo;
-class MemoryObject;
class raw_ostream;
class MCContext;
-/// MCDisassembler - Superclass for all disassemblers. Consumes a memory region
-/// and provides an array of assembly instructions.
+/// Superclass for all disassemblers. Consumes a memory region and provides an
+/// array of assembly instructions.
class MCDisassembler {
public:
/// Ternary decode status. Most backends will just use Fail and
@@ -54,34 +54,31 @@ public:
Success = 3
};
- /// Constructor - Performs initial setup for the disassembler.
MCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx)
: Ctx(Ctx), STI(STI), Symbolizer(), CommentStream(nullptr) {}
virtual ~MCDisassembler();
- /// getInstruction - Returns the disassembly of a single instruction.
+ /// Returns the disassembly of a single instruction.
///
- /// @param instr - An MCInst to populate with the contents of the
+ /// @param Instr - An MCInst to populate with the contents of the
/// instruction.
- /// @param size - A value to populate with the size of the instruction, or
+ /// @param Size - A value to populate with the size of the instruction, or
/// the number of bytes consumed while attempting to decode
/// an invalid instruction.
- /// @param region - The memory object to use as a source for machine code.
- /// @param address - The address, in the memory space of region, of the first
+ /// @param Address - The address, in the memory space of region, of the first
/// byte of the instruction.
- /// @param vStream - The stream to print warnings and diagnostic messages on.
- /// @param cStream - The stream to print comments and annotations on.
+ /// @param VStream - The stream to print warnings and diagnostic messages on.
+ /// @param CStream - The stream to print comments and annotations on.
/// @return - MCDisassembler::Success if the instruction is valid,
/// MCDisassembler::SoftFail if the instruction was
/// disassemblable but invalid,
/// MCDisassembler::Fail if the instruction was invalid.
- virtual DecodeStatus getInstruction(MCInst& instr,
- uint64_t& size,
- const MemoryObject &region,
- uint64_t address,
- raw_ostream &vStream,
- raw_ostream &cStream) const = 0;
+ virtual DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
+ raw_ostream &VStream,
+ raw_ostream &CStream) const = 0;
+
private:
MCContext &Ctx;
diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h
index 6cd9a9a..a221d26 100644
--- a/include/llvm/MC/MCDwarf.h
+++ b/include/llvm/MC/MCDwarf.h
@@ -457,7 +457,7 @@ public:
return Offset;
}
- const StringRef getValues() const {
+ StringRef getValues() const {
assert(Operation == OpEscape);
return StringRef(&Values[0], Values.size());
}
@@ -466,13 +466,15 @@ public:
struct MCDwarfFrameInfo {
MCDwarfFrameInfo()
: Begin(nullptr), End(nullptr), Personality(nullptr), Lsda(nullptr),
- Instructions(), PersonalityEncoding(), LsdaEncoding(0),
- CompactUnwindEncoding(0), IsSignalFrame(false), IsSimple(false) {}
+ Instructions(), CurrentCfaRegister(0), PersonalityEncoding(),
+ LsdaEncoding(0), CompactUnwindEncoding(0), IsSignalFrame(false),
+ IsSimple(false) {}
MCSymbol *Begin;
MCSymbol *End;
const MCSymbol *Personality;
const MCSymbol *Lsda;
std::vector<MCCFIInstruction> Instructions;
+ unsigned CurrentCfaRegister;
unsigned PersonalityEncoding;
unsigned LsdaEncoding;
uint32_t CompactUnwindEncoding;
diff --git a/include/llvm/MC/MCELF.h b/include/llvm/MC/MCELF.h
index 7e59911..294a51b 100644
--- a/include/llvm/MC/MCELF.h
+++ b/include/llvm/MC/MCELF.h
@@ -27,9 +27,9 @@ class MCELF {
static void SetType(MCSymbolData &SD, unsigned Type);
static unsigned GetType(const MCSymbolData &SD);
static void SetVisibility(MCSymbolData &SD, unsigned Visibility);
- static unsigned GetVisibility(MCSymbolData &SD);
+ static unsigned GetVisibility(const MCSymbolData &SD);
static void setOther(MCSymbolData &SD, unsigned Other);
- static unsigned getOther(MCSymbolData &SD);
+ static unsigned getOther(const MCSymbolData &SD);
};
}
diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h
index 127f162..421e7a0 100644
--- a/include/llvm/MC/MCELFObjectWriter.h
+++ b/include/llvm/MC/MCELFObjectWriter.h
@@ -22,6 +22,7 @@ class MCFragment;
class MCObjectWriter;
class MCSectionData;
class MCSymbol;
+class MCSymbolData;
class MCValue;
class MCELFObjectTargetWriter {
@@ -54,7 +55,8 @@ public:
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel) const = 0;
- virtual bool needsRelocateWithSymbol(unsigned Type) const;
+ virtual bool needsRelocateWithSymbol(const MCSymbolData &SD,
+ unsigned Type) const;
/// @name Accessors
/// @{
diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h
index 66729fe..ab6c5e3 100644
--- a/include/llvm/MC/MCELFStreamer.h
+++ b/include/llvm/MC/MCELFStreamer.h
@@ -41,10 +41,18 @@ public:
virtual ~MCELFStreamer();
+ /// state management
+ void reset() override {
+ LocalCommons.clear();
+ BindingExplicitlySet.clear();
+ SeenIdent = false;
+ MCObjectStreamer::reset();
+ }
+
/// @name MCStreamer Interface
/// @{
- void InitSections() override;
+ void InitSections(bool NoExecStack) override;
void ChangeSection(const MCSection *Section,
const MCExpr *Subsection) override;
void EmitLabel(MCSymbol *Symbol) override;
@@ -107,8 +115,7 @@ private:
MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter,
- bool RelaxAll, bool NoExecStack,
- bool IsThumb);
+ bool RelaxAll, bool IsThumb);
} // end namespace llvm
diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h
index e96ecb4..f0e8611 100644
--- a/include/llvm/MC/MCExpr.h
+++ b/include/llvm/MC/MCExpr.h
@@ -19,6 +19,7 @@ class MCAsmInfo;
class MCAsmLayout;
class MCAssembler;
class MCContext;
+class MCFixup;
class MCSection;
class MCSectionData;
class MCStreamer;
@@ -49,11 +50,17 @@ private:
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
const SectionAddrMap *Addrs) const;
+
+ bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
+ const MCAsmLayout *Layout,
+ const SectionAddrMap *Addrs, bool InSet) const;
+
protected:
explicit MCExpr(ExprKind _Kind) : Kind(_Kind) {}
bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
+ const MCFixup *Fixup,
const SectionAddrMap *Addrs, bool InSet,
bool ForceVarExpansion) const;
@@ -87,13 +94,17 @@ public:
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;
bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
+ int64_t evaluateKnownAbsolute(const MCAsmLayout &Layout) const;
+
/// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable
/// value, i.e. an expression of the fixed form (a - b + constant).
///
/// @param Res - The relocatable value, if evaluation succeeds.
/// @param Layout - The assembler layout object to use for evaluating values.
+ /// @param Fixup - The Fixup object if available.
/// @result - True on success.
- bool EvaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout) const;
+ bool EvaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout,
+ const MCFixup *Fixup) const;
/// \brief Try to evaluate the expression to the form (a - b + constant) where
/// neither a nor b are variables.
@@ -101,7 +112,8 @@ public:
/// This is a more aggressive variant of EvaluateAsRelocatable. The intended
/// use is for when relocations are not available, like the symbol value in
/// the symbol table.
- bool EvaluateAsValue(MCValue &Res, const MCAsmLayout *Layout) const;
+ bool EvaluateAsValue(MCValue &Res, const MCAsmLayout *Layout,
+ const MCFixup *Fixup) const;
/// FindAssociatedSection - Find the "associated section" for this expression,
/// which is currently defined as the absolute section for constants, or
@@ -238,6 +250,7 @@ public:
VK_PPC_GOT_TLSLD_HI, // symbol@got@tlsld@h
VK_PPC_GOT_TLSLD_HA, // symbol@got@tlsld@ha
VK_PPC_TLSLD, // symbol@tlsld
+ VK_PPC_LOCAL, // symbol@local
VK_Mips_GPREL,
VK_Mips_GOT_CALL,
@@ -270,21 +283,20 @@ public:
};
private:
- /// The symbol being referenced.
- const MCSymbol *Symbol;
-
/// The symbol reference modifier.
- const VariantKind Kind;
+ const unsigned Kind : 16;
- /// MCAsmInfo that is used to print symbol variants correctly.
- const MCAsmInfo *MAI;
+ /// Specifies how the variant kind should be printed.
+ const unsigned UseParensForSymbolVariant : 1;
- explicit MCSymbolRefExpr(const MCSymbol *_Symbol, VariantKind _Kind,
- const MCAsmInfo *_MAI)
- : MCExpr(MCExpr::SymbolRef), Symbol(_Symbol), Kind(_Kind), MAI(_MAI) {
- assert(Symbol);
- assert(MAI);
- }
+ // FIXME: Remove this bit.
+ const unsigned HasSubsectionsViaSymbols : 1;
+
+ /// The symbol being referenced.
+ const MCSymbol *Symbol;
+
+ explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
+ const MCAsmInfo *MAI);
public:
/// @name Construction
@@ -304,9 +316,12 @@ public:
/// @{
const MCSymbol &getSymbol() const { return *Symbol; }
- const MCAsmInfo &getMCAsmInfo() const { return *MAI; }
- VariantKind getKind() const { return Kind; }
+ VariantKind getKind() const { return static_cast<VariantKind>(Kind); }
+
+ void printVariantKind(raw_ostream &OS) const;
+
+ bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
/// @}
/// @name Static Utility Functions
@@ -524,7 +539,8 @@ public:
virtual void PrintImpl(raw_ostream &OS) const = 0;
virtual bool EvaluateAsRelocatableImpl(MCValue &Res,
- const MCAsmLayout *Layout) const = 0;
+ const MCAsmLayout *Layout,
+ const MCFixup *Fixup) const = 0;
virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
virtual const MCSection *FindAssociatedSection() const = 0;
diff --git a/include/llvm/MC/MCInstPrinter.h b/include/llvm/MC/MCInstPrinter.h
index 7f55b29..95124c3 100644
--- a/include/llvm/MC/MCInstPrinter.h
+++ b/include/llvm/MC/MCInstPrinter.h
@@ -1,4 +1,4 @@
-//===-- MCInstPrinter.h - Convert an MCInst to target assembly syntax -----===//
+//===- MCInstPrinter.h - MCInst to target assembly syntax -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
diff --git a/include/llvm/MC/MCInstrDesc.h b/include/llvm/MC/MCInstrDesc.h
index 101778e..d4f93c1 100644
--- a/include/llvm/MC/MCInstrDesc.h
+++ b/include/llvm/MC/MCInstrDesc.h
@@ -125,7 +125,10 @@ namespace MCID {
Rematerializable,
CheapAsAMove,
ExtraSrcRegAllocReq,
- ExtraDefRegAllocReq
+ ExtraDefRegAllocReq,
+ RegSequence,
+ ExtractSubreg,
+ InsertSubreg
};
}
@@ -357,6 +360,47 @@ public:
return Flags & (1 << MCID::FoldableAsLoad);
}
+ /// \brief Return true if this instruction behaves
+ /// the same way as the generic REG_SEQUENCE instructions.
+ /// E.g., on ARM,
+ /// dX VMOVDRR rY, rZ
+ /// is equivalent to
+ /// dX = REG_SEQUENCE rY, ssub_0, rZ, ssub_1.
+ ///
+ /// Note that for the optimizers to be able to take advantage of
+ /// this property, TargetInstrInfo::getRegSequenceLikeInputs has to be
+ /// override accordingly.
+ bool isRegSequenceLike() const { return Flags & (1 << MCID::RegSequence); }
+
+ /// \brief Return true if this instruction behaves
+ /// the same way as the generic EXTRACT_SUBREG instructions.
+ /// E.g., on ARM,
+ /// rX, rY VMOVRRD dZ
+ /// is equivalent to two EXTRACT_SUBREG:
+ /// rX = EXTRACT_SUBREG dZ, ssub_0
+ /// rY = EXTRACT_SUBREG dZ, ssub_1
+ ///
+ /// Note that for the optimizers to be able to take advantage of
+ /// this property, TargetInstrInfo::getExtractSubregLikeInputs has to be
+ /// override accordingly.
+ bool isExtractSubregLike() const {
+ return Flags & (1 << MCID::ExtractSubreg);
+ }
+
+ /// \brief Return true if this instruction behaves
+ /// the same way as the generic INSERT_SUBREG instructions.
+ /// E.g., on ARM,
+ /// dX = VSETLNi32 dY, rZ, Imm
+ /// is equivalent to a INSERT_SUBREG:
+ /// dX = INSERT_SUBREG dY, rZ, translateImmToSubIdx(Imm)
+ ///
+ /// Note that for the optimizers to be able to take advantage of
+ /// this property, TargetInstrInfo::getInsertSubregLikeInputs has to be
+ /// override accordingly.
+ bool isInsertSubregLike() const {
+ return Flags & (1 << MCID::InsertSubreg);
+ }
+
//===--------------------------------------------------------------------===//
// Side Effect Analysis
//===--------------------------------------------------------------------===//
diff --git a/include/llvm/MC/MCInstrItineraries.h b/include/llvm/MC/MCInstrItineraries.h
index 5104345..94d599f 100644
--- a/include/llvm/MC/MCInstrItineraries.h
+++ b/include/llvm/MC/MCInstrItineraries.h
@@ -22,7 +22,7 @@
namespace llvm {
//===----------------------------------------------------------------------===//
-/// Instruction stage - These values represent a non-pipelined step in
+/// These values represent a non-pipelined step in
/// the execution of an instruction. Cycles represents the number of
/// discrete time slots needed to complete the stage. Units represent
/// the choice of functional units that can be used to complete the
@@ -67,12 +67,12 @@ struct InstrStage {
int NextCycles_; ///< Number of machine cycles to next stage
ReservationKinds Kind_; ///< Kind of the FU reservation
- /// getCycles - returns the number of cycles the stage is occupied
+ /// Returns the number of cycles the stage is occupied.
unsigned getCycles() const {
return Cycles_;
}
- /// getUnits - returns the choice of FUs
+ /// Returns the choice of FUs.
unsigned getUnits() const {
return Units_;
}
@@ -81,7 +81,7 @@ struct InstrStage {
return Kind_;
}
- /// getNextCycles - returns the number of cycles from the start of
+ /// Returns the number of cycles from the start of
/// this stage to the start of the next stage in the itinerary
unsigned getNextCycles() const {
return (NextCycles_ >= 0) ? (unsigned)NextCycles_ : Cycles_;
@@ -90,10 +90,9 @@ struct InstrStage {
//===----------------------------------------------------------------------===//
-/// Instruction itinerary - An itinerary represents the scheduling
-/// information for an instruction. This includes a set of stages
-/// occupies by the instruction, and the pipeline cycle in which
-/// operands are read and written.
+/// An itinerary represents the scheduling information for an instruction.
+/// This includes a set of stages occupied by the instruction and the pipeline
+/// cycle in which operands are read and written.
///
struct InstrItinerary {
int NumMicroOps; ///< # of micro-ops, -1 means it's variable
@@ -105,12 +104,11 @@ struct InstrItinerary {
//===----------------------------------------------------------------------===//
-/// Instruction itinerary Data - Itinerary data supplied by a subtarget to be
-/// used by a target.
+/// Itinerary data supplied by a subtarget to be used by a target.
///
class InstrItineraryData {
public:
- const MCSchedModel *SchedModel; ///< Basic machine properties.
+ 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 pathes
@@ -118,45 +116,38 @@ public:
/// Ctors.
///
- InstrItineraryData() : SchedModel(&MCSchedModel::DefaultSchedModel),
+ InstrItineraryData() : SchedModel(MCSchedModel::GetDefaultSchedModel()),
Stages(nullptr), OperandCycles(nullptr),
Forwardings(nullptr), Itineraries(nullptr) {}
- InstrItineraryData(const MCSchedModel *SM, const InstrStage *S,
+ InstrItineraryData(const MCSchedModel &SM, const InstrStage *S,
const unsigned *OS, const unsigned *F)
: SchedModel(SM), Stages(S), OperandCycles(OS), Forwardings(F),
- Itineraries(SchedModel->InstrItineraries) {}
+ Itineraries(SchedModel.InstrItineraries) {}
- /// isEmpty - Returns true if there are no itineraries.
- ///
+ /// Returns true if there are no itineraries.
bool isEmpty() const { return Itineraries == nullptr; }
- /// isEndMarker - Returns true if the index is for the end marker
- /// itinerary.
- ///
+ /// Returns true if the index is for the end marker itinerary.
bool isEndMarker(unsigned ItinClassIndx) const {
return ((Itineraries[ItinClassIndx].FirstStage == ~0U) &&
(Itineraries[ItinClassIndx].LastStage == ~0U));
}
- /// beginStage - Return the first stage of the itinerary.
- ///
+ /// Return the first stage of the itinerary.
const InstrStage *beginStage(unsigned ItinClassIndx) const {
unsigned StageIdx = Itineraries[ItinClassIndx].FirstStage;
return Stages + StageIdx;
}
- /// endStage - Return the last+1 stage of the itinerary.
- ///
+ /// Return the last+1 stage of the itinerary.
const InstrStage *endStage(unsigned ItinClassIndx) const {
unsigned StageIdx = Itineraries[ItinClassIndx].LastStage;
return Stages + StageIdx;
}
- /// getStageLatency - Return the total stage latency of the given
- /// class. The latency is the maximum completion time for any stage
- /// in the itinerary.
- ///
+ /// Return the total stage latency of the given class.
+ /// The latency is the maximum completion time for any stage in the itinerary.
/// If no stages exist, it defaults to one cycle.
unsigned getStageLatency(unsigned ItinClassIndx) const {
// If the target doesn't provide itinerary information, use a simple
@@ -174,9 +165,8 @@ public:
return Latency;
}
- /// getOperandCycle - Return the cycle for the given class and
- /// operand. Return -1 if no cycle is specified for the operand.
- ///
+ /// Return the cycle for the given class and operand.
+ /// Return -1 if no cycle is specified for the operand.
int getOperandCycle(unsigned ItinClassIndx, unsigned OperandIdx) const {
if (isEmpty())
return -1;
@@ -189,7 +179,7 @@ public:
return (int)OperandCycles[FirstIdx + OperandIdx];
}
- /// hasPipelineForwarding - Return true if there is a pipeline forwarding
+ /// Return true if there is a pipeline forwarding
/// between instructions of itinerary classes DefClass and UseClasses so that
/// value produced by an instruction of itinerary class DefClass, operand
/// index DefIdx can be bypassed when it's read by an instruction of
@@ -212,7 +202,7 @@ public:
Forwardings[FirstUseIdx + UseIdx];
}
- /// getOperandLatency - Compute and return the use operand latency of a given
+ /// Compute and return the use operand latency of a given
/// itinerary class and operand index if the value is produced by an
/// instruction of the specified itinerary class and def operand index.
int getOperandLatency(unsigned DefClass, unsigned DefIdx,
@@ -236,9 +226,8 @@ public:
return UseCycle;
}
- /// getNumMicroOps - Return the number of micro-ops that the given class
- /// decodes to. Return -1 for classes that require dynamic lookup via
- /// TargetInstrInfo.
+ /// Return the number of micro-ops that the given class decodes to.
+ /// Return -1 for classes that require dynamic lookup via TargetInstrInfo.
int getNumMicroOps(unsigned ItinClassIndx) const {
if (isEmpty())
return 1;
diff --git a/include/llvm/MC/MCLinkerOptimizationHint.h b/include/llvm/MC/MCLinkerOptimizationHint.h
index 50fd527..1f91b0d 100644
--- a/include/llvm/MC/MCLinkerOptimizationHint.h
+++ b/include/llvm/MC/MCLinkerOptimizationHint.h
@@ -45,7 +45,7 @@ static inline StringRef MCLOHDirectiveName() {
return StringRef(".loh");
}
-static inline bool isValidMCLOHType(MCLOHType Kind) {
+static inline bool isValidMCLOHType(unsigned Kind) {
return Kind >= MCLOH_AdrpAdrp && Kind <= MCLOH_AdrpLdrGot;
}
diff --git a/include/llvm/MC/MCMachObjectWriter.h b/include/llvm/MC/MCMachObjectWriter.h
index 12a7f0e..0c5aa8a 100644
--- a/include/llvm/MC/MCMachObjectWriter.h
+++ b/include/llvm/MC/MCMachObjectWriter.h
@@ -14,6 +14,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectWriter.h"
+#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MachO.h"
#include <vector>
@@ -104,7 +105,7 @@ class MachObjectWriter : public MCObjectWriter {
/// @name Symbol Table Data
/// @{
- SmallString<256> StringTable;
+ StringTableBuilder StringTable;
std::vector<MachSymbolData> LocalSymbolData;
std::vector<MachSymbolData> ExternalSymbolData;
std::vector<MachSymbolData> UndefinedSymbolData;
@@ -239,8 +240,7 @@ public:
/// ComputeSymbolTable - Compute the symbol table data
///
- /// \param StringTable [out] - The string table data.
- void ComputeSymbolTable(MCAssembler &Asm, SmallString<256> &StringTable,
+ void ComputeSymbolTable(MCAssembler &Asm,
std::vector<MachSymbolData> &LocalSymbolData,
std::vector<MachSymbolData> &ExternalSymbolData,
std::vector<MachSymbolData> &UndefinedSymbolData);
diff --git a/include/llvm/MC/MCObjectDisassembler.h b/include/llvm/MC/MCObjectDisassembler.h
deleted file mode 100644
index 5b935db..0000000
--- a/include/llvm/MC/MCObjectDisassembler.h
+++ /dev/null
@@ -1,174 +0,0 @@
-//===-- llvm/MC/MCObjectDisassembler.h --------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains the declaration of the MCObjectDisassembler class, which
-// can be used to construct an MCModule and an MC CFG from an ObjectFile.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MC_MCOBJECTDISASSEMBLER_H
-#define LLVM_MC_MCOBJECTDISASSEMBLER_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/MemoryObject.h"
-#include <vector>
-
-namespace llvm {
-
-namespace object {
- class ObjectFile;
- class MachOObjectFile;
-}
-
-class MCBasicBlock;
-class MCDisassembler;
-class MCFunction;
-class MCInstrAnalysis;
-class MCModule;
-class MCObjectSymbolizer;
-
-/// \brief Disassemble an ObjectFile to an MCModule and MCFunctions.
-/// This class builds on MCDisassembler to disassemble whole sections, creating
-/// MCAtom (MCTextAtom for disassembled sections and MCDataAtom for raw data).
-/// It can also be used to create a control flow graph consisting of MCFunctions
-/// and MCBasicBlocks.
-class MCObjectDisassembler {
-public:
- MCObjectDisassembler(const object::ObjectFile &Obj,
- const MCDisassembler &Dis,
- const MCInstrAnalysis &MIA);
- virtual ~MCObjectDisassembler() {}
-
- /// \brief Build an MCModule, creating atoms and optionally functions.
- /// \param withCFG Also build a CFG by adding MCFunctions to the Module.
- /// If withCFG is false, the MCModule built only contains atoms, representing
- /// what was found in the object file. If withCFG is true, MCFunctions are
- /// created, containing MCBasicBlocks. All text atoms are split to form basic
- /// block atoms, which then each back an MCBasicBlock.
- MCModule *buildModule(bool withCFG = false);
-
- MCModule *buildEmptyModule();
-
- typedef std::vector<uint64_t> AddressSetTy;
- /// \name Create a new MCFunction.
- MCFunction *createFunction(MCModule *Module, uint64_t BeginAddr,
- AddressSetTy &CallTargets,
- AddressSetTy &TailCallTargets);
-
- /// \brief Set the region on which to fallback if disassembly was requested
- /// somewhere not accessible in the object file.
- /// This is used for dynamic disassembly (see RawMemoryObject).
- void setFallbackRegion(std::unique_ptr<MemoryObject> &Region) {
- FallbackRegion.reset(Region.release());
- }
-
- /// \brief Set the symbolizer to use to get information on external functions.
- /// Note that this isn't used to do instruction-level symbolization (that is,
- /// plugged into MCDisassembler), but to symbolize function call targets.
- void setSymbolizer(MCObjectSymbolizer *ObjectSymbolizer) {
- MOS = ObjectSymbolizer;
- }
-
- /// \brief Get the effective address of the entrypoint, or 0 if there is none.
- virtual uint64_t getEntrypoint();
-
- /// \name Get the addresses of static constructors/destructors in the object.
- /// The caller is expected to know how to interpret the addresses;
- /// for example, Mach-O init functions expect 5 arguments, not for ELF.
- /// The addresses are original object file load addresses, not effective.
- /// @{
- virtual ArrayRef<uint64_t> getStaticInitFunctions();
- virtual ArrayRef<uint64_t> getStaticExitFunctions();
- /// @}
-
- /// \name Translation between effective and objectfile load address.
- /// @{
- /// \brief Compute the effective load address, from an objectfile virtual
- /// address. This is implemented in a format-specific way, to take into
- /// account things like PIE/ASLR when doing dynamic disassembly.
- /// For example, on Mach-O this would be done by adding the VM addr slide,
- /// on glibc ELF by keeping a map between segment load addresses, filled
- /// using dl_iterate_phdr, etc..
- /// In most static situations and in the default impl., this returns \p Addr.
- virtual uint64_t getEffectiveLoadAddr(uint64_t Addr);
-
- /// \brief Compute the original load address, as specified in the objectfile.
- /// This is the inverse of getEffectiveLoadAddr.
- virtual uint64_t getOriginalLoadAddr(uint64_t EffectiveAddr);
- /// @}
-
-protected:
- const object::ObjectFile &Obj;
- const MCDisassembler &Dis;
- const MCInstrAnalysis &MIA;
- MCObjectSymbolizer *MOS;
-
- /// \brief The fallback memory region, outside the object file.
- std::unique_ptr<MemoryObject> FallbackRegion;
-
- /// \brief Return a memory region suitable for reading starting at \p Addr.
- /// In most cases, this returns a StringRefMemoryObject backed by the
- /// containing section. When no section was found, this returns the
- /// FallbackRegion, if it is suitable.
- /// If it is not, or if there is no fallback region, this returns 0.
- MemoryObject *getRegionFor(uint64_t Addr);
-
-private:
- /// \brief Fill \p Module by creating an atom for each section.
- /// This could be made much smarter, using information like symbols, but also
- /// format-specific features, like mach-o function_start or data_in_code LCs.
- void buildSectionAtoms(MCModule *Module);
-
- /// \brief Enrich \p Module with a CFG consisting of MCFunctions.
- /// \param Module An MCModule returned by buildModule, with no CFG.
- /// NOTE: Each MCBasicBlock in a MCFunction is backed by a single MCTextAtom.
- /// When the CFG is built, contiguous instructions that were previously in a
- /// single MCTextAtom will be split in multiple basic block atoms.
- void buildCFG(MCModule *Module);
-
- MCBasicBlock *getBBAt(MCModule *Module, MCFunction *MCFN, uint64_t BeginAddr,
- AddressSetTy &CallTargets,
- AddressSetTy &TailCallTargets);
-};
-
-class MCMachOObjectDisassembler : public MCObjectDisassembler {
- const object::MachOObjectFile &MOOF;
-
- uint64_t VMAddrSlide;
- uint64_t HeaderLoadAddress;
-
- // __DATA;__mod_init_func support.
- llvm::StringRef ModInitContents;
- // __DATA;__mod_exit_func support.
- llvm::StringRef ModExitContents;
-
-public:
- /// \brief Construct a Mach-O specific object disassembler.
- /// \param VMAddrSlide The virtual address slide applied by dyld.
- /// \param HeaderLoadAddress The load address of the mach_header for this
- /// object.
- MCMachOObjectDisassembler(const object::MachOObjectFile &MOOF,
- const MCDisassembler &Dis,
- const MCInstrAnalysis &MIA, uint64_t VMAddrSlide,
- uint64_t HeaderLoadAddress);
-
-protected:
- uint64_t getEffectiveLoadAddr(uint64_t Addr) override;
- uint64_t getOriginalLoadAddr(uint64_t EffectiveAddr) override;
- uint64_t getEntrypoint() override;
-
- ArrayRef<uint64_t> getStaticInitFunctions() override;
- ArrayRef<uint64_t> getStaticExitFunctions() override;
-};
-
-}
-
-#endif
diff --git a/include/llvm/MC/MCObjectFileInfo.h b/include/llvm/MC/MCObjectFileInfo.h
index 4d1715e..321043c 100644
--- a/include/llvm/MC/MCObjectFileInfo.h
+++ b/include/llvm/MC/MCObjectFileInfo.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_MC_MCBJECTFILEINFO_H
-#define LLVM_MC_MCBJECTFILEINFO_H
+#ifndef LLVM_MC_MCOBJECTFILEINFO_H
+#define LLVM_MC_MCOBJECTFILEINFO_H
#include "llvm/ADT/Triple.h"
#include "llvm/Support/CodeGen.h"
@@ -116,6 +116,7 @@ protected:
/// These are used for the Fission separate debug information files.
const MCSection *DwarfInfoDWOSection;
+ const MCSection *DwarfTypesDWOSection;
const MCSection *DwarfAbbrevDWOSection;
const MCSection *DwarfStrDWOSection;
const MCSection *DwarfLineDWOSection;
@@ -261,7 +262,9 @@ public:
return DwarfInfoDWOSection;
}
const MCSection *getDwarfTypesSection(uint64_t Hash) const;
- const MCSection *getDwarfTypesDWOSection(uint64_t Hash) const;
+ const MCSection *getDwarfTypesDWOSection() const {
+ return DwarfTypesDWOSection;
+ }
const MCSection *getDwarfAbbrevDWOSection() const {
return DwarfAbbrevDWOSection;
}
diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h
index 8d37c85..0866ff5 100644
--- a/include/llvm/MC/MCObjectStreamer.h
+++ b/include/llvm/MC/MCObjectStreamer.h
@@ -10,6 +10,7 @@
#ifndef LLVM_MC_MCOBJECTSTREAMER_H
#define LLVM_MC_MCOBJECTSTREAMER_H
+#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCStreamer.h"
@@ -37,11 +38,16 @@ class MCObjectStreamer : public MCStreamer {
MCSectionData::iterator CurInsertionPoint;
bool EmitEHFrame;
bool EmitDebugFrame;
+ SmallVector<MCSymbolData *, 2> PendingLabels;
virtual void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo&) = 0;
void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
+ // If any labels have been emitted but not assigned fragments, ensure that
+ // they get assigned, either to F if possible or to a new data fragment.
+ void flushPendingLabels(MCFragment *F);
+
protected:
MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS,
MCCodeEmitter *_Emitter);
@@ -69,14 +75,15 @@ protected:
MCFragment *getCurrentFragment() const;
- void insert(MCFragment *F) const {
+ void insert(MCFragment *F) {
+ flushPendingLabels(F);
CurSectionData->getFragmentList().insert(CurInsertionPoint, F);
F->setParent(CurSectionData);
}
/// Get a data fragment to write into, creating a new one if the current
/// fragment is not a data fragment.
- MCDataFragment *getOrCreateDataFragment() const;
+ MCDataFragment *getOrCreateDataFragment();
public:
void visitUsedSymbol(const MCSymbol &Sym) override;
@@ -126,7 +133,7 @@ public:
void EmitZeros(uint64_t NumBytes) override;
void FinishImpl() override;
- virtual bool mayHaveInstructions() const {
+ bool mayHaveInstructions() const override {
return getCurrentSectionData()->hasInstructions();
}
};
diff --git a/include/llvm/MC/MCObjectSymbolizer.h b/include/llvm/MC/MCObjectSymbolizer.h
deleted file mode 100644
index f75b7f5..0000000
--- a/include/llvm/MC/MCObjectSymbolizer.h
+++ /dev/null
@@ -1,83 +0,0 @@
-//===-- llvm/MC/MCObjectSymbolizer.h --------------------------------------===//
-//
-// 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 MCObjectSymbolizer class, an MCSymbolizer that is
-// backed by an object::ObjectFile.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MC_MCOBJECTSYMBOLIZER_H
-#define LLVM_MC_MCOBJECTSYMBOLIZER_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/MC/MCSymbolizer.h"
-#include "llvm/Object/ObjectFile.h"
-#include <vector>
-
-namespace llvm {
-
-class MCExpr;
-class MCInst;
-class MCRelocationInfo;
-class raw_ostream;
-
-/// \brief An ObjectFile-backed symbolizer.
-class MCObjectSymbolizer : public MCSymbolizer {
-protected:
- const object::ObjectFile *Obj;
-
- // Map a load address to the first relocation that applies there. As far as I
- // know, if there are several relocations at the exact same address, they are
- // related and the others can be determined from the first that was found in
- // the relocation table. For instance, on x86-64 mach-o, a SUBTRACTOR
- // relocation (referencing the minuend symbol) is followed by an UNSIGNED
- // relocation (referencing the subtrahend symbol).
- const object::RelocationRef *findRelocationAt(uint64_t Addr);
- const object::SectionRef *findSectionContaining(uint64_t Addr);
-
- MCObjectSymbolizer(MCContext &Ctx, std::unique_ptr<MCRelocationInfo> RelInfo,
- const object::ObjectFile *Obj);
-
-public:
- /// \name Overridden MCSymbolizer methods:
- /// @{
- bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &cStream,
- int64_t Value, uint64_t Address,
- bool IsBranch, uint64_t Offset,
- uint64_t InstSize) override;
-
- void tryAddingPcLoadReferenceComment(raw_ostream &cStream,
- int64_t Value,
- uint64_t Address) override;
- /// @}
-
- /// \brief Look for an external function symbol at \p Addr.
- /// (References through the ELF PLT, Mach-O stubs, and similar).
- /// \returns An MCExpr representing the external symbol, or 0 if not found.
- virtual StringRef findExternalFunctionAt(uint64_t Addr);
-
- /// \brief Create an object symbolizer for \p Obj.
- static MCObjectSymbolizer *
- createObjectSymbolizer(MCContext &Ctx,
- std::unique_ptr<MCRelocationInfo> RelInfo,
- const object::ObjectFile *Obj);
-
-private:
- typedef DenseMap<uint64_t, object::RelocationRef> AddrToRelocMap;
- typedef std::vector<object::SectionRef> SortedSectionList;
- SortedSectionList SortedSections;
- AddrToRelocMap AddrToReloc;
-
- void buildSectionList();
- void buildRelocationByAddrMap();
-};
-
-}
-
-#endif
diff --git a/include/llvm/MC/MCParser/AsmLexer.h b/include/llvm/MC/MCParser/AsmLexer.h
index 0b550ba..a9a30f1 100644
--- a/include/llvm/MC/MCParser/AsmLexer.h
+++ b/include/llvm/MC/MCParser/AsmLexer.h
@@ -49,7 +49,7 @@ public:
const AsmToken peekTok(bool ShouldSkipSpace = true) override;
- bool isAtStartOfComment(char Char);
+ bool isAtStartOfComment(const char *Ptr);
bool isAtStatementSeparator(const char *Ptr);
const MCAsmInfo &getMAI() const { return MAI; }
diff --git a/include/llvm/MC/MCParser/MCAsmLexer.h b/include/llvm/MC/MCParser/MCAsmLexer.h
index e3d4181..b05891c 100644
--- a/include/llvm/MC/MCParser/MCAsmLexer.h
+++ b/include/llvm/MC/MCParser/MCAsmLexer.h
@@ -18,7 +18,7 @@
namespace llvm {
-/// AsmToken - Target independent representation for an assembler token.
+/// Target independent representation for an assembler token.
class AsmToken {
public:
enum TokenKind {
@@ -74,25 +74,26 @@ public:
SMLoc getLoc() const;
SMLoc getEndLoc() const;
+ SMRange getLocRange() const;
- /// getStringContents - Get the contents of a string token (without quotes).
+ /// Get the contents of a string token (without quotes).
StringRef getStringContents() const {
assert(Kind == String && "This token isn't a string!");
return Str.slice(1, Str.size() - 1);
}
- /// getIdentifier - Get the identifier string for the current token, which
- /// should be an identifier or a string. This gets the portion of the string
- /// which should be used as the identifier, e.g., it does not include the
- /// quotes on strings.
+ /// Get the identifier string for the current token, which should be an
+ /// identifier or a string. This gets the portion of the string which should
+ /// be used as the identifier, e.g., it does not include the quotes on
+ /// strings.
StringRef getIdentifier() const {
if (Kind == Identifier)
return getString();
return getStringContents();
}
- /// getString - Get the string for the current token, this includes all
- /// characters (for example, the quotes on strings) in the token.
+ /// Get the string for the current token, this includes all characters (for
+ /// example, the quotes on strings) in the token.
///
/// The returned StringRef points into the source manager's memory buffer, and
/// is safe to store across calls to Lex().
@@ -113,8 +114,8 @@ public:
}
};
-/// MCAsmLexer - Generic assembler lexer interface, for use by target specific
-/// assembly lexers.
+/// Generic assembler lexer interface, for use by target specific assembly
+/// lexers.
class MCAsmLexer {
/// The current token, stored in the base class for faster access.
AsmToken CurTok;
@@ -142,7 +143,7 @@ protected: // Can only create subclasses.
public:
virtual ~MCAsmLexer();
- /// Lex - Consume the next token from the input stream and return it.
+ /// Consume the next token from the input stream and return it.
///
/// The lexer will continuosly return the end-of-file token once the end of
/// the main input file has been reached.
@@ -152,37 +153,37 @@ public:
virtual StringRef LexUntilEndOfStatement() = 0;
- /// getLoc - Get the current source location.
+ /// Get the current source location.
SMLoc getLoc() const;
- /// getTok - Get the current (last) lexed token.
- const AsmToken &getTok() {
+ /// Get the current (last) lexed token.
+ const AsmToken &getTok() const {
return CurTok;
}
- /// peekTok - Look ahead at the next token to be lexed.
+ /// Look ahead at the next token to be lexed.
virtual const AsmToken peekTok(bool ShouldSkipSpace = true) = 0;
- /// getErrLoc - Get the current error location
+ /// Get the current error location
const SMLoc &getErrLoc() {
return ErrLoc;
}
- /// getErr - Get the current error string
+ /// Get the current error string
const std::string &getErr() {
return Err;
}
- /// getKind - Get the kind of current token.
+ /// Get the kind of current token.
AsmToken::TokenKind getKind() const { return CurTok.getKind(); }
- /// is - Check if the current token has kind \p K.
+ /// Check if the current token has kind \p K.
bool is(AsmToken::TokenKind K) const { return CurTok.is(K); }
- /// isNot - Check if the current token has kind \p K.
+ /// Check if the current token has kind \p K.
bool isNot(AsmToken::TokenKind K) const { return CurTok.isNot(K); }
- /// setSkipSpace - Set whether spaces should be ignored by the lexer
+ /// Set whether spaces should be ignored by the lexer
void setSkipSpace(bool val) { SkipSpace = val; }
bool getAllowAtInIdentifier() { return AllowAtInIdentifier; }
diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h
index 9836795..34188e6 100644
--- a/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/include/llvm/MC/MCParser/MCAsmParser.h
@@ -45,20 +45,22 @@ public:
}
};
-/// MCAsmParserSemaCallback - Generic Sema callback for assembly parser.
+/// Generic Sema callback for assembly parser.
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;
};
-/// MCAsmParser - Generic assembler parser interface, for use by target specific
-/// assembly parsers.
+/// Generic assembler parser interface, for use by target specific assembly
+/// parsers.
class MCAsmParser {
public:
typedef bool (*DirectiveHandler)(MCAsmParserExtension*, StringRef, SMLoc);
@@ -85,10 +87,13 @@ public:
virtual SourceMgr &getSourceManager() = 0;
virtual MCAsmLexer &getLexer() = 0;
+ const MCAsmLexer &getLexer() const {
+ return const_cast<MCAsmParser*>(this)->getLexer();
+ }
virtual MCContext &getContext() = 0;
- /// getStreamer - Return the output streamer for the assembler.
+ /// Return the output streamer for the assembler.
virtual MCStreamer &getStreamer() = 0;
MCTargetAsmParser &getTargetParser() const { return *TargetParser; }
@@ -100,51 +105,49 @@ public:
bool getShowParsedOperands() const { return ShowParsedOperands; }
void setShowParsedOperands(bool Value) { ShowParsedOperands = Value; }
- /// Run - Run the parser on the input source buffer.
+ /// Run the parser on the input source buffer.
virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false) = 0;
virtual void setParsingInlineAsm(bool V) = 0;
virtual bool isParsingInlineAsm() = 0;
- /// parseMSInlineAsm - Parse ms-style inline assembly.
- virtual bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
- unsigned &NumOutputs, unsigned &NumInputs,
- SmallVectorImpl<std::pair<void *, bool> > &OpDecls,
- SmallVectorImpl<std::string> &Constraints,
- SmallVectorImpl<std::string> &Clobbers,
- const MCInstrInfo *MII,
- const MCInstPrinter *IP,
- MCAsmParserSemaCallback &SI) = 0;
-
- /// Note - Emit a note at the location \p L, with the message \p Msg.
+ /// Parse ms-style inline assembly.
+ virtual bool parseMSInlineAsm(
+ void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
+ unsigned &NumInputs, SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
+ SmallVectorImpl<std::string> &Constraints,
+ SmallVectorImpl<std::string> &Clobbers, const MCInstrInfo *MII,
+ const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) = 0;
+
+ /// Emit a note at the location \p L, with the message \p Msg.
virtual void Note(SMLoc L, const Twine &Msg,
ArrayRef<SMRange> Ranges = None) = 0;
- /// Warning - Emit a warning at the location \p L, with the message \p Msg.
+ /// Emit a warning at the location \p L, with the message \p Msg.
///
/// \return The return value is true, if warnings are fatal.
virtual bool Warning(SMLoc L, const Twine &Msg,
ArrayRef<SMRange> Ranges = None) = 0;
- /// Error - Emit an error at the location \p L, with the message \p Msg.
+ /// Emit an error at the location \p L, with the message \p Msg.
///
/// \return The return value is always true, as an idiomatic convenience to
/// clients.
virtual bool Error(SMLoc L, const Twine &Msg,
ArrayRef<SMRange> Ranges = None) = 0;
- /// Lex - Get the next AsmToken in the stream, possibly handling file
- /// inclusion first.
+ /// Get the next AsmToken in the stream, possibly handling file inclusion
+ /// first.
virtual const AsmToken &Lex() = 0;
- /// getTok - Get the current AsmToken from the stream.
- const AsmToken &getTok();
+ /// Get the current AsmToken from the stream.
+ const AsmToken &getTok() const;
/// \brief Report an error at the current lexer location.
bool TokError(const Twine &Msg, ArrayRef<SMRange> Ranges = None);
- /// parseIdentifier - Parse an identifier or string (as a quoted identifier)
- /// and set \p Res to the identifier contents.
+ /// Parse an identifier or string (as a quoted identifier) and set \p Res to
+ /// the identifier contents.
virtual bool parseIdentifier(StringRef &Res) = 0;
/// \brief Parse up to the end of statement and return the contents from the
@@ -152,15 +155,14 @@ public:
/// will be either the EndOfStatement or EOF.
virtual StringRef parseStringToEndOfStatement() = 0;
- /// parseEscapedString - Parse the current token as a string which may include
- /// escaped characters and return the string contents.
+ /// Parse the current token as a string which may include escaped characters
+ /// and return the string contents.
virtual bool parseEscapedString(std::string &Data) = 0;
- /// eatToEndOfStatement - Skip to the end of the current statement, for error
- /// recovery.
+ /// Skip to the end of the current statement, for error recovery.
virtual void eatToEndOfStatement() = 0;
- /// parseExpression - Parse an arbitrary expression.
+ /// Parse an arbitrary expression.
///
/// @param Res - The value of the expression. The result is undefined
/// on error.
@@ -168,31 +170,30 @@ public:
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
bool parseExpression(const MCExpr *&Res);
- /// parsePrimaryExpr - Parse a primary expression.
+ /// Parse a primary expression.
///
/// @param Res - The value of the expression. The result is undefined
/// on error.
/// @result - False on success.
virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) = 0;
- /// parseParenExpression - Parse an arbitrary expression, assuming that an
- /// initial '(' has already been consumed.
+ /// Parse an arbitrary expression, assuming that an initial '(' has already
+ /// been consumed.
///
/// @param Res - The value of the expression. The result is undefined
/// on error.
/// @result - False on success.
virtual bool parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
- /// parseAbsoluteExpression - Parse an expression which must evaluate to an
- /// absolute value.
+ /// Parse an expression which must evaluate to an absolute value.
///
/// @param Res - The value of the absolute expression. The result is undefined
/// on error.
/// @result - False on success.
virtual bool parseAbsoluteExpression(int64_t &Res) = 0;
- /// checkForValidSection - Ensure that we have a valid section set in the
- /// streamer. Otherwise, report an error and switch to .text.
+ /// Ensure that we have a valid section set in the streamer. Otherwise, report
+ /// an error and switch to .text.
virtual void checkForValidSection() = 0;
};
diff --git a/include/llvm/MC/MCParser/MCAsmParserExtension.h b/include/llvm/MC/MCParser/MCAsmParserExtension.h
index 2eda3a9..bfc0afa 100644
--- a/include/llvm/MC/MCParser/MCAsmParserExtension.h
+++ b/include/llvm/MC/MCParser/MCAsmParserExtension.h
@@ -52,8 +52,17 @@ public:
/// @{
MCContext &getContext() { return getParser().getContext(); }
+
MCAsmLexer &getLexer() { return getParser().getLexer(); }
+ const MCAsmLexer &getLexer() const {
+ return const_cast<MCAsmParserExtension *>(this)->getLexer();
+ }
+
MCAsmParser &getParser() { return *Parser; }
+ const MCAsmParser &getParser() const {
+ return const_cast<MCAsmParserExtension*>(this)->getParser();
+ }
+
SourceMgr &getSourceManager() { return getParser().getSourceManager(); }
MCStreamer &getStreamer() { return getParser().getStreamer(); }
bool Warning(SMLoc L, const Twine &Msg) {
diff --git a/include/llvm/MC/MCRegisterInfo.h b/include/llvm/MC/MCRegisterInfo.h
index 766f631..df556e7 100644
--- a/include/llvm/MC/MCRegisterInfo.h
+++ b/include/llvm/MC/MCRegisterInfo.h
@@ -32,9 +32,9 @@ public:
typedef const MCPhysReg* iterator;
typedef const MCPhysReg* const_iterator;
- const char *Name;
const iterator RegsBegin;
const uint8_t *const RegSet;
+ const uint32_t NameIdx;
const uint16_t RegsSize;
const uint16_t RegSetSize;
const uint16_t ID;
@@ -46,10 +46,6 @@ public:
///
unsigned getID() const { return ID; }
- /// getName() - Return the register class name for debugging.
- ///
- const char *getName() const { return Name; }
-
/// begin/end - Return all of the registers in this class.
///
iterator begin() const { return RegsBegin; }
@@ -162,6 +158,7 @@ private:
const MCPhysReg (*RegUnitRoots)[2]; // Pointer to regunit root table.
const MCPhysReg *DiffLists; // Pointer to the difflists array
const char *RegStrings; // Pointer to the string table.
+ const char *RegClassStrings; // Pointer to the class strings.
const uint16_t *SubRegIndices; // Pointer to the subreg lookup
// array.
const SubRegCoveredBits *SubRegIdxRanges; // Pointer to the subreg covered
@@ -243,6 +240,7 @@ public:
unsigned NRU,
const MCPhysReg *DL,
const char *Strings,
+ const char *ClassStrings,
const uint16_t *SubIndices,
unsigned NumIndices,
const SubRegCoveredBits *SubIdxRanges,
@@ -254,6 +252,7 @@ public:
Classes = C;
DiffLists = DL;
RegStrings = Strings;
+ RegClassStrings = ClassStrings;
NumClasses = NC;
RegUnitRoots = RURoots;
NumRegUnits = NRU;
@@ -401,6 +400,10 @@ public:
return Classes[i];
}
+ const char *getRegClassName(const MCRegisterClass *Class) const {
+ return RegClassStrings + Class->NameIdx;
+ }
+
/// \brief Returns the encoding for RegNo
uint16_t getEncodingValue(unsigned RegNo) const {
assert(RegNo < NumRegs &&
diff --git a/include/llvm/MC/MCSchedule.h b/include/llvm/MC/MCSchedule.h
index 862a0fd..1adfedd 100644
--- a/include/llvm/MC/MCSchedule.h
+++ b/include/llvm/MC/MCSchedule.h
@@ -133,10 +133,7 @@ struct MCSchedClassDesc {
/// provides a detailed reservation table describing each cycle of instruction
/// execution. Subtargets may define any or all of the above categories of data
/// depending on the type of CPU and selected scheduler.
-class MCSchedModel {
-public:
- static MCSchedModel DefaultSchedModel; // For unknown processors.
-
+struct MCSchedModel {
// IssueWidth is the maximum number of instructions that may be scheduled in
// the same per-cycle group.
unsigned IssueWidth;
@@ -186,10 +183,11 @@ public:
// takes to recover from a branch misprediction.
unsigned MispredictPenalty;
static const unsigned DefaultMispredictPenalty = 10;
+
+ bool PostRAScheduler; // default value is false
bool CompleteModel;
-private:
unsigned ProcID;
const MCProcResourceDesc *ProcResourceTable;
const MCSchedClassDesc *SchedClassTable;
@@ -199,35 +197,6 @@ private:
friend class InstrItineraryData;
const InstrItinerary *InstrItineraries;
-public:
- // Default's must be specified as static const literals so that tablegenerated
- // target code can use it in static initializers. The defaults need to be
- // initialized in this default ctor because some clients directly instantiate
- // MCSchedModel instead of using a generated itinerary.
- MCSchedModel(): IssueWidth(DefaultIssueWidth),
- MicroOpBufferSize(DefaultMicroOpBufferSize),
- LoopMicroOpBufferSize(DefaultLoopMicroOpBufferSize),
- LoadLatency(DefaultLoadLatency),
- HighLatency(DefaultHighLatency),
- MispredictPenalty(DefaultMispredictPenalty),
- CompleteModel(true), ProcID(0), ProcResourceTable(nullptr),
- SchedClassTable(nullptr), NumProcResourceKinds(0),
- NumSchedClasses(0), InstrItineraries(nullptr) {
- (void)NumProcResourceKinds;
- (void)NumSchedClasses;
- }
-
- // Table-gen driven ctor.
- MCSchedModel(unsigned iw, int mbs, int lmbs, unsigned ll, unsigned hl,
- unsigned mp, bool cm, unsigned pi, const MCProcResourceDesc *pr,
- const MCSchedClassDesc *sc, unsigned npr, unsigned nsc,
- const InstrItinerary *ii):
- IssueWidth(iw), MicroOpBufferSize(mbs), LoopMicroOpBufferSize(lmbs),
- LoadLatency(ll), HighLatency(hl),
- MispredictPenalty(mp), CompleteModel(cm), ProcID(pi),
- ProcResourceTable(pr), SchedClassTable(sc), NumProcResourceKinds(npr),
- NumSchedClasses(nsc), InstrItineraries(ii) {}
-
unsigned getProcessorID() const { return ProcID; }
/// Does this machine model include instruction-level scheduling.
@@ -254,6 +223,26 @@ public:
assert(SchedClassIdx < NumSchedClasses && "bad scheduling class idx");
return &SchedClassTable[SchedClassIdx];
}
+
+ // /\brief Returns a default initialized model. Used for unknown processors.
+ static MCSchedModel GetDefaultSchedModel() {
+ MCSchedModel Ret = { DefaultIssueWidth,
+ DefaultMicroOpBufferSize,
+ DefaultLoopMicroOpBufferSize,
+ DefaultLoadLatency,
+ DefaultHighLatency,
+ DefaultMispredictPenalty,
+ false,
+ true,
+ 0,
+ nullptr,
+ nullptr,
+ 0,
+ 0,
+ nullptr
+ };
+ return Ret;
+ }
};
} // End llvm namespace
diff --git a/include/llvm/MC/MCSectionCOFF.h b/include/llvm/MC/MCSectionCOFF.h
index d205e2a..0bbf369 100644
--- a/include/llvm/MC/MCSectionCOFF.h
+++ b/include/llvm/MC/MCSectionCOFF.h
@@ -36,7 +36,7 @@ class MCSymbol;
/// The COMDAT symbol of this section. Only valid if this is a COMDAT
/// section. Two COMDAT sections are merged if they have the same
/// COMDAT symbol.
- const MCSymbol *COMDATSymbol;
+ MCSymbol *COMDATSymbol;
/// Selection - This is the Selection field for the section symbol, if
/// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
@@ -45,7 +45,7 @@ class MCSymbol;
private:
friend class MCContext;
MCSectionCOFF(StringRef Section, unsigned Characteristics,
- const MCSymbol *COMDATSymbol, int Selection, SectionKind K)
+ MCSymbol *COMDATSymbol, int Selection, SectionKind K)
: MCSection(SV_COFF, K), SectionName(Section),
Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
Selection(Selection) {
@@ -67,7 +67,7 @@ class MCSymbol;
return SectionName.str() + "_end";
}
unsigned getCharacteristics() const { return Characteristics; }
- const MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
+ MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
int getSelection() const { return Selection; }
void setSelection(int Selection) const;
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
index 216de75..df896a6 100644
--- a/include/llvm/MC/MCStreamer.h
+++ b/include/llvm/MC/MCStreamer.h
@@ -20,7 +20,7 @@
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCLinkerOptimizationHint.h"
-#include "llvm/MC/MCWin64EH.h"
+#include "llvm/MC/MCWinEH.h"
#include "llvm/Support/DataTypes.h"
#include <string>
@@ -91,18 +91,20 @@ public:
AArch64TargetStreamer(MCStreamer &S);
~AArch64TargetStreamer();
-
void finish() override;
/// Callback used to implement the ldr= pseudo.
/// Add a new entry to the constant pool for the current section and return an
/// MCExpr that can be used to refer to the constant pool location.
- const MCExpr *addConstantPoolEntry(const MCExpr *);
+ const MCExpr *addConstantPoolEntry(const MCExpr *, unsigned Size);
/// Callback used to implemnt the .ltorg directive.
/// Emit contents of constant pool for the current section.
void emitCurrentConstantPool();
+ /// Callback used to implement the .inst directive.
+ virtual void emitInst(uint32_t Inst);
+
private:
std::unique_ptr<AssemblerConstantPools> ConstantPools;
};
@@ -175,15 +177,15 @@ class MCStreamer {
MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION;
MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION;
- std::vector<MCDwarfFrameInfo> FrameInfos;
- MCDwarfFrameInfo *getCurrentFrameInfo();
+ std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
+ MCDwarfFrameInfo *getCurrentDwarfFrameInfo();
+ void EnsureValidDwarfFrame();
+
MCSymbol *EmitCFICommon();
- void EnsureValidFrame();
- std::vector<MCWin64EHUnwindInfo *> W64UnwindInfos;
- MCWin64EHUnwindInfo *CurrentW64UnwindInfo;
- void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame);
- void EnsureValidW64UnwindInfo();
+ std::vector<WinEH::FrameInfo *> WinFrameInfos;
+ WinEH::FrameInfo *CurrentWinFrameInfo;
+ void EnsureValidWinFrameInfo();
// SymbolOrdering - Tracks an index to represent the order
// a symbol was emitted in. Zero means we did not emit that symbol.
@@ -196,18 +198,14 @@ class MCStreamer {
protected:
MCStreamer(MCContext &Ctx);
- const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
- const MCSymbol *B);
-
- const MCExpr *ForceExpAbs(const MCExpr *Expr);
-
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
- MCWin64EHUnwindInfo *getCurrentW64UnwindInfo() {
- return CurrentW64UnwindInfo;
+ WinEH::FrameInfo *getCurrentWinFrameInfo() {
+ return CurrentWinFrameInfo;
}
- void EmitW64Tables();
+
+ virtual void EmitWindowsUnwindTables();
virtual void EmitRawTextImpl(StringRef String);
@@ -231,20 +229,14 @@ public:
return TargetStreamer.get();
}
- unsigned getNumFrameInfos() { return FrameInfos.size(); }
-
- const MCDwarfFrameInfo &getFrameInfo(unsigned i) { return FrameInfos[i]; }
-
- ArrayRef<MCDwarfFrameInfo> getFrameInfos() const { return FrameInfos; }
-
- unsigned getNumW64UnwindInfos() { return W64UnwindInfos.size(); }
-
- MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) {
- return *W64UnwindInfos[i];
+ unsigned getNumFrameInfos() { return DwarfFrameInfos.size(); }
+ ArrayRef<MCDwarfFrameInfo> getDwarfFrameInfos() const {
+ return DwarfFrameInfos;
}
- ArrayRef<MCWin64EHUnwindInfo *> getW64UnwindInfos() const {
- return W64UnwindInfos;
+ unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
+ ArrayRef<WinEH::FrameInfo *> getWinFrameInfos() const {
+ return WinFrameInfos;
}
void generateCompactUnwindEncodings(MCAsmBackend *MAB);
@@ -354,8 +346,8 @@ public:
/// @p Section. This is required to update CurSection.
///
/// This corresponds to assembler directives like .section, .text, etc.
- void SwitchSection(const MCSection *Section,
- const MCExpr *Subsection = nullptr) {
+ virtual void SwitchSection(const MCSection *Section,
+ const MCExpr *Subsection = nullptr) {
assert(Section && "Cannot switch to a null section!");
MCSectionSubPair curSection = SectionStack.back().first;
SectionStack.back().second = curSection;
@@ -378,7 +370,7 @@ public:
}
/// Create the default sections and set the initial one.
- virtual void InitSections();
+ virtual void InitSections(bool NoExecStack);
/// AssignSection - Sets the symbol's section.
///
@@ -557,12 +549,6 @@ public:
/// to pass in a MCExpr for constant integers.
virtual void EmitIntValue(uint64_t Value, unsigned Size);
- /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO
- /// this is done by producing
- /// foo = value
- /// .long foo
- void EmitAbsValue(const MCExpr *Value, unsigned Size);
-
virtual void EmitULEB128Value(const MCExpr *Value);
virtual void EmitSLEB128Value(const MCExpr *Value);
@@ -577,7 +563,8 @@ public:
/// EmitSymbolValue - Special case of EmitValue that avoids the client
/// having to pass in a MCExpr for MCSymbols.
- void EmitSymbolValue(const MCSymbol *Sym, unsigned Size);
+ void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
+ bool IsSectionRelative = false);
/// EmitGPRel64Value - Emit the expression @p Value into the output as a
/// gprel64 (64-bit GP relative) value.
@@ -673,11 +660,6 @@ public:
StringRef FileName);
virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
-
- void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
- int PointerSize);
-
- virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding);
virtual void EmitCFISections(bool EH, bool Debug);
void EmitCFIStartProc(bool IsSimple);
void EmitCFIEndProc();
@@ -786,8 +768,8 @@ MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
/// createELFStreamer - Create a machine code streamer which will generate
/// ELF format object files.
MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
- raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll,
- bool NoExecStack);
+ raw_ostream &OS, MCCodeEmitter *CE,
+ bool RelaxAll);
} // end namespace llvm
diff --git a/include/llvm/MC/MCSubtargetInfo.h b/include/llvm/MC/MCSubtargetInfo.h
index 088c5e7..9d09bd8 100644
--- a/include/llvm/MC/MCSubtargetInfo.h
+++ b/include/llvm/MC/MCSubtargetInfo.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_MC_MCSUBTARGET_H
-#define LLVM_MC_MCSUBTARGET_H
+#ifndef LLVM_MC_MCSUBTARGETINFO_H
+#define LLVM_MC_MCSUBTARGETINFO_H
#include "llvm/MC/MCInstrItineraries.h"
#include "llvm/MC/SubtargetFeature.h"
@@ -36,7 +36,7 @@ class MCSubtargetInfo {
const MCWriteProcResEntry *WriteProcResTable;
const MCWriteLatencyEntry *WriteLatencyTable;
const MCReadAdvanceEntry *ReadAdvanceTable;
- const MCSchedModel *CPUSchedModel;
+ MCSchedModel CPUSchedModel;
const InstrStage *Stages; // Instruction itinerary stages
const unsigned *OperandCycles; // Itinerary operand cycles
@@ -65,6 +65,10 @@ public:
return FeatureBits;
}
+ /// setFeatureBits - Set the feature bits.
+ ///
+ void setFeatureBits(uint64_t FeatureBits_) { FeatureBits = FeatureBits_; }
+
/// InitMCProcessorInfo - Set or change the CPU (optionally supplemented with
/// feature string). Recompute feature bits and scheduling model.
void InitMCProcessorInfo(StringRef CPU, StringRef FS);
@@ -82,11 +86,11 @@ public:
/// getSchedModelForCPU - Get the machine model of a CPU.
///
- const MCSchedModel *getSchedModelForCPU(StringRef CPU) const;
+ MCSchedModel getSchedModelForCPU(StringRef CPU) const;
/// getSchedModel - Get the machine model for this subtarget's CPU.
///
- const MCSchedModel *getSchedModel() const { return CPUSchedModel; }
+ const MCSchedModel &getSchedModel() const { return CPUSchedModel; }
/// Return an iterator at the first process resource consumed by the given
/// scheduling class.
diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h
index 384cc1b..cf92307 100644
--- a/include/llvm/MC/MCTargetAsmParser.h
+++ b/include/llvm/MC/MCTargetAsmParser.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_MC_TARGETPARSER_H
-#define LLVM_MC_TARGETPARSER_H
+#ifndef LLVM_MC_MCTARGETASMPARSER_H
+#define LLVM_MC_MCTARGETASMPARSER_H
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
@@ -38,20 +38,22 @@ enum AsmRewriteKind {
AOK_Input, // Rewrite in terms of $N.
AOK_Output, // Rewrite in terms of $N.
AOK_SizeDirective, // Add a sizing directive (e.g., dword ptr).
+ AOK_Label, // Rewrite local labels.
AOK_Skip // Skip emission (e.g., offset/type operators).
};
const char AsmRewritePrecedence [] = {
0, // AOK_Delete
- 1, // AOK_Align
- 1, // AOK_DotOperator
- 1, // AOK_Emit
- 3, // AOK_Imm
- 3, // AOK_ImmPrefix
- 2, // AOK_Input
- 2, // AOK_Output
- 4, // AOK_SizeDirective
- 1 // AOK_Skip
+ 2, // AOK_Align
+ 2, // AOK_DotOperator
+ 2, // AOK_Emit
+ 4, // AOK_Imm
+ 4, // AOK_ImmPrefix
+ 3, // AOK_Input
+ 3, // AOK_Output
+ 5, // AOK_SizeDirective
+ 1, // AOK_Label
+ 2 // AOK_Skip
};
struct AsmRewrite {
@@ -59,9 +61,12 @@ struct AsmRewrite {
SMLoc Loc;
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) {}
+ AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len, StringRef label)
+ : Kind(kind), Loc(loc), Len(len), Val(0), Label(label) {}
};
struct ParseInstructionInfo {
@@ -93,7 +98,7 @@ protected: // Can only create subclasses.
MCTargetAsmParser();
/// AvailableFeatures - The current set of available features.
- unsigned AvailableFeatures;
+ uint64_t AvailableFeatures;
/// ParsingInlineAsm - Are we parsing ms-style inline assembly?
bool ParsingInlineAsm;
@@ -108,12 +113,14 @@ protected: // Can only create subclasses.
public:
virtual ~MCTargetAsmParser();
- unsigned getAvailableFeatures() const { return AvailableFeatures; }
- void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
+ uint64_t getAvailableFeatures() const { return AvailableFeatures; }
+ void setAvailableFeatures(uint64_t Value) { AvailableFeatures = Value; }
bool isParsingInlineAsm () { return ParsingInlineAsm; }
void setParsingInlineAsm (bool Value) { ParsingInlineAsm = Value; }
+ MCTargetOptions getTargetOptions() const { return MCOptions; }
+
void setSemaCallback(MCAsmParserSemaCallback *Callback) {
SemaCallback = Callback;
}
@@ -121,6 +128,9 @@ public:
virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc,
SMLoc &EndLoc) = 0;
+ /// Sets frame register corresponding to the current MachineFunction.
+ virtual void SetFrameRegister(unsigned RegNo) {}
+
/// ParseInstruction - Parse one assembly instruction.
///
/// The parser is positioned following the instruction name. The target
@@ -161,9 +171,12 @@ public:
/// explaining the match failure.
virtual bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
OperandVector &Operands, MCStreamer &Out,
- unsigned &ErrorInfo,
+ uint64_t &ErrorInfo,
bool MatchingInlineAsm) = 0;
+ /// Allows targets to let registers opt out of clobber lists.
+ virtual bool OmitRegisterFromClobberLists(unsigned RegNo) { return false; }
+
/// Allow a target to add special case operand matching for things that
/// tblgen doesn't/can't handle effectively. For example, literal
/// immediates on ARM. TableGen expects a token operand, but the parser
diff --git a/include/llvm/MC/MCTargetOptions.h b/include/llvm/MC/MCTargetOptions.h
index eb4348e..de79bae 100644
--- a/include/llvm/MC/MCTargetOptions.h
+++ b/include/llvm/MC/MCTargetOptions.h
@@ -24,6 +24,7 @@ public:
bool MCRelaxAll : 1;
bool MCNoExecStack : 1;
+ bool MCFatalWarnings : 1;
bool MCSaveTempLabels : 1;
bool MCUseDwarfDirectory : 1;
bool ShowMCEncoding : 1;
@@ -38,12 +39,13 @@ inline bool operator==(const MCTargetOptions &LHS, const MCTargetOptions &RHS) {
return (ARE_EQUAL(SanitizeAddress) &&
ARE_EQUAL(MCRelaxAll) &&
ARE_EQUAL(MCNoExecStack) &&
+ ARE_EQUAL(MCFatalWarnings) &&
ARE_EQUAL(MCSaveTempLabels) &&
ARE_EQUAL(MCUseDwarfDirectory) &&
ARE_EQUAL(ShowMCEncoding) &&
ARE_EQUAL(ShowMCInst) &&
ARE_EQUAL(AsmVerbose) &&
- ARE_EQUAL(DwarfVersion));
+ ARE_EQUAL(DwarfVersion));
#undef ARE_EQUAL
}
diff --git a/include/llvm/MC/MCWin64EH.h b/include/llvm/MC/MCWin64EH.h
index d21e762..0e81a19 100644
--- a/include/llvm/MC/MCWin64EH.h
+++ b/include/llvm/MC/MCWin64EH.h
@@ -15,79 +15,49 @@
#ifndef LLVM_MC_MCWIN64EH_H
#define LLVM_MC_MCWIN64EH_H
+#include "llvm/MC/MCWinEH.h"
#include "llvm/Support/Win64EH.h"
-#include <cassert>
#include <vector>
namespace llvm {
- class StringRef;
- class MCStreamer;
- class MCSymbol;
+class MCStreamer;
+class MCSymbol;
- class MCWin64EHInstruction {
- public:
- typedef Win64EH::UnwindOpcodes OpType;
- private:
- OpType Operation;
- MCSymbol *Label;
- unsigned Offset;
- unsigned Register;
- public:
- MCWin64EHInstruction(OpType Op, MCSymbol *L, unsigned Reg)
- : Operation(Op), Label(L), Offset(0), Register(Reg) {
- assert(Op == Win64EH::UOP_PushNonVol);
- }
- MCWin64EHInstruction(MCSymbol *L, unsigned Size)
- : Operation(Size>128 ? Win64EH::UOP_AllocLarge : Win64EH::UOP_AllocSmall),
- Label(L), Offset(Size) { }
- MCWin64EHInstruction(OpType Op, MCSymbol *L, unsigned Reg, unsigned Off)
- : Operation(Op), Label(L), Offset(Off), Register(Reg) {
- assert(Op == Win64EH::UOP_SetFPReg ||
- Op == Win64EH::UOP_SaveNonVol ||
- Op == Win64EH::UOP_SaveNonVolBig ||
- Op == Win64EH::UOP_SaveXMM128 ||
- Op == Win64EH::UOP_SaveXMM128Big);
- }
- MCWin64EHInstruction(OpType Op, MCSymbol *L, bool Code)
- : Operation(Op), Label(L), Offset(Code ? 1 : 0) {
- assert(Op == Win64EH::UOP_PushMachFrame);
- }
- OpType getOperation() const { return Operation; }
- MCSymbol *getLabel() const { return Label; }
- unsigned getOffset() const { return Offset; }
- unsigned getSize() const { return Offset; }
- unsigned getRegister() const { return Register; }
- bool isPushCodeFrame() const { return Offset == 1; }
- };
+namespace Win64EH {
+struct Instruction {
+ static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg) {
+ return WinEH::Instruction(Win64EH::UOP_PushNonVol, L, Reg, -1);
+ }
+ static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size) {
+ return WinEH::Instruction(Size > 128 ? UOP_AllocLarge : UOP_AllocSmall, L,
+ -1, Size);
+ }
+ static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code) {
+ return WinEH::Instruction(UOP_PushMachFrame, L, -1, Code ? 1 : 0);
+ }
+ static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg,
+ unsigned Offset) {
+ return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveNonVolBig
+ : UOP_SaveNonVol,
+ L, Reg, Offset);
+ }
+ static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg,
+ unsigned Offset) {
+ return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveXMM128Big
+ : UOP_SaveXMM128,
+ L, Reg, Offset);
+ }
+ static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off) {
+ return WinEH::Instruction(UOP_SetFPReg, L, Reg, Off);
+ }
+};
- struct MCWin64EHUnwindInfo {
- MCWin64EHUnwindInfo()
- : Begin(nullptr), End(nullptr),ExceptionHandler(nullptr),
- Function(nullptr), PrologEnd(nullptr), Symbol(nullptr),
- HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
- ChainedParent(nullptr), Instructions() {}
- MCSymbol *Begin;
- MCSymbol *End;
- const MCSymbol *ExceptionHandler;
- const MCSymbol *Function;
- MCSymbol *PrologEnd;
- MCSymbol *Symbol;
- bool HandlesUnwind;
- bool HandlesExceptions;
- int LastFrameInst;
- MCWin64EHUnwindInfo *ChainedParent;
- std::vector<MCWin64EHInstruction> Instructions;
- };
-
- class MCWin64EHUnwindEmitter {
- public:
- static StringRef GetSectionSuffix(const MCSymbol *func);
- //
- // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
- //
- static void Emit(MCStreamer &streamer);
- static void EmitUnwindInfo(MCStreamer &streamer, MCWin64EHUnwindInfo *info);
- };
+class UnwindEmitter : public WinEH::UnwindEmitter {
+public:
+ void Emit(MCStreamer &Streamer) const override;
+ void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI) const override;
+};
+}
} // end namespace llvm
#endif
diff --git a/include/llvm/MC/MCWinCOFFStreamer.h b/include/llvm/MC/MCWinCOFFStreamer.h
index 7d2d0e4..57a75ce 100644
--- a/include/llvm/MC/MCWinCOFFStreamer.h
+++ b/include/llvm/MC/MCWinCOFFStreamer.h
@@ -30,10 +30,16 @@ public:
MCWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB, MCCodeEmitter &CE,
raw_ostream &OS);
+ /// state management
+ void reset() override {
+ CurSymbol = nullptr;
+ MCObjectStreamer::reset();
+ }
+
/// \name MCStreamer interface
/// \{
- void InitSections() override;
+ void InitSections(bool NoExecStack) override;
void EmitLabel(MCSymbol *Symbol) override;
void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
void EmitThumbFunc(MCSymbol *Func) override;
diff --git a/include/llvm/MC/MCWinEH.h b/include/llvm/MC/MCWinEH.h
new file mode 100644
index 0000000..05b58c7
--- /dev/null
+++ b/include/llvm/MC/MCWinEH.h
@@ -0,0 +1,84 @@
+//===- MCWinEH.h - Windows Unwinding Support --------------------*- 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_MCWINEH_H
+#define LLVM_MC_MCWINEH_H
+
+#include <vector>
+
+namespace llvm {
+class MCContext;
+class MCSection;
+class MCStreamer;
+class MCSymbol;
+class StringRef;
+
+namespace WinEH {
+struct Instruction {
+ const MCSymbol *Label;
+ const unsigned Offset;
+ const unsigned Register;
+ const unsigned Operation;
+
+ Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off)
+ : Label(L), Offset(Off), Register(Reg), Operation(Op) {}
+};
+
+struct FrameInfo {
+ const MCSymbol *Begin;
+ const MCSymbol *End;
+ const MCSymbol *ExceptionHandler;
+ const MCSymbol *Function;
+ const MCSymbol *PrologEnd;
+ const MCSymbol *Symbol;
+
+ bool HandlesUnwind;
+ bool HandlesExceptions;
+
+ int LastFrameInst;
+ const FrameInfo *ChainedParent;
+ std::vector<Instruction> Instructions;
+
+ FrameInfo()
+ : Begin(nullptr), End(nullptr), ExceptionHandler(nullptr),
+ Function(nullptr), PrologEnd(nullptr), Symbol(nullptr),
+ HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
+ ChainedParent(nullptr), Instructions() {}
+ FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
+ : Begin(BeginFuncEHLabel), End(nullptr), ExceptionHandler(nullptr),
+ Function(Function), PrologEnd(nullptr), Symbol(nullptr),
+ HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
+ ChainedParent(nullptr), Instructions() {}
+ FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel,
+ const FrameInfo *ChainedParent)
+ : Begin(BeginFuncEHLabel), End(nullptr), ExceptionHandler(nullptr),
+ Function(Function), PrologEnd(nullptr), Symbol(nullptr),
+ HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
+ ChainedParent(ChainedParent), Instructions() {}
+};
+
+class UnwindEmitter {
+public:
+ static const MCSection *getPDataSection(const MCSymbol *Function,
+ MCContext &Context);
+ static const MCSection *getXDataSection(const MCSymbol *Function,
+ MCContext &Context);
+
+ virtual ~UnwindEmitter() { }
+
+ //
+ // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
+ //
+ virtual void Emit(MCStreamer &Streamer) const = 0;
+ virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const = 0;
+};
+}
+}
+
+#endif
diff --git a/include/llvm/MC/StringTableBuilder.h b/include/llvm/MC/StringTableBuilder.h
index 065e9e0..897d449 100644
--- a/include/llvm/MC/StringTableBuilder.h
+++ b/include/llvm/MC/StringTableBuilder.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_MC_STRINGTABLE_BUILDER_H
-#define LLVM_MC_STRINGTABLE_BUILDER_H
+#ifndef LLVM_MC_STRINGTABLEBUILDER_H
+#define LLVM_MC_STRINGTABLEBUILDER_H
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
@@ -26,12 +26,18 @@ public:
/// copy of s. Can only be used before the table is finalized.
StringRef add(StringRef s) {
assert(!isFinalized());
- return StringIndexMap.GetOrCreateValue(s, 0).getKey();
+ return StringIndexMap.insert(std::make_pair(s, 0)).first->first();
}
+ enum Kind {
+ ELF,
+ WinCOFF,
+ MachO
+ };
+
/// \brief Analyze the strings and build the final table. No more strings can
/// be added after this point.
- void finalize();
+ void finalize(Kind kind);
/// \brief Retrieve the string table data. Can only be used after the table
/// is finalized.
@@ -48,6 +54,8 @@ public:
return StringIndexMap[s];
}
+ void clear();
+
private:
bool isFinalized() {
return !StringTable.empty();
diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h
index c5d62a6..bfecb8b 100644
--- a/include/llvm/MC/SubtargetFeature.h
+++ b/include/llvm/MC/SubtargetFeature.h
@@ -72,21 +72,21 @@ struct SubtargetInfoKV {
class SubtargetFeatures {
std::vector<std::string> Features; // Subtarget features as a vector
public:
- explicit SubtargetFeatures(const StringRef Initial = "");
+ explicit SubtargetFeatures(StringRef Initial = "");
/// Features string accessors.
std::string getString() const;
/// Adding Features.
- void AddFeature(const StringRef String);
+ void AddFeature(StringRef String);
/// ToggleFeature - Toggle a feature and returns the newly updated feature
/// bits.
- uint64_t ToggleFeature(uint64_t Bits, const StringRef String,
+ uint64_t ToggleFeature(uint64_t Bits, StringRef String,
ArrayRef<SubtargetFeatureKV> FeatureTable);
/// Get feature bits of a CPU.
- uint64_t getFeatureBits(const StringRef CPU,
+ uint64_t getFeatureBits(StringRef CPU,
ArrayRef<SubtargetFeatureKV> CPUTable,
ArrayRef<SubtargetFeatureKV> FeatureTable);