LLVM: lib/IR/DataLayout.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

35#include

36#include

37#include

38#include

39#include

40#include

41

42using namespace llvm;

43

44

45

46

47

49 : StructSize(TypeSize::getFixed(0)) {

50 assert(ST->isOpaque() && "Cannot get layout of opaque structs");

51 IsPadded = false;

52 NumElements = ST->getNumElements();

53

54

55 for (unsigned i = 0, e = NumElements; i != e; ++i) {

56 Type *Ty = ST->getElementType(i);

57 if (i == 0 && Ty->isScalableTy())

59

60 const Align TyAlign = ST->isPacked() ? Align(1) : DL.getABITypeAlign(Ty);

61

62

63

64

65

66

67

68

69 if (!StructSize.isScalable() && isAligned(TyAlign, StructSize)) {

70 IsPadded = true;

72 }

73

74

75 StructAlignment = std::max(TyAlign, StructAlignment);

76

78

79 StructSize += DL.getTypeAllocSize(Ty);

80 }

81

82

83

84 if (!StructSize.isScalable() && isAligned(StructAlignment, StructSize)) {

85 IsPadded = true;

87 }

88}

89

90

91

93 assert(!StructSize.isScalable() &&

94 "Cannot get element at offset for structure containing scalable "

95 "vector types");

98

102 });

103 assert(SI != MemberOffsets.begin() && "Offset not in structure type!");

104 --SI;

108 (SI + 1 == MemberOffsets.end() ||

110 "Upper bound didn't work!");

111

112

113

114

115

116

117 return SI - MemberOffsets.begin();

118}

119

120namespace {

121

122class StructLayoutMap {

124 LayoutInfoTy LayoutInfo;

125

126public:

127 ~StructLayoutMap() {

128

129 for (const auto &I : LayoutInfo) {

131 Value->~StructLayout();

133 }

134 }

135

136 StructLayout *&operator[](StructType *STy) { return LayoutInfo[STy]; }

137};

138

139}

140

141

142

143

144

149

158

159namespace {

160

161struct LessPrimitiveBitWidth {

163 unsigned RHSBitWidth) const {

164 return LHS.BitWidth < RHSBitWidth;

165 }

166};

167

168

169struct LessPointerAddrSpace {

171 unsigned RHSAddrSpace) const {

172 return LHS.AddrSpace < RHSAddrSpace;

173 }

174};

175}

176

177

178

195

204

206 if (Error Err = parseLayoutString(LayoutString))

208}

209

211 delete static_cast<StructLayoutMap *>(LayoutMap);

212 LayoutMap = nullptr;

213 StringRepresentation = Other.StringRepresentation;

214 BigEndian = Other.BigEndian;

215 AllocaAddrSpace = Other.AllocaAddrSpace;

216 ProgramAddrSpace = Other.ProgramAddrSpace;

217 DefaultGlobalsAddrSpace = Other.DefaultGlobalsAddrSpace;

218 StackNaturalAlign = Other.StackNaturalAlign;

219 FunctionPtrAlign = Other.FunctionPtrAlign;

220 TheFunctionPtrAlignType = Other.TheFunctionPtrAlignType;

221 ManglingMode = Other.ManglingMode;

222 LegalIntWidths = Other.LegalIntWidths;

223 IntSpecs = Other.IntSpecs;

224 FloatSpecs = Other.FloatSpecs;

225 VectorSpecs = Other.VectorSpecs;

226 PointerSpecs = Other.PointerSpecs;

227 StructABIAlignment = Other.StructABIAlignment;

228 StructPrefAlignment = Other.StructPrefAlignment;

229 return *this;

230}

231

233

234 return BigEndian == Other.BigEndian &&

235 AllocaAddrSpace == Other.AllocaAddrSpace &&

236 ProgramAddrSpace == Other.ProgramAddrSpace &&

237 DefaultGlobalsAddrSpace == Other.DefaultGlobalsAddrSpace &&

238 StackNaturalAlign == Other.StackNaturalAlign &&

239 FunctionPtrAlign == Other.FunctionPtrAlign &&

240 TheFunctionPtrAlignType == Other.TheFunctionPtrAlignType &&

241 ManglingMode == Other.ManglingMode &&

242 LegalIntWidths == Other.LegalIntWidths && IntSpecs == Other.IntSpecs &&

243 FloatSpecs == Other.FloatSpecs && VectorSpecs == Other.VectorSpecs &&

244 PointerSpecs == Other.PointerSpecs &&

245 StructABIAlignment == Other.StructABIAlignment &&

246 StructPrefAlignment == Other.StructPrefAlignment;

247}

248

251 if (Error Err = Layout.parseLayoutString(LayoutString))

252 return std::move(Err);

253 return Layout;

254}

255

257 return createStringError("malformed specification, must be of the form \"" +

258 Format + "\"");

259}

260

261

263 if (Str.empty())

264 return createStringError("address space component cannot be empty");

265

267 return createStringError("address space must be a 24-bit integer");

268

270}

271

272

273

274

275

278 if (Str.empty())

279 return createStringError("address space component cannot be empty");

280

281 if (isDigit(Str.front())) {

282 if (Str.consumeInteger(10, AddrSpace) || isUInt<24>(AddrSpace))

283 return createStringError("address space must be a 24-bit integer");

284 }

285

286 if (Str.empty())

288

289 if (Str.front() != '(')

290 return createStringError("address space must be a 24-bit integer");

291

292

293 if (Str.back() != ')' || Str.size() == 2)

295

297

298

299

300

301

302

303

304

305 if (AddrSpaceName.size() == 1) {

306 char C = AddrSpaceName.front();

307 if (C == 'P' || C == 'G' || C == 'A')

309 "Cannot use predefined address space names P/G/A in data layout");

310 }

312}

313

314

317 if (Str.empty())

319

321 return createStringError(Name + " must be a non-zero 24-bit integer");

322

324}

325

326

327

328

329

330

331

332

333

334

335

336

338 bool AllowZero = false) {

339 if (Str.empty())

340 return createStringError(Name + " alignment component cannot be empty");

341

344 return createStringError(Name + " alignment must be a 16-bit integer");

345

346 if (Value == 0) {

347 if (!AllowZero)

349 Alignment = Align(1);

351 }

352

353 constexpr unsigned ByteWidth = 8;

356 Name + " alignment must be a power of two times the byte width");

357

358 Alignment = Align(Value / ByteWidth);

360}

361

363

366 assert(Specifier == 'i' || Specifier == 'f' || Specifier == 'v');

368

369 if (Components.size() < 2 || Components.size() > 3)

371

372

375 return Err;

376

377

380 return Err;

381

382 if (Specifier == 'i' && BitWidth == 8 && ABIAlign != 1)

384

385

386 Align PrefAlign = ABIAlign;

387 if (Components.size() > 2)

389 return Err;

390

391 if (PrefAlign < ABIAlign)

393 "preferred alignment cannot be less than the ABI alignment");

394

395 setPrimitiveSpec(Specifier, BitWidth, ABIAlign, PrefAlign);

397}

398

400

404

405 if (Components.size() < 2 || Components.size() > 3)

407

408

409

410

411 if (!Components[0].empty()) {

415 }

416

417

420 parseAlignment(Components[1], ABIAlign, "ABI", true))

421 return Err;

422

423

424 Align PrefAlign = ABIAlign;

425 if (Components.size() > 2)

427 return Err;

428

429 if (PrefAlign < ABIAlign)

431 "preferred alignment cannot be less than the ABI alignment");

432

433 StructABIAlignment = ABIAlign;

434 StructPrefAlignment = PrefAlign;

436}

437

438Error DataLayout::parsePointerSpec(

440

444

445 if (Components.size() < 3 || Components.size() > 5)

447

448

449 unsigned AddrSpace = 0;

450 bool ExternalState = false;

451 bool UnstableRepr = false;

452 StringRef AddrSpaceName;

453 StringRef AddrSpaceStr = Components[0];

454 while (!AddrSpaceStr.empty()) {

455 char C = AddrSpaceStr.front();

456 if (C == 'e') {

457 ExternalState = true;

458 } else if (C == 'u') {

459 UnstableRepr = true;

461 return createStringError("'%c' is not a valid pointer specification flag",

462 C);

463 } else {

464 break;

465 }

466 AddrSpaceStr = AddrSpaceStr.drop_front(1);

467 }

468 if (!AddrSpaceStr.empty())

471 return Err;

472 if (AddrSpace == 0 && (ExternalState || UnstableRepr))

474 "address space 0 cannot be unstable or have external state");

475

476

477 if (!AddrSpaceName.empty() && !AddrSpaceNames.insert(AddrSpaceName).second)

478 return createStringError("address space name `" + AddrSpaceName +

479 "` already used");

480

481

484 return Err;

485

486

489 return Err;

490

491

492

493 Align PrefAlign = ABIAlign;

494 if (Components.size() > 3)

496 return Err;

497

498 if (PrefAlign < ABIAlign)

500 "preferred alignment cannot be less than the ABI alignment");

501

502

503 unsigned IndexBitWidth = BitWidth;

504 if (Components.size() > 4)

505 if (Error Err = parseSize(Components[4], IndexBitWidth, "index size"))

506 return Err;

507

508 if (IndexBitWidth > BitWidth)

510 "index size cannot be larger than the pointer size");

511

512 setPointerSpec(AddrSpace, BitWidth, ABIAlign, PrefAlign, IndexBitWidth,

513 UnstableRepr, ExternalState, AddrSpaceName);

515}

516

517Error DataLayout::parseSpecification(

520

522

524

525

528

529 for (StringRef Str : split(Rest, ':')) {

530 unsigned AddrSpace;

532 return Err;

533 if (AddrSpace == 0)

534 return createStringError("address space 0 cannot be non-integral");

535 NonIntegralAddressSpaces.push_back(AddrSpace);

536 }

538 }

539

540

541 assert(!Spec.empty() && "Empty specification is handled by the caller");

543

544 if (Specifier == 'i' || Specifier == 'f' || Specifier == 'v')

545 return parsePrimitiveSpec(Spec);

546

547 if (Specifier == 'a')

548 return parseAggregateSpec(Spec);

549

550 if (Specifier == 'p')

551 return parsePointerSpec(Spec, AddrSpaceNames);

552

554 switch (Specifier) {

555 case 's':

556

557

558 break;

559 case 'e':

560 case 'E':

561 if (!Rest.empty())

563 "malformed specification, must be just 'e' or 'E'");

565 break;

566 case 'n':

567

568 for (StringRef Str : split(Rest, ':')) {

571 return Err;

572 LegalIntWidths.push_back(BitWidth);

573 }

574 break;

575 case 'S': {

576

577 if (Rest.empty())

581 return Err;

582 StackNaturalAlign = Alignment;

583 break;

584 }

585 case 'F': {

586

587 if (Rest.empty())

591 switch (Type) {

592 case 'i':

594 break;

595 case 'n':

597 break;

598 default:

599 return createStringError("unknown function pointer alignment type '" +

600 Twine(Type) + "'");

601 }

604 return Err;

605 FunctionPtrAlign = Alignment;

606 break;

607 }

608 case 'P': {

609 if (Rest.empty())

612 return Err;

613 break;

614 }

615 case 'A': {

616 if (Rest.empty())

619 return Err;

620 break;

621 }

622 case 'G': {

623 if (Rest.empty())

626 return Err;

627 break;

628 }

629 case 'm':

632 if (Rest.size() > 1)

634 switch (Rest[0]) {

635 default:

637 case 'e':

638 ManglingMode = MM_ELF;

639 break;

640 case 'l':

641 ManglingMode = MM_GOFF;

642 break;

643 case 'o':

644 ManglingMode = MM_MachO;

645 break;

646 case 'm':

647 ManglingMode = MM_Mips;

648 break;

649 case 'w':

650 ManglingMode = MM_WinCOFF;

651 break;

652 case 'x':

653 ManglingMode = MM_WinCOFFX86;

654 break;

655 case 'a':

656 ManglingMode = MM_XCOFF;

657 break;

658 }

659 break;

660 default:

661 return createStringError("unknown specifier '" + Twine(Specifier) + "'");

662 }

663

665}

666

667Error DataLayout::parseLayoutString(StringRef LayoutString) {

668 StringRepresentation = LayoutString.str();

669

670 if (LayoutString.empty())

672

673

674

675 SmallVector<unsigned, 8> NonIntegralAddressSpaces;

676 SmallDenseSet<StringRef, 8> AddessSpaceNames;

677 for (StringRef Spec : split(StringRepresentation, '-')) {

678 if (Spec.empty())

680 if (Error Err = parseSpecification(Spec, NonIntegralAddressSpaces,

681 AddessSpaceNames))

682 return Err;

683 }

684

685

686

687 for (unsigned AS : NonIntegralAddressSpaces) {

688

689

690 const PointerSpec &PS = getPointerSpec(AS);

691 setPointerSpec(AS, PS.BitWidth, PS.ABIAlign, PS.PrefAlign, PS.IndexBitWidth,

692 true, false,

694 }

695

697}

698

699void DataLayout::setPrimitiveSpec(char Specifier, uint32_t BitWidth,

701 SmallVectorImpl *Specs;

702 switch (Specifier) {

703 default:

705 case 'i':

706 Specs = &IntSpecs;

707 break;

708 case 'f':

709 Specs = &FloatSpecs;

710 break;

711 case 'v':

712 Specs = &VectorSpecs;

713 break;

714 }

715

717 if (I != Specs->end() && I->BitWidth == BitWidth) {

718

719 I->ABIAlign = ABIAlign;

720 I->PrefAlign = PrefAlign;

721 } else {

722

724 }

725}

726

728DataLayout::getPointerSpec(uint32_t AddrSpace) const {

729 if (AddrSpace != 0) {

730 auto I = lower_bound(PointerSpecs, AddrSpace, LessPointerAddrSpace());

731 if (I != PointerSpecs.end() && I->AddrSpace == AddrSpace)

732 return *I;

733 }

734

735 assert(PointerSpecs[0].AddrSpace == 0);

736 return PointerSpecs[0];

737}

738

739void DataLayout::setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth,

741 uint32_t IndexBitWidth, bool HasUnstableRepr,

742 bool HasExternalState,

744 auto I = lower_bound(PointerSpecs, AddrSpace, LessPointerAddrSpace());

745 if (I == PointerSpecs.end() || I->AddrSpace != AddrSpace) {

747 IndexBitWidth, HasUnstableRepr,

748 HasExternalState, AddrSpaceName.str()});

749 } else {

751 I->ABIAlign = ABIAlign;

752 I->PrefAlign = PrefAlign;

753 I->IndexBitWidth = IndexBitWidth;

754 I->HasUnstableRepresentation = HasUnstableRepr;

755 I->HasExternalState = HasExternalState;

756 I->AddrSpaceName = AddrSpaceName.str();

757 }

758}

759

760Align DataLayout::getIntegerAlignment(uint32_t BitWidth,

761 bool abi_or_pref) const {

762 auto I = IntSpecs.begin();

763 for (; I != IntSpecs.end(); ++I) {

765 break;

766 }

767

768

769

770

771 if (I == IntSpecs.end())

772 --I;

773 return abi_or_pref ? I->ABIAlign : I->PrefAlign;

774}

775

777

779 if (!LayoutMap)

780 LayoutMap = new StructLayoutMap();

781

782 StructLayoutMap *STM = static_cast<StructLayoutMap*>(LayoutMap);

784 if (SL) return SL;

785

786

787

790

791

792

793 SL = L;

794

796

797 return L;

798}

799

801 return getPointerSpec(AS).ABIAlign;

802}

803

805 return getPointerSpec(AS).AddrSpaceName;

806}

807

811 });

812 if (II != PointerSpecs.end())

813 return II->AddrSpace;

814 return std::nullopt;

815}

816

818 return getPointerSpec(AS).PrefAlign;

819}

820

824

826 assert(Ty->isPtrOrPtrVectorTy() &&

827 "This should only be called with a pointer or pointer vector type");

828 Ty = Ty->getScalarType();

830}

831

833 return divideCeil(getPointerSpec(AS).IndexBitWidth, 8);

834}

835

837 assert(Ty->isPtrOrPtrVectorTy() &&

838 "This should only be called with a pointer or pointer vector type");

839 Ty = Ty->getScalarType();

841}

842

843

844

845

846

847

848

849

850

851Align DataLayout::getAlignment(Type *Ty, bool abi_or_pref) const {

852 assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");

853 switch (Ty->getTypeID()) {

854

861 }

864

866

869

870

872 const Align Align = abi_or_pref ? StructABIAlignment : StructPrefAlignment;

874 }

881

882

888 if (I != FloatSpecs.end() && I->BitWidth == BitWidth)

889 return abi_or_pref ? I->ABIAlign : I->PrefAlign;

890

891

892

893

894

895

896

898 }

903 if (I != VectorSpecs.end() && I->BitWidth == BitWidth)

904 return abi_or_pref ? I->ABIAlign : I->PrefAlign;

905

906

907

908

909

910

911

913 }

915 return Align(64);

918 return getAlignment(LayoutTy, abi_or_pref);

919 }

920 default:

922 }

923}

924

926 switch (Ty->getTypeID()) {

928

929

931 return ATy->getNumElements() * getTypeAllocSize(ATy->getElementType());

932 }

936

939

942 }

944 unsigned BitWidth = Ty->getIntegerBitWidth();

946 Align A = getIntegerAlignment(BitWidth, true);

948 }

950 unsigned AS = Ty->getPointerAddressSpace();

953 }

957 }

958 default:

960 }

961}

962

964 return getAlignment(Ty, true);

965}

966

968 return getAlignment(Ty, false);

969}

970

975

977 assert(Ty->isPtrOrPtrVectorTy() &&

978 "Expected a pointer or pointer vector type.");

983 return IntTy;

984}

985

987 for (unsigned LegalIntWidth : LegalIntWidths)

988 if (Width <= LegalIntWidth)

990 return nullptr;

991}

992

995 return Max != LegalIntWidths.end() ? *Max : 0;

996}

997

1002

1004 assert(Ty->isPtrOrPtrVectorTy() &&

1005 "Expected a pointer or pointer vector type.");

1010 return IntTy;

1011}

1012

1015 int64_t Result = 0;

1016

1020 for (; GTI != GTE; ++GTI) {

1025

1026

1028

1029

1031 } else {

1034 }

1035 }

1036

1037 return Result;

1038}

1039

1041

1042

1043

1045 if (ElemSize.isScalable() || ElemSize == 0 ||

1048 }

1049

1051 APInt Index = Offset.sdiv(FixedElemSize);

1052 Offset -= Index * FixedElemSize;

1053 if (Offset.isNegative()) {

1054

1055 --Index;

1056 Offset += FixedElemSize;

1057 assert(Offset.isNonNegative() && "Remaining offset shouldn't be negative");

1058 }

1059 return Index;

1060}

1061

1065 ElemTy = ArrTy->getElementType();

1067 }

1068

1070

1071

1072

1073 return std::nullopt;

1074 }

1075

1080 return std::nullopt;

1081

1084 ElemTy = STy->getElementType(Index);

1085 return APInt(32, Index);

1086 }

1087

1088

1089 return std::nullopt;

1090}

1091

1094 assert(ElemTy->isSized() && "Element type must be sized");

1097 while (Offset != 0) {

1099 if (!Index)

1100 break;

1102 }

1103

1104 return Indices;

1105}

1106

1107

1108

1111

1112

1113 if (GVAlignment && GV->hasSection())

1114 return *GVAlignment;

1115

1116

1117

1118

1119

1120

1121

1124 if (GVAlignment) {

1125 if (*GVAlignment >= Alignment)

1126 Alignment = *GVAlignment;

1127 else

1128 Alignment = std::max(*GVAlignment, getABITypeAlign(ElemType));

1129 }

1130

1131

1132

1133

1135 if (Alignment < Align(16)) {

1136

1137

1139 Alignment = Align(16);

1140 }

1141 }

1142 return Alignment;

1143}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static SmallVector< size_t > getMemberOffsets(const DataLayout &DL, GlobalVariable *Handle, llvm::function_ref< bool(Type *)> IsPadding)

This file contains the declarations for the subclasses of Constant, which represent the different fla...

static Error parseSize(StringRef Str, unsigned &BitWidth, StringRef Name="size")

Attempts to parse a size component of a specification.

Definition DataLayout.cpp:315

static APInt getElementIndex(TypeSize ElemSize, APInt &Offset)

Definition DataLayout.cpp:1040

static Error parseAddrSpace(StringRef Str, unsigned &AddrSpace)

Attempts to parse an address space component of a specification.

Definition DataLayout.cpp:262

static Error createSpecFormatError(Twine Format)

Definition DataLayout.cpp:256

static Error parseAlignment(StringRef Str, Align &Alignment, StringRef Name, bool AllowZero=false)

Attempts to parse an alignment component of a specification.

Definition DataLayout.cpp:337

constexpr DataLayout::PrimitiveSpec DefaultFloatSpecs[]

Definition DataLayout.cpp:185

constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[]

Definition DataLayout.cpp:191

constexpr DataLayout::PrimitiveSpec DefaultIntSpecs[]

Definition DataLayout.cpp:179

static Error parseAddrSpaceAndName(StringRef Str, unsigned &AddrSpace, StringRef &AddrSpaceName)

Attempts to parse an address space component of a specification allowing name to be specified as well...

Definition DataLayout.cpp:276

This file defines the DenseMap class.

This file defines counterparts of C library allocation functions defined in the namespace 'std'.

static unsigned getAddressSpace(const Value *V, unsigned MaxLookup)

uint64_t IntrinsicInst * II

static uint32_t getAlignment(const MCSectionCOFF &Sec)

Class for arbitrary precision integers.

static APInt getZero(unsigned numBits)

Get the '0' value for the specified bit-width.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

A parsed version of the target data layout string in and methods for querying it.

LLVM_ABI std::optional< unsigned > getNamedAddressSpace(StringRef Name) const

Definition DataLayout.cpp:808

LLVM_ABI StringRef getAddressSpaceName(unsigned AS) const

Definition DataLayout.cpp:804

unsigned getPointerSizeInBits(unsigned AS=0) const

The size in bits of the pointer representation in a given address space.

@ MultipleOfFunctionAlign

The function pointer alignment is a multiple of the function alignment.

@ Independent

The function pointer alignment is independent of the function alignment.

LLVM_ABI SmallVector< APInt > getGEPIndicesForOffset(Type *&ElemTy, APInt &Offset) const

Get GEP indices to access Offset inside ElemTy.

Definition DataLayout.cpp:1092

LLVM_ABI unsigned getLargestLegalIntTypeSizeInBits() const

Returns the size of largest legal integer type size, or 0 if none are set.

Definition DataLayout.cpp:993

LLVM_ABI unsigned getIndexSize(unsigned AS) const

The index size in bytes used for address calculation, rounded up to a whole number of bytes.

Definition DataLayout.cpp:832

LLVM_ABI const StructLayout * getStructLayout(StructType *Ty) const

Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...

Definition DataLayout.cpp:778

LLVM_ABI DataLayout()

Constructs a DataLayout with default values.

Definition DataLayout.cpp:196

LLVM_ABI IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const

Returns an integer type with size at least as big as that of a pointer in the given address space.

Definition DataLayout.cpp:971

LLVM_ABI Align getABITypeAlign(Type *Ty) const

Returns the minimum ABI-required alignment for the specified type.

Definition DataLayout.cpp:963

LLVM_ABI unsigned getIndexTypeSizeInBits(Type *Ty) const

The size in bits of the index used in GEP calculation for this type.

Definition DataLayout.cpp:836

LLVM_ABI unsigned getPointerTypeSizeInBits(Type *) const

The pointer representation size in bits for this type.

Definition DataLayout.cpp:825

LLVM_ABI DataLayout & operator=(const DataLayout &Other)

Definition DataLayout.cpp:210

LLVM_ABI IntegerType * getIndexType(LLVMContext &C, unsigned AddressSpace) const

Returns the type of a GEP index in AddressSpace.

Definition DataLayout.cpp:998

LLVM_ABI TypeSize getTypeAllocSize(Type *Ty) const

Returns the offset in bytes between successive objects of the specified type, including alignment pad...

Definition DataLayout.cpp:925

LLVM_ABI std::optional< APInt > getGEPIndexForOffset(Type *&ElemTy, APInt &Offset) const

Get single GEP index to access Offset inside ElemTy.

Definition DataLayout.cpp:1062

LLVM_ABI Type * getSmallestLegalIntType(LLVMContext &C, unsigned Width=0) const

Returns the smallest integer type with size at least as big as Width bits.

Definition DataLayout.cpp:986

LLVM_ABI Align getPreferredAlign(const GlobalVariable *GV) const

Returns the preferred alignment of the specified global.

Definition DataLayout.cpp:1109

LLVM_ABI ~DataLayout()

Definition DataLayout.cpp:776

LLVM_ABI unsigned getPointerSize(unsigned AS=0) const

The pointer representation size in bytes, rounded up to a whole number of bytes.

Definition DataLayout.cpp:821

LLVM_ABI Align getPointerPrefAlignment(unsigned AS=0) const

Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of...

Definition DataLayout.cpp:817

unsigned getIndexSizeInBits(unsigned AS) const

The size in bits of indices used for address calculation in getelementptr and for addresses in the gi...

TypeSize getTypeSizeInBits(Type *Ty) const

Size examples:

TypeSize getTypeStoreSize(Type *Ty) const

Returns the maximum number of bytes that may be overwritten by storing the specified type.

LLVM_ABI bool operator==(const DataLayout &Other) const

Definition DataLayout.cpp:232

LLVM_ABI int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef< Value * > Indices) const

Returns the offset from the beginning of the type for the specified indices.

Definition DataLayout.cpp:1013

LLVM_ABI Align getPointerABIAlignment(unsigned AS) const

Layout pointer alignment.

Definition DataLayout.cpp:800

LLVM_ABI Align getPrefTypeAlign(Type *Ty) const

Returns the preferred stack/global alignment for the specified type.

Definition DataLayout.cpp:967

static LLVM_ABI Expected< DataLayout > parse(StringRef LayoutString)

Parse a data layout string and return the layout.

Definition DataLayout.cpp:249

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Tagged union holding either a T or a Error.

bool hasSection() const

Check if this global has a custom object file section.

Type * getValueType() const

bool hasInitializer() const

Definitions have initializers, declarations don't.

MaybeAlign getAlign() const

Returns the alignment of the given variable.

Class to represent integer types.

static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)

This static method is the primary way of constructing an IntegerType.

This is an important class for using LLVM in a threaded context.

Implements a dense probed hash-table based set with some number of buckets stored inline.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

iterator insert(iterator I, T &&Elt)

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

std::pair< StringRef, StringRef > split(char Separator) const

Split into two substrings around the first occurrence of a separator character.

std::string str() const

str - Get the contents as an std::string.

bool starts_with(StringRef Prefix) const

Check if this string starts with the given Prefix.

constexpr bool empty() const

empty - Check if the string is empty.

StringRef drop_front(size_t N=1) const

Return a StringRef equal to 'this' but with the first N elements dropped.

constexpr size_t size() const

size - Get the string size.

char front() const

front - Get the first character in the string.

bool consume_front(StringRef Prefix)

Returns true if this StringRef has the given prefix and removes that prefix.

StringRef drop_back(size_t N=1) const

Return a StringRef equal to 'this' but with the last N elements dropped.

Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...

TypeSize getSizeInBytes() const

MutableArrayRef< TypeSize > getMemberOffsets()

LLVM_ABI unsigned getElementContainingOffset(uint64_t FixedOffset) const

Given a valid byte offset into the structure, returns the structure index that contains it.

Definition DataLayout.cpp:92

TypeSize getElementOffset(unsigned Idx) const

Align getAlignment() const

Class to represent struct types.

static constexpr std::enable_if_t< std::is_same_v< Foo< TrailingTys... >, Foo< Tys... > >, size_t > totalSizeToAlloc(typename trailing_objects_internal::ExtractSecondType< TrailingTys, size_t >::type... Counts)

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

static constexpr TypeSize getFixed(ScalarTy ExactSize)

static constexpr TypeSize getScalable(ScalarTy MinimumSize)

The instances of the Type class are immutable: once they are created, they are never changed.

LLVM_ABI unsigned getIntegerBitWidth() const

@ X86_AMXTyID

AMX vectors (8192 bits, X86 specific)

@ HalfTyID

16-bit floating point type

@ TargetExtTyID

Target extension type.

@ ScalableVectorTyID

Scalable SIMD vector type.

@ FloatTyID

32-bit floating point type

@ IntegerTyID

Arbitrary bit width integers.

@ FixedVectorTyID

Fixed width SIMD vector type.

@ BFloatTyID

16-bit floating point type (7-bit significand)

@ DoubleTyID

64-bit floating point type

@ X86_FP80TyID

80-bit floating point type (X87)

@ PPC_FP128TyID

128-bit floating point type (two 64-bits, PowerPC)

@ FP128TyID

128-bit floating point type (112-bit significand)

bool isIntegerTy() const

True if this is an instance of IntegerType.

static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)

LLVM Value Representation.

Type * getType() const

All values are typed, get the type of this value.

Base class of all SIMD vector types.

static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)

This static method is the primary way to construct an VectorType.

std::pair< iterator, bool > insert(const ValueT &V)

constexpr ScalarTy getFixedValue() const

static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

constexpr bool isScalable() const

Returns whether the quantity is scaled by a runtime quantity (vscale).

constexpr ScalarTy getKnownMinValue() const

Returns the minimum value this quantity can represent.

static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

StructType * getStructTypeOrNull() const

TypeSize getSequentialElementStride(const DataLayout &DL) const

Value * getOperand() const

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

constexpr char Align[]

Key for Kernel::Arg::Metadata::mAlign.

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

bool isAligned(Align Lhs, uint64_t SizeInBytes)

Checks that SizeInBytes is a multiple of the alignment.

constexpr bool isUIntN(unsigned N, uint64_t x)

Checks if an unsigned integer fits into the given (dynamic) bit width.

gep_type_iterator gep_type_end(const User *GEP)

auto upper_bound(R &&Range, T &&Value)

Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

uint64_t PowerOf2Ceil(uint64_t A)

Returns the power of two which is greater than or equal to the given value.

bool isAlpha(char C)

Checks if character C is a valid letter as classified by "C" locale.

constexpr bool isPowerOf2_32(uint32_t Value)

Return true if the argument is a power of two > 0.

LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)

bool isDigit(char C)

Checks if character C is one of the 10 decimal digits.

constexpr bool isUInt(uint64_t x)

Checks if an unsigned integer fits into the given bit width.

LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)

iterator_range< SplittingIterator > split(StringRef Str, StringRef Separator)

Split the specified string over a separator and return a range-compatible iterable over its partition...

class LLVM_GSL_OWNER SmallVector

Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

constexpr T divideCeil(U Numerator, V Denominator)

Returns the integer ceil(Numerator / Denominator).

auto lower_bound(R &&Range, T &&Value)

Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

auto max_element(R &&Range)

Provide wrappers to std::max_element which take ranges instead of having to pass begin/end explicitly...

constexpr unsigned BitWidth

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

auto find_if(R &&Range, UnaryPredicate P)

Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.

gep_type_iterator gep_type_begin(const User *GEP)

bool to_integer(StringRef S, N &Num, unsigned Base=0)

Convert the string S to an integer of the specified type using the radix Base. If Base is 0,...

This struct is a compact representation of a valid (non-zero power of two) alignment.

static constexpr Align Constant()

Allow constructions of constexpr Align.

Pointer type specification.

bool HasUnstableRepresentation

Pointers in this address space don't have a well-defined bitwise representation (e....

LLVM_ABI bool operator==(const PointerSpec &Other) const

Definition DataLayout.cpp:150

std::string AddrSpaceName

bool HasExternalState

Pointers in this address space have additional state bits that are located at a target-defined locati...

uint32_t IndexBitWidth

The index bit width also defines the address size in this address space.

Primitive type specification.

LLVM_ABI bool operator==(const PrimitiveSpec &Other) const

Definition DataLayout.cpp:145

This struct is a compact representation of a valid (power of two) or undefined (0) alignment.