mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 23:17:16 +00:00
LLVMContext: Store APInt/APFloat directly into the ConstantInt/FP DenseMaps.
Required some APInt massaging to get proper empty/tombstone values. Apart from making the code a bit simpler this also reduces the bucket size of the ConstantInt map from 32 to 24 bytes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223478 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
+9
-10
@@ -555,18 +555,17 @@ Constant *ConstantInt::getFalse(Type *Ty) {
|
||||
}
|
||||
|
||||
|
||||
// Get a ConstantInt from an APInt. Note that the value stored in the DenseMap
|
||||
// as the key, is a DenseMapAPIntKeyInfo::KeyTy which has provided the
|
||||
// operator== and operator!= to ensure that the DenseMap doesn't attempt to
|
||||
// compare APInt's of different widths, which would violate an APInt class
|
||||
// invariant which generates an assertion.
|
||||
// Get a ConstantInt from an APInt.
|
||||
ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt &V) {
|
||||
// Get the corresponding integer type for the bit width of the value.
|
||||
IntegerType *ITy = IntegerType::get(Context, V.getBitWidth());
|
||||
// get an existing value or the insertion position
|
||||
LLVMContextImpl *pImpl = Context.pImpl;
|
||||
ConstantInt *&Slot = pImpl->IntConstants[DenseMapAPIntKeyInfo::KeyTy(V, ITy)];
|
||||
if (!Slot) Slot = new ConstantInt(ITy, V);
|
||||
ConstantInt *&Slot = pImpl->IntConstants[V];
|
||||
if (!Slot) {
|
||||
// Get the corresponding integer type for the bit width of the value.
|
||||
IntegerType *ITy = IntegerType::get(Context, V.getBitWidth());
|
||||
Slot = new ConstantInt(ITy, V);
|
||||
}
|
||||
assert(Slot->getType() == IntegerType::get(Context, V.getBitWidth()));
|
||||
return Slot;
|
||||
}
|
||||
|
||||
@@ -689,7 +688,7 @@ Constant *ConstantFP::getZeroValueForNegation(Type *Ty) {
|
||||
ConstantFP* ConstantFP::get(LLVMContext &Context, const APFloat& V) {
|
||||
LLVMContextImpl* pImpl = Context.pImpl;
|
||||
|
||||
ConstantFP *&Slot = pImpl->FPConstants[DenseMapAPFloatKeyInfo::KeyTy(V)];
|
||||
ConstantFP *&Slot = pImpl->FPConstants[V];
|
||||
|
||||
if (!Slot) {
|
||||
Type *Ty;
|
||||
|
||||
Reference in New Issue
Block a user