[CodeGen] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 296404
This commit is contained in:
Eugene Zelenko 2017-02-27 22:45:06 +00:00
parent 48b9ccfac2
commit d8db98615d
14 changed files with 298 additions and 224 deletions

View File

@ -1,4 +1,4 @@
//===-- FastISel.h - Definition of the FastISel class ---*- C++ -*---------===// //===- FastISel.h - Definition of the FastISel class ------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -16,10 +16,21 @@
#define LLVM_CODEGEN_FASTISEL_H #define LLVM_CODEGEN_FASTISEL_H
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineValueType.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallingConv.h" #include "llvm/IR/CallingConv.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/IntrinsicInst.h"
#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLowering.h"
#include <algorithm>
#include <cstdint>
#include <utility>
#include <vector>
namespace llvm { namespace llvm {
@ -31,8 +42,8 @@ class MachineConstantPool;
class FastISel { class FastISel {
public: public:
struct ArgListEntry { struct ArgListEntry {
Value *Val; Value *Val = nullptr;
Type *Ty; Type *Ty = nullptr;
bool IsSExt : 1; bool IsSExt : 1;
bool IsZExt : 1; bool IsZExt : 1;
bool IsInReg : 1; bool IsInReg : 1;
@ -43,13 +54,12 @@ public:
bool IsReturned : 1; bool IsReturned : 1;
bool IsSwiftSelf : 1; bool IsSwiftSelf : 1;
bool IsSwiftError : 1; bool IsSwiftError : 1;
uint16_t Alignment; uint16_t Alignment = 0;
ArgListEntry() ArgListEntry()
: Val(nullptr), Ty(nullptr), IsSExt(false), IsZExt(false), : IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false),
IsInReg(false), IsSRet(false), IsNest(false), IsByVal(false), IsNest(false), IsByVal(false), IsInAlloca(false), IsReturned(false),
IsInAlloca(false), IsReturned(false), IsSwiftSelf(false), IsSwiftSelf(false), IsSwiftError(false) {}
IsSwiftError(false), Alignment(0) {}
/// \brief Set CallLoweringInfo attribute flags based on a call instruction /// \brief Set CallLoweringInfo attribute flags based on a call instruction
/// and called function attributes. /// and called function attributes.
@ -58,29 +68,28 @@ public:
typedef std::vector<ArgListEntry> ArgListTy; typedef std::vector<ArgListEntry> ArgListTy;
struct CallLoweringInfo { struct CallLoweringInfo {
Type *RetTy; Type *RetTy = nullptr;
bool RetSExt : 1; bool RetSExt : 1;
bool RetZExt : 1; bool RetZExt : 1;
bool IsVarArg : 1; bool IsVarArg : 1;
bool IsInReg : 1; bool IsInReg : 1;
bool DoesNotReturn : 1; bool DoesNotReturn : 1;
bool IsReturnValueUsed : 1; bool IsReturnValueUsed : 1;
bool IsPatchPoint : 1;
// \brief IsTailCall Should be modified by implementations of FastLowerCall // \brief IsTailCall Should be modified by implementations of FastLowerCall
// that perform tail call conversions. // that perform tail call conversions.
bool IsTailCall; bool IsTailCall = false;
unsigned NumFixedArgs; unsigned NumFixedArgs = -1;
CallingConv::ID CallConv; CallingConv::ID CallConv = CallingConv::C;
const Value *Callee; const Value *Callee = nullptr;
MCSymbol *Symbol; MCSymbol *Symbol = nullptr;
ArgListTy Args; ArgListTy Args;
ImmutableCallSite *CS; ImmutableCallSite *CS = nullptr;
MachineInstr *Call; MachineInstr *Call = nullptr;
unsigned ResultReg; unsigned ResultReg = 0;
unsigned NumResultRegs; unsigned NumResultRegs = 0;
bool IsPatchPoint;
SmallVector<Value *, 16> OutVals; SmallVector<Value *, 16> OutVals;
SmallVector<ISD::ArgFlagsTy, 16> OutFlags; SmallVector<ISD::ArgFlagsTy, 16> OutFlags;
@ -89,11 +98,8 @@ public:
SmallVector<unsigned, 4> InRegs; SmallVector<unsigned, 4> InRegs;
CallLoweringInfo() CallLoweringInfo()
: RetTy(nullptr), RetSExt(false), RetZExt(false), IsVarArg(false), : RetSExt(false), RetZExt(false), IsVarArg(false), IsInReg(false),
IsInReg(false), DoesNotReturn(false), IsReturnValueUsed(true), DoesNotReturn(false), IsReturnValueUsed(true), IsPatchPoint(false) {}
IsTailCall(false), NumFixedArgs(-1), CallConv(CallingConv::C),
Callee(nullptr), Symbol(nullptr), CS(nullptr), Call(nullptr),
ResultReg(0), NumResultRegs(0), IsPatchPoint(false) {}
CallLoweringInfo &setCallee(Type *ResultTy, FunctionType *FuncTy, CallLoweringInfo &setCallee(Type *ResultTy, FunctionType *FuncTy,
const Value *Target, ArgListTy &&ArgsList, const Value *Target, ArgListTy &&ArgsList,
@ -510,7 +516,6 @@ protected:
} }
} }
bool lowerCall(const CallInst *I); bool lowerCall(const CallInst *I);
/// \brief Select and emit code for a binary operator instruction, which has /// \brief Select and emit code for a binary operator instruction, which has
/// an opcode which directly corresponds to the given ISD opcode. /// an opcode which directly corresponds to the given ISD opcode.
@ -567,4 +572,4 @@ private:
} // end namespace llvm } // end namespace llvm
#endif #endif // LLVM_CODEGEN_FASTISEL_H

View File

@ -1,4 +1,4 @@
//===------------------- FaultMaps.h - The "FaultMaps" section --*- C++ -*-===// //===- FaultMaps.h - The "FaultMaps" section --------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -12,17 +12,17 @@
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Endian.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/Format.h" #include <cassert>
#include <cstddef>
#include <vector> #include <cstdint>
#include <map> #include <map>
#include <vector>
namespace llvm { namespace llvm {
class AsmPrinter; class AsmPrinter;
class MCExpr; class MCExpr;
class MCSymbol; class raw_ostream;
class MCStreamer;
class FaultMaps { class FaultMaps {
public: public:
@ -33,10 +33,10 @@ public:
FaultKindMax FaultKindMax
}; };
static const char *faultTypeToString(FaultKind);
explicit FaultMaps(AsmPrinter &AP); explicit FaultMaps(AsmPrinter &AP);
static const char *faultTypeToString(FaultKind);
void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel); void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel);
void serializeToFaultMapSection(); void serializeToFaultMapSection();
@ -44,13 +44,11 @@ private:
static const char *WFMP; static const char *WFMP;
struct FaultInfo { struct FaultInfo {
FaultKind Kind; FaultKind Kind = FaultKindMax;
const MCExpr *FaultingOffsetExpr; const MCExpr *FaultingOffsetExpr = nullptr;
const MCExpr *HandlerOffsetExpr; const MCExpr *HandlerOffsetExpr = nullptr;
FaultInfo() FaultInfo() = default;
: Kind(FaultKindMax), FaultingOffsetExpr(nullptr),
HandlerOffsetExpr(nullptr) {}
explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset, explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset,
const MCExpr *HandlerOffset) const MCExpr *HandlerOffset)
@ -158,11 +156,11 @@ public:
static const size_t FunctionInfoHeaderSize = FunctionFaultInfosOffset; static const size_t FunctionInfoHeaderSize = FunctionFaultInfosOffset;
const uint8_t *P; const uint8_t *P = nullptr;
const uint8_t *E; const uint8_t *E = nullptr;
public: public:
FunctionInfoAccessor() : P(nullptr), E(nullptr) {} FunctionInfoAccessor() = default;
explicit FunctionInfoAccessor(const uint8_t *P, const uint8_t *E) explicit FunctionInfoAccessor(const uint8_t *P, const uint8_t *E)
: P(P), E(E) {} : P(P), E(E) {}
@ -219,6 +217,6 @@ raw_ostream &operator<<(raw_ostream &OS,
raw_ostream &operator<<(raw_ostream &OS, const FaultMapParser &); raw_ostream &operator<<(raw_ostream &OS, const FaultMapParser &);
} // namespace llvm } // end namespace llvm
#endif #endif // LLVM_CODEGEN_FAULTMAPS_H

View File

@ -1,4 +1,4 @@
//===-- llvm/CodeGen/GCStrategy.h - Garbage collection ----------*- C++ -*-===// //===- llvm/CodeGen/GCStrategy.h - Garbage collection -----------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -47,19 +47,20 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef LLVM_IR_GCSTRATEGY_H #ifndef LLVM_CODEGEN_GCSTRATEGY_H
#define LLVM_IR_GCSTRATEGY_H #define LLVM_CODEGEN_GCSTRATEGY_H
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Registry.h" #include "llvm/Support/Registry.h"
#include <string> #include <string>
namespace llvm { namespace llvm {
class Type;
namespace GC { namespace GC {
/// PointKind - Used to indicate whether the address of the call instruction /// PointKind - Used to indicate whether the address of the call instruction
/// or the address after the call instruction is listed in the stackmap. For /// or the address after the call instruction is listed in the stackmap. For
/// most runtimes, PostCall safepoints are appropriate. /// most runtimes, PostCall safepoints are appropriate.
@ -68,7 +69,8 @@ enum PointKind {
PreCall, ///< Instr is a call instruction. PreCall, ///< Instr is a call instruction.
PostCall ///< Instr is the return address of a call. PostCall ///< Instr is the return address of a call.
}; };
}
} // end namespace GC
/// GCStrategy describes a garbage collector algorithm's code generation /// GCStrategy describes a garbage collector algorithm's code generation
/// requirements, and provides overridable hooks for those needs which cannot /// requirements, and provides overridable hooks for those needs which cannot
@ -77,24 +79,25 @@ enum PointKind {
/// be immutable. /// be immutable.
class GCStrategy { class GCStrategy {
private: private:
std::string Name;
friend class GCModuleInfo; friend class GCModuleInfo;
std::string Name;
protected: protected:
bool UseStatepoints; /// Uses gc.statepoints as opposed to gc.roots, bool UseStatepoints = false; /// Uses gc.statepoints as opposed to gc.roots,
/// if set, none of the other options can be /// if set, none of the other options can be
/// anything but their default values. /// anything but their default values.
unsigned NeededSafePoints; ///< Bitmask of required safe points. unsigned NeededSafePoints = 0; ///< Bitmask of required safe points.
bool CustomReadBarriers; ///< Default is to insert loads. bool CustomReadBarriers = false; ///< Default is to insert loads.
bool CustomWriteBarriers; ///< Default is to insert stores. bool CustomWriteBarriers = false; ///< Default is to insert stores.
bool CustomRoots; ///< Default is to pass through to backend. bool CustomRoots = false; ///< Default is to pass through to backend.
bool InitRoots; ///< If set, roots are nulled during lowering. bool InitRoots= true; ///< If set, roots are nulled during lowering.
bool UsesMetadata; ///< If set, backend must emit metadata tables. bool UsesMetadata = false; ///< If set, backend must emit metadata tables.
public: public:
GCStrategy(); GCStrategy();
virtual ~GCStrategy() {} virtual ~GCStrategy() = default;
/// Return the name of the GC strategy. This is the value of the collector /// Return the name of the GC strategy. This is the value of the collector
/// name string specified on functions which use this strategy. /// name string specified on functions which use this strategy.
@ -172,6 +175,7 @@ public:
/// register your GCMetadataPrinter subclass with the /// register your GCMetadataPrinter subclass with the
/// GCMetadataPrinterRegistery as well. /// GCMetadataPrinterRegistery as well.
typedef Registry<GCStrategy> GCRegistry; typedef Registry<GCStrategy> GCRegistry;
}
#endif } // end namespace llvm
#endif // LLVM_CODEGEN_GCSTRATEGY_H

View File

@ -1,4 +1,4 @@
//===-- CodeGen/MachineInstBuilder.h - Simplify creation of MIs -*- C++ -*-===// //===- CodeGen/MachineInstBuilder.h - Simplify creation of MIs --*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -19,9 +19,18 @@
#ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H #ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H
#define LLVM_CODEGEN_MACHINEINSTRBUILDER_H #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBundle.h" #include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <cstdint>
#include <utility>
namespace llvm { namespace llvm {
@ -29,6 +38,7 @@ class MCInstrDesc;
class MDNode; class MDNode;
namespace RegState { namespace RegState {
enum { enum {
Define = 0x2, Define = 0x2,
Implicit = 0x4, Implicit = 0x4,
@ -42,13 +52,15 @@ namespace RegState {
ImplicitDefine = Implicit | Define, ImplicitDefine = Implicit | Define,
ImplicitKill = Implicit | Kill ImplicitKill = Implicit | Kill
}; };
}
} // end namespace RegState
class MachineInstrBuilder { class MachineInstrBuilder {
MachineFunction *MF; MachineFunction *MF = nullptr;
MachineInstr *MI; MachineInstr *MI = nullptr;
public: public:
MachineInstrBuilder() : MF(nullptr), MI(nullptr) {} MachineInstrBuilder() = default;
/// Create a MachineInstrBuilder for manipulating an existing instruction. /// Create a MachineInstrBuilder for manipulating an existing instruction.
/// F must be the machine function that was used to allocate I. /// F must be the machine function that was used to allocate I.
@ -518,6 +530,6 @@ public:
} }
}; };
} // End llvm namespace } // end namespace llvm
#endif #endif // LLVM_CODEGEN_MACHINEINSTRBUILDER_H

View File

@ -1,4 +1,4 @@
//===-- Solution.h ------- PBQP Solution ------------------------*- C++ -*-===// //===- Solution.h - PBQP Solution -------------------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -14,8 +14,8 @@
#ifndef LLVM_CODEGEN_PBQP_SOLUTION_H #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
#define LLVM_CODEGEN_PBQP_SOLUTION_H #define LLVM_CODEGEN_PBQP_SOLUTION_H
#include "Graph.h" #include "llvm/CodeGen/PBQP/Graph.h"
#include "Math.h" #include <cassert>
#include <map> #include <map>
namespace llvm { namespace llvm {
@ -26,17 +26,17 @@ namespace PBQP {
/// To get the selection for each node in the problem use the getSelection method. /// To get the selection for each node in the problem use the getSelection method.
class Solution { class Solution {
private: private:
typedef std::map<GraphBase::NodeId, unsigned> SelectionsMap; typedef std::map<GraphBase::NodeId, unsigned> SelectionsMap;
SelectionsMap selections; SelectionsMap selections;
unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions; unsigned r0Reductions = 0;
unsigned r1Reductions = 0;
unsigned r2Reductions = 0;
unsigned rNReductions = 0;
public: public:
/// \brief Initialise an empty solution. /// \brief Initialise an empty solution.
Solution() Solution() = default;
: r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
/// \brief Set the selection for a given node. /// \brief Set the selection for a given node.
/// @param nodeId Node id. /// @param nodeId Node id.
@ -53,10 +53,9 @@ namespace PBQP {
assert(sItr != selections.end() && "No selection for node."); assert(sItr != selections.end() && "No selection for node.");
return sItr->second; return sItr->second;
} }
}; };
} // namespace PBQP } // end namespace PBQP
} // namespace llvm } // end namespace llvm
#endif // LLVM_CODEGEN_PBQP_SOLUTION_H #endif // LLVM_CODEGEN_PBQP_SOLUTION_H

View File

@ -1,4 +1,4 @@
//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===// //===- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -118,11 +118,11 @@ namespace ISD {
class SDValue { class SDValue {
friend struct DenseMapInfo<SDValue>; friend struct DenseMapInfo<SDValue>;
SDNode *Node; // The node defining the value we are using. SDNode *Node = nullptr; // The node defining the value we are using.
unsigned ResNo; // Which return value of the node we are using. unsigned ResNo = 0; // Which return value of the node we are using.
public: public:
SDValue() : Node(nullptr), ResNo(0) {} SDValue() = default;
SDValue(SDNode *node, unsigned resno); SDValue(SDNode *node, unsigned resno);
/// get the index which selects a specific result in the SDNode /// get the index which selects a specific result in the SDNode
@ -250,16 +250,16 @@ class SDUse {
/// Val - The value being used. /// Val - The value being used.
SDValue Val; SDValue Val;
/// User - The user of this value. /// User - The user of this value.
SDNode *User; SDNode *User = nullptr;
/// Prev, Next - Pointers to the uses list of the SDNode referred by /// Prev, Next - Pointers to the uses list of the SDNode referred by
/// this operand. /// this operand.
SDUse **Prev, *Next; SDUse **Prev = nullptr;
SDUse *Next = nullptr;
SDUse(const SDUse &U) = delete;
void operator=(const SDUse &U) = delete;
public: public:
SDUse() : User(nullptr), Prev(nullptr), Next(nullptr) {} SDUse() = default;
SDUse(const SDUse &U) = delete;
SDUse &operator=(const SDUse &) = delete;
/// Normally SDUse will just implicitly convert to an SDValue that it holds. /// Normally SDUse will just implicitly convert to an SDValue that it holds.
operator const SDValue&() const { return Val; } operator const SDValue&() const { return Val; }
@ -353,17 +353,10 @@ private:
public: public:
/// Default constructor turns off all optimization flags. /// Default constructor turns off all optimization flags.
SDNodeFlags() { SDNodeFlags()
NoUnsignedWrap = false; : NoUnsignedWrap(false), NoSignedWrap(false), Exact(false),
NoSignedWrap = false; UnsafeAlgebra(false), NoNaNs(false), NoInfs(false),
Exact = false; NoSignedZeros(false), AllowReciprocal(false), VectorReduction(false) {}
UnsafeAlgebra = false;
NoNaNs = false;
NoInfs = false;
NoSignedZeros = false;
AllowReciprocal = false;
VectorReduction = false;
}
// These are mutators for each flag. // These are mutators for each flag.
void setNoUnsignedWrap(bool b) { NoUnsignedWrap = b; } void setNoUnsignedWrap(bool b) { NoUnsignedWrap = b; }
@ -446,6 +439,7 @@ protected:
class LSBaseSDNodeBitfields { class LSBaseSDNodeBitfields {
friend class LSBaseSDNode; friend class LSBaseSDNode;
uint16_t : NumMemSDNodeBits; uint16_t : NumMemSDNodeBits;
uint16_t AddressingMode : 3; // enum ISD::MemIndexedMode uint16_t AddressingMode : 3; // enum ISD::MemIndexedMode
@ -493,21 +487,26 @@ protected:
static_assert(sizeof(StoreSDNodeBitfields) <= 2, "field too wide"); static_assert(sizeof(StoreSDNodeBitfields) <= 2, "field too wide");
private: private:
friend class SelectionDAG;
// TODO: unfriend HandleSDNode once we fix its operand handling.
friend class HandleSDNode;
/// Unique id per SDNode in the DAG. /// Unique id per SDNode in the DAG.
int NodeId; int NodeId = -1;
/// The values that are used by this operation. /// The values that are used by this operation.
SDUse *OperandList; SDUse *OperandList = nullptr;
/// The types of the values this node defines. SDNode's may /// The types of the values this node defines. SDNode's may
/// define multiple values simultaneously. /// define multiple values simultaneously.
const EVT *ValueList; const EVT *ValueList;
/// List of uses for this SDNode. /// List of uses for this SDNode.
SDUse *UseList; SDUse *UseList = nullptr;
/// The number of entries in the Operand/Value list. /// The number of entries in the Operand/Value list.
unsigned short NumOperands, NumValues; unsigned short NumOperands = 0;
unsigned short NumValues;
// The ordering of the SDNodes. It roughly corresponds to the ordering of the // The ordering of the SDNodes. It roughly corresponds to the ordering of the
// original LLVM instructions. // original LLVM instructions.
@ -522,10 +521,6 @@ private:
/// Return a pointer to the specified value type. /// Return a pointer to the specified value type.
static const EVT *getValueTypeList(EVT VT); static const EVT *getValueTypeList(EVT VT);
friend class SelectionDAG;
// TODO: unfriend HandleSDNode once we fix its operand handling.
friend class HandleSDNode;
public: public:
/// Unique and persistent id per SDNode in the DAG. /// Unique and persistent id per SDNode in the DAG.
/// Used for debug printing. /// Used for debug printing.
@ -616,10 +611,10 @@ public:
/// operands that use a specific SDNode. /// operands that use a specific SDNode.
class use_iterator class use_iterator
: public std::iterator<std::forward_iterator_tag, SDUse, ptrdiff_t> { : public std::iterator<std::forward_iterator_tag, SDUse, ptrdiff_t> {
SDUse *Op;
friend class SDNode; friend class SDNode;
SDUse *Op = nullptr;
explicit use_iterator(SDUse *op) : Op(op) {} explicit use_iterator(SDUse *op) : Op(op) {}
public: public:
@ -628,8 +623,8 @@ public:
typedef std::iterator<std::forward_iterator_tag, typedef std::iterator<std::forward_iterator_tag,
SDUse, ptrdiff_t>::pointer pointer; SDUse, ptrdiff_t>::pointer pointer;
use_iterator() = default;
use_iterator(const use_iterator &I) : Op(I.Op) {} use_iterator(const use_iterator &I) : Op(I.Op) {}
use_iterator() : Op(nullptr) {}
bool operator==(const use_iterator &x) const { bool operator==(const use_iterator &x) const {
return Op == x.Op; return Op == x.Op;
@ -900,9 +895,8 @@ protected:
/// SDNodes are created without any operands, and never own the operand /// SDNodes are created without any operands, and never own the operand
/// storage. To add operands, see SelectionDAG::createOperands. /// storage. To add operands, see SelectionDAG::createOperands.
SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs) SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs)
: NodeType(Opc), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs), : NodeType(Opc), ValueList(VTs.VTs), NumValues(VTs.NumVTs),
UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs), IROrder(Order), IROrder(Order), debugLoc(std::move(dl)) {
debugLoc(std::move(dl)) {
memset(&RawSDNodeBits, 0, sizeof(RawSDNodeBits)); memset(&RawSDNodeBits, 0, sizeof(RawSDNodeBits));
assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor"); assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
assert(NumValues == VTs.NumVTs && assert(NumValues == VTs.NumVTs &&
@ -1370,10 +1364,10 @@ public:
}; };
class ConstantSDNode : public SDNode { class ConstantSDNode : public SDNode {
const ConstantInt *Value;
friend class SelectionDAG; friend class SelectionDAG;
const ConstantInt *Value;
ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val,
const DebugLoc &DL, EVT VT) const DebugLoc &DL, EVT VT)
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DL, : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DL,
@ -1405,10 +1399,10 @@ uint64_t SDNode::getConstantOperandVal(unsigned Num) const {
} }
class ConstantFPSDNode : public SDNode { class ConstantFPSDNode : public SDNode {
const ConstantFP *Value;
friend class SelectionDAG; friend class SelectionDAG;
const ConstantFP *Value;
ConstantFPSDNode(bool isTarget, const ConstantFP *val, const DebugLoc &DL, ConstantFPSDNode(bool isTarget, const ConstantFP *val, const DebugLoc &DL,
EVT VT) EVT VT)
: SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, DL, : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, DL,
@ -1479,10 +1473,12 @@ ConstantSDNode *isConstOrConstSplat(SDValue V);
ConstantFPSDNode *isConstOrConstSplatFP(SDValue V); ConstantFPSDNode *isConstOrConstSplatFP(SDValue V);
class GlobalAddressSDNode : public SDNode { class GlobalAddressSDNode : public SDNode {
friend class SelectionDAG;
const GlobalValue *TheGlobal; const GlobalValue *TheGlobal;
int64_t Offset; int64_t Offset;
unsigned char TargetFlags; unsigned char TargetFlags;
friend class SelectionDAG;
GlobalAddressSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, GlobalAddressSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL,
const GlobalValue *GA, EVT VT, int64_t o, const GlobalValue *GA, EVT VT, int64_t o,
unsigned char TargetFlags); unsigned char TargetFlags);
@ -1503,10 +1499,10 @@ public:
}; };
class FrameIndexSDNode : public SDNode { class FrameIndexSDNode : public SDNode {
int FI;
friend class SelectionDAG; friend class SelectionDAG;
int FI;
FrameIndexSDNode(int fi, EVT VT, bool isTarg) FrameIndexSDNode(int fi, EVT VT, bool isTarg)
: SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex,
0, DebugLoc(), getSDVTList(VT)), FI(fi) { 0, DebugLoc(), getSDVTList(VT)), FI(fi) {
@ -1522,11 +1518,11 @@ public:
}; };
class JumpTableSDNode : public SDNode { class JumpTableSDNode : public SDNode {
friend class SelectionDAG;
int JTI; int JTI;
unsigned char TargetFlags; unsigned char TargetFlags;
friend class SelectionDAG;
JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF) JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF)
: SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable,
0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) { 0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) {
@ -1543,6 +1539,8 @@ public:
}; };
class ConstantPoolSDNode : public SDNode { class ConstantPoolSDNode : public SDNode {
friend class SelectionDAG;
union { union {
const Constant *ConstVal; const Constant *ConstVal;
MachineConstantPoolValue *MachineCPVal; MachineConstantPoolValue *MachineCPVal;
@ -1551,8 +1549,6 @@ class ConstantPoolSDNode : public SDNode {
unsigned Alignment; // Minimum alignment requirement of CP (not log2 value). unsigned Alignment; // Minimum alignment requirement of CP (not log2 value).
unsigned char TargetFlags; unsigned char TargetFlags;
friend class SelectionDAG;
ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o, ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o,
unsigned Align, unsigned char TF) unsigned Align, unsigned char TF)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
@ -1606,12 +1602,12 @@ public:
/// Completely target-dependent object reference. /// Completely target-dependent object reference.
class TargetIndexSDNode : public SDNode { class TargetIndexSDNode : public SDNode {
friend class SelectionDAG;
unsigned char TargetFlags; unsigned char TargetFlags;
int Index; int Index;
int64_t Offset; int64_t Offset;
friend class SelectionDAG;
public: public:
TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF) TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF)
: SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)), : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)),
@ -1627,10 +1623,10 @@ public:
}; };
class BasicBlockSDNode : public SDNode { class BasicBlockSDNode : public SDNode {
MachineBasicBlock *MBB;
friend class SelectionDAG; friend class SelectionDAG;
MachineBasicBlock *MBB;
/// Debug info is meaningful and potentially useful here, but we create /// Debug info is meaningful and potentially useful here, but we create
/// blocks out of order when they're jumped to, which makes it a bit /// blocks out of order when they're jumped to, which makes it a bit
/// harder. Let's see if we need it first. /// harder. Let's see if we need it first.
@ -1648,10 +1644,10 @@ public:
/// A "pseudo-class" with methods for operating on BUILD_VECTORs. /// A "pseudo-class" with methods for operating on BUILD_VECTORs.
class BuildVectorSDNode : public SDNode { class BuildVectorSDNode : public SDNode {
public:
// These are constructed as SDNodes and then cast to BuildVectorSDNodes. // These are constructed as SDNodes and then cast to BuildVectorSDNodes.
explicit BuildVectorSDNode() = delete; explicit BuildVectorSDNode() = delete;
public:
/// Check if this is a constant splat, and if so, find the /// Check if this is a constant splat, and if so, find the
/// smallest element size that splats the vector. If MinSplatBits is /// smallest element size that splats the vector. If MinSplatBits is
/// nonzero, the element size must be at least that large. Note that the /// nonzero, the element size must be at least that large. Note that the
@ -1708,10 +1704,10 @@ public:
/// in the LLVM IR representation. /// in the LLVM IR representation.
/// ///
class SrcValueSDNode : public SDNode { class SrcValueSDNode : public SDNode {
const Value *V;
friend class SelectionDAG; friend class SelectionDAG;
const Value *V;
/// Create a SrcValue for a general value. /// Create a SrcValue for a general value.
explicit SrcValueSDNode(const Value *v) explicit SrcValueSDNode(const Value *v)
: SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {} : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {}
@ -1726,10 +1722,10 @@ public:
}; };
class MDNodeSDNode : public SDNode { class MDNodeSDNode : public SDNode {
const MDNode *MD;
friend class SelectionDAG; friend class SelectionDAG;
const MDNode *MD;
explicit MDNodeSDNode(const MDNode *md) explicit MDNodeSDNode(const MDNode *md)
: SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md) : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md)
{} {}
@ -1743,10 +1739,10 @@ public:
}; };
class RegisterSDNode : public SDNode { class RegisterSDNode : public SDNode {
unsigned Reg;
friend class SelectionDAG; friend class SelectionDAG;
unsigned Reg;
RegisterSDNode(unsigned reg, EVT VT) RegisterSDNode(unsigned reg, EVT VT)
: SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {} : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {}
@ -1759,11 +1755,11 @@ public:
}; };
class RegisterMaskSDNode : public SDNode { class RegisterMaskSDNode : public SDNode {
friend class SelectionDAG;
// The memory for RegMask is not owned by the node. // The memory for RegMask is not owned by the node.
const uint32_t *RegMask; const uint32_t *RegMask;
friend class SelectionDAG;
RegisterMaskSDNode(const uint32_t *mask) RegisterMaskSDNode(const uint32_t *mask)
: SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)), : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)),
RegMask(mask) {} RegMask(mask) {}
@ -1777,12 +1773,12 @@ public:
}; };
class BlockAddressSDNode : public SDNode { class BlockAddressSDNode : public SDNode {
friend class SelectionDAG;
const BlockAddress *BA; const BlockAddress *BA;
int64_t Offset; int64_t Offset;
unsigned char TargetFlags; unsigned char TargetFlags;
friend class SelectionDAG;
BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba, BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba,
int64_t o, unsigned char Flags) int64_t o, unsigned char Flags)
: SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)), : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)),
@ -1801,10 +1797,10 @@ public:
}; };
class EHLabelSDNode : public SDNode { class EHLabelSDNode : public SDNode {
MCSymbol *Label;
friend class SelectionDAG; friend class SelectionDAG;
MCSymbol *Label;
EHLabelSDNode(unsigned Order, const DebugLoc &dl, MCSymbol *L) EHLabelSDNode(unsigned Order, const DebugLoc &dl, MCSymbol *L)
: SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {} : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {}
@ -1817,11 +1813,11 @@ public:
}; };
class ExternalSymbolSDNode : public SDNode { class ExternalSymbolSDNode : public SDNode {
friend class SelectionDAG;
const char *Symbol; const char *Symbol;
unsigned char TargetFlags; unsigned char TargetFlags;
friend class SelectionDAG;
ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT) ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT)
: SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {} 0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {}
@ -1837,9 +1833,10 @@ public:
}; };
class MCSymbolSDNode : public SDNode { class MCSymbolSDNode : public SDNode {
friend class SelectionDAG;
MCSymbol *Symbol; MCSymbol *Symbol;
friend class SelectionDAG;
MCSymbolSDNode(MCSymbol *Symbol, EVT VT) MCSymbolSDNode(MCSymbol *Symbol, EVT VT)
: SDNode(ISD::MCSymbol, 0, DebugLoc(), getSDVTList(VT)), Symbol(Symbol) {} : SDNode(ISD::MCSymbol, 0, DebugLoc(), getSDVTList(VT)), Symbol(Symbol) {}
@ -1852,10 +1849,10 @@ public:
}; };
class CondCodeSDNode : public SDNode { class CondCodeSDNode : public SDNode {
ISD::CondCode Condition;
friend class SelectionDAG; friend class SelectionDAG;
ISD::CondCode Condition;
explicit CondCodeSDNode(ISD::CondCode Cond) explicit CondCodeSDNode(ISD::CondCode Cond)
: SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)), : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)),
Condition(Cond) {} Condition(Cond) {}
@ -1871,10 +1868,10 @@ public:
/// This class is used to represent EVT's, which are used /// This class is used to represent EVT's, which are used
/// to parameterize some operations. /// to parameterize some operations.
class VTSDNode : public SDNode { class VTSDNode : public SDNode {
EVT ValueType;
friend class SelectionDAG; friend class SelectionDAG;
EVT ValueType;
explicit VTSDNode(EVT VT) explicit VTSDNode(EVT VT)
: SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)), : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)),
ValueType(VT) {} ValueType(VT) {}
@ -2003,6 +2000,7 @@ public:
class MaskedLoadSDNode : public MaskedLoadStoreSDNode { class MaskedLoadSDNode : public MaskedLoadStoreSDNode {
public: public:
friend class SelectionDAG; friend class SelectionDAG;
MaskedLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, MaskedLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
ISD::LoadExtType ETy, bool IsExpanding, EVT MemVT, ISD::LoadExtType ETy, bool IsExpanding, EVT MemVT,
MachineMemOperand *MMO) MachineMemOperand *MMO)
@ -2122,11 +2120,11 @@ private:
friend class SelectionDAG; friend class SelectionDAG;
MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, SDVTList VTs) MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, SDVTList VTs)
: SDNode(Opc, Order, DL, VTs), MemRefs(nullptr), MemRefsEnd(nullptr) {} : SDNode(Opc, Order, DL, VTs) {}
/// Memory reference descriptions for this instruction. /// Memory reference descriptions for this instruction.
mmo_iterator MemRefs; mmo_iterator MemRefs = nullptr;
mmo_iterator MemRefsEnd; mmo_iterator MemRefsEnd = nullptr;
public: public:
mmo_iterator memoperands_begin() const { return MemRefs; } mmo_iterator memoperands_begin() const { return MemRefs; }
@ -2192,9 +2190,11 @@ template <> struct GraphTraits<SDNode*> {
typedef SDNodeIterator ChildIteratorType; typedef SDNodeIterator ChildIteratorType;
static NodeRef getEntryNode(SDNode *N) { return N; } static NodeRef getEntryNode(SDNode *N) { return N; }
static ChildIteratorType child_begin(NodeRef N) { static ChildIteratorType child_begin(NodeRef N) {
return SDNodeIterator::begin(N); return SDNodeIterator::begin(N);
} }
static ChildIteratorType child_end(NodeRef N) { static ChildIteratorType child_end(NodeRef N) {
return SDNodeIterator::end(N); return SDNodeIterator::end(N);
} }

View File

@ -1,4 +1,4 @@
//==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==// //==- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info --*- C++ -*-==//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -15,24 +15,22 @@
#ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
#define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
#include "llvm/IR/Module.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetLoweringObjectFile.h"
namespace llvm { namespace llvm {
class MachineModuleInfo;
class Mangler;
class MCAsmInfo;
class MCSection;
class MCSectionMachO;
class MCSymbol;
class MCContext;
class GlobalValue;
class TargetMachine;
class GlobalValue;
class MachineModuleInfo;
class Mangler;
class MCContext;
class MCSection;
class MCSymbol;
class TargetMachine;
class TargetLoweringObjectFileELF : public TargetLoweringObjectFile { class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
bool UseInitArray; bool UseInitArray = false;
mutable unsigned NextUniqueID = 1; // ID 0 is reserved for execute-only sections mutable unsigned NextUniqueID = 1; // ID 0 is reserved for execute-only sections
protected: protected:
@ -40,9 +38,8 @@ protected:
MCSymbolRefExpr::VK_None; MCSymbolRefExpr::VK_None;
public: public:
TargetLoweringObjectFileELF() : UseInitArray(false) {} TargetLoweringObjectFileELF() = default;
~TargetLoweringObjectFileELF() override = default;
~TargetLoweringObjectFileELF() override {}
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
const MCSymbol *Sym) const override; const MCSymbol *Sym) const override;
@ -89,12 +86,10 @@ public:
const TargetMachine &TM) const override; const TargetMachine &TM) const override;
}; };
class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
public: public:
~TargetLoweringObjectFileMachO() override {}
TargetLoweringObjectFileMachO(); TargetLoweringObjectFileMachO();
~TargetLoweringObjectFileMachO() override = default;
void Initialize(MCContext &Ctx, const TargetMachine &TM) override; void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
@ -135,13 +130,11 @@ public:
const TargetMachine &TM) const override; const TargetMachine &TM) const override;
}; };
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile { class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
mutable unsigned NextUniqueID = 0; mutable unsigned NextUniqueID = 0;
public: public:
~TargetLoweringObjectFileCOFF() override {} ~TargetLoweringObjectFileCOFF() override = default;
void Initialize(MCContext &Ctx, const TargetMachine &TM) override; void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
@ -175,9 +168,8 @@ class TargetLoweringObjectFileWasm : public TargetLoweringObjectFile {
mutable unsigned NextUniqueID = 0; mutable unsigned NextUniqueID = 0;
public: public:
TargetLoweringObjectFileWasm() {} TargetLoweringObjectFileWasm() = default;
~TargetLoweringObjectFileWasm() override = default;
~TargetLoweringObjectFileWasm() override {}
MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
const TargetMachine &TM) const override; const TargetMachine &TM) const override;
@ -200,4 +192,4 @@ void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV,
} // end namespace llvm } // end namespace llvm
#endif #endif // LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H

View File

@ -1,4 +1,4 @@
//===-- llvm/CodeGen/TargetSchedule.h - Sched Machine Model -----*- C++ -*-===// //===- llvm/CodeGen/TargetSchedule.h - Sched Machine Model ------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -23,10 +23,8 @@
namespace llvm { namespace llvm {
class TargetRegisterInfo;
class TargetSubtargetInfo;
class TargetInstrInfo;
class MachineInstr; class MachineInstr;
class TargetInstrInfo;
/// Provide an instruction scheduling machine model to CodeGen passes. /// Provide an instruction scheduling machine model to CodeGen passes.
class TargetSchedModel { class TargetSchedModel {
@ -34,8 +32,8 @@ class TargetSchedModel {
// processor. // processor.
MCSchedModel SchedModel; MCSchedModel SchedModel;
InstrItineraryData InstrItins; InstrItineraryData InstrItins;
const TargetSubtargetInfo *STI; const TargetSubtargetInfo *STI = nullptr;
const TargetInstrInfo *TII; const TargetInstrInfo *TII = nullptr;
SmallVector<unsigned, 16> ResourceFactors; SmallVector<unsigned, 16> ResourceFactors;
unsigned MicroOpFactor; // Multiply to normalize microops to resource units. unsigned MicroOpFactor; // Multiply to normalize microops to resource units.
@ -44,7 +42,7 @@ class TargetSchedModel {
unsigned computeInstrLatency(const MCSchedClassDesc &SCDesc) const; unsigned computeInstrLatency(const MCSchedClassDesc &SCDesc) const;
public: public:
TargetSchedModel(): SchedModel(MCSchedModel::GetDefaultSchedModel()), STI(nullptr), TII(nullptr) {} TargetSchedModel() : SchedModel(MCSchedModel::GetDefaultSchedModel()) {}
/// \brief Initialize the machine model for instruction scheduling. /// \brief Initialize the machine model for instruction scheduling.
/// ///
@ -185,6 +183,6 @@ public:
const MachineInstr *DepMI) const; const MachineInstr *DepMI) const;
}; };
} // namespace llvm } // end namespace llvm
#endif #endif // LLVM_CODEGEN_TARGETSCHEDULE_H

View File

@ -1,4 +1,4 @@
//===-- BuiltinGCs.cpp - Boilerplate for our built in GC types --*- C++ -*-===// //===- BuiltinGCs.cpp - Boilerplate for our built in GC types -------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -14,6 +14,8 @@
#include "llvm/CodeGen/GCs.h" #include "llvm/CodeGen/GCs.h"
#include "llvm/CodeGen/GCStrategy.h" #include "llvm/CodeGen/GCStrategy.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/Support/Casting.h"
using namespace llvm; using namespace llvm;
@ -77,6 +79,7 @@ public:
UsesMetadata = false; UsesMetadata = false;
CustomRoots = false; CustomRoots = false;
} }
Optional<bool> isGCManagedPointer(const Type *Ty) const override { Optional<bool> isGCManagedPointer(const Type *Ty) const override {
// Method is only valid on pointer typed values. // Method is only valid on pointer typed values.
const PointerType *PT = cast<PointerType>(Ty); const PointerType *PT = cast<PointerType>(Ty);
@ -110,6 +113,7 @@ public:
UsesMetadata = false; UsesMetadata = false;
CustomRoots = false; CustomRoots = false;
} }
Optional<bool> isGCManagedPointer(const Type *Ty) const override { Optional<bool> isGCManagedPointer(const Type *Ty) const override {
// Method is only valid on pointer typed values. // Method is only valid on pointer typed values.
const PointerType *PT = cast<PointerType>(Ty); const PointerType *PT = cast<PointerType>(Ty);
@ -117,7 +121,8 @@ public:
return (1 == PT->getAddressSpace()); return (1 == PT->getAddressSpace());
} }
}; };
}
} // end anonymous namespace
// Register all the above so that they can be found at runtime. Note that // Register all the above so that they can be found at runtime. Note that
// these static initializers are important since the registration list is // these static initializers are important since the registration list is

View File

@ -1,4 +1,4 @@
//===---------------------------- FaultMaps.cpp ---------------------------===// //===- FaultMaps.cpp ------------------------------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -7,14 +7,17 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/CodeGen/FaultMaps.h" #include "llvm/ADT/Twine.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/FaultMaps.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
@ -102,12 +105,10 @@ void FaultMaps::emitFunctionInfo(const MCSymbol *FnLabel,
} }
} }
const char *FaultMaps::faultTypeToString(FaultMaps::FaultKind FT) { const char *FaultMaps::faultTypeToString(FaultMaps::FaultKind FT) {
switch (FT) { switch (FT) {
default: default:
llvm_unreachable("unhandled fault type!"); llvm_unreachable("unhandled fault type!");
case FaultMaps::FaultingLoad: case FaultMaps::FaultingLoad:
return "FaultingLoad"; return "FaultingLoad";
case FaultMaps::FaultingLoadStore: case FaultMaps::FaultingLoadStore:

View File

@ -1,4 +1,4 @@
//===-- GCStrategy.cpp - Garbage Collector Description --------------------===// //===- GCStrategy.cpp - Garbage Collector Description ---------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -18,7 +18,4 @@ using namespace llvm;
LLVM_INSTANTIATE_REGISTRY(GCRegistry) LLVM_INSTANTIATE_REGISTRY(GCRegistry)
GCStrategy::GCStrategy() GCStrategy::GCStrategy() = default;
: UseStatepoints(false), NeededSafePoints(0), CustomReadBarriers(false),
CustomWriteBarriers(false), CustomRoots(false), InitRoots(true),
UsesMetadata(false) {}

View File

@ -1,4 +1,4 @@
//===-- FastISel.cpp - Implementation of the FastISel class ---------------===// //===- FastISel.cpp - Implementation of the FastISel class ----------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -39,35 +39,76 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/CodeGen/Analysis.h" #include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/FastISel.h" #include "llvm/CodeGen/FastISel.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h" #include "llvm/CodeGen/FunctionLoweringInfo.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineValueType.h"
#include "llvm/CodeGen/StackMaps.h" #include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h" #include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h" #include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h" #include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h" #include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Operator.h" #include "llvm/IR/Operator.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Target/TargetSubtargetInfo.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <utility>
using namespace llvm; using namespace llvm;
#define DEBUG_TYPE "isel" #define DEBUG_TYPE "isel"
@ -1665,7 +1706,7 @@ FastISel::FastISel(FunctionLoweringInfo &FuncInfo,
TRI(*MF->getSubtarget().getRegisterInfo()), LibInfo(LibInfo), TRI(*MF->getSubtarget().getRegisterInfo()), LibInfo(LibInfo),
SkipTargetIndependentISel(SkipTargetIndependentISel) {} SkipTargetIndependentISel(SkipTargetIndependentISel) {}
FastISel::~FastISel() {} FastISel::~FastISel() = default;
bool FastISel::fastLowerArguments() { return false; } bool FastISel::fastLowerArguments() { return false; }

View File

@ -1,4 +1,4 @@
//===-- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info --===// //===- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info ---===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -12,18 +12,27 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h" #include "llvm/ADT/Triple.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/IR/Comdat.h"
#include "llvm/IR/Constants.h" #include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h" #include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h" #include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h" #include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
@ -32,18 +41,23 @@
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSectionWasm.h" #include "llvm/MC/MCSectionWasm.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolELF.h" #include "llvm/MC/MCSymbolELF.h"
#include "llvm/MC/MCSymbolWasm.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/ProfileData/InstrProf.h" #include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/COFF.h" #include "llvm/Support/COFF.h"
#include "llvm/Support/Dwarf.h" #include "llvm/Support/Dwarf.h"
#include "llvm/Support/ELF.h" #include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MachO.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetSubtargetInfo.h" #include <cassert>
#include <string>
using namespace llvm; using namespace llvm;
using namespace dwarf; using namespace dwarf;
@ -55,10 +69,10 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol(
const GlobalValue *GV, const TargetMachine &TM, const GlobalValue *GV, const TargetMachine &TM,
MachineModuleInfo *MMI) const { MachineModuleInfo *MMI) const {
unsigned Encoding = getPersonalityEncoding(); unsigned Encoding = getPersonalityEncoding();
if ((Encoding & 0x80) == dwarf::DW_EH_PE_indirect) if ((Encoding & 0x80) == DW_EH_PE_indirect)
return getContext().getOrCreateSymbol(StringRef("DW.ref.") + return getContext().getOrCreateSymbol(StringRef("DW.ref.") +
TM.getSymbol(GV)->getName()); TM.getSymbol(GV)->getName());
if ((Encoding & 0x70) == dwarf::DW_EH_PE_absptr) if ((Encoding & 0x70) == DW_EH_PE_absptr)
return TM.getSymbol(GV); return TM.getSymbol(GV);
report_fatal_error("We do not support this DWARF encoding yet!"); report_fatal_error("We do not support this DWARF encoding yet!");
} }
@ -88,8 +102,7 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(
const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference( const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
MachineModuleInfo *MMI, MCStreamer &Streamer) const { MachineModuleInfo *MMI, MCStreamer &Streamer) const {
if (Encoding & DW_EH_PE_indirect) {
if (Encoding & dwarf::DW_EH_PE_indirect) {
MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>(); MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM); MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
@ -104,7 +117,7 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
return TargetLoweringObjectFile:: return TargetLoweringObjectFile::
getTTypeReference(MCSymbolRefExpr::create(SSym, getContext()), getTTypeReference(MCSymbolRefExpr::create(SSym, getContext()),
Encoding & ~dwarf::DW_EH_PE_indirect, Streamer); Encoding & ~DW_EH_PE_indirect, Streamer);
} }
return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM, return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM,
@ -151,7 +164,6 @@ getELFKindForNamedSection(StringRef Name, SectionKind K) {
return K; return K;
} }
static unsigned getELFSectionType(StringRef Name, SectionKind K) { static unsigned getELFSectionType(StringRef Name, SectionKind K) {
// Use SHT_NOTE for section whose name starts with ".note" to allow // Use SHT_NOTE for section whose name starts with ".note" to allow
// emitting ELF notes from C variable declaration. // emitting ELF notes from C variable declaration.
@ -725,7 +737,7 @@ const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference(
return TargetLoweringObjectFile:: return TargetLoweringObjectFile::
getTTypeReference(MCSymbolRefExpr::create(SSym, getContext()), getTTypeReference(MCSymbolRefExpr::create(SSym, getContext()),
Encoding & ~dwarf::DW_EH_PE_indirect, Streamer); Encoding & ~DW_EH_PE_indirect, Streamer);
} }
return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM, return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM,

View File

@ -1,4 +1,4 @@
//===-- llvm/Target/TargetSchedule.cpp - Sched Machine Model ----*- C++ -*-===// //===- llvm/Target/TargetSchedule.cpp - Sched Machine Model ---------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -12,12 +12,22 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/TargetSchedule.h" #include "llvm/CodeGen/TargetSchedule.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrItineraries.h"
#include "llvm/MC/MCSchedule.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Target/TargetSubtargetInfo.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
using namespace llvm; using namespace llvm;
@ -37,13 +47,14 @@ bool TargetSchedModel::hasInstrItineraries() const {
static unsigned gcd(unsigned Dividend, unsigned Divisor) { static unsigned gcd(unsigned Dividend, unsigned Divisor) {
// Dividend and Divisor will be naturally swapped as needed. // Dividend and Divisor will be naturally swapped as needed.
while(Divisor) { while (Divisor) {
unsigned Rem = Dividend % Divisor; unsigned Rem = Dividend % Divisor;
Dividend = Divisor; Dividend = Divisor;
Divisor = Rem; Divisor = Rem;
}; };
return Dividend; return Dividend;
} }
static unsigned lcm(unsigned A, unsigned B) { static unsigned lcm(unsigned A, unsigned B) {
unsigned LCM = (uint64_t(A) * B) / gcd(A, B); unsigned LCM = (uint64_t(A) * B) / gcd(A, B);
assert((LCM >= A && LCM >= B) && "LCM overflow"); assert((LCM >= A && LCM >= B) && "LCM overflow");
@ -100,7 +111,6 @@ static unsigned capLatency(int Cycles) {
/// evaluation of predicates that depend on instruction operands or flags. /// evaluation of predicates that depend on instruction operands or flags.
const MCSchedClassDesc *TargetSchedModel:: const MCSchedClassDesc *TargetSchedModel::
resolveSchedClass(const MachineInstr *MI) const { resolveSchedClass(const MachineInstr *MI) const {
// Get the definition's scheduling class descriptor from this machine model. // Get the definition's scheduling class descriptor from this machine model.
unsigned SchedClass = MI->getDesc().getSchedClass(); unsigned SchedClass = MI->getDesc().getSchedClass();
const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SchedClass); const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SchedClass);