aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-02-05 02:00:12 +0000
committerChris Lattner <sabre@nondot.org>2005-02-05 02:00:12 +0000
commiteecfea4da6771b01997d3dc9648e699b476a3079 (patch)
tree77ddabb3deac6b1b32e58699e6218076f90e1c90
parent88fe29a1da91017d8390039e3e8baaf2775afa88 (diff)
Eliminate the explicit opcode field in ConstantExpr, using the SubclassData
field to hold it instead. This shrinks memory usage for 176.gcc from 57628728 to 57598144 bytes, a small reduction of about 30K. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20047 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Constants.h22
1 files changed, 9 insertions, 13 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index d22270e871..91e7b208a2 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -510,26 +510,22 @@ public:
/// ConstantExpr - a constant value that is initialized with an expression using
-/// other constant values. This is only used to represent values that cannot be
-/// evaluated at compile-time (e.g., something derived from an address) because
-/// it does not have a mechanism to store the actual value. Use the appropriate
-/// Constant subclass above for known constants.
+/// other constant values.
///
+/// This class uses the standard Instruction opcodes to define the various
+/// constant expressions. The Opcode field for the ConstantExpr class is
+/// maintained in the Value::SubclassData field.
class ConstantExpr : public Constant {
- unsigned iType; // Operation type (an Instruction opcode)
friend struct ConstantCreator<ConstantExpr,Type,
std::pair<unsigned, std::vector<Constant*> > >;
friend struct ConvertConstantType<ConstantExpr, Type>;
protected:
ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)
- : Constant(Ty, ConstantExprVal, Ops, NumOps), iType(Opcode) {}
-
- // Select instruction creation ctor
- ConstantExpr(Constant *C, Constant *V1, Constant *V2);
- // GEP instruction creation ctor
- ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
- const Type *DestTy);
+ : Constant(Ty, ConstantExprVal, Ops, NumOps) {
+ // Operation type (an Instruction opcode) is stored as the SubclassData.
+ SubclassData = Opcode;
+ }
// These private methods are used by the type resolution code to create
// ConstantExprs in intermediate forms.
@@ -609,7 +605,7 @@ public:
virtual bool isNullValue() const { return false; }
/// getOpcode - Return the opcode at the root of this constant expression
- unsigned getOpcode() const { return iType; }
+ unsigned getOpcode() const { return SubclassData; }
/// getOpcodeName - Return a string representation for an opcode.
const char *getOpcodeName() const;