mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-15 16:38:41 +00:00
Split SimpleConstantVal up into its components, so each Constant subclass gets
a different enum value. This allows 'classof' for these to be really simple, not needing to call getType() anymore. This speeds up isa/dyncast/etc for constants, and also makes them smaller. For example, the text section of a release build of InstCombine.cpp shrinks from 230037 bytes to 216363 bytes, a 6% reduction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23466 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a9ec8ab32b
commit
225e8dd2f5
@ -61,12 +61,8 @@ public:
|
|||||||
static inline bool classof(const Constant *) { return true; }
|
static inline bool classof(const Constant *) { return true; }
|
||||||
static inline bool classof(const GlobalValue *) { return true; }
|
static inline bool classof(const GlobalValue *) { return true; }
|
||||||
static inline bool classof(const Value *V) {
|
static inline bool classof(const Value *V) {
|
||||||
return V->getValueType() == Value::SimpleConstantVal ||
|
return V->getValueType() >= ConstantFirstVal &&
|
||||||
V->getValueType() == Value::ConstantExprVal ||
|
V->getValueType() <= ConstantLastVal;
|
||||||
V->getValueType() == Value::ConstantAggregateZeroVal ||
|
|
||||||
V->getValueType() == Value::FunctionVal ||
|
|
||||||
V->getValueType() == Value::GlobalVariableVal ||
|
|
||||||
V->getValueType() == Value::UndefValueVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// replaceUsesOfWithOnConstant - This method is a special form of
|
/// replaceUsesOfWithOnConstant - This method is a special form of
|
||||||
|
@ -47,7 +47,7 @@ protected:
|
|||||||
int64_t Signed;
|
int64_t Signed;
|
||||||
uint64_t Unsigned;
|
uint64_t Unsigned;
|
||||||
} Val;
|
} Val;
|
||||||
ConstantIntegral(const Type *Ty, uint64_t V);
|
ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// getRawValue - return the underlying value of this constant as a 64-bit
|
/// getRawValue - return the underlying value of this constant as a 64-bit
|
||||||
@ -98,8 +98,9 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantIntegral *) { return true; }
|
static inline bool classof(const ConstantIntegral *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantBoolVal ||
|
||||||
V->getType()->isIntegral();
|
V->getValueType() == ConstantSIntVal ||
|
||||||
|
V->getValueType() == ConstantUIntVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantBool *) { return true; }
|
static inline bool classof(const ConstantBool *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return (V == True) | (V == False);
|
return V->getValueType() == ConstantBoolVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -146,7 +147,7 @@ public:
|
|||||||
class ConstantInt : public ConstantIntegral {
|
class ConstantInt : public ConstantIntegral {
|
||||||
protected:
|
protected:
|
||||||
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
|
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
|
||||||
ConstantInt(const Type *Ty, uint64_t V);
|
ConstantInt(const Type *Ty, ValueTy VT, uint64_t V);
|
||||||
public:
|
public:
|
||||||
/// equalsInt - Provide a helper method that can be used to determine if the
|
/// equalsInt - Provide a helper method that can be used to determine if the
|
||||||
/// constant contained within is equal to a constant. This only works for
|
/// constant contained within is equal to a constant. This only works for
|
||||||
@ -173,8 +174,8 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantInt *) { return true; }
|
static inline bool classof(const ConstantInt *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantSIntVal ||
|
||||||
V->getType()->isInteger();
|
V->getValueType() == ConstantUIntVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -227,8 +228,7 @@ public:
|
|||||||
///
|
///
|
||||||
static inline bool classof(const ConstantSInt *) { return true; }
|
static inline bool classof(const ConstantSInt *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantSIntVal;
|
||||||
V->getType()->isSigned();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -263,8 +263,7 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantUInt *) { return true; }
|
static inline bool classof(const ConstantUInt *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantUIntVal;
|
||||||
V->getType()->isUnsigned();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -301,8 +300,7 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantFP *) { return true; }
|
static inline bool classof(const ConstantFP *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantFPVal;
|
||||||
V->getType()->isFloatingPoint();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -380,8 +378,7 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantArray *) { return true; }
|
static inline bool classof(const ConstantArray *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantArrayVal;
|
||||||
V->getType()->getTypeID() == Type::ArrayTyID;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -422,8 +419,7 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantStruct *) { return true; }
|
static inline bool classof(const ConstantStruct *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantStructVal;
|
||||||
V->getType()->getTypeID() == Type::StructTyID;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -461,8 +457,7 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantPacked *) { return true; }
|
static inline bool classof(const ConstantPacked *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantPackedVal;
|
||||||
V->getType()->getTypeID() == Type::PackedTyID;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -475,7 +470,7 @@ class ConstantPointerNull : public Constant {
|
|||||||
protected:
|
protected:
|
||||||
ConstantPointerNull(const PointerType *T)
|
ConstantPointerNull(const PointerType *T)
|
||||||
: Constant(reinterpret_cast<const Type*>(T),
|
: Constant(reinterpret_cast<const Type*>(T),
|
||||||
Value::SimpleConstantVal, 0, 0) {}
|
Value::ConstantPointerNullVal, 0, 0) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -498,8 +493,7 @@ public:
|
|||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const ConstantPointerNull *) { return true; }
|
static inline bool classof(const ConstantPointerNull *) { return true; }
|
||||||
static bool classof(const Value *V) {
|
static bool classof(const Value *V) {
|
||||||
return V->getValueType() == SimpleConstantVal &&
|
return V->getValueType() == ConstantPointerNullVal;
|
||||||
isa<PointerType>(V->getType());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,8 +146,19 @@ public:
|
|||||||
UndefValueVal, // This is an instance of UndefValue
|
UndefValueVal, // This is an instance of UndefValue
|
||||||
ConstantExprVal, // This is an instance of ConstantExpr
|
ConstantExprVal, // This is an instance of ConstantExpr
|
||||||
ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull
|
ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull
|
||||||
SimpleConstantVal, // This is some other type of Constant
|
ConstantBoolVal, // This is an instance of ConstantBool
|
||||||
|
ConstantSIntVal, // This is an instance of ConstantSInt
|
||||||
|
ConstantUIntVal, // This is an instance of ConstantUInt
|
||||||
|
ConstantFPVal, // This is an instance of ConstantFP
|
||||||
|
ConstantArrayVal, // This is an instance of ConstantArray
|
||||||
|
ConstantStructVal, // This is an instance of ConstantStruct
|
||||||
|
ConstantPackedVal, // This is an instance of ConstantPacked
|
||||||
|
ConstantPointerNullVal, // This is an instance of ConstantPointerNull
|
||||||
InstructionVal, // This is an instance of Instruction
|
InstructionVal, // This is an instance of Instruction
|
||||||
|
|
||||||
|
// Markers:
|
||||||
|
ConstantFirstVal = FunctionVal,
|
||||||
|
ConstantLastVal = ConstantPointerNullVal,
|
||||||
};
|
};
|
||||||
unsigned getValueType() const {
|
unsigned getValueType() const {
|
||||||
return SubclassID;
|
return SubclassID;
|
||||||
@ -194,12 +205,8 @@ void Use::set(Value *V) {
|
|||||||
// the subtype header files to test to see if the value is a subclass...
|
// the subtype header files to test to see if the value is a subclass...
|
||||||
//
|
//
|
||||||
template <> inline bool isa_impl<Constant, Value>(const Value &Val) {
|
template <> inline bool isa_impl<Constant, Value>(const Value &Val) {
|
||||||
return Val.getValueType() == Value::SimpleConstantVal ||
|
return Val.getValueType() >= Value::ConstantFirstVal &&
|
||||||
Val.getValueType() == Value::FunctionVal ||
|
Val.getValueType() <= Value::ConstantLastVal;
|
||||||
Val.getValueType() == Value::GlobalVariableVal ||
|
|
||||||
Val.getValueType() == Value::ConstantExprVal ||
|
|
||||||
Val.getValueType() == Value::ConstantAggregateZeroVal ||
|
|
||||||
Val.getValueType() == Value::UndefValueVal;
|
|
||||||
}
|
}
|
||||||
template <> inline bool isa_impl<Argument, Value>(const Value &Val) {
|
template <> inline bool isa_impl<Argument, Value>(const Value &Val) {
|
||||||
return Val.getValueType() == Value::ArgumentVal;
|
return Val.getValueType() == Value::ArgumentVal;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user