Commit 7b451a92 by Jim Stichnoth

Subzero: Class definition cleanup.

For consistency, put deleted ctors at the beginning of the class definition. If the default copy ctor or assignment operator is not deleted, and the default implementation is used, leave it commented out to indicate it is intentional. Also, fixed one C++11 related TODO. BUG= none R=jvoung@chromium.org, kschimpf@google.com Review URL: https://codereview.chromium.org/656123003
parent 5ce0abb8
......@@ -48,10 +48,6 @@ CfgNode *Cfg::makeNode(const IceString &Name) {
return Node;
}
Variable *Cfg::makeVariable(Type Ty, const IceString &Name) {
return makeVariable<Variable>(Ty, Name);
}
void Cfg::addArg(Variable *Arg) {
Arg->setIsArg();
Args.push_back(Arg);
......
......@@ -28,6 +28,9 @@
namespace Ice {
class Cfg {
Cfg(const Cfg &) = delete;
Cfg &operator=(const Cfg &) = delete;
public:
Cfg(GlobalContext *Ctx);
~Cfg();
......@@ -67,15 +70,13 @@ public:
// Manage Variables.
// Create a new Variable with a particular type and an optional
// name. The Node argument is the node where the variable is defined.
template <typename T> T *makeVariable(Type Ty, const IceString &Name = "") {
template <typename T = Variable>
T *makeVariable(Type Ty, const IceString &Name = "") {
SizeT Index = Variables.size();
T *Var = T::create(this, Ty, Index, Name);
Variables.push_back(Var);
return Var;
}
// TODO(stichnot): Remove this function with C++11, and use default
// argument <typename T=Variable> above.
Variable *makeVariable(Type Ty, const IceString &Name = "");
SizeT getNumVariables() const { return Variables.size(); }
const VarList &getVariables() const { return Variables; }
......@@ -187,9 +188,6 @@ private:
// register allocation, resetCurrentNode() should be called to avoid
// spurious validation failures.
const CfgNode *CurrentNode;
Cfg(const Cfg &) = delete;
Cfg &operator=(const Cfg &) = delete;
};
} // end of namespace Ice
......
......@@ -21,6 +21,9 @@
namespace Ice {
class CfgNode {
CfgNode(const CfgNode &) = delete;
CfgNode &operator=(const CfgNode &) = delete;
public:
static CfgNode *create(Cfg *Func, SizeT LabelIndex, IceString Name = "") {
return new (Func->allocate<CfgNode>()) CfgNode(Func, LabelIndex, Name);
......@@ -76,8 +79,6 @@ public:
private:
CfgNode(Cfg *Func, SizeT LabelIndex, IceString Name);
CfgNode(const CfgNode &) = delete;
CfgNode &operator=(const CfgNode &) = delete;
Cfg *const Func;
const SizeT Number; // label index
IceString Name; // for dumping only
......
......@@ -25,6 +25,9 @@ class Module;
namespace Ice {
class Converter : public Translator {
Converter(const Converter &) = delete;
Converter &operator=(const Converter &) = delete;
public:
Converter(llvm::Module *Mod, GlobalContext *Ctx, const Ice::ClFlags &Flags)
: Translator(Ctx, Flags), Mod(Mod) {}
......@@ -64,9 +67,6 @@ private:
// Installs global declarations into GlobalDeclarationMap.
void installGlobalDeclarations(llvm::Module *Mod);
Converter(const Converter &) = delete;
Converter &operator=(const Converter &) = delete;
};
} // end of namespace ICE.
......
......@@ -34,6 +34,9 @@ class FuncSigType;
// This class collects rudimentary statistics during translation.
class CodeStats {
CodeStats(const CodeStats &) = delete;
// CodeStats &operator=(const CodeStats &) = delete;
public:
CodeStats()
: InstructionsEmitted(0), RegistersSaved(0), FrameBytes(0), Spills(0),
......@@ -65,6 +68,9 @@ private:
// be synchronized, especially the constant pool, the allocator, and
// the output streams.
class GlobalContext {
GlobalContext(const GlobalContext &) = delete;
GlobalContext &operator=(const GlobalContext &) = delete;
public:
GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit,
VerboseMask Mask, TargetArch Arch, OptLevel Opt,
......@@ -201,8 +207,6 @@ private:
CodeStats StatsCumulative;
std::vector<TimerStack> Timers;
std::vector<GlobalDeclaration *> GlobalDeclarations;
GlobalContext(const GlobalContext &) = delete;
GlobalContext &operator=(const GlobalContext &) = delete;
// Private helpers for mangleName()
typedef llvm::SmallVector<char, 32> ManglerVector;
......
......@@ -24,6 +24,9 @@ class InstCall;
static const size_t kMaxIntrinsicParameters = 6;
class Intrinsics {
Intrinsics(const Intrinsics &) = delete;
Intrinsics &operator=(const Intrinsics &) = delete;
public:
Intrinsics();
~Intrinsics();
......@@ -158,9 +161,6 @@ private:
// TODO(jvoung): May want to switch to something like LLVM's StringMap.
typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap;
IntrinsicMap Map;
Intrinsics(const Intrinsics &) = delete;
Intrinsics &operator=(const Intrinsics &) = delete;
};
} // end of namespace Ice
......
......@@ -26,6 +26,11 @@
namespace Ice {
class LivenessNode {
// TODO: Disable these constructors when Liveness::Nodes is no
// longer an STL container.
// LivenessNode(const LivenessNode &) = delete;
// LivenessNode &operator=(const LivenessNode &) = delete;
public:
LivenessNode() : NumLocals(0) {}
// NumLocals is the number of Variables local to this block.
......@@ -43,12 +48,6 @@ public:
// index/key of each element is less than NumLocals +
// Liveness::NumGlobals.
LiveBeginEndMap LiveBegin, LiveEnd;
private:
// TODO: Disable these constructors when Liveness::Nodes is no
// longer an STL container.
// LivenessNode(const LivenessNode &) = delete;
// LivenessNode &operator=(const LivenessNode &) = delete;
};
class Liveness {
......
......@@ -26,6 +26,9 @@
namespace Ice {
class Operand {
Operand(const Operand &) = delete;
Operand &operator=(const Operand &) = delete;
public:
static const size_t MaxTargetKinds = 10;
enum OperandKind {
......@@ -86,10 +89,6 @@ protected:
// Vars and NumVars are initialized by the derived class.
SizeT NumVars;
Variable **Vars;
private:
Operand(const Operand &) = delete;
Operand &operator=(const Operand &) = delete;
};
template<class StreamType>
......@@ -101,6 +100,9 @@ inline StreamType &operator<<(StreamType &Str, const Operand &Op) {
// Constant is the abstract base class for constants. All
// constants are allocated from a global arena and are pooled.
class Constant : public Operand {
Constant(const Constant &) = delete;
Constant &operator=(const Constant &) = delete;
public:
uint32_t getPoolEntryID() const { return PoolEntryID; }
using Operand::dump;
......@@ -124,15 +126,14 @@ protected:
// within its constant pool. It is used for building the constant
// pool in the object code and for referencing its entries.
const uint32_t PoolEntryID;
private:
Constant(const Constant &) = delete;
Constant &operator=(const Constant &) = delete;
};
// ConstantPrimitive<> wraps a primitive type.
template <typename T, Operand::OperandKind K>
class ConstantPrimitive : public Constant {
ConstantPrimitive(const ConstantPrimitive &) = delete;
ConstantPrimitive &operator=(const ConstantPrimitive &) = delete;
public:
static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value,
uint32_t PoolEntryID) {
......@@ -154,8 +155,6 @@ public:
private:
ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID)
: Constant(K, Ty, PoolEntryID), Value(Value) {}
ConstantPrimitive(const ConstantPrimitive &) = delete;
ConstantPrimitive &operator=(const ConstantPrimitive &) = delete;
~ConstantPrimitive() override {}
const T Value;
};
......@@ -182,15 +181,13 @@ template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const
// ConstantRelocatable can fit into the global constant pool
// template mechanism.
class RelocatableTuple {
// RelocatableTuple(const RelocatableTuple &) = delete;
RelocatableTuple &operator=(const RelocatableTuple &) = delete;
public:
RelocatableTuple(const RelocOffsetT Offset, const IceString &Name,
bool SuppressMangling)
: Offset(Offset), Name(Name), SuppressMangling(SuppressMangling) {}
RelocatableTuple(const RelocatableTuple &Other)
: Offset(Other.Offset), Name(Other.Name),
SuppressMangling(Other.SuppressMangling) {}
const RelocOffsetT Offset;
const IceString Name;
......@@ -202,6 +199,9 @@ bool operator<(const RelocatableTuple &A, const RelocatableTuple &B);
// ConstantRelocatable represents a symbolic constant combined with
// a fixed offset.
class ConstantRelocatable : public Constant {
ConstantRelocatable(const ConstantRelocatable &) = delete;
ConstantRelocatable &operator=(const ConstantRelocatable &) = delete;
public:
static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty,
const RelocatableTuple &Tuple,
......@@ -229,8 +229,6 @@ private:
bool SuppressMangling, uint32_t PoolEntryID)
: Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset),
Name(Name), SuppressMangling(SuppressMangling) {}
ConstantRelocatable(const ConstantRelocatable &) = delete;
ConstantRelocatable &operator=(const ConstantRelocatable &) = delete;
~ConstantRelocatable() override {}
const RelocOffsetT Offset; // fixed offset to add
const IceString Name; // optional for debug/dump
......@@ -241,6 +239,9 @@ private:
// legal to lower ConstantUndef to any value, backends should try to
// make code generation deterministic by lowering ConstantUndefs to 0.
class ConstantUndef : public Constant {
ConstantUndef(const ConstantUndef &) = delete;
ConstantUndef &operator=(const ConstantUndef &) = delete;
public:
static ConstantUndef *create(GlobalContext *Ctx, Type Ty,
uint32_t PoolEntryID) {
......@@ -260,8 +261,6 @@ public:
private:
ConstantUndef(Type Ty, uint32_t PoolEntryID)
: Constant(kConstUndef, Ty, PoolEntryID) {}
ConstantUndef(const ConstantUndef &) = delete;
ConstantUndef &operator=(const ConstantUndef &) = delete;
~ConstantUndef() override {}
};
......@@ -269,6 +268,9 @@ private:
// special value that represents infinite weight, and an addWeight()
// method that ensures that W+infinity=infinity.
class RegWeight {
// RegWeight(const RegWeight &) = delete;
// RegWeight &operator=(const RegWeight &) = delete;
public:
RegWeight() : Weight(0) {}
RegWeight(uint32_t Weight) : Weight(Weight) {}
......@@ -300,6 +302,9 @@ bool operator==(const RegWeight &A, const RegWeight &B);
// weight, in case e.g. we want a live range to have higher weight
// inside a loop.
class LiveRange {
// LiveRange(const LiveRange &) = delete;
// LiveRange &operator=(const LiveRange &) = delete;
public:
LiveRange() : Weight(0), IsNonpoints(false) {}
......@@ -516,6 +521,9 @@ typedef std::vector<const Inst *> InstDefList;
// VariableTracking tracks the metadata for a single variable. It is
// only meant to be used internally by VariablesMetadata.
class VariableTracking {
// VariableTracking(const VariableTracking &) = delete;
VariableTracking &operator=(const VariableTracking &) = delete;
public:
enum MultiDefState {
// TODO(stichnot): Consider using just a simple counter.
......@@ -543,7 +551,6 @@ public:
void markDef(const Inst *Instr, const CfgNode *Node);
private:
VariableTracking &operator=(const VariableTracking &) = delete;
MultiDefState MultiDef;
MultiBlockState MultiBlock;
const CfgNode *SingleUseNode;
......@@ -556,6 +563,9 @@ private:
// VariablesMetadata analyzes and summarizes the metadata for the
// complete set of Variables.
class VariablesMetadata {
VariablesMetadata(const VariablesMetadata &) = delete;
VariablesMetadata &operator=(const VariablesMetadata &) = delete;
public:
VariablesMetadata(const Cfg *Func) : Func(Func) {}
// Initialize the state by traversing all instructions/variables in
......@@ -602,8 +612,6 @@ private:
const Cfg *Func;
std::vector<VariableTracking> Metadata;
const static InstDefList NoDefinitions;
VariablesMetadata(const VariablesMetadata &) = delete;
VariablesMetadata &operator=(const VariablesMetadata &) = delete;
};
} // end of namespace Ice
......
......@@ -22,14 +22,14 @@
namespace Ice {
class RandomNumberGenerator {
RandomNumberGenerator(const RandomNumberGenerator &) = delete;
RandomNumberGenerator &operator=(const RandomNumberGenerator &) = delete;
public:
RandomNumberGenerator(llvm::StringRef Salt);
uint64_t next(uint64_t Max);
private:
RandomNumberGenerator(const RandomNumberGenerator &) = delete;
RandomNumberGenerator &operator=(const RandomNumberGenerator &) = delete;
uint64_t State;
};
......@@ -37,16 +37,16 @@ private:
// reason for the wrapper class is that we want to keep the
// RandomNumberGenerator interface identical to LLVM's.
class RandomNumberGeneratorWrapper {
RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &) = delete;
RandomNumberGeneratorWrapper &
operator=(const RandomNumberGeneratorWrapper &) = delete;
public:
uint64_t next(uint64_t Max) { return RNG.next(Max); }
bool getTrueWithProbability(float Probability);
RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {}
private:
RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &) = delete;
RandomNumberGeneratorWrapper &
operator=(const RandomNumberGeneratorWrapper &) = delete;
RandomNumberGenerator &RNG;
};
......
......@@ -35,6 +35,9 @@ class Assembler;
// when inserting new instructions in order to track whether variables
// are used as single-block or multi-block.
class LoweringContext {
LoweringContext(const LoweringContext &) = delete;
LoweringContext &operator=(const LoweringContext &) = delete;
public:
LoweringContext() : Node(NULL) {}
~LoweringContext() {}
......@@ -86,11 +89,12 @@ private:
void skipDeleted(InstList::iterator &I) const;
void advanceForward(InstList::iterator &I) const;
void advanceBackward(InstList::iterator &I) const;
LoweringContext(const LoweringContext &) = delete;
LoweringContext &operator=(const LoweringContext &) = delete;
};
class TargetLowering {
TargetLowering(const TargetLowering &) = delete;
TargetLowering &operator=(const TargetLowering &) = delete;
public:
static TargetLowering *createLowering(TargetArch Target, Cfg *Func);
static Assembler *createAssembler(TargetArch Target, Cfg *Func);
......@@ -233,16 +237,16 @@ protected:
// natural location, as arguments are pushed for a function call.
int32_t StackAdjustment;
LoweringContext Context;
private:
TargetLowering(const TargetLowering &) = delete;
TargetLowering &operator=(const TargetLowering &) = delete;
};
// TargetGlobalInitLowering is used for "lowering" global
// initializers. It is separated out from TargetLowering because it
// does not require a Cfg.
class TargetGlobalInitLowering {
TargetGlobalInitLowering(const TargetGlobalInitLowering &) = delete;
TargetGlobalInitLowering &operator=(const TargetGlobalInitLowering &) =
delete;
public:
static TargetGlobalInitLowering *createLowering(TargetArch Target,
GlobalContext *Ctx);
......@@ -253,11 +257,6 @@ public:
protected:
TargetGlobalInitLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
GlobalContext *Ctx;
private:
TargetGlobalInitLowering(const TargetGlobalInitLowering &) = delete;
TargetGlobalInitLowering &operator=(const TargetGlobalInitLowering &) =
delete;
};
} // end of namespace Ice
......
......@@ -25,6 +25,9 @@
namespace Ice {
class TargetX8632 : public TargetLowering {
TargetX8632(const TargetX8632 &) = delete;
TargetX8632 &operator=(const TargetX8632 &) = delete;
public:
static TargetX8632 *create(Cfg *Func) { return new TargetX8632(Func); }
......@@ -483,13 +486,14 @@ protected:
static IceString RegNames[];
private:
TargetX8632(const TargetX8632 &) = delete;
TargetX8632 &operator=(const TargetX8632 &) = delete;
~TargetX8632() override {}
template <typename T> void emitConstantPool() const;
};
class TargetGlobalInitX8632 : public TargetGlobalInitLowering {
TargetGlobalInitX8632(const TargetGlobalInitX8632 &) = delete;
TargetGlobalInitX8632 &operator=(const TargetGlobalInitX8632 &) = delete;
public:
static TargetGlobalInitLowering *create(GlobalContext *Ctx) {
return new TargetGlobalInitX8632(Ctx);
......@@ -501,8 +505,6 @@ protected:
TargetGlobalInitX8632(GlobalContext *Ctx);
private:
TargetGlobalInitX8632(const TargetGlobalInitX8632 &) = delete;
TargetGlobalInitX8632 &operator=(const TargetGlobalInitX8632 &) = delete;
~TargetGlobalInitX8632() override {}
};
......
......@@ -31,6 +31,9 @@ typedef std::vector<TimerTreeNode>::size_type TTindex;
// the TimerTreeNode::Nodes array, and the parent is always at a lower
// index.
class TimerTreeNode {
// TimerTreeNode(const TimerTreeNode &) = delete;
TimerTreeNode &operator=(const TimerTreeNode &) = delete;
public:
TimerTreeNode() : Parent(0), Interior(0), Time(0), UpdateCount(0) {}
std::vector<TTindex> Children; // indexed by TimerIdT
......
......@@ -32,6 +32,9 @@ class GlobalContext;
// other intermediate representations down to ICE, and then call the appropriate
// (inherited) methods to convert ICE into machine instructions.
class Translator {
Translator(const Translator &) = delete;
Translator &operator=(const Translator &) = delete;
public:
typedef std::vector<VariableDeclaration *> VariableDeclarationListType;
......@@ -81,11 +84,8 @@ protected:
// GlobalContext instead of Cfg, and then make emitConstantPool use
// that.
std::unique_ptr<Cfg> Func;
private:
Translator(const Translator &) = delete;
Translator &operator=(const Translator &) = delete;
};
}
} // end of namespace Ice
#endif // SUBZERO_SRC_ICETRANSLATOR_H
......@@ -22,6 +22,9 @@
namespace Ice {
class PNaClTranslator : public Translator {
PNaClTranslator(const PNaClTranslator &) = delete;
PNaClTranslator &operator=(const PNaClTranslator &) = delete;
public:
PNaClTranslator(GlobalContext *Ctx, const ClFlags &Flags)
: Translator(Ctx, Flags) {}
......@@ -29,11 +32,8 @@ public:
// converted to machine code. Sets ErrorStatus to true if any
// errors occurred.
void translate(const std::string &IRFilename);
private:
PNaClTranslator(const PNaClTranslator &) = delete;
PNaClTranslator &operator=(const PNaClTranslator &) = delete;
};
}
} // end of namespace Ice
#endif // SUBZERO_SRC_PNACLTRANSLATOR_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment