diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h index cdaea250c33..694d6b0ba1f 100644 --- a/include/llvm/CodeGen/FastISel.h +++ b/include/llvm/CodeGen/FastISel.h @@ -1,4 +1,4 @@ -//===-- FastISel.h - Definition of the FastISel class ---*- C++ -*---------===// +//===- FastISel.h - Definition of the FastISel class ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,10 +16,21 @@ #define LLVM_CODEGEN_FASTISEL_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineValueType.h" +#include "llvm/IR/Attributes.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/Target/TargetLowering.h" +#include +#include +#include +#include namespace llvm { @@ -31,8 +42,8 @@ class MachineConstantPool; class FastISel { public: struct ArgListEntry { - Value *Val; - Type *Ty; + Value *Val = nullptr; + Type *Ty = nullptr; bool IsSExt : 1; bool IsZExt : 1; bool IsInReg : 1; @@ -43,13 +54,12 @@ public: bool IsReturned : 1; bool IsSwiftSelf : 1; bool IsSwiftError : 1; - uint16_t Alignment; + uint16_t Alignment = 0; ArgListEntry() - : Val(nullptr), Ty(nullptr), IsSExt(false), IsZExt(false), - IsInReg(false), IsSRet(false), IsNest(false), IsByVal(false), - IsInAlloca(false), IsReturned(false), IsSwiftSelf(false), - IsSwiftError(false), Alignment(0) {} + : IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false), + IsNest(false), IsByVal(false), IsInAlloca(false), IsReturned(false), + IsSwiftSelf(false), IsSwiftError(false) {} /// \brief Set CallLoweringInfo attribute flags based on a call instruction /// and called function attributes. @@ -58,29 +68,28 @@ public: typedef std::vector ArgListTy; struct CallLoweringInfo { - Type *RetTy; + Type *RetTy = nullptr; bool RetSExt : 1; bool RetZExt : 1; bool IsVarArg : 1; bool IsInReg : 1; bool DoesNotReturn : 1; bool IsReturnValueUsed : 1; + bool IsPatchPoint : 1; // \brief IsTailCall Should be modified by implementations of FastLowerCall // that perform tail call conversions. - bool IsTailCall; + bool IsTailCall = false; - unsigned NumFixedArgs; - CallingConv::ID CallConv; - const Value *Callee; - MCSymbol *Symbol; + unsigned NumFixedArgs = -1; + CallingConv::ID CallConv = CallingConv::C; + const Value *Callee = nullptr; + MCSymbol *Symbol = nullptr; ArgListTy Args; - ImmutableCallSite *CS; - MachineInstr *Call; - unsigned ResultReg; - unsigned NumResultRegs; - - bool IsPatchPoint; + ImmutableCallSite *CS = nullptr; + MachineInstr *Call = nullptr; + unsigned ResultReg = 0; + unsigned NumResultRegs = 0; SmallVector OutVals; SmallVector OutFlags; @@ -89,11 +98,8 @@ public: SmallVector InRegs; CallLoweringInfo() - : RetTy(nullptr), RetSExt(false), RetZExt(false), IsVarArg(false), - IsInReg(false), DoesNotReturn(false), IsReturnValueUsed(true), - IsTailCall(false), NumFixedArgs(-1), CallConv(CallingConv::C), - Callee(nullptr), Symbol(nullptr), CS(nullptr), Call(nullptr), - ResultReg(0), NumResultRegs(0), IsPatchPoint(false) {} + : RetSExt(false), RetZExt(false), IsVarArg(false), IsInReg(false), + DoesNotReturn(false), IsReturnValueUsed(true), IsPatchPoint(false) {} CallLoweringInfo &setCallee(Type *ResultTy, FunctionType *FuncTy, const Value *Target, ArgListTy &&ArgsList, @@ -510,7 +516,6 @@ protected: } } - bool lowerCall(const CallInst *I); /// \brief Select and emit code for a binary operator instruction, which has /// an opcode which directly corresponds to the given ISD opcode. @@ -567,4 +572,4 @@ private: } // end namespace llvm -#endif +#endif // LLVM_CODEGEN_FASTISEL_H diff --git a/include/llvm/CodeGen/FaultMaps.h b/include/llvm/CodeGen/FaultMaps.h index a278e7c1388..0f0005b83c5 100644 --- a/include/llvm/CodeGen/FaultMaps.h +++ b/include/llvm/CodeGen/FaultMaps.h @@ -1,4 +1,4 @@ -//===------------------- FaultMaps.h - The "FaultMaps" section --*- C++ -*-===// +//===- FaultMaps.h - The "FaultMaps" section --------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,17 +12,17 @@ #include "llvm/MC/MCSymbol.h" #include "llvm/Support/Endian.h" -#include "llvm/Support/Format.h" - -#include +#include +#include +#include #include +#include namespace llvm { class AsmPrinter; class MCExpr; -class MCSymbol; -class MCStreamer; +class raw_ostream; class FaultMaps { public: @@ -33,10 +33,10 @@ public: FaultKindMax }; - static const char *faultTypeToString(FaultKind); - explicit FaultMaps(AsmPrinter &AP); + static const char *faultTypeToString(FaultKind); + void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel); void serializeToFaultMapSection(); @@ -44,13 +44,11 @@ private: static const char *WFMP; struct FaultInfo { - FaultKind Kind; - const MCExpr *FaultingOffsetExpr; - const MCExpr *HandlerOffsetExpr; + FaultKind Kind = FaultKindMax; + const MCExpr *FaultingOffsetExpr = nullptr; + const MCExpr *HandlerOffsetExpr = nullptr; - FaultInfo() - : Kind(FaultKindMax), FaultingOffsetExpr(nullptr), - HandlerOffsetExpr(nullptr) {} + FaultInfo() = default; explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset, const MCExpr *HandlerOffset) @@ -158,11 +156,11 @@ public: static const size_t FunctionInfoHeaderSize = FunctionFaultInfosOffset; - const uint8_t *P; - const uint8_t *E; + const uint8_t *P = nullptr; + const uint8_t *E = nullptr; public: - FunctionInfoAccessor() : P(nullptr), E(nullptr) {} + FunctionInfoAccessor() = default; explicit FunctionInfoAccessor(const uint8_t *P, const uint8_t *E) : P(P), E(E) {} @@ -219,6 +217,6 @@ raw_ostream &operator<<(raw_ostream &OS, raw_ostream &operator<<(raw_ostream &OS, const FaultMapParser &); -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_CODEGEN_FAULTMAPS_H diff --git a/include/llvm/CodeGen/GCStrategy.h b/include/llvm/CodeGen/GCStrategy.h index 3088a86a326..5b1fafea25b 100644 --- a/include/llvm/CodeGen/GCStrategy.h +++ b/include/llvm/CodeGen/GCStrategy.h @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/GCStrategy.h - Garbage collection ----------*- C++ -*-===// +//===- llvm/CodeGen/GCStrategy.h - Garbage collection -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -47,19 +47,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_IR_GCSTRATEGY_H -#define LLVM_IR_GCSTRATEGY_H +#ifndef LLVM_CODEGEN_GCSTRATEGY_H +#define LLVM_CODEGEN_GCSTRATEGY_H +#include "llvm/ADT/None.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 namespace llvm { + +class Type; + namespace GC { + /// PointKind - Used to indicate whether the address of the call instruction /// or the address after the call instruction is listed in the stackmap. For /// most runtimes, PostCall safepoints are appropriate. @@ -68,7 +69,8 @@ enum PointKind { PreCall, ///< Instr is a call instruction. PostCall ///< Instr is the return address of a call. }; -} + +} // end namespace GC /// GCStrategy describes a garbage collector algorithm's code generation /// requirements, and provides overridable hooks for those needs which cannot @@ -77,24 +79,25 @@ enum PointKind { /// be immutable. class GCStrategy { private: - std::string Name; friend class GCModuleInfo; -protected: - bool UseStatepoints; /// Uses gc.statepoints as opposed to gc.roots, - /// if set, none of the other options can be - /// anything but their default values. + std::string Name; - unsigned NeededSafePoints; ///< Bitmask of required safe points. - bool CustomReadBarriers; ///< Default is to insert loads. - bool CustomWriteBarriers; ///< Default is to insert stores. - bool CustomRoots; ///< Default is to pass through to backend. - bool InitRoots; ///< If set, roots are nulled during lowering. - bool UsesMetadata; ///< If set, backend must emit metadata tables. +protected: + bool UseStatepoints = false; /// Uses gc.statepoints as opposed to gc.roots, + /// if set, none of the other options can be + /// anything but their default values. + + unsigned NeededSafePoints = 0; ///< Bitmask of required safe points. + bool CustomReadBarriers = false; ///< Default is to insert loads. + bool CustomWriteBarriers = false; ///< Default is to insert stores. + bool CustomRoots = false; ///< Default is to pass through to backend. + bool InitRoots= true; ///< If set, roots are nulled during lowering. + bool UsesMetadata = false; ///< If set, backend must emit metadata tables. public: GCStrategy(); - virtual ~GCStrategy() {} + virtual ~GCStrategy() = default; /// Return the name of the GC strategy. This is the value of the collector /// name string specified on functions which use this strategy. @@ -172,6 +175,7 @@ public: /// register your GCMetadataPrinter subclass with the /// GCMetadataPrinterRegistery as well. typedef Registry GCRegistry; -} -#endif +} // end namespace llvm + +#endif // LLVM_CODEGEN_GCSTRATEGY_H diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h index 233a467e17e..c9564df2d8e 100644 --- a/include/llvm/CodeGen/MachineInstrBuilder.h +++ b/include/llvm/CodeGen/MachineInstrBuilder.h @@ -1,4 +1,4 @@ -//===-- CodeGen/MachineInstBuilder.h - Simplify creation of MIs -*- C++ -*-===// +//===- CodeGen/MachineInstBuilder.h - Simplify creation of MIs --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -19,9 +19,18 @@ #ifndef 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/MachineInstr.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 +#include +#include namespace llvm { @@ -29,6 +38,7 @@ class MCInstrDesc; class MDNode; namespace RegState { + enum { Define = 0x2, Implicit = 0x4, @@ -42,13 +52,15 @@ namespace RegState { ImplicitDefine = Implicit | Define, ImplicitKill = Implicit | Kill }; -} + +} // end namespace RegState class MachineInstrBuilder { - MachineFunction *MF; - MachineInstr *MI; + MachineFunction *MF = nullptr; + MachineInstr *MI = nullptr; + public: - MachineInstrBuilder() : MF(nullptr), MI(nullptr) {} + MachineInstrBuilder() = default; /// Create a MachineInstrBuilder for manipulating an existing instruction. /// 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 diff --git a/include/llvm/CodeGen/PBQP/Solution.h b/include/llvm/CodeGen/PBQP/Solution.h index bd74805a239..d96b5eac452 100644 --- a/include/llvm/CodeGen/PBQP/Solution.h +++ b/include/llvm/CodeGen/PBQP/Solution.h @@ -1,4 +1,4 @@ -//===-- Solution.h ------- PBQP Solution ------------------------*- C++ -*-===// +//===- Solution.h - PBQP Solution -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,8 +14,8 @@ #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H #define LLVM_CODEGEN_PBQP_SOLUTION_H -#include "Graph.h" -#include "Math.h" +#include "llvm/CodeGen/PBQP/Graph.h" +#include #include namespace llvm { @@ -26,17 +26,17 @@ namespace PBQP { /// To get the selection for each node in the problem use the getSelection method. class Solution { private: - typedef std::map SelectionsMap; SelectionsMap selections; - unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions; + unsigned r0Reductions = 0; + unsigned r1Reductions = 0; + unsigned r2Reductions = 0; + unsigned rNReductions = 0; public: - /// \brief Initialise an empty solution. - Solution() - : r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {} + Solution() = default; /// \brief Set the selection for a given node. /// @param nodeId Node id. @@ -53,10 +53,9 @@ namespace PBQP { assert(sItr != selections.end() && "No selection for node."); return sItr->second; } - }; -} // namespace PBQP -} // namespace llvm +} // end namespace PBQP +} // end namespace llvm #endif // LLVM_CODEGEN_PBQP_SOLUTION_H diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 4630541e972..9295702e389 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===// +//===- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -118,11 +118,11 @@ namespace ISD { class SDValue { friend struct DenseMapInfo; - SDNode *Node; // The node defining the value we are using. - unsigned ResNo; // Which return value of the node we are using. + SDNode *Node = nullptr; // The node defining the value we are using. + unsigned ResNo = 0; // Which return value of the node we are using. public: - SDValue() : Node(nullptr), ResNo(0) {} + SDValue() = default; SDValue(SDNode *node, unsigned resno); /// get the index which selects a specific result in the SDNode @@ -250,16 +250,16 @@ class SDUse { /// Val - The value being used. SDValue Val; /// User - The user of this value. - SDNode *User; + SDNode *User = nullptr; /// Prev, Next - Pointers to the uses list of the SDNode referred by /// this operand. - SDUse **Prev, *Next; - - SDUse(const SDUse &U) = delete; - void operator=(const SDUse &U) = delete; + SDUse **Prev = nullptr; + SDUse *Next = nullptr; 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. operator const SDValue&() const { return Val; } @@ -353,17 +353,10 @@ private: public: /// Default constructor turns off all optimization flags. - SDNodeFlags() { - NoUnsignedWrap = false; - NoSignedWrap = false; - Exact = false; - UnsafeAlgebra = false; - NoNaNs = false; - NoInfs = false; - NoSignedZeros = false; - AllowReciprocal = false; - VectorReduction = false; - } + SDNodeFlags() + : NoUnsignedWrap(false), NoSignedWrap(false), Exact(false), + UnsafeAlgebra(false), NoNaNs(false), NoInfs(false), + NoSignedZeros(false), AllowReciprocal(false), VectorReduction(false) {} // These are mutators for each flag. void setNoUnsignedWrap(bool b) { NoUnsignedWrap = b; } @@ -446,6 +439,7 @@ protected: class LSBaseSDNodeBitfields { friend class LSBaseSDNode; + uint16_t : NumMemSDNodeBits; uint16_t AddressingMode : 3; // enum ISD::MemIndexedMode @@ -493,21 +487,26 @@ protected: static_assert(sizeof(StoreSDNodeBitfields) <= 2, "field too wide"); private: + friend class SelectionDAG; + // TODO: unfriend HandleSDNode once we fix its operand handling. + friend class HandleSDNode; + /// Unique id per SDNode in the DAG. - int NodeId; + int NodeId = -1; /// The values that are used by this operation. - SDUse *OperandList; + SDUse *OperandList = nullptr; /// The types of the values this node defines. SDNode's may /// define multiple values simultaneously. const EVT *ValueList; /// List of uses for this SDNode. - SDUse *UseList; + SDUse *UseList = nullptr; /// 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 // original LLVM instructions. @@ -522,10 +521,6 @@ private: /// Return a pointer to the specified value type. static const EVT *getValueTypeList(EVT VT); - friend class SelectionDAG; - // TODO: unfriend HandleSDNode once we fix its operand handling. - friend class HandleSDNode; - public: /// Unique and persistent id per SDNode in the DAG. /// Used for debug printing. @@ -616,10 +611,10 @@ public: /// operands that use a specific SDNode. class use_iterator : public std::iterator { - SDUse *Op; - friend class SDNode; + SDUse *Op = nullptr; + explicit use_iterator(SDUse *op) : Op(op) {} public: @@ -628,8 +623,8 @@ public: typedef std::iterator::pointer pointer; + use_iterator() = default; use_iterator(const use_iterator &I) : Op(I.Op) {} - use_iterator() : Op(nullptr) {} bool operator==(const use_iterator &x) const { return Op == x.Op; @@ -900,9 +895,8 @@ protected: /// SDNodes are created without any operands, and never own the operand /// storage. To add operands, see SelectionDAG::createOperands. SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs) - : NodeType(Opc), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs), - UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs), IROrder(Order), - debugLoc(std::move(dl)) { + : NodeType(Opc), ValueList(VTs.VTs), NumValues(VTs.NumVTs), + IROrder(Order), debugLoc(std::move(dl)) { memset(&RawSDNodeBits, 0, sizeof(RawSDNodeBits)); assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor"); assert(NumValues == VTs.NumVTs && @@ -1370,10 +1364,10 @@ public: }; class ConstantSDNode : public SDNode { - const ConstantInt *Value; - friend class SelectionDAG; + const ConstantInt *Value; + ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, const DebugLoc &DL, EVT VT) : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DL, @@ -1405,10 +1399,10 @@ uint64_t SDNode::getConstantOperandVal(unsigned Num) const { } class ConstantFPSDNode : public SDNode { - const ConstantFP *Value; - friend class SelectionDAG; + const ConstantFP *Value; + ConstantFPSDNode(bool isTarget, const ConstantFP *val, const DebugLoc &DL, EVT VT) : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, DL, @@ -1479,10 +1473,12 @@ ConstantSDNode *isConstOrConstSplat(SDValue V); ConstantFPSDNode *isConstOrConstSplatFP(SDValue V); class GlobalAddressSDNode : public SDNode { + friend class SelectionDAG; + const GlobalValue *TheGlobal; int64_t Offset; unsigned char TargetFlags; - friend class SelectionDAG; + GlobalAddressSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, const GlobalValue *GA, EVT VT, int64_t o, unsigned char TargetFlags); @@ -1503,10 +1499,10 @@ public: }; class FrameIndexSDNode : public SDNode { - int FI; - friend class SelectionDAG; + int FI; + FrameIndexSDNode(int fi, EVT VT, bool isTarg) : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, 0, DebugLoc(), getSDVTList(VT)), FI(fi) { @@ -1522,11 +1518,11 @@ public: }; class JumpTableSDNode : public SDNode { + friend class SelectionDAG; + int JTI; unsigned char TargetFlags; - friend class SelectionDAG; - JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF) : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, 0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) { @@ -1543,6 +1539,8 @@ public: }; class ConstantPoolSDNode : public SDNode { + friend class SelectionDAG; + union { const Constant *ConstVal; MachineConstantPoolValue *MachineCPVal; @@ -1551,8 +1549,6 @@ class ConstantPoolSDNode : public SDNode { unsigned Alignment; // Minimum alignment requirement of CP (not log2 value). unsigned char TargetFlags; - friend class SelectionDAG; - ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o, unsigned Align, unsigned char TF) : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, @@ -1606,12 +1602,12 @@ public: /// Completely target-dependent object reference. class TargetIndexSDNode : public SDNode { + friend class SelectionDAG; + unsigned char TargetFlags; int Index; int64_t Offset; - friend class SelectionDAG; - public: TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF) : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)), @@ -1627,10 +1623,10 @@ public: }; class BasicBlockSDNode : public SDNode { - MachineBasicBlock *MBB; - friend class SelectionDAG; + MachineBasicBlock *MBB; + /// 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 /// harder. Let's see if we need it first. @@ -1648,10 +1644,10 @@ public: /// A "pseudo-class" with methods for operating on BUILD_VECTORs. class BuildVectorSDNode : public SDNode { +public: // These are constructed as SDNodes and then cast to BuildVectorSDNodes. explicit BuildVectorSDNode() = delete; -public: /// Check if this is a constant splat, and if so, find the /// smallest element size that splats the vector. If MinSplatBits is /// nonzero, the element size must be at least that large. Note that the @@ -1708,10 +1704,10 @@ public: /// in the LLVM IR representation. /// class SrcValueSDNode : public SDNode { - const Value *V; - friend class SelectionDAG; + const Value *V; + /// Create a SrcValue for a general value. explicit SrcValueSDNode(const Value *v) : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {} @@ -1726,10 +1722,10 @@ public: }; class MDNodeSDNode : public SDNode { - const MDNode *MD; - friend class SelectionDAG; + const MDNode *MD; + explicit MDNodeSDNode(const MDNode *md) : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md) {} @@ -1743,10 +1739,10 @@ public: }; class RegisterSDNode : public SDNode { - unsigned Reg; - friend class SelectionDAG; + unsigned Reg; + RegisterSDNode(unsigned reg, EVT VT) : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {} @@ -1759,11 +1755,11 @@ public: }; class RegisterMaskSDNode : public SDNode { + friend class SelectionDAG; + // The memory for RegMask is not owned by the node. const uint32_t *RegMask; - friend class SelectionDAG; - RegisterMaskSDNode(const uint32_t *mask) : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)), RegMask(mask) {} @@ -1777,12 +1773,12 @@ public: }; class BlockAddressSDNode : public SDNode { + friend class SelectionDAG; + const BlockAddress *BA; int64_t Offset; unsigned char TargetFlags; - friend class SelectionDAG; - BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba, int64_t o, unsigned char Flags) : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)), @@ -1801,10 +1797,10 @@ public: }; class EHLabelSDNode : public SDNode { - MCSymbol *Label; - friend class SelectionDAG; + MCSymbol *Label; + EHLabelSDNode(unsigned Order, const DebugLoc &dl, MCSymbol *L) : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {} @@ -1817,11 +1813,11 @@ public: }; class ExternalSymbolSDNode : public SDNode { + friend class SelectionDAG; + const char *Symbol; unsigned char TargetFlags; - friend class SelectionDAG; - ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT) : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {} @@ -1837,9 +1833,10 @@ public: }; class MCSymbolSDNode : public SDNode { + friend class SelectionDAG; + MCSymbol *Symbol; - friend class SelectionDAG; MCSymbolSDNode(MCSymbol *Symbol, EVT VT) : SDNode(ISD::MCSymbol, 0, DebugLoc(), getSDVTList(VT)), Symbol(Symbol) {} @@ -1852,10 +1849,10 @@ public: }; class CondCodeSDNode : public SDNode { - ISD::CondCode Condition; - friend class SelectionDAG; + ISD::CondCode Condition; + explicit CondCodeSDNode(ISD::CondCode Cond) : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)), Condition(Cond) {} @@ -1871,10 +1868,10 @@ public: /// This class is used to represent EVT's, which are used /// to parameterize some operations. class VTSDNode : public SDNode { - EVT ValueType; - friend class SelectionDAG; + EVT ValueType; + explicit VTSDNode(EVT VT) : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)), ValueType(VT) {} @@ -2003,6 +2000,7 @@ public: class MaskedLoadSDNode : public MaskedLoadStoreSDNode { public: friend class SelectionDAG; + MaskedLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::LoadExtType ETy, bool IsExpanding, EVT MemVT, MachineMemOperand *MMO) @@ -2122,11 +2120,11 @@ private: friend class SelectionDAG; 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. - mmo_iterator MemRefs; - mmo_iterator MemRefsEnd; + mmo_iterator MemRefs = nullptr; + mmo_iterator MemRefsEnd = nullptr; public: mmo_iterator memoperands_begin() const { return MemRefs; } @@ -2192,9 +2190,11 @@ template <> struct GraphTraits { typedef SDNodeIterator ChildIteratorType; static NodeRef getEntryNode(SDNode *N) { return N; } + static ChildIteratorType child_begin(NodeRef N) { return SDNodeIterator::begin(N); } + static ChildIteratorType child_end(NodeRef N) { return SDNodeIterator::end(N); } diff --git a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h index 41b76c9f1f0..eccedb1434c 100644 --- a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h +++ b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h @@ -1,4 +1,4 @@ -//==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==// +//==- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info --*- C++ -*-==// // // The LLVM Compiler Infrastructure // @@ -15,24 +15,22 @@ #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H +#include "llvm/IR/Module.h" #include "llvm/MC/MCExpr.h" -#include "llvm/MC/SectionKind.h" #include "llvm/Target/TargetLoweringObjectFile.h" 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 { - bool UseInitArray; + bool UseInitArray = false; mutable unsigned NextUniqueID = 1; // ID 0 is reserved for execute-only sections protected: @@ -40,9 +38,8 @@ protected: MCSymbolRefExpr::VK_None; public: - TargetLoweringObjectFileELF() : UseInitArray(false) {} - - ~TargetLoweringObjectFileELF() override {} + TargetLoweringObjectFileELF() = default; + ~TargetLoweringObjectFileELF() override = default; void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, const MCSymbol *Sym) const override; @@ -89,12 +86,10 @@ public: const TargetMachine &TM) const override; }; - - class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { public: - ~TargetLoweringObjectFileMachO() override {} TargetLoweringObjectFileMachO(); + ~TargetLoweringObjectFileMachO() override = default; void Initialize(MCContext &Ctx, const TargetMachine &TM) override; @@ -135,13 +130,11 @@ public: const TargetMachine &TM) const override; }; - - class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile { mutable unsigned NextUniqueID = 0; public: - ~TargetLoweringObjectFileCOFF() override {} + ~TargetLoweringObjectFileCOFF() override = default; void Initialize(MCContext &Ctx, const TargetMachine &TM) override; MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, @@ -175,9 +168,8 @@ class TargetLoweringObjectFileWasm : public TargetLoweringObjectFile { mutable unsigned NextUniqueID = 0; public: - TargetLoweringObjectFileWasm() {} - - ~TargetLoweringObjectFileWasm() override {} + TargetLoweringObjectFileWasm() = default; + ~TargetLoweringObjectFileWasm() override = default; MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override; @@ -200,4 +192,4 @@ void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, } // end namespace llvm -#endif +#endif // LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H diff --git a/include/llvm/CodeGen/TargetSchedule.h b/include/llvm/CodeGen/TargetSchedule.h index 81054aba066..5489dff8301 100644 --- a/include/llvm/CodeGen/TargetSchedule.h +++ b/include/llvm/CodeGen/TargetSchedule.h @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/TargetSchedule.h - Sched Machine Model -----*- C++ -*-===// +//===- llvm/CodeGen/TargetSchedule.h - Sched Machine Model ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -23,10 +23,8 @@ namespace llvm { -class TargetRegisterInfo; -class TargetSubtargetInfo; -class TargetInstrInfo; class MachineInstr; +class TargetInstrInfo; /// Provide an instruction scheduling machine model to CodeGen passes. class TargetSchedModel { @@ -34,8 +32,8 @@ class TargetSchedModel { // processor. MCSchedModel SchedModel; InstrItineraryData InstrItins; - const TargetSubtargetInfo *STI; - const TargetInstrInfo *TII; + const TargetSubtargetInfo *STI = nullptr; + const TargetInstrInfo *TII = nullptr; SmallVector ResourceFactors; unsigned MicroOpFactor; // Multiply to normalize microops to resource units. @@ -44,7 +42,7 @@ class TargetSchedModel { unsigned computeInstrLatency(const MCSchedClassDesc &SCDesc) const; public: - TargetSchedModel(): SchedModel(MCSchedModel::GetDefaultSchedModel()), STI(nullptr), TII(nullptr) {} + TargetSchedModel() : SchedModel(MCSchedModel::GetDefaultSchedModel()) {} /// \brief Initialize the machine model for instruction scheduling. /// @@ -185,6 +183,6 @@ public: const MachineInstr *DepMI) const; }; -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_CODEGEN_TARGETSCHEDULE_H diff --git a/lib/CodeGen/BuiltinGCs.cpp b/lib/CodeGen/BuiltinGCs.cpp index ff7c99de042..e4eab8c513d 100644 --- a/lib/CodeGen/BuiltinGCs.cpp +++ b/lib/CodeGen/BuiltinGCs.cpp @@ -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 // @@ -14,6 +14,8 @@ #include "llvm/CodeGen/GCs.h" #include "llvm/CodeGen/GCStrategy.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/Support/Casting.h" using namespace llvm; @@ -77,6 +79,7 @@ public: UsesMetadata = false; CustomRoots = false; } + Optional isGCManagedPointer(const Type *Ty) const override { // Method is only valid on pointer typed values. const PointerType *PT = cast(Ty); @@ -110,6 +113,7 @@ public: UsesMetadata = false; CustomRoots = false; } + Optional isGCManagedPointer(const Type *Ty) const override { // Method is only valid on pointer typed values. const PointerType *PT = cast(Ty); @@ -117,7 +121,8 @@ public: return (1 == PT->getAddressSpace()); } }; -} + +} // end anonymous namespace // Register all the above so that they can be found at runtime. Note that // these static initializers are important since the registration list is diff --git a/lib/CodeGen/FaultMaps.cpp b/lib/CodeGen/FaultMaps.cpp index 374d6c7136a..43f36412897 100644 --- a/lib/CodeGen/FaultMaps.cpp +++ b/lib/CodeGen/FaultMaps.cpp @@ -1,4 +1,4 @@ -//===---------------------------- FaultMaps.cpp ---------------------------===// +//===- FaultMaps.cpp ------------------------------------------------------===// // // 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/FaultMaps.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCStreamer.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; @@ -102,12 +105,10 @@ void FaultMaps::emitFunctionInfo(const MCSymbol *FnLabel, } } - const char *FaultMaps::faultTypeToString(FaultMaps::FaultKind FT) { switch (FT) { default: llvm_unreachable("unhandled fault type!"); - case FaultMaps::FaultingLoad: return "FaultingLoad"; case FaultMaps::FaultingLoadStore: diff --git a/lib/CodeGen/GCStrategy.cpp b/lib/CodeGen/GCStrategy.cpp index 31ab86fdf27..6be4c16c630 100644 --- a/lib/CodeGen/GCStrategy.cpp +++ b/lib/CodeGen/GCStrategy.cpp @@ -1,4 +1,4 @@ -//===-- GCStrategy.cpp - Garbage Collector Description --------------------===// +//===- GCStrategy.cpp - Garbage Collector Description ---------------------===// // // The LLVM Compiler Infrastructure // @@ -18,7 +18,4 @@ using namespace llvm; LLVM_INSTANTIATE_REGISTRY(GCRegistry) -GCStrategy::GCStrategy() - : UseStatepoints(false), NeededSafePoints(0), CustomReadBarriers(false), - CustomWriteBarriers(false), CustomRoots(false), InitRoots(true), - UsesMetadata(false) {} +GCStrategy::GCStrategy() = default; diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index f30f57d0c1e..fcd77a8b078 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1,4 +1,4 @@ -//===-- FastISel.cpp - Implementation of the FastISel class ---------------===// +//===- FastISel.cpp - Implementation of the FastISel class ----------------===// // // 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/SmallPtrSet.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/BranchProbabilityInfo.h" -#include "llvm/Analysis/Loads.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/CodeGen/Analysis.h" #include "llvm/CodeGen/FastISel.h" #include "llvm/CodeGen/FunctionLoweringInfo.h" +#include "llvm/CodeGen/ISDOpcodes.h" +#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/CodeGen/MachineModuleInfo.h" +#include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/MachineValueType.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/DebugInfo.h" +#include "llvm/IR/DebugLoc.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.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/IntrinsicInst.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/IR/Mangler.h" +#include "llvm/IR/Metadata.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/ErrorHandling.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetSubtargetInfo.h" +#include +#include +#include +#include +#include + using namespace llvm; #define DEBUG_TYPE "isel" @@ -1665,7 +1706,7 @@ FastISel::FastISel(FunctionLoweringInfo &FuncInfo, TRI(*MF->getSubtarget().getRegisterInfo()), LibInfo(LibInfo), SkipTargetIndependentISel(SkipTargetIndependentISel) {} -FastISel::~FastISel() {} +FastISel::~FastISel() = default; bool FastISel::fastLowerArguments() { return false; } diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 21431a166c0..dab6231ee1b 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info --===// +//===- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info ---===// // // The LLVM Compiler Infrastructure // @@ -12,18 +12,27 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" +#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" +#include "llvm/IR/Comdat.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.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/Mangler.h" +#include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" +#include "llvm/IR/Type.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" @@ -32,18 +41,23 @@ #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionWasm.h" #include "llvm/MC/MCStreamer.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbolELF.h" -#include "llvm/MC/MCSymbolWasm.h" #include "llvm/MC/MCValue.h" +#include "llvm/MC/SectionKind.h" #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/CodeGen.h" #include "llvm/Support/COFF.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/ELF.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MachO.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetSubtargetInfo.h" +#include +#include + using namespace llvm; using namespace dwarf; @@ -55,10 +69,10 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol( const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const { unsigned Encoding = getPersonalityEncoding(); - if ((Encoding & 0x80) == dwarf::DW_EH_PE_indirect) + if ((Encoding & 0x80) == DW_EH_PE_indirect) return getContext().getOrCreateSymbol(StringRef("DW.ref.") + TM.getSymbol(GV)->getName()); - if ((Encoding & 0x70) == dwarf::DW_EH_PE_absptr) + if ((Encoding & 0x70) == DW_EH_PE_absptr) return TM.getSymbol(GV); report_fatal_error("We do not support this DWARF encoding yet!"); } @@ -88,8 +102,7 @@ void TargetLoweringObjectFileELF::emitPersonalityValue( const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference( const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const { - - if (Encoding & dwarf::DW_EH_PE_indirect) { + if (Encoding & DW_EH_PE_indirect) { MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo(); MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM); @@ -104,7 +117,7 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference( return TargetLoweringObjectFile:: getTTypeReference(MCSymbolRefExpr::create(SSym, getContext()), - Encoding & ~dwarf::DW_EH_PE_indirect, Streamer); + Encoding & ~DW_EH_PE_indirect, Streamer); } return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM, @@ -151,7 +164,6 @@ getELFKindForNamedSection(StringRef Name, SectionKind K) { return K; } - static unsigned getELFSectionType(StringRef Name, SectionKind K) { // Use SHT_NOTE for section whose name starts with ".note" to allow // emitting ELF notes from C variable declaration. @@ -725,7 +737,7 @@ const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference( return TargetLoweringObjectFile:: getTTypeReference(MCSymbolRefExpr::create(SSym, getContext()), - Encoding & ~dwarf::DW_EH_PE_indirect, Streamer); + Encoding & ~DW_EH_PE_indirect, Streamer); } return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM, diff --git a/lib/CodeGen/TargetSchedule.cpp b/lib/CodeGen/TargetSchedule.cpp index 83e52d33535..a4dd753975c 100644 --- a/lib/CodeGen/TargetSchedule.cpp +++ b/lib/CodeGen/TargetSchedule.cpp @@ -1,4 +1,4 @@ -//===-- llvm/Target/TargetSchedule.cpp - Sched Machine Model ----*- C++ -*-===// +//===- llvm/Target/TargetSchedule.cpp - Sched Machine Model ---------------===// // // 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/MC/MCInstrDesc.h" +#include "llvm/MC/MCInstrItineraries.h" +#include "llvm/MC/MCSchedule.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSubtargetInfo.h" +#include +#include +#include using namespace llvm; @@ -37,13 +47,14 @@ bool TargetSchedModel::hasInstrItineraries() const { static unsigned gcd(unsigned Dividend, unsigned Divisor) { // Dividend and Divisor will be naturally swapped as needed. - while(Divisor) { + while (Divisor) { unsigned Rem = Dividend % Divisor; Dividend = Divisor; Divisor = Rem; }; return Dividend; } + static unsigned lcm(unsigned A, unsigned B) { unsigned LCM = (uint64_t(A) * B) / gcd(A, B); 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. const MCSchedClassDesc *TargetSchedModel:: resolveSchedClass(const MachineInstr *MI) const { - // Get the definition's scheduling class descriptor from this machine model. unsigned SchedClass = MI->getDesc().getSchedClass(); const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SchedClass);