Skip to content

Commit

Permalink
[MC] Fix some Clang-tidy modernize and Include What You Use warnings;…
Browse files Browse the repository at this point in the history
… other minor fixes (NFC).

llvm-svn: 294813
  • Loading branch information
EugeneZelenko committed Feb 11, 2017
1 parent a2eb926 commit d3a6c89
Show file tree
Hide file tree
Showing 21 changed files with 261 additions and 240 deletions.
140 changes: 82 additions & 58 deletions llvm/include/llvm/MC/MCAsmInfo.h

Large diffs are not rendered by default.

42 changes: 23 additions & 19 deletions llvm/include/llvm/MC/MCAsmInfoCOFF.h
@@ -1,4 +1,4 @@
//===-- MCAsmInfoCOFF.h - COFF asm properties -------------------*- C++ -*-===//
//===- MCAsmInfoCOFF.h - COFF asm properties --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -13,24 +13,28 @@
#include "llvm/MC/MCAsmInfo.h"

namespace llvm {
class MCAsmInfoCOFF : public MCAsmInfo {
virtual void anchor();
protected:
explicit MCAsmInfoCOFF();
};

class MCAsmInfoMicrosoft : public MCAsmInfoCOFF {
void anchor() override;
protected:
explicit MCAsmInfoMicrosoft();
};

class MCAsmInfoGNUCOFF : public MCAsmInfoCOFF {
void anchor() override;
protected:
explicit MCAsmInfoGNUCOFF();
};
}

class MCAsmInfoCOFF : public MCAsmInfo {
virtual void anchor();

protected:
explicit MCAsmInfoCOFF();
};

class MCAsmInfoMicrosoft : public MCAsmInfoCOFF {
void anchor() override;

protected:
explicit MCAsmInfoMicrosoft();
};

class MCAsmInfoGNUCOFF : public MCAsmInfoCOFF {
void anchor() override;

protected:
explicit MCAsmInfoGNUCOFF();
};

} // end namespace llvm

#endif // LLVM_MC_MCASMINFOCOFF_H
16 changes: 9 additions & 7 deletions llvm/include/llvm/MC/MCAsmInfoDarwin.h
@@ -1,4 +1,4 @@
//===---- MCAsmInfoDarwin.h - Darwin asm properties -------------*- C++ -*-===//
//===- MCAsmInfoDarwin.h - Darwin asm properties ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -18,12 +18,14 @@
#include "llvm/MC/MCAsmInfo.h"

namespace llvm {
class MCAsmInfoDarwin : public MCAsmInfo {
public:
explicit MCAsmInfoDarwin();
bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
};
}

class MCAsmInfoDarwin : public MCAsmInfo {
public:
explicit MCAsmInfoDarwin();

bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
};

} // end namespace llvm

#endif // LLVM_MC_MCASMINFODARWIN_H
10 changes: 6 additions & 4 deletions llvm/include/llvm/MC/MCAsmInfoELF.h
@@ -1,4 +1,4 @@
//===-- llvm/MC/MCAsmInfoELF.h - ELF Asm info -------------------*- C++ -*-===//
//===- llvm/MC/MCAsmInfoELF.h - ELF Asm info --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -13,17 +13,19 @@
#include "llvm/MC/MCAsmInfo.h"

namespace llvm {

class MCAsmInfoELF : public MCAsmInfo {
virtual void anchor();
MCSection *getNonexecutableStackSection(MCContext &Ctx) const final;

protected:
/// Targets which have non-executable stacks by default can set this to false
/// to disable the special section which requests a non-executable stack.
bool UsesNonexecutableStackSection;
bool UsesNonexecutableStackSection = true;

MCAsmInfoELF();
};
}

#endif
} // end namespace llvm

#endif // LLVM_MC_MCASMINFOELF_H
30 changes: 20 additions & 10 deletions llvm/include/llvm/MC/MCInst.h
@@ -1,4 +1,4 @@
//===-- llvm/MC/MCInst.h - MCInst class -------------------------*- C++ -*-===//
//===- llvm/MC/MCInst.h - MCInst class --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -18,15 +18,17 @@

#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/SMLoc.h"
#include <cassert>
#include <cstddef>
#include <cstdint>

namespace llvm {
class raw_ostream;
class MCAsmInfo;
class MCInstPrinter;

class MCExpr;
class MCInst;
class MCInstPrinter;
class raw_ostream;

/// \brief Instances of this class represent operands of the MCInst class.
/// This is a simple discriminated union.
Expand All @@ -39,7 +41,7 @@ class MCOperand {
kExpr, ///< Relocatable immediate operand.
kInst ///< Sub-instruction operand.
};
MachineOperandType Kind;
MachineOperandType Kind = kInvalid;

union {
unsigned RegVal;
Expand All @@ -50,7 +52,7 @@ class MCOperand {
};

public:
MCOperand() : Kind(kInvalid), FPImmVal(0.0) {}
MCOperand() : FPImmVal(0.0) {}

bool isValid() const { return Kind != kInvalid; }
bool isReg() const { return Kind == kRegister; }
Expand All @@ -75,6 +77,7 @@ class MCOperand {
assert(isImm() && "This is not an immediate");
return ImmVal;
}

void setImm(int64_t Val) {
assert(isImm() && "This is not an immediate");
ImmVal = Val;
Expand All @@ -94,6 +97,7 @@ class MCOperand {
assert(isExpr() && "This is not an expression");
return ExprVal;
}

void setExpr(const MCExpr *Val) {
assert(isExpr() && "This is not an expression");
ExprVal = Val;
Expand All @@ -103,6 +107,7 @@ class MCOperand {
assert(isInst() && "This is not a sub-instruction");
return InstVal;
}

void setInst(const MCInst *Val) {
assert(isInst() && "This is not a sub-instruction");
InstVal = Val;
Expand All @@ -114,24 +119,28 @@ class MCOperand {
Op.RegVal = Reg;
return Op;
}

static MCOperand createImm(int64_t Val) {
MCOperand Op;
Op.Kind = kImmediate;
Op.ImmVal = Val;
return Op;
}

static MCOperand createFPImm(double Val) {
MCOperand Op;
Op.Kind = kFPImmediate;
Op.FPImmVal = Val;
return Op;
}

static MCOperand createExpr(const MCExpr *Val) {
MCOperand Op;
Op.Kind = kExpr;
Op.ExprVal = Val;
return Op;
}

static MCOperand createInst(const MCInst *Val) {
MCOperand Op;
Op.Kind = kInst;
Expand All @@ -148,12 +157,12 @@ template <> struct isPodLike<MCOperand> { static const bool value = true; };
/// \brief Instances of this class represent a single low-level machine
/// instruction.
class MCInst {
unsigned Opcode;
unsigned Opcode = 0;
SMLoc Loc;
SmallVector<MCOperand, 8> Operands;

public:
MCInst() : Opcode(0) {}
MCInst() = default;

void setOpcode(unsigned Op) { Opcode = Op; }
unsigned getOpcode() const { return Opcode; }
Expand All @@ -176,6 +185,7 @@ class MCInst {
const_iterator begin() const { return Operands.begin(); }
iterator end() { return Operands.end(); }
const_iterator end() const { return Operands.end(); }

iterator insert(iterator I, const MCOperand &Op) {
return Operands.insert(I, Op);
}
Expand All @@ -202,4 +212,4 @@ inline raw_ostream& operator<<(raw_ostream &OS, const MCInst &MI) {

} // end namespace llvm

#endif
#endif // LLVM_MC_MCINST_H
16 changes: 7 additions & 9 deletions llvm/include/llvm/MC/MCInstPrinter.h
Expand Up @@ -16,12 +16,12 @@
namespace llvm {

template <typename T> class ArrayRef;
class MCInst;
class raw_ostream;
class MCAsmInfo;
class MCInst;
class MCInstrInfo;
class MCRegisterInfo;
class MCSubtargetInfo;
class raw_ostream;
class StringRef;

/// Convert `Bytes' to a hex string and output to `OS'
Expand All @@ -43,28 +43,26 @@ class MCInstPrinter {
/// \brief A stream that comments can be emitted to if desired. Each comment
/// must end with a newline. This will be null if verbose assembly emission
/// is disable.
raw_ostream *CommentStream;
raw_ostream *CommentStream = nullptr;
const MCAsmInfo &MAI;
const MCInstrInfo &MII;
const MCRegisterInfo &MRI;

/// True if we are printing marked up assembly.
bool UseMarkup;
bool UseMarkup = false;

/// True if we are printing immediates as hex.
bool PrintImmHex;
bool PrintImmHex = false;

/// Which style to use for printing hexadecimal values.
HexStyle::Style PrintHexStyle;
HexStyle::Style PrintHexStyle = HexStyle::C;

/// Utility function for printing annotations.
void printAnnotation(raw_ostream &OS, StringRef Annot);

public:
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
const MCRegisterInfo &mri)
: CommentStream(nullptr), MAI(mai), MII(mii), MRI(mri), UseMarkup(false),
PrintImmHex(false), PrintHexStyle(HexStyle::C) {}
const MCRegisterInfo &mri) : MAI(mai), MII(mii), MRI(mri) {}

virtual ~MCInstPrinter();

Expand Down
11 changes: 6 additions & 5 deletions llvm/include/llvm/MC/MCInstrAnalysis.h
@@ -1,4 +1,4 @@
//===-- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks ------*- C++ -*-===//
//===- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -18,18 +18,19 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
#include <cstdint>

namespace llvm {

class MCInstrAnalysis {
protected:
friend class Target;

const MCInstrInfo *Info;

public:
MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}

virtual ~MCInstrAnalysis() {}
virtual ~MCInstrAnalysis() = default;

virtual bool isBranch(const MCInst &Inst) const {
return Info->get(Inst.getOpcode()).isBranch();
Expand Down Expand Up @@ -66,6 +67,6 @@ class MCInstrAnalysis {
uint64_t &Target) const;
};

} // End llvm namespace
} // end namespace llvm

#endif
#endif // LLVM_MC_MCINSTRANALYSIS_H
28 changes: 12 additions & 16 deletions llvm/include/llvm/MC/MCInstrItineraries.h
@@ -1,4 +1,4 @@
//===-- llvm/MC/MCInstrItineraries.h - Scheduling ---------------*- C++ -*-===//
//===- llvm/MC/MCInstrItineraries.h - Scheduling ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -88,7 +88,6 @@ struct InstrStage {
}
};


//===----------------------------------------------------------------------===//
/// An itinerary represents the scheduling information for an instruction.
/// This includes a set of stages occupied by the instruction and the pipeline
Expand All @@ -102,23 +101,20 @@ struct InstrItinerary {
unsigned LastOperandCycle; ///< Index of last + 1 operand rd/wr
};


//===----------------------------------------------------------------------===//
/// Itinerary data supplied by a subtarget to be used by a target.
///
class InstrItineraryData {
public:
MCSchedModel SchedModel; ///< Basic machine properties.
const InstrStage *Stages; ///< Array of stages selected
const unsigned *OperandCycles; ///< Array of operand cycles selected
const unsigned *Forwardings; ///< Array of pipeline forwarding paths
const InstrItinerary *Itineraries; ///< Array of itineraries selected

/// Ctors.
InstrItineraryData() : SchedModel(MCSchedModel::GetDefaultSchedModel()),
Stages(nullptr), OperandCycles(nullptr),
Forwardings(nullptr), Itineraries(nullptr) {}

MCSchedModel SchedModel =
MCSchedModel::GetDefaultSchedModel(); ///< Basic machine properties.
const InstrStage *Stages = nullptr; ///< Array of stages selected
const unsigned *OperandCycles = nullptr; ///< Array of operand cycles selected
const unsigned *Forwardings = nullptr; ///< Array of pipeline forwarding paths
const InstrItinerary *Itineraries =
nullptr; ///< Array of itineraries selected

InstrItineraryData() = default;
InstrItineraryData(const MCSchedModel &SM, const InstrStage *S,
const unsigned *OS, const unsigned *F)
: SchedModel(SM), Stages(S), OperandCycles(OS), Forwardings(F),
Expand Down Expand Up @@ -234,6 +230,6 @@ class InstrItineraryData {
}
};

} // End llvm namespace
} // end namespace llvm

#endif
#endif // LLVM_MC_MCINSTRITINERARIES_H

0 comments on commit d3a6c89

Please sign in to comment.