forked from OSchip/llvm-project
Eliminated the Unique class in favor of NonCopyable and NonCopyableV
llvm-svn: 280
This commit is contained in:
parent
e2472bbf6c
commit
78a307b170
|
@ -24,7 +24,7 @@
|
||||||
#ifndef LLVM_CODEGEN_INSTRFOREST_H
|
#ifndef LLVM_CODEGEN_INSTRFOREST_H
|
||||||
#define LLVM_CODEGEN_INSTRFOREST_H
|
#define LLVM_CODEGEN_INSTRFOREST_H
|
||||||
|
|
||||||
#include "llvm/Support/Unique.h"
|
#include "llvm/Support/NonCopyable.h"
|
||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include <hash_map>
|
#include <hash_map>
|
||||||
#include <hash_set>
|
#include <hash_set>
|
||||||
|
@ -128,7 +128,7 @@ MainTreeNode(BasicTreeNode* node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class InstrTreeNode: public Unique {
|
class InstrTreeNode : public NonCopyableV {
|
||||||
public:
|
public:
|
||||||
enum InstrTreeNodeType { NTInstructionNode,
|
enum InstrTreeNodeType { NTInstructionNode,
|
||||||
NTVRegListNode,
|
NTVRegListNode,
|
||||||
|
@ -144,7 +144,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
/*ctor*/ InstrTreeNode (InstrTreeNodeType nodeType,
|
/*ctor*/ InstrTreeNode (InstrTreeNodeType nodeType,
|
||||||
Value* _val);
|
Value* _val);
|
||||||
/*dtor*/ virtual ~InstrTreeNode ();
|
/*dtor*/ virtual ~InstrTreeNode () {}
|
||||||
|
|
||||||
BasicTreeNode* getBasicNode () { return &basicNode; }
|
BasicTreeNode* getBasicNode () { return &basicNode; }
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ protected:
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
class InstrForest :
|
class InstrForest :
|
||||||
public Unique,
|
public NonCopyable,
|
||||||
private hash_map<const Instruction*, InstructionNode*> {
|
private hash_map<const Instruction*, InstructionNode*> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "llvm/CodeGen/InstrForest.h"
|
#include "llvm/CodeGen/InstrForest.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include "llvm/Support/Unique.h"
|
#include "llvm/Support/NonCopyable.h"
|
||||||
#include "llvm/CodeGen/TargetMachine.h"
|
#include "llvm/CodeGen/TargetMachine.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -177,7 +177,7 @@ MachineOperand::InitializeReg(unsigned int _regNum)
|
||||||
// opcode and set bits in opCodeMask for each of these flags.
|
// opcode and set bits in opCodeMask for each of these flags.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
class MachineInstr : public Unique {
|
class MachineInstr : public NonCopyable {
|
||||||
private:
|
private:
|
||||||
MachineOpCode opCode;
|
MachineOpCode opCode;
|
||||||
OpCodeMask opCodeMask; // extra bits for variants of an opcode
|
OpCodeMask opCodeMask; // extra bits for variants of an opcode
|
||||||
|
@ -187,7 +187,7 @@ public:
|
||||||
/*ctor*/ MachineInstr (MachineOpCode _opCode,
|
/*ctor*/ MachineInstr (MachineOpCode _opCode,
|
||||||
OpCodeMask _opCodeMask = 0x0);
|
OpCodeMask _opCodeMask = 0x0);
|
||||||
|
|
||||||
/*dtor*/ ~MachineInstr ();
|
inline ~MachineInstr () {}
|
||||||
|
|
||||||
const MachineOpCode getOpCode () const;
|
const MachineOpCode getOpCode () const;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#ifndef LLVM_CODEGEN_TARGETMACHINE_H
|
#ifndef LLVM_CODEGEN_TARGETMACHINE_H
|
||||||
#define LLVM_CODEGEN_TARGETMACHINE_H
|
#define LLVM_CODEGEN_TARGETMACHINE_H
|
||||||
|
|
||||||
#include "llvm/Support/Unique.h"
|
#include "llvm/Support/NonCopyable.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ extern const MachineInstrInfo* TargetMachineInstrInfo;
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
class TargetMachine: public Unique {
|
class TargetMachine : public NonCopyableV {
|
||||||
public:
|
public:
|
||||||
int optSizeForSubWordData;
|
int optSizeForSubWordData;
|
||||||
int intSize;
|
int intSize;
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
unsigned int getStorageSize(const TargetMachine& tmi) const {
|
unsigned int getStorageSize(const TargetMachine& tmi) const {
|
||||||
if (layoutCache->targetInfo && *layoutCache->targetInfo != tmi) {
|
if (layoutCache->targetInfo && layoutCache->targetInfo != &tmi) {
|
||||||
// target machine has changed (hey it could happen). discard cached info.
|
// target machine has changed (hey it could happen). discard cached info.
|
||||||
ResetCachedInfo();
|
ResetCachedInfo();
|
||||||
layoutCache->targetInfo = &tmi;
|
layoutCache->targetInfo = &tmi;
|
||||||
|
@ -134,7 +134,7 @@ public:
|
||||||
}
|
}
|
||||||
unsigned int getElementOffset(int i, const TargetMachine& tmi) const {
|
unsigned int getElementOffset(int i, const TargetMachine& tmi) const {
|
||||||
// target machine has changed (hey it could happen). discard cached info.
|
// target machine has changed (hey it could happen). discard cached info.
|
||||||
if (layoutCache->targetInfo && *layoutCache->targetInfo != tmi)
|
if (layoutCache->targetInfo && layoutCache->targetInfo != &tmi)
|
||||||
ResetCachedInfo();
|
ResetCachedInfo();
|
||||||
|
|
||||||
if (layoutCache->memberOffsets[i] < 0) {
|
if (layoutCache->memberOffsets[i] < 0) {
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
|
//===-- include/Support/DataTypes.h - Define fixed size types ----*- C++ -*--=//
|
||||||
|
//
|
||||||
|
// This file contains definitions to figure out the size of _HOST_ data types.
|
||||||
|
// This file is important because different host OS's define different macros,
|
||||||
|
// which makes portability tough. This file exports the following definitions:
|
||||||
|
//
|
||||||
|
// LITTLE_ENDIAN: is #define'd if the host is little endian
|
||||||
|
// int64_t : is a typedef for the signed 64 bit system type
|
||||||
|
// uint64_t : is a typedef for the unsigned 64 bit system type
|
||||||
|
//
|
||||||
|
// No library is required when using these functinons.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// TODO: This file sucks. Not only does it not work, but this stuff should be
|
// TODO: This file sucks. Not only does it not work, but this stuff should be
|
||||||
// autoconfiscated anyways. Major FIXME
|
// autoconfiscated anyways. Major FIXME
|
||||||
|
@ -6,11 +19,6 @@
|
||||||
#ifndef LLVM_SUPPORT_DATATYPES_H
|
#ifndef LLVM_SUPPORT_DATATYPES_H
|
||||||
#define LLVM_SUPPORT_DATATYPES_H
|
#define LLVM_SUPPORT_DATATYPES_H
|
||||||
|
|
||||||
// Should define the following:
|
|
||||||
// LITTLE_ENDIAN if applicable
|
|
||||||
// int64_t
|
|
||||||
// uint64_t
|
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
#include <stdint.h> // Defined by ISO C 99
|
#include <stdint.h> // Defined by ISO C 99
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
//===-- NonCopyable.h - Disable copy ctor and op= in subclasses --*- C++ -*--=//
|
||||||
|
//
|
||||||
|
// This file defines the NonCopyable and NonCopyableV classes. These mixin
|
||||||
|
// classes may be used to mark a class not being copyable. You should derive
|
||||||
|
// from NonCopyable if you don't want to have a virtual dtor, or NonCopyableV
|
||||||
|
// if you do want polymorphic behavior in your class.
|
||||||
|
//
|
||||||
|
// No library is required when using these functinons.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_SUPPORT_NONCOPYABLE_H
|
||||||
|
#define LLVM_SUPPORT_NONCOPYABLE_H
|
||||||
|
|
||||||
|
class NonCopyable {
|
||||||
|
// Disable the copy constructor and the assignment operator
|
||||||
|
// by making them both private:
|
||||||
|
//
|
||||||
|
NonCopyable(const NonCopyable &); // DO NOT IMPLEMENT
|
||||||
|
NonCopyable &operator=(const NonCopyable &); // DO NOT IMPLEMENT
|
||||||
|
protected:
|
||||||
|
inline NonCopyable() {}
|
||||||
|
inline ~NonCopyable() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class NonCopyableV {
|
||||||
|
// Disable the copy constructor and the assignment operator
|
||||||
|
// by making them both private:
|
||||||
|
//
|
||||||
|
NonCopyableV(const NonCopyableV &); // DO NOT IMPLEMENT
|
||||||
|
NonCopyableV &operator=(const NonCopyableV &); // DO NOT IMPLEMENT
|
||||||
|
protected:
|
||||||
|
inline NonCopyableV() {}
|
||||||
|
virtual ~NonCopyableV() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,56 +0,0 @@
|
||||||
//************************************************************-*- C++ -*-
|
|
||||||
// class Unique:
|
|
||||||
// Mixin class for classes that should never be copied.
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
// This mixin disables both the copy constructor and the
|
|
||||||
// assignment operator. It also provides a default equality operator.
|
|
||||||
//
|
|
||||||
// History:
|
|
||||||
// 09/24/96 - vadve - Created (adapted from dHPF).
|
|
||||||
//
|
|
||||||
//***************************************************************************
|
|
||||||
|
|
||||||
#ifndef UNIQUE_H
|
|
||||||
#define UNIQUE_H
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
|
|
||||||
class Unique
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
/*ctor*/ Unique () {}
|
|
||||||
/*dtor*/ virtual ~Unique () {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual bool operator== (const Unique& u1) const;
|
|
||||||
virtual bool operator!= (const Unique& u1) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
//
|
|
||||||
// Disable the copy constructor and the assignment operator
|
|
||||||
// by making them both private:
|
|
||||||
//
|
|
||||||
/*ctor*/ Unique (Unique&) { assert(0); }
|
|
||||||
virtual Unique& operator= (const Unique& u1) { assert(0);
|
|
||||||
return *this; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Unique object equality.
|
|
||||||
inline bool
|
|
||||||
Unique::operator==(const Unique& u2) const
|
|
||||||
{
|
|
||||||
return (bool) (this == &u2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Unique object inequality.
|
|
||||||
inline bool
|
|
||||||
Unique::operator!=(const Unique& u2) const
|
|
||||||
{
|
|
||||||
return (bool) !(this == &u2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -50,10 +50,6 @@ InstrTreeNode::InstrTreeNode(InstrTreeNodeType nodeType,
|
||||||
basicNode.treeNodePtr = this;
|
basicNode.treeNodePtr = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstrTreeNode::~InstrTreeNode()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InstrTreeNode::dump(int dumpChildren,
|
InstrTreeNode::dump(int dumpChildren,
|
||||||
int indent) const
|
int indent) const
|
||||||
|
|
|
@ -45,10 +45,6 @@ MachineInstr::MachineInstr(MachineOpCode _opCode,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineInstr::~MachineInstr()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MachineInstr::SetMachineOperand(unsigned int i,
|
MachineInstr::SetMachineOperand(unsigned int i,
|
||||||
MachineOperand::MachineOperandType operandType,
|
MachineOperand::MachineOperandType operandType,
|
||||||
|
|
Loading…
Reference in New Issue