@@ -83,7 +83,7 @@ unsigned StructLayout::getElementContainingOffset(uint64_t Offset) const {
83
83
assert ((SI == &MemberOffsets[0 ] || *(SI-1 ) <= Offset) &&
84
84
(SI+1 == &MemberOffsets[NumElements] || *(SI+1 ) > Offset) &&
85
85
" Upper bound didn't work!" );
86
-
86
+
87
87
// Multiple fields can have the same offset if any of them are zero sized.
88
88
// For example, in { i32, [0 x i32], i32 }, searching for offset 4 will stop
89
89
// at the i32 element, because it is the last element at that offset. This is
@@ -153,16 +153,16 @@ void TargetData::init(StringRef Desc) {
153
153
std::pair<StringRef, StringRef> Split = Desc.split (' -' );
154
154
StringRef Token = Split.first ;
155
155
Desc = Split.second ;
156
-
156
+
157
157
if (Token.empty ())
158
158
continue ;
159
-
159
+
160
160
Split = Token.split (' :' );
161
161
StringRef Specifier = Split.first ;
162
162
Token = Split.second ;
163
-
163
+
164
164
assert (!Specifier.empty () && " Can't be empty here" );
165
-
165
+
166
166
switch (Specifier[0 ]) {
167
167
case ' E' :
168
168
LittleEndian = false ;
@@ -197,7 +197,7 @@ void TargetData::init(StringRef Desc) {
197
197
unsigned Size = getInt (Specifier.substr (1 ));
198
198
Split = Token.split (' :' );
199
199
unsigned ABIAlign = getInt (Split.first ) / 8 ;
200
-
200
+
201
201
Split = Split.second .split (' :' );
202
202
unsigned PrefAlign = getInt (Split.first ) / 8 ;
203
203
if (PrefAlign == 0 )
@@ -215,7 +215,7 @@ void TargetData::init(StringRef Desc) {
215
215
Token = Split.second ;
216
216
} while (!Specifier.empty () || !Token.empty ());
217
217
break ;
218
-
218
+
219
219
default :
220
220
break ;
221
221
}
@@ -231,7 +231,7 @@ TargetData::TargetData() : ImmutablePass(ID) {
231
231
" Tool did not specify a TargetData to use?" );
232
232
}
233
233
234
- TargetData::TargetData (const Module *M)
234
+ TargetData::TargetData (const Module *M)
235
235
: ImmutablePass(ID) {
236
236
init (M->getDataLayout ());
237
237
}
@@ -249,14 +249,14 @@ TargetData::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
249
249
return ;
250
250
}
251
251
}
252
-
252
+
253
253
Alignments.push_back (TargetAlignElem::get (align_type, abi_align,
254
254
pref_align, bit_width));
255
255
}
256
256
257
- // / getAlignmentInfo - Return the alignment (either ABI if ABIInfo = true or
257
+ // / getAlignmentInfo - Return the alignment (either ABI if ABIInfo = true or
258
258
// / preferred if ABIInfo = false) the target wants for the specified datatype.
259
- unsigned TargetData::getAlignmentInfo (AlignTypeEnum AlignType,
259
+ unsigned TargetData::getAlignmentInfo (AlignTypeEnum AlignType,
260
260
uint32_t BitWidth, bool ABIInfo,
261
261
const Type *Ty) const {
262
262
// Check to see if we have an exact match and remember the best match we see.
@@ -266,18 +266,18 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
266
266
if (Alignments[i].AlignType == AlignType &&
267
267
Alignments[i].TypeBitWidth == BitWidth)
268
268
return ABIInfo ? Alignments[i].ABIAlign : Alignments[i].PrefAlign ;
269
-
269
+
270
270
// The best match so far depends on what we're looking for.
271
- if (AlignType == INTEGER_ALIGN &&
271
+ if (AlignType == INTEGER_ALIGN &&
272
272
Alignments[i].AlignType == INTEGER_ALIGN) {
273
273
// The "best match" for integers is the smallest size that is larger than
274
274
// the BitWidth requested.
275
- if (Alignments[i].TypeBitWidth > BitWidth && (BestMatchIdx == -1 ||
275
+ if (Alignments[i].TypeBitWidth > BitWidth && (BestMatchIdx == -1 ||
276
276
Alignments[i].TypeBitWidth < Alignments[BestMatchIdx].TypeBitWidth ))
277
277
BestMatchIdx = i;
278
278
// However, if there isn't one that's larger, then we must use the
279
279
// largest one we have (see below)
280
- if (LargestInt == -1 ||
280
+ if (LargestInt == -1 ||
281
281
Alignments[i].TypeBitWidth > Alignments[LargestInt].TypeBitWidth )
282
282
LargestInt = i;
283
283
}
@@ -322,8 +322,8 @@ class StructLayoutMap : public AbstractTypeUser {
322
322
I->first ->removeAbstractTypeUser (this );
323
323
LayoutInfo.erase (I);
324
324
}
325
-
326
-
325
+
326
+
327
327
// / refineAbstractType - The callback method invoked when an abstract type is
328
328
// / resolved to another type. An object must override this method to update
329
329
// / its internal state to reference NewType instead of OldType.
@@ -385,21 +385,21 @@ TargetData::~TargetData() {
385
385
const StructLayout *TargetData::getStructLayout (const StructType *Ty) const {
386
386
if (!LayoutMap)
387
387
LayoutMap = new StructLayoutMap ();
388
-
388
+
389
389
StructLayoutMap *STM = static_cast <StructLayoutMap*>(LayoutMap);
390
390
StructLayout *&SL = (*STM)[Ty];
391
391
if (SL) return SL;
392
392
393
- // Otherwise, create the struct layout. Because it is variable length, we
393
+ // Otherwise, create the struct layout. Because it is variable length, we
394
394
// malloc it, then use placement new.
395
395
int NumElts = Ty->getNumElements ();
396
396
StructLayout *L =
397
397
(StructLayout *)malloc (sizeof (StructLayout)+(NumElts-1 ) * sizeof (uint64_t ));
398
-
398
+
399
399
// Set SL before calling StructLayout's ctor. The ctor could cause other
400
400
// entries to be added to TheMap, invalidating our reference.
401
401
SL = L;
402
-
402
+
403
403
new (L) StructLayout (Ty, *this );
404
404
405
405
if (Ty->isAbstract ())
@@ -414,14 +414,14 @@ const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
414
414
// / avoid a dangling pointer in this cache.
415
415
void TargetData::InvalidateStructLayoutInfo (const StructType *Ty) const {
416
416
if (!LayoutMap) return ; // No cache.
417
-
417
+
418
418
static_cast <StructLayoutMap*>(LayoutMap)->InvalidateEntry (Ty);
419
419
}
420
420
421
421
std::string TargetData::getStringRepresentation () const {
422
422
std::string Result;
423
423
raw_string_ostream OS (Result);
424
-
424
+
425
425
OS << (LittleEndian ? " e" : " E" )
426
426
<< " -p:" << PointerMemSize*8 << ' :' << PointerABIAlign*8
427
427
<< ' :' << PointerPrefAlign*8 ;
@@ -430,10 +430,10 @@ std::string TargetData::getStringRepresentation() const {
430
430
OS << ' -' << (char )AI.AlignType << AI.TypeBitWidth << ' :'
431
431
<< AI.ABIAlign *8 << ' :' << AI.PrefAlign *8 ;
432
432
}
433
-
433
+
434
434
if (!LegalIntWidths.empty ()) {
435
435
OS << " -n" << (unsigned )LegalIntWidths[0 ];
436
-
436
+
437
437
for (unsigned i = 1 , e = LegalIntWidths.size (); i != e; ++i)
438
438
OS << ' :' << (unsigned )LegalIntWidths[i];
439
439
}
0 commit comments