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

157

158namespace {

159

160struct LessPrimitiveBitWidth {

162 unsigned RHSBitWidth) const {

163 return LHS.BitWidth < RHSBitWidth;

164 }

165};

166

167

168struct LessPointerAddrSpace {

170 unsigned RHSAddrSpace) const {

171 return LHS.AddrSpace < RHSAddrSpace;

172 }

173};

174}

175

176

177

194

195

200

206

208 if (Error Err = parseLayoutString(LayoutString))

210}

211

213 delete static_cast<StructLayoutMap *>(LayoutMap);

214 LayoutMap = nullptr;

215 StringRepresentation = Other.StringRepresentation;

216 BigEndian = Other.BigEndian;

217 AllocaAddrSpace = Other.AllocaAddrSpace;

218 ProgramAddrSpace = Other.ProgramAddrSpace;

219 DefaultGlobalsAddrSpace = Other.DefaultGlobalsAddrSpace;

220 StackNaturalAlign = Other.StackNaturalAlign;

221 FunctionPtrAlign = Other.FunctionPtrAlign;

222 TheFunctionPtrAlignType = Other.TheFunctionPtrAlignType;

223 ManglingMode = Other.ManglingMode;

224 LegalIntWidths = Other.LegalIntWidths;

225 IntSpecs = Other.IntSpecs;

226 FloatSpecs = Other.FloatSpecs;

227 VectorSpecs = Other.VectorSpecs;

228 PointerSpecs = Other.PointerSpecs;

229 StructABIAlignment = Other.StructABIAlignment;

230 StructPrefAlignment = Other.StructPrefAlignment;

231 return *this;

232}

233

235

236 return BigEndian == Other.BigEndian &&

237 AllocaAddrSpace == Other.AllocaAddrSpace &&

238 ProgramAddrSpace == Other.ProgramAddrSpace &&

239 DefaultGlobalsAddrSpace == Other.DefaultGlobalsAddrSpace &&

240 StackNaturalAlign == Other.StackNaturalAlign &&

241 FunctionPtrAlign == Other.FunctionPtrAlign &&

242 TheFunctionPtrAlignType == Other.TheFunctionPtrAlignType &&

243 ManglingMode == Other.ManglingMode &&

244 LegalIntWidths == Other.LegalIntWidths && IntSpecs == Other.IntSpecs &&

245 FloatSpecs == Other.FloatSpecs && VectorSpecs == Other.VectorSpecs &&

246 PointerSpecs == Other.PointerSpecs &&

247 StructABIAlignment == Other.StructABIAlignment &&

248 StructPrefAlignment == Other.StructPrefAlignment;

249}

250

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

254 return std::move(Err);

255 return Layout;

256}

257

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

260 Format + "\"");

261}

262

263

265 if (Str.empty())

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

267

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

270

272}

273

274

277 if (Str.empty())

279

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

282

284}

285

286

287

288

289

290

291

292

293

294

295

296

298 bool AllowZero = false) {

299 if (Str.empty())

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

301

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

305

306 if (Value == 0) {

307 if (!AllowZero)

309 Alignment = Align(1);

311 }

312

313 constexpr unsigned ByteWidth = 8;

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

317

318 Alignment = Align(Value / ByteWidth);

320}

321

323

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

328

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

331

332

335 return Err;

336

337

340 return Err;

341

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

344

345

346 Align PrefAlign = ABIAlign;

347 if (Components.size() > 2)

349 return Err;

350

351 if (PrefAlign < ABIAlign)

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

354

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

357}

358

360

364

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

367

368

369

370

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

375 }

376

377

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

381 return Err;

382

383

384 Align PrefAlign = ABIAlign;

385 if (Components.size() > 2)

387 return Err;

388

389 if (PrefAlign < ABIAlign)

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

392

393 StructABIAlignment = ABIAlign;

394 StructPrefAlignment = PrefAlign;

396}

397

399

403

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

406

407

408 unsigned AddrSpace = 0;

409 bool ExternalState = false;

410 bool UnstableRepr = false;

411 StringRef AddrSpaceStr = Components[0];

412 while (!AddrSpaceStr.empty()) {

413 char C = AddrSpaceStr.front();

414 if (C == 'e') {

415 ExternalState = true;

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

417 UnstableRepr = true;

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

420 C);

421 } else {

422 break;

423 }

424 AddrSpaceStr = AddrSpaceStr.drop_front(1);

425 }

426 if (!AddrSpaceStr.empty())

428 return Err;

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

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

432

433

436 return Err;

437

438

441 return Err;

442

443

444

445 Align PrefAlign = ABIAlign;

446 if (Components.size() > 3)

448 return Err;

449

450 if (PrefAlign < ABIAlign)

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

453

454

455 unsigned IndexBitWidth = BitWidth;

456 if (Components.size() > 4)

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

458 return Err;

459

460 if (IndexBitWidth > BitWidth)

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

463

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

465 UnstableRepr, ExternalState);

467}

468

469Error DataLayout::parseSpecification(

471

473

475

476

479

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

481 unsigned AddrSpace;

483 return Err;

484 if (AddrSpace == 0)

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

486 NonIntegralAddressSpaces.push_back(AddrSpace);

487 }

489 }

490

491

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

494

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

496 return parsePrimitiveSpec(Spec);

497

498 if (Specifier == 'a')

499 return parseAggregateSpec(Spec);

500

501 if (Specifier == 'p')

502 return parsePointerSpec(Spec);

503

505 switch (Specifier) {

506 case 's':

507

508

509 break;

510 case 'e':

511 case 'E':

512 if (!Rest.empty())

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

516 break;

517 case 'n':

518

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

522 return Err;

523 LegalIntWidths.push_back(BitWidth);

524 }

525 break;

526 case 'S': {

527

528 if (Rest.empty())

532 return Err;

533 StackNaturalAlign = Alignment;

534 break;

535 }

536 case 'F': {

537

538 if (Rest.empty())

542 switch (Type) {

543 case 'i':

545 break;

546 case 'n':

548 break;

549 default:

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

551 Twine(Type) + "'");

552 }

555 return Err;

556 FunctionPtrAlign = Alignment;

557 break;

558 }

559 case 'P': {

560 if (Rest.empty())

563 return Err;

564 break;

565 }

566 case 'A': {

567 if (Rest.empty())

570 return Err;

571 break;

572 }

573 case 'G': {

574 if (Rest.empty())

577 return Err;

578 break;

579 }

580 case 'm':

583 if (Rest.size() > 1)

585 switch (Rest[0]) {

586 default:

588 case 'e':

589 ManglingMode = MM_ELF;

590 break;

591 case 'l':

592 ManglingMode = MM_GOFF;

593 break;

594 case 'o':

595 ManglingMode = MM_MachO;

596 break;

597 case 'm':

598 ManglingMode = MM_Mips;

599 break;

600 case 'w':

601 ManglingMode = MM_WinCOFF;

602 break;

603 case 'x':

604 ManglingMode = MM_WinCOFFX86;

605 break;

606 case 'a':

607 ManglingMode = MM_XCOFF;

608 break;

609 }

610 break;

611 default:

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

613 }

614

616}

617

618Error DataLayout::parseLayoutString(StringRef LayoutString) {

619 StringRepresentation = std::string(LayoutString);

620

621 if (LayoutString.empty())

623

624

625

626 SmallVector<unsigned, 8> NonIntegralAddressSpaces;

627 for (StringRef Spec : split(LayoutString, '-')) {

628 if (Spec.empty())

630 if (Error Err = parseSpecification(Spec, NonIntegralAddressSpaces))

631 return Err;

632 }

633

634

635

636 for (unsigned AS : NonIntegralAddressSpaces) {

637

638

639 const PointerSpec &PS = getPointerSpec(AS);

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

641 true, false);

642 }

643

645}

646

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

649 SmallVectorImpl *Specs;

650 switch (Specifier) {

651 default:

653 case 'i':

654 Specs = &IntSpecs;

655 break;

656 case 'f':

657 Specs = &FloatSpecs;

658 break;

659 case 'v':

660 Specs = &VectorSpecs;

661 break;

662 }

663

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

666

667 I->ABIAlign = ABIAlign;

668 I->PrefAlign = PrefAlign;

669 } else {

670

672 }

673}

674

676DataLayout::getPointerSpec(uint32_t AddrSpace) const {

677 if (AddrSpace != 0) {

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

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

680 return *I;

681 }

682

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

684 return PointerSpecs[0];

685}

686

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

689 uint32_t IndexBitWidth, bool HasUnstableRepr,

690 bool HasExternalState) {

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

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

694 IndexBitWidth, HasUnstableRepr,

695 HasExternalState});

696 } else {

698 I->ABIAlign = ABIAlign;

699 I->PrefAlign = PrefAlign;

700 I->IndexBitWidth = IndexBitWidth;

701 I->HasUnstableRepresentation = HasUnstableRepr;

702 I->HasExternalState = HasExternalState;

703 }

704}

705

706Align DataLayout::getIntegerAlignment(uint32_t BitWidth,

707 bool abi_or_pref) const {

708 auto I = IntSpecs.begin();

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

711 break;

712 }

713

714

715

716

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

718 --I;

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

720}

721

723

725 if (!LayoutMap)

726 LayoutMap = new StructLayoutMap();

727

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

730 if (SL) return SL;

731

732

733

736

737

738

739 SL = L;

740

742

743 return L;

744}

745

747 return getPointerSpec(AS).ABIAlign;

748}

749

751 return getPointerSpec(AS).PrefAlign;

752}

753

757

759 assert(Ty->isPtrOrPtrVectorTy() &&

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

761 Ty = Ty->getScalarType();

763}

764

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

767}

768

770 assert(Ty->isPtrOrPtrVectorTy() &&

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

772 Ty = Ty->getScalarType();

774}

775

776

777

778

779

780

781

782

783

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

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

786 switch (Ty->getTypeID()) {

787

794 }

797

799

802

803

805 const Align Align = abi_or_pref ? StructABIAlignment : StructPrefAlignment;

807 }

814

815

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

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

823

824

825

826

827

828

829

831 }

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

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

838

839

840

841

842

843

844

846 }

848 return Align(64);

851 return getAlignment(LayoutTy, abi_or_pref);

852 }

853 default:

855 }

856}

857

859 switch (Ty->getTypeID()) {

861

862

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

865 }

869

872

875 }

877 unsigned BitWidth = Ty->getIntegerBitWidth();

879 Align A = getIntegerAlignment(BitWidth, true);

881 }

883 unsigned AS = Ty->getPointerAddressSpace();

886 }

890 }

891 default:

893 }

894}

895

897 return getAlignment(Ty, true);

898}

899

901 return getAlignment(Ty, false);

902}

903

908

910 assert(Ty->isPtrOrPtrVectorTy() &&

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

916 return IntTy;

917}

918

920 for (unsigned LegalIntWidth : LegalIntWidths)

921 if (Width <= LegalIntWidth)

923 return nullptr;

924}

925

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

929}

930

935

937 assert(Ty->isPtrOrPtrVectorTy() &&

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

943 return IntTy;

944}

945

948 int64_t Result = 0;

949

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

958

959

961

962

964 } else {

967 }

968 }

969

970 return Result;

971}

972

974

975

976

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

981 }

982

984 APInt Index = Offset.sdiv(FixedElemSize);

985 Offset -= Index * FixedElemSize;

986 if (Offset.isNegative()) {

987

988 --Index;

989 Offset += FixedElemSize;

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

991 }

992 return Index;

993}

994

998 ElemTy = ArrTy->getElementType();

1000 }

1001

1003

1004

1005

1006 return std::nullopt;

1007 }

1008

1013 return std::nullopt;

1014

1017 ElemTy = STy->getElementType(Index);

1018 return APInt(32, Index);

1019 }

1020

1021

1022 return std::nullopt;

1023}

1024

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

1030 while (Offset != 0) {

1032 if (!Index)

1033 break;

1035 }

1036

1037 return Indices;

1038}

1039

1040

1041

1044

1045

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

1047 return *GVAlignment;

1048

1049

1050

1051

1052

1053

1054

1057 if (GVAlignment) {

1058 if (*GVAlignment >= Alignment)

1059 Alignment = *GVAlignment;

1060 else

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

1062 }

1063

1064

1065

1066

1068 if (Alignment < Align(16)) {

1069

1070

1072 Alignment = Align(16);

1073 }

1074 }

1075 return Alignment;

1076}

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:275

static APInt getElementIndex(TypeSize ElemSize, APInt &Offset)

Definition DataLayout.cpp:973

static Error parseAddrSpace(StringRef Str, unsigned &AddrSpace)

Attempts to parse an address space component of a specification.

Definition DataLayout.cpp:264

static Error createSpecFormatError(Twine Format)

Definition DataLayout.cpp:258

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

Attempts to parse an alignment component of a specification.

Definition DataLayout.cpp:297

constexpr DataLayout::PrimitiveSpec DefaultFloatSpecs[]

Definition DataLayout.cpp:184

constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[]

Definition DataLayout.cpp:190

constexpr DataLayout::PointerSpec DefaultPointerSpecs[]

Definition DataLayout.cpp:196

constexpr DataLayout::PrimitiveSpec DefaultIntSpecs[]

Definition DataLayout.cpp:178

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)

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.

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:1025

LLVM_ABI unsigned getLargestLegalIntTypeSizeInBits() const

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

Definition DataLayout.cpp:926

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:765

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:724

LLVM_ABI DataLayout()

Constructs a DataLayout with default values.

Definition DataLayout.cpp:201

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:904

LLVM_ABI Align getABITypeAlign(Type *Ty) const

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

Definition DataLayout.cpp:896

LLVM_ABI unsigned getIndexTypeSizeInBits(Type *Ty) const

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

Definition DataLayout.cpp:769

LLVM_ABI unsigned getPointerTypeSizeInBits(Type *) const

The pointer representation size in bits for this type.

Definition DataLayout.cpp:758

LLVM_ABI DataLayout & operator=(const DataLayout &Other)

Definition DataLayout.cpp:212

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

Returns the type of a GEP index in AddressSpace.

Definition DataLayout.cpp:931

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:858

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

Get single GEP index to access Offset inside ElemTy.

Definition DataLayout.cpp:995

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:919

LLVM_ABI Align getPreferredAlign(const GlobalVariable *GV) const

Returns the preferred alignment of the specified global.

Definition DataLayout.cpp:1042

LLVM_ABI ~DataLayout()

Definition DataLayout.cpp:722

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:754

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:750

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:234

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:946

LLVM_ABI Align getPointerABIAlignment(unsigned AS) const

Layout pointer alignment.

Definition DataLayout.cpp:746

LLVM_ABI Align getPrefTypeAlign(Type *Ty) const

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

Definition DataLayout.cpp:900

static LLVM_ABI Expected< DataLayout > parse(StringRef LayoutString)

Parse a data layout string and return the layout.

Definition DataLayout.cpp:251

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.

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.

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.

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.

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)

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.

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

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.