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);

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

77 getMemberOffsets()[i] = StructSize;

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

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

95 "vector types");

98

99 const auto *SI =

100 std::upper_bound(MemberOffsets.begin(), MemberOffsets.end(), Offset,

102 return TypeSize::isKnownLT(LHS, RHS);

103 });

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

105 --SI;

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

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

112

113

114

115

116

117

118 return SI - MemberOffsets.begin();

119}

120

121namespace {

122

123class StructLayoutMap {

125 LayoutInfoTy LayoutInfo;

126

127public:

128 ~StructLayoutMap() {

129

130 for (const auto &I : LayoutInfo) {

132 Value->~StructLayout();

134 }

135 }

136

138};

139

140}

141

142

143

144

145

149}

150

153 ABIAlign == Other.ABIAlign && PrefAlign == Other.PrefAlign &&

154 IndexBitWidth == Other.IndexBitWidth &&

155 IsNonIntegral == Other.IsNonIntegral;

156}

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

177 if (T.isOSBinFormatGOFF())

178 return "-m:l";

179 if (T.isOSBinFormatMachO())

180 return "-m:o";

181 if ((T.isOSWindows() || T.isUEFI()) && T.isOSBinFormatCOFF())

182 return T.getArch() == Triple::x86 ? "-m:x" : "-m:w";

183 if (T.isOSBinFormatXCOFF())

184 return "-m:a";

185 return "-m:e";

186}

187

188

189

191 {1, Align::Constant<1>(), Align::Constant<1>()},

192 {8, Align::Constant<1>(), Align::Constant<1>()},

193 {16, Align::Constant<2>(), Align::Constant<2>()},

194 {32, Align::Constant<4>(), Align::Constant<4>()},

195 {64, Align::Constant<4>(), Align::Constant<8>()},

196};

198 {16, Align::Constant<2>(), Align::Constant<2>()},

199 {32, Align::Constant<4>(), Align::Constant<4>()},

200 {64, Align::Constant<8>(), Align::Constant<8>()},

201 {128, Align::Constant<16>(), Align::Constant<16>()},

202};

204 {64, Align::Constant<8>(), Align::Constant<8>()},

205 {128, Align::Constant<16>(), Align::Constant<16>()},

206};

207

208

210

211 {0, 64, Align::Constant<8>(), Align::Constant<8>(), 64, false},

212};

213

219

221 if (Error Err = parseLayoutString(LayoutString))

223}

224

226 delete static_cast<StructLayoutMap *>(LayoutMap);

227 LayoutMap = nullptr;

228 StringRepresentation = Other.StringRepresentation;

229 BigEndian = Other.BigEndian;

230 AllocaAddrSpace = Other.AllocaAddrSpace;

231 ProgramAddrSpace = Other.ProgramAddrSpace;

232 DefaultGlobalsAddrSpace = Other.DefaultGlobalsAddrSpace;

233 StackNaturalAlign = Other.StackNaturalAlign;

234 FunctionPtrAlign = Other.FunctionPtrAlign;

235 TheFunctionPtrAlignType = Other.TheFunctionPtrAlignType;

236 ManglingMode = Other.ManglingMode;

237 LegalIntWidths = Other.LegalIntWidths;

238 IntSpecs = Other.IntSpecs;

239 FloatSpecs = Other.FloatSpecs;

240 VectorSpecs = Other.VectorSpecs;

241 PointerSpecs = Other.PointerSpecs;

242 StructABIAlignment = Other.StructABIAlignment;

243 StructPrefAlignment = Other.StructPrefAlignment;

244 return *this;

245}

246

248

249 return BigEndian == Other.BigEndian &&

250 AllocaAddrSpace == Other.AllocaAddrSpace &&

251 ProgramAddrSpace == Other.ProgramAddrSpace &&

252 DefaultGlobalsAddrSpace == Other.DefaultGlobalsAddrSpace &&

253 StackNaturalAlign == Other.StackNaturalAlign &&

254 FunctionPtrAlign == Other.FunctionPtrAlign &&

255 TheFunctionPtrAlignType == Other.TheFunctionPtrAlignType &&

256 ManglingMode == Other.ManglingMode &&

257 LegalIntWidths == Other.LegalIntWidths && IntSpecs == Other.IntSpecs &&

258 FloatSpecs == Other.FloatSpecs && VectorSpecs == Other.VectorSpecs &&

259 PointerSpecs == Other.PointerSpecs &&

260 StructABIAlignment == Other.StructABIAlignment &&

261 StructPrefAlignment == Other.StructPrefAlignment;

262}

263

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

267 return std::move(Err);

268 return Layout;

269}

270

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

274}

275

276

278 if (Str.empty())

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

280

281 if (!to_integer(Str, AddrSpace, 10) || !isUInt<24>(AddrSpace))

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

283

285}

286

287

290 if (Str.empty())

292

295

297}

298

299

300

301

302

303

304

305

306

307

308

309

311 bool AllowZero = false) {

312 if (Str.empty())

314

316 if (!to_integer(Str, Value, 10) || !isUInt<16>(Value))

318

319 if (Value == 0) {

320 if (!AllowZero)

322 Alignment = Align(1);

324 }

325

326 constexpr unsigned ByteWidth = 8;

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

330

331 Alignment = Align(Value / ByteWidth);

333}

334

336

338 char Specifier = Spec.front();

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

340 Spec.drop_front().split(Components, ':');

341

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

344

345

348 return Err;

349

350

353 return Err;

354

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

357

358

359 Align PrefAlign = ABIAlign;

360 if (Components.size() > 2)

362 return Err;

363

364 if (PrefAlign < ABIAlign)

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

367

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

370}

371

373

376 Spec.drop_front().split(Components, ':');

377

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

380

381

382

383

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

386 if (!to_integer(Components[0], BitWidth, 10) || BitWidth != 0)

388 }

389

390

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

394 return Err;

395

396

397 Align PrefAlign = ABIAlign;

398 if (Components.size() > 2)

400 return Err;

401

402 if (PrefAlign < ABIAlign)

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

405

406 StructABIAlignment = ABIAlign;

407 StructPrefAlignment = PrefAlign;

409}

410

412

415 Spec.drop_front().split(Components, ':');

416

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

419

420

421 unsigned AddrSpace = 0;

422 if (!Components[0].empty())

424 return Err;

425

426

429 return Err;

430

431

434 return Err;

435

436

437

438 Align PrefAlign = ABIAlign;

439 if (Components.size() > 3)

441 return Err;

442

443 if (PrefAlign < ABIAlign)

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

446

447

448 unsigned IndexBitWidth = BitWidth;

449 if (Components.size() > 4)

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

451 return Err;

452

453 if (IndexBitWidth > BitWidth)

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

456

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

458 false);

460}

461

462Error DataLayout::parseSpecification(

464

465 if (Spec.starts_with("ni")) {

466

468

469

472

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

474 unsigned AddrSpace;

476 return Err;

477 if (AddrSpace == 0)

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

479 NonIntegralAddressSpaces.push_back(AddrSpace);

480 }

482 }

483

484

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

486 char Specifier = Spec.front();

487

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

489 return parsePrimitiveSpec(Spec);

490

491 if (Specifier == 'a')

492 return parseAggregateSpec(Spec);

493

494 if (Specifier == 'p')

495 return parsePointerSpec(Spec);

496

498 switch (Specifier) {

499 case 's':

500

501

502 break;

503 case 'e':

504 case 'E':

505 if (!Rest.empty())

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

508 BigEndian = Specifier == 'E';

509 break;

510 case 'n':

511

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

515 return Err;

517 }

518 break;

519 case 'S': {

520

521 if (Rest.empty())

525 return Err;

526 StackNaturalAlign = Alignment;

527 break;

528 }

529 case 'F': {

530

531 if (Rest.empty())

535 switch (Type) {

536 case 'i':

538 break;

539 case 'n':

541 break;

542 default:

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

545 }

548 return Err;

549 FunctionPtrAlign = Alignment;

550 break;

551 }

552 case 'P': {

553 if (Rest.empty())

556 return Err;

557 break;

558 }

559 case 'A': {

560 if (Rest.empty())

563 return Err;

564 break;

565 }

566 case 'G': {

567 if (Rest.empty())

570 return Err;

571 break;

572 }

573 case 'm':

576 if (Rest.size() > 1)

578 switch (Rest[0]) {

579 default:

581 case 'e':

582 ManglingMode = MM_ELF;

583 break;

584 case 'l':

585 ManglingMode = MM_GOFF;

586 break;

587 case 'o':

588 ManglingMode = MM_MachO;

589 break;

590 case 'm':

591 ManglingMode = MM_Mips;

592 break;

593 case 'w':

594 ManglingMode = MM_WinCOFF;

595 break;

596 case 'x':

597 ManglingMode = MM_WinCOFFX86;

598 break;

599 case 'a':

600 ManglingMode = MM_XCOFF;

601 break;

602 }

603 break;

604 default:

606 }

607

609}

610

611Error DataLayout::parseLayoutString(StringRef LayoutString) {

612 StringRepresentation = std::string(LayoutString);

613

614 if (LayoutString.empty())

616

617

618

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

621 if (Spec.empty())

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

624 return Err;

625 }

626

627

628

629 for (unsigned AS : NonIntegralAddressSpaces) {

630

631

632 const PointerSpec &PS = getPointerSpec(AS);

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

634 true);

635 }

636

638}

639

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

643 switch (Specifier) {

644 default:

646 case 'i':

647 Specs = &IntSpecs;

648 break;

649 case 'f':

650 Specs = &FloatSpecs;

651 break;

652 case 'v':

653 Specs = &VectorSpecs;

654 break;

655 }

656

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

659

660 I->ABIAlign = ABIAlign;

661 I->PrefAlign = PrefAlign;

662 } else {

663

664 Specs->insert(I, PrimitiveSpec{BitWidth, ABIAlign, PrefAlign});

665 }

666}

667

669DataLayout::getPointerSpec(uint32_t AddrSpace) const {

670 if (AddrSpace != 0) {

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

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

673 return *I;

674 }

675

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

677 return PointerSpecs[0];

678}

679

682 uint32_t IndexBitWidth, bool IsNonIntegral) {

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

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

685 PointerSpecs.insert(I, PointerSpec{AddrSpace, BitWidth, ABIAlign, PrefAlign,

686 IndexBitWidth, IsNonIntegral});

687 } else {

689 I->ABIAlign = ABIAlign;

690 I->PrefAlign = PrefAlign;

691 I->IndexBitWidth = IndexBitWidth;

692 I->IsNonIntegral = IsNonIntegral;

693 }

694}

695

697 bool abi_or_pref) const {

699

700

701

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

703 --I;

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

705}

706

708

710 if (!LayoutMap)

711 LayoutMap = new StructLayoutMap();

712

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

715 if (SL) return SL;

716

717

718

720 StructLayout::totalSizeToAlloc(Ty->getNumElements()));

721

722

723

724 SL = L;

725

727

728 return L;

729}

730

732 return getPointerSpec(AS).ABIAlign;

733}

734

736 return getPointerSpec(AS).PrefAlign;

737}

738

741}

742

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

748}

749

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

752}

753

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

759}

760

761

762

763

764

765

766

767

768

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

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

772

776 unsigned AS = cast(Ty)->getAddressSpace();

779 }

781 return getAlignment(cast(Ty)->getElementType(), abi_or_pref);

782

784

785 if (cast(Ty)->isPacked() && abi_or_pref)

787

788

790 const Align Align = abi_or_pref ? StructABIAlignment : StructPrefAlignment;

792 }

799

800

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

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

808

809

810

811

812

813

814

816 }

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

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

823

824

825

826

827

828

829

831 }

833 return Align(64);

835 Type *LayoutTy = cast(Ty)->getLayoutType();

836 return getAlignment(LayoutTy, abi_or_pref);

837 }

838 default:

840 }

841}

842

844 return getAlignment(Ty, true);

845}

846

848 return getAlignment(Ty, false);

849}

850

854}

855

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

861 if (VectorType *VecTy = dyn_cast(Ty))

863 return IntTy;

864}

865

867 for (unsigned LegalIntWidth : LegalIntWidths)

868 if (Width <= LegalIntWidth)

870 return nullptr;

871}

872

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

876}

877

881}

882

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

888 if (VectorType *VecTy = dyn_cast(Ty))

890 return IntTy;

891}

892

895 int64_t Result = 0;

896

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

903 assert(Idx->getType()->isIntegerTy(32) && "Illegal struct idx");

904 unsigned FieldNo = cast(Idx)->getZExtValue();

905

906

908

909

911 } else {

912 if (int64_t ArrayIdx = cast(Idx)->getSExtValue())

914 }

915 }

916

917 return Result;

918}

919

921

922

923

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

928 }

929

931 Offset -= Index * ElemSize;

932 if (Offset.isNegative()) {

933

934 --Index;

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

937 }

938 return Index;

939}

940

943 if (auto *ArrTy = dyn_cast(ElemTy)) {

944 ElemTy = ArrTy->getElementType();

946 }

947

948 if (isa(ElemTy)) {

949

950

951

952 return std::nullopt;

953 }

954

955 if (auto *STy = dyn_cast(ElemTy)) {

959 return std::nullopt;

960

963 ElemTy = STy->getElementType(Index);

964 return APInt(32, Index);

965 }

966

967

968 return std::nullopt;

969}

970

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

976 while (Offset != 0) {

978 if (!Index)

979 break;

981 }

982

983 return Indices;

984}

985

986

987

990

991

993 return *GVAlignment;

994

995

996

997

998

999

1000

1003 if (GVAlignment) {

1004 if (*GVAlignment >= Alignment)

1005 Alignment = *GVAlignment;

1006 else

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

1008 }

1009

1010

1011

1012

1014 if (Alignment < Align(16)) {

1015

1016

1018 Alignment = Align(16);

1019 }

1020 }

1021 return Alignment;

1022}

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

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.

static APInt getElementIndex(TypeSize ElemSize, APInt &Offset)

static Error parseAddrSpace(StringRef Str, unsigned &AddrSpace)

Attempts to parse an address space component of a specification.

static Error createSpecFormatError(Twine Format)

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

Attempts to parse an alignment component of a specification.

constexpr DataLayout::PrimitiveSpec DefaultFloatSpecs[]

constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[]

constexpr DataLayout::PointerSpec DefaultPointerSpecs[]

constexpr DataLayout::PrimitiveSpec DefaultIntSpecs[]

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx

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)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

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.

static const char * getManglingComponent(const Triple &T)

unsigned getPointerSizeInBits(unsigned AS=0) const

Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...

@ MultipleOfFunctionAlign

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

@ Independent

The function pointer alignment is independent of the function alignment.

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

Get GEP indices to access Offset inside ElemTy.

unsigned getLargestLegalIntTypeSizeInBits() const

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

unsigned getIndexSize(unsigned AS) const

rounded up to a whole number of bytes.

const StructLayout * getStructLayout(StructType *Ty) const

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

DataLayout()

Constructs a DataLayout with default values.

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.

Align getABITypeAlign(Type *Ty) const

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

unsigned getIndexTypeSizeInBits(Type *Ty) const

Layout size of the index used in GEP calculation.

unsigned getPointerTypeSizeInBits(Type *) const

Layout pointer size, in bits, based on the type.

DataLayout & operator=(const DataLayout &Other)

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

Returns the type of a GEP index in AddressSpace.

TypeSize getTypeAllocSize(Type *Ty) const

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

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

Get single GEP index to access Offset inside ElemTy.

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

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

Align getPreferredAlign(const GlobalVariable *GV) const

Returns the preferred alignment of the specified global.

unsigned getPointerSize(unsigned AS=0) const

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

Align getPointerPrefAlignment(unsigned AS=0) const

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

unsigned getIndexSizeInBits(unsigned AS) const

Size in bits of index used for address calculation in getelementptr.

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.

bool operator==(const DataLayout &Other) const

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

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

Align getPointerABIAlignment(unsigned AS) const

Layout pointer alignment.

Align getPrefTypeAlign(Type *Ty) const

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

static Expected< DataLayout > parse(StringRef LayoutString)

Parse a data layout string and return the layout.

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.

MaybeAlign getAlign() const

Returns the alignment of the given variable or function.

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.

Class to represent integer types.

static 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.

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()

unsigned getElementContainingOffset(uint64_t FixedOffset) const

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

TypeSize getElementOffset(unsigned Idx) const

Align getAlignment() const

Class to represent struct types.

unsigned getNumElements() const

Random access to the elements.

Triple - Helper class for working with autoconf configuration names.

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.

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)

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

bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const

Return true if it makes sense to take the size of this type.

bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const

Return true if this is a type whose size is a known multiple of vscale.

LLVMContext & getContext() const

Return the LLVMContext in which this type was uniqued.

bool isPtrOrPtrVectorTy() const

Return true if this is a pointer type or a vector of pointer types.

TypeID getTypeID() const

Return the type id for the type.

Type * getScalarType() const

If this is a vector type, return the element type, otherwise return 'this'.

LLVM Value Representation.

Base class of all SIMD vector types.

static 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)

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.

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

bool isUIntN(unsigned N, uint64_t x)

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

bool isAligned(Align Lhs, uint64_t SizeInBytes)

Checks that SizeInBytes is a multiple of the alignment.

gep_type_iterator gep_type_end(const User *GEP)

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.

constexpr bool isPowerOf2_32(uint32_t Value)

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

void report_fatal_error(Error Err, bool gen_crash_diag=true)

Report a serious error, calling any installed error handler.

LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)

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

gep_type_iterator gep_type_begin(const User *GEP)

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

Pointer type specification.

bool operator==(const PointerSpec &Other) const

Primitive type specification.

bool operator==(const PrimitiveSpec &Other) const

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