File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,18 @@ class DataLayout : public ImmutablePass {
271
271
unsigned getPointerSizeInBits (unsigned AS = 0 ) const {
272
272
return getPointerSize (AS) * 8 ;
273
273
}
274
+
275
+ // / Layout pointer size, in bits, based on the type. If this function is
276
+ // / called with a pointer type, then the type size of the pointer is returned.
277
+ // / If this function is called with a vector of pointers, then the type size
278
+ // / of the pointer is returned. This should only be called with a pointer or
279
+ // / vector of pointers.
280
+ unsigned getPointerTypeSizeInBits (Type *) const ;
281
+
282
+ unsigned getPointerTypeSize (Type *Ty) const {
283
+ return getPointerTypeSizeInBits (Ty) / 8 ;
284
+ }
285
+
274
286
// / Size examples:
275
287
// /
276
288
// / Type SizeInBits StoreSizeInBits AllocSizeInBits[*]
Original file line number Diff line number Diff line change @@ -507,6 +507,16 @@ std::string DataLayout::getStringRepresentation() const {
507
507
return OS.str ();
508
508
}
509
509
510
+ unsigned DataLayout::getPointerTypeSizeInBits (Type *Ty) const {
511
+ assert (Ty->isPtrOrPtrVectorTy () &&
512
+ " This should only be called with a pointer or pointer vector type" );
513
+
514
+ if (Ty->isPointerTy ())
515
+ return getTypeSizeInBits (Ty);
516
+
517
+ Type *EleTy = cast<VectorType>(Ty)->getElementType ();
518
+ return getTypeSizeInBits (EleTy);
519
+ }
510
520
511
521
/* !
512
522
\param abi_or_pref Flag that determines which alignment is returned. true
You can’t perform that action at this time.
0 commit comments