1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

MC: clang-format. NFC.

llvm-svn: 237470
This commit is contained in:
Jim Grosbach 2015-05-15 19:13:20 +00:00
parent eb68de6ea2
commit 06d3c91b51
4 changed files with 107 additions and 149 deletions

View File

@ -29,19 +29,19 @@ class MCSymbolData;
/// even during the relaxation process.
class MCAsmLayout {
public:
typedef llvm::SmallVectorImpl<MCSectionData*>::const_iterator const_iterator;
typedef llvm::SmallVectorImpl<MCSectionData*>::iterator iterator;
typedef llvm::SmallVectorImpl<MCSectionData *>::const_iterator const_iterator;
typedef llvm::SmallVectorImpl<MCSectionData *>::iterator iterator;
private:
MCAssembler &Assembler;
/// List of sections in layout order.
llvm::SmallVector<MCSectionData*, 16> SectionOrder;
llvm::SmallVector<MCSectionData *, 16> SectionOrder;
/// The last fragment which was laid out, or 0 if nothing has been laid
/// out. Fragments are always laid out in order, so all fragments with a
/// lower ordinal will be valid.
mutable DenseMap<const MCSectionData*, MCFragment*> LastValidFragment;
mutable DenseMap<const MCSectionData *, MCFragment *> LastValidFragment;
/// \brief Make sure that the layout for the given fragment is valid, lazily
/// computing it if necessary.
@ -69,10 +69,10 @@ public:
/// \name Section Access (in layout order)
/// @{
llvm::SmallVectorImpl<MCSectionData*> &getSectionOrder() {
llvm::SmallVectorImpl<MCSectionData *> &getSectionOrder() {
return SectionOrder;
}
const llvm::SmallVectorImpl<MCSectionData*> &getSectionOrder() const {
const llvm::SmallVectorImpl<MCSectionData *> &getSectionOrder() const {
return SectionOrder;
}

View File

@ -47,8 +47,8 @@ class MCAsmBackend;
class MCFragment : public ilist_node<MCFragment> {
friend class MCAsmLayout;
MCFragment(const MCFragment&) = delete;
void operator=(const MCFragment&) = delete;
MCFragment(const MCFragment &) = delete;
void operator=(const MCFragment &) = delete;
public:
enum FragmentType {
@ -112,21 +112,18 @@ public:
/// \brief Should this fragment be placed at the end of an aligned bundle?
virtual bool alignToBundleEnd() const { return false; }
virtual void setAlignToBundleEnd(bool V) { }
virtual void setAlignToBundleEnd(bool V) {}
/// \brief Get the padding size that must be inserted before this fragment.
/// Used for bundling. By default, no padding is inserted.
/// Note that padding size is restricted to 8 bits. This is an optimization
/// to reduce the amount of space used for each fragment. In practice, larger
/// padding should never be required.
virtual uint8_t getBundlePadding() const {
return 0;
}
virtual uint8_t getBundlePadding() const { return 0; }
/// \brief Set the padding size for this fragment. By default it's a no-op,
/// and only some fragments have a meaningful implementation.
virtual void setBundlePadding(uint8_t N) {
}
virtual void setBundlePadding(uint8_t N) {}
void dump();
};
@ -138,33 +135,28 @@ class MCEncodedFragment : public MCFragment {
virtual void anchor();
uint8_t BundlePadding;
public:
MCEncodedFragment(MCFragment::FragmentType FType, MCSectionData *SD = nullptr)
: MCFragment(FType, SD), BundlePadding(0)
{
}
: MCFragment(FType, SD), BundlePadding(0) {}
~MCEncodedFragment() override;
virtual SmallVectorImpl<char> &getContents() = 0;
virtual const SmallVectorImpl<char> &getContents() const = 0;
uint8_t getBundlePadding() const override {
return BundlePadding;
}
uint8_t getBundlePadding() const override { return BundlePadding; }
void setBundlePadding(uint8_t N) override {
BundlePadding = N;
}
void setBundlePadding(uint8_t N) override { BundlePadding = N; }
static bool classof(const MCFragment *F) {
MCFragment::FragmentType Kind = F->getKind();
switch (Kind) {
default:
return false;
case MCFragment::FT_Relaxable:
case MCFragment::FT_CompactEncodedInst:
case MCFragment::FT_Data:
return true;
default:
return false;
case MCFragment::FT_Relaxable:
case MCFragment::FT_CompactEncodedInst:
case MCFragment::FT_Data:
return true;
}
}
};
@ -178,9 +170,7 @@ class MCEncodedFragmentWithFixups : public MCEncodedFragment {
public:
MCEncodedFragmentWithFixups(MCFragment::FragmentType FType,
MCSectionData *SD = nullptr)
: MCEncodedFragment(FType, SD)
{
}
: MCEncodedFragment(FType, SD) {}
~MCEncodedFragmentWithFixups() override;
@ -191,7 +181,7 @@ public:
virtual const SmallVectorImpl<MCFixup> &getFixups() const = 0;
virtual fixup_iterator fixup_begin() = 0;
virtual const_fixup_iterator fixup_begin() const = 0;
virtual const_fixup_iterator fixup_begin() const = 0;
virtual fixup_iterator fixup_end() = 0;
virtual const_fixup_iterator fixup_end() const = 0;
@ -216,25 +206,18 @@ class MCDataFragment : public MCEncodedFragmentWithFixups {
/// Fixups - The list of fixups in this fragment.
SmallVector<MCFixup, 4> Fixups;
public:
MCDataFragment(MCSectionData *SD = nullptr)
: MCEncodedFragmentWithFixups(FT_Data, SD),
HasInstructions(false), AlignToBundleEnd(false)
{
}
: MCEncodedFragmentWithFixups(FT_Data, SD), HasInstructions(false),
AlignToBundleEnd(false) {}
SmallVectorImpl<char> &getContents() override { return Contents; }
const SmallVectorImpl<char> &getContents() const override {
return Contents;
}
const SmallVectorImpl<char> &getContents() const override { return Contents; }
SmallVectorImpl<MCFixup> &getFixups() override {
return Fixups;
}
SmallVectorImpl<MCFixup> &getFixups() override { return Fixups; }
const SmallVectorImpl<MCFixup> &getFixups() const override {
return Fixups;
}
const SmallVectorImpl<MCFixup> &getFixups() const override { return Fixups; }
bool hasInstructions() const override { return HasInstructions; }
virtual void setHasInstructions(bool V) { HasInstructions = V; }
@ -245,8 +228,8 @@ public:
fixup_iterator fixup_begin() override { return Fixups.begin(); }
const_fixup_iterator fixup_begin() const override { return Fixups.begin(); }
fixup_iterator fixup_end() override {return Fixups.end();}
const_fixup_iterator fixup_end() const override {return Fixups.end();}
fixup_iterator fixup_end() override { return Fixups.end(); }
const_fixup_iterator fixup_end() const override { return Fixups.end(); }
static bool classof(const MCFragment *F) {
return F->getKind() == MCFragment::FT_Data;
@ -265,15 +248,12 @@ class MCCompactEncodedInstFragment : public MCEncodedFragment {
bool AlignToBundleEnd;
SmallVector<char, 4> Contents;
public:
MCCompactEncodedInstFragment(MCSectionData *SD = nullptr)
: MCEncodedFragment(FT_CompactEncodedInst, SD), AlignToBundleEnd(false)
{
}
: MCEncodedFragment(FT_CompactEncodedInst, SD), AlignToBundleEnd(false) {}
bool hasInstructions() const override {
return true;
}
bool hasInstructions() const override { return true; }
SmallVectorImpl<char> &getContents() override { return Contents; }
const SmallVectorImpl<char> &getContents() const override { return Contents; }
@ -315,25 +295,21 @@ public:
const SmallVectorImpl<char> &getContents() const override { return Contents; }
const MCInst &getInst() const { return Inst; }
void setInst(const MCInst& Value) { Inst = Value; }
void setInst(const MCInst &Value) { Inst = Value; }
const MCSubtargetInfo &getSubtargetInfo() { return STI; }
SmallVectorImpl<MCFixup> &getFixups() override {
return Fixups;
}
SmallVectorImpl<MCFixup> &getFixups() override { return Fixups; }
const SmallVectorImpl<MCFixup> &getFixups() const override {
return Fixups;
}
const SmallVectorImpl<MCFixup> &getFixups() const override { return Fixups; }
bool hasInstructions() const override { return true; }
fixup_iterator fixup_begin() override { return Fixups.begin(); }
const_fixup_iterator fixup_begin() const override { return Fixups.begin(); }
fixup_iterator fixup_end() override {return Fixups.end();}
const_fixup_iterator fixup_end() const override {return Fixups.end();}
fixup_iterator fixup_end() override { return Fixups.end(); }
const_fixup_iterator fixup_end() const override { return Fixups.end(); }
static bool classof(const MCFragment *F) {
return F->getKind() == MCFragment::FT_Relaxable;
@ -463,11 +439,13 @@ class MCLEBFragment : public MCFragment {
bool IsSigned;
SmallString<8> Contents;
public:
MCLEBFragment(const MCExpr &Value_, bool IsSigned_,
MCSectionData *SD = nullptr)
: MCFragment(FT_LEB, SD),
Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); }
: MCFragment(FT_LEB, SD), Value(&Value_), IsSigned(IsSigned_) {
Contents.push_back(0);
}
/// \name Accessors
/// @{
@ -559,8 +537,8 @@ public:
class MCSectionData : public ilist_node<MCSectionData> {
friend class MCAsmLayout;
MCSectionData(const MCSectionData&) = delete;
void operator=(const MCSectionData&) = delete;
MCSectionData(const MCSectionData &) = delete;
void operator=(const MCSectionData &) = delete;
public:
typedef iplist<MCFragment> FragmentListType;
@ -577,6 +555,7 @@ public:
BundleLocked,
BundleLockedAlignToEnd
};
private:
FragmentListType Fragments;
const MCSection *Section;
@ -658,13 +637,9 @@ public:
iterator getSubsectionInsertionPoint(unsigned Subsection);
bool isBundleLocked() const {
return BundleLockState != NotBundleLocked;
}
bool isBundleLocked() const { return BundleLockState != NotBundleLocked; }
BundleLockStateType getBundleLockState() const {
return BundleLockState;
}
BundleLockStateType getBundleLockState() const { return BundleLockState; }
void setBundleLockState(BundleLockStateType NewState);
@ -771,14 +746,9 @@ public:
return CommonSize;
}
void setSize(const MCExpr *SS) {
SymbolSize = SS;
}
const MCExpr *getSize() const {
return SymbolSize;
}
void setSize(const MCExpr *SS) { SymbolSize = SS; }
const MCExpr *getSize() const { return SymbolSize; }
/// getCommonAlignment - Return the alignment of a 'common' symbol.
unsigned getCommonAlignment() const {
@ -844,11 +814,11 @@ public:
typedef FileNameVectorType::const_iterator const_file_name_iterator;
typedef std::vector<IndirectSymbolData>::const_iterator
const_indirect_symbol_iterator;
const_indirect_symbol_iterator;
typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
typedef std::vector<DataRegionData>::const_iterator
const_data_region_iterator;
const_data_region_iterator;
typedef std::vector<DataRegionData>::iterator data_region_iterator;
/// MachO specific deployment target version info.
@ -860,9 +830,10 @@ public:
unsigned Minor;
unsigned Update;
} VersionMinInfoType;
private:
MCAssembler(const MCAssembler&) = delete;
void operator=(const MCAssembler&) = delete;
MCAssembler(const MCAssembler &) = delete;
void operator=(const MCAssembler &) = delete;
MCContext &Context;
@ -883,19 +854,19 @@ private:
/// The map of sections to their associated assembler backend data.
//
// FIXME: Avoid this indirection?
DenseMap<const MCSection*, MCSectionData*> SectionMap;
DenseMap<const MCSection *, MCSectionData *> SectionMap;
/// The map of symbols to their associated assembler backend data.
//
// FIXME: Avoid this indirection?
DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
DenseMap<const MCSymbol *, MCSymbolData *> SymbolMap;
std::vector<IndirectSymbolData> IndirectSymbols;
std::vector<DataRegionData> DataRegions;
/// The list of linker options to propagate into the object file.
std::vector<std::vector<std::string> > LinkerOptions;
std::vector<std::vector<std::string>> LinkerOptions;
/// List of declared file names
FileNameVectorType FileNames;
@ -907,7 +878,7 @@ private:
// here. Maybe when the relocation stuff moves to target specific,
// this can go with it? The streamer would need some target specific
// refactoring too.
mutable SmallPtrSet<const MCSymbol*, 64> ThumbFuncs;
mutable SmallPtrSet<const MCSymbol *, 64> ThumbFuncs;
/// \brief The bundle alignment size currently set in the assembler.
///
@ -929,6 +900,7 @@ private:
MCLOHContainer LOHContainer;
VersionMinInfoType VersionMinInfo;
private:
/// Evaluate a fixup to a relocatable expression and the value which should be
/// placed into the fixup.
@ -943,9 +915,9 @@ private:
/// \return Whether the fixup value was fully resolved. This is true if the
/// \p Value result is fixed, otherwise the value may change due to
/// relocation.
bool evaluateFixup(const MCAsmLayout &Layout,
const MCFixup &Fixup, const MCFragment *DF,
MCValue &Target, uint64_t &Value) const;
bool evaluateFixup(const MCAsmLayout &Layout, const MCFixup &Fixup,
const MCFragment *DF, MCValue &Target,
uint64_t &Value) const;
/// Check whether a fixup can be satisfied, or whether it needs to be relaxed
/// (increased in size, in order to hold its value correctly).
@ -1008,8 +980,8 @@ public:
void setIsThumbFunc(const MCSymbol *Func) { ThumbFuncs.insert(Func); }
/// ELF e_header flags
unsigned getELFHeaderEFlags() const {return ELFHeaderEFlags;}
void setELFHeaderEFlags(unsigned Flags) { ELFHeaderEFlags = Flags;}
unsigned getELFHeaderEFlags() const { return ELFHeaderEFlags; }
void setELFHeaderEFlags(unsigned Flags) { ELFHeaderEFlags = Flags; }
/// MachO deployment target version information.
const VersionMinInfoType &getVersionMinInfo() const { return VersionMinInfo; }
@ -1053,26 +1025,18 @@ public:
void Finish();
// FIXME: This does not belong here.
bool getSubsectionsViaSymbols() const {
return SubsectionsViaSymbols;
}
void setSubsectionsViaSymbols(bool Value) {
SubsectionsViaSymbols = Value;
}
bool getSubsectionsViaSymbols() const { return SubsectionsViaSymbols; }
void setSubsectionsViaSymbols(bool Value) { SubsectionsViaSymbols = Value; }
bool getRelaxAll() const { return RelaxAll; }
void setRelaxAll(bool Value) { RelaxAll = Value; }
bool isBundlingEnabled() const {
return BundleAlignSize != 0;
}
bool isBundlingEnabled() const { return BundleAlignSize != 0; }
unsigned getBundleAlignSize() const {
return BundleAlignSize;
}
unsigned getBundleAlignSize() const { return BundleAlignSize; }
void setBundleAlignSize(unsigned Size) {
assert((Size == 0 || !(Size & (Size - 1))) &&
assert((Size == 0 || !(Size & (Size - 1))) &&
"Expect a power-of-two bundle align size");
BundleAlignSize = Size;
}
@ -1105,7 +1069,9 @@ public:
const_symbol_iterator symbol_end() const { return Symbols.end(); }
symbol_range symbols() { return make_range(symbol_begin(), symbol_end()); }
const_symbol_range symbols() const { return make_range(symbol_begin(), symbol_end()); }
const_symbol_range symbols() const {
return make_range(symbol_begin(), symbol_end());
}
size_t symbol_size() const { return Symbols.size(); }
@ -1140,7 +1106,7 @@ public:
/// \name Linker Option List Access
/// @{
std::vector<std::vector<std::string> > &getLinkerOptions() {
std::vector<std::vector<std::string>> &getLinkerOptions() {
return LinkerOptions;
}
@ -1151,20 +1117,14 @@ public:
// FIXME: This is a total hack, this should not be here. Once things are
// factored so that the streamer has direct access to the .o writer, it can
// disappear.
std::vector<DataRegionData> &getDataRegions() {
return DataRegions;
}
std::vector<DataRegionData> &getDataRegions() { return DataRegions; }
data_region_iterator data_region_begin() {
return DataRegions.begin();
}
data_region_iterator data_region_begin() { return DataRegions.begin(); }
const_data_region_iterator data_region_begin() const {
return DataRegions.begin();
}
data_region_iterator data_region_end() {
return DataRegions.end();
}
data_region_iterator data_region_end() { return DataRegions.end(); }
const_data_region_iterator data_region_end() const {
return DataRegions.end();
}
@ -1178,10 +1138,8 @@ public:
// FIXME: This is a total hack, this should not be here. Once things are
// factored so that the streamer has direct access to the .o writer, it can
// disappear.
MCLOHContainer & getLOHContainer() {
return LOHContainer;
}
const MCLOHContainer & getLOHContainer() const {
MCLOHContainer &getLOHContainer() { return LOHContainer; }
const MCLOHContainer &getLOHContainer() const {
return const_cast<MCAssembler *>(this)->getLOHContainer();
}
/// @}
@ -1198,7 +1156,8 @@ public:
bool *Created = nullptr) {
MCSectionData *&Entry = SectionMap[&Section];
if (Created) *Created = !Entry;
if (Created)
*Created = !Entry;
if (!Entry)
Entry = new MCSectionData(Section, this);
@ -1224,7 +1183,8 @@ public:
bool *Created = nullptr) {
MCSymbolData *&Entry = SymbolMap[&Symbol];
if (Created) *Created = !Entry;
if (Created)
*Created = !Entry;
if (!Entry)
Entry = new MCSymbolData(Symbol, nullptr, 0, this);
@ -1235,9 +1195,7 @@ public:
return FileNames.begin();
}
const_file_name_iterator file_names_end() const {
return FileNames.end();
}
const_file_name_iterator file_names_end() const { return FileNames.end(); }
void addFileName(StringRef FileName) {
if (std::find(file_names_begin(), file_names_end(), FileName) ==
@ -1258,8 +1216,7 @@ public:
/// \brief Compute the amount of padding required before the fragment \p F to
/// obey bundling restrictions, where \p FOffset is the fragment's offset in
/// its section and \p FSize is the fragment's size.
uint64_t computeBundlePadding(const MCAssembler &Assembler,
const MCFragment *F,
uint64_t computeBundlePadding(const MCAssembler &Assembler, const MCFragment *F,
uint64_t FOffset, uint64_t FSize);
} // end namespace llvm

View File

@ -24,6 +24,7 @@ class MCCodeEmitter {
private:
MCCodeEmitter(const MCCodeEmitter &) = delete;
void operator=(const MCCodeEmitter &) = delete;
protected: // Can only create subclasses.
MCCodeEmitter();
@ -31,7 +32,7 @@ public:
virtual ~MCCodeEmitter();
/// Lifetime management
virtual void reset() { }
virtual void reset() {}
/// EncodeInstruction - Encode the given \p Inst to bytes on the output
/// stream \p OS.

View File

@ -19,33 +19,33 @@
namespace llvm {
class MCCodeGenInfo {
/// RelocationModel - Relocation model: static, pic, etc.
///
Reloc::Model RelocationModel;
class MCCodeGenInfo {
/// RelocationModel - Relocation model: static, pic, etc.
///
Reloc::Model RelocationModel;
/// CMModel - Code model.
///
CodeModel::Model CMModel;
/// CMModel - Code model.
///
CodeModel::Model CMModel;
/// OptLevel - Optimization level.
///
CodeGenOpt::Level OptLevel;
/// OptLevel - Optimization level.
///
CodeGenOpt::Level OptLevel;
public:
void InitMCCodeGenInfo(Reloc::Model RM = Reloc::Default,
CodeModel::Model CM = CodeModel::Default,
CodeGenOpt::Level OL = CodeGenOpt::Default);
public:
void InitMCCodeGenInfo(Reloc::Model RM = Reloc::Default,
CodeModel::Model CM = CodeModel::Default,
CodeGenOpt::Level OL = CodeGenOpt::Default);
Reloc::Model getRelocationModel() const { return RelocationModel; }
Reloc::Model getRelocationModel() const { return RelocationModel; }
CodeModel::Model getCodeModel() const { return CMModel; }
CodeModel::Model getCodeModel() const { return CMModel; }
CodeGenOpt::Level getOptLevel() const { return OptLevel; }
CodeGenOpt::Level getOptLevel() const { return OptLevel; }
// Allow overriding OptLevel on a per-function basis.
void setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; }
};
// Allow overriding OptLevel on a per-function basis.
void setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; }
};
} // namespace llvm
#endif