From eecfea4da6771b01997d3dc9648e699b476a3079 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 5 Feb 2005 02:00:12 +0000 Subject: [PATCH] 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 --- include/llvm/Constants.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index d22270e8712..91e7b208a21 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 > >; friend struct ConvertConstantType; 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 &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;