LLVM 23.0.0git
DerivedTypes.h
Go to the documentation of this file.
1//===- llvm/DerivedTypes.h - Classes for handling data types ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the declarations of classes that represent "derived
10// types". These are things like "arrays of x" or "structure of x, y, z" or
11// "function returning x taking (y,z) as parameters", etc...
12//
13// The implementations of these classes live in the Type.cpp file.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_IR_DERIVEDTYPES_H
18#define LLVM_IR_DERIVEDTYPES_H
19
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/STLExtras.h"
22#include "llvm/ADT/StringRef.h"
23#include "llvm/IR/Type.h"
27#include <cassert>
28#include <cstdint>
29
30namespace llvm {
31
32class Value;
33class APInt;
34class LLVMContext;
35template <typename T> class Expected;
36class Error;
37
38/// Class to represent integer types. Note that this class is also used to
39/// represent the built-in integer types: Int1Ty, Int8Ty, Int16Ty, Int32Ty and
40/// Int64Ty.
41/// Integer representation type
42class IntegerType : public Type {
43 friend class LLVMContextImpl;
44
45protected:
46 explicit IntegerType(LLVMContext &C, unsigned NumBits) : Type(C, IntegerTyID){
47 setSubclassData(NumBits);
48 }
49
50public:
51 /// This enum is just used to hold constants we need for IntegerType.
52 enum {
53 MIN_INT_BITS = 1, ///< Minimum number of bits that can be specified
54 MAX_INT_BITS = (1<<23) ///< Maximum number of bits that can be specified
55 ///< Note that bit width is stored in the Type classes SubclassData field
56 ///< which has 24 bits. SelectionDAG type legalization can require a
57 ///< power of 2 IntegerType, so limit to the largest representable power
58 ///< of 2, 8388608.
59 };
60
61 /// This static method is the primary way of constructing an IntegerType.
62 /// If an IntegerType with the same NumBits value was previously instantiated,
63 /// that instance will be returned. Otherwise a new one will be created. Only
64 /// one instance with a given NumBits value is ever created.
65 /// Get or create an IntegerType instance.
66 LLVM_ABI static IntegerType *get(LLVMContext &C, unsigned NumBits);
67
68 /// Returns type twice as wide the input type.
72
73 /// Returns type half as wide the input type.
75 unsigned BitWidth = getBitWidth();
76 assert((BitWidth & 1) == 0 &&
77 "Cannot truncate integer type with odd bit-width");
78 return Type::getIntNTy(getContext(), BitWidth / 2);
79 }
80
81 /// Get the number of bits in this IntegerType
82 unsigned getBitWidth() const { return getSubclassData(); }
83
84 /// Return a bitmask with ones set for all of the bits that can be set by an
85 /// unsigned version of this type. This is 0xFF for i8, 0xFFFF for i16, etc.
87 return ~uint64_t(0UL) >> (64-getBitWidth());
88 }
89
90 /// Return a uint64_t with just the most significant bit set (the sign bit, if
91 /// the value is treated as a signed number).
93 return 1ULL << (getBitWidth()-1);
94 }
95
96 /// For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
97 /// @returns a bit mask with ones set for all the bits of this type.
98 /// Get a bit mask for this type.
99 LLVM_ABI APInt getMask() const;
100
101 /// Methods for support type inquiry through isa, cast, and dyn_cast.
102 static bool classof(const Type *T) {
103 return T->getTypeID() == IntegerTyID;
104 }
105};
106
107unsigned Type::getIntegerBitWidth() const {
108 return cast<IntegerType>(this)->getBitWidth();
109}
110
111bool Type::isIntegerTy(unsigned BitWidth) const {
112 return isIntegerTy() && getIntegerBitWidth() == BitWidth;
113}
114
115bool Type::isIntOrIntVectorTy(unsigned BitWidth) const {
117}
118
119/// Class to represent byte types.
120class ByteType : public Type {
121 friend class LLVMContextImpl;
122
123protected:
124 explicit ByteType(LLVMContext &C, unsigned NumBits) : Type(C, ByteTyID) {
125 setSubclassData(NumBits);
126 }
127
128public:
129 /// This enum is just used to hold constants we need for ByteType.
130 enum {
131 MIN_BYTE_BITS = 1, ///< Minimum number of bits that can be specified
133 (1 << 23) ///< Maximum number of bits that can be specified
134 ///< Note that bit width is stored in the Type classes
135 ///< SubclassData field which has 24 bits. SelectionDAG type
136 ///< legalization can require a power of 2 ByteType, so limit
137 ///< to the largest representable power of 2, 8388608.
138 };
139
140 /// This static method is the primary way of constructing a ByteType.
141 /// If a ByteType with the same NumBits value was previously instantiated,
142 /// that instance will be returned. Otherwise a new one will be created. Only
143 /// one instance with a given NumBits value is ever created.
144 /// Get or create a ByteType instance.
145 LLVM_ABI static ByteType *get(LLVMContext &C, unsigned NumBits);
146
147 /// Get the number of bits in this ByteType
148 unsigned getBitWidth() const { return getSubclassData(); }
149
150 /// For example, this is 0xFF for an 8 bit byte, 0xFFFF for b16, etc.
151 /// @returns a bit mask with ones set for all the bits of this type.
152 /// Get a bit mask for this type.
153 LLVM_ABI APInt getMask() const;
154
155 /// Methods for support type inquiry through isa, cast, and dyn_cast.
156 static bool classof(const Type *T) { return T->getTypeID() == ByteTyID; }
157};
158
159unsigned Type::getByteBitWidth() const {
160 return cast<ByteType>(this)->getBitWidth();
161}
162
163/// Class to represent function types
164///
165class FunctionType : public Type {
166 FunctionType(Type *Result, ArrayRef<Type*> Params, bool IsVarArgs);
167
168public:
169 FunctionType(const FunctionType &) = delete;
170 FunctionType &operator=(const FunctionType &) = delete;
171
172 /// This static method is the primary way of constructing a FunctionType.
173 LLVM_ABI static FunctionType *get(Type *Result, ArrayRef<Type *> Params,
174 bool isVarArg);
175
176 /// Create a FunctionType taking no parameters.
177 LLVM_ABI static FunctionType *get(Type *Result, bool isVarArg);
178
179 /// Return true if the specified type is valid as a return type.
180 LLVM_ABI static bool isValidReturnType(Type *RetTy);
181
182 /// Return true if the specified type is valid as an argument type.
183 LLVM_ABI static bool isValidArgumentType(Type *ArgTy);
184
185 bool isVarArg() const { return getSubclassData()!=0; }
186 Type *getReturnType() const { return ContainedTys[0]; }
187
189
193 return ArrayRef(param_begin(), param_end());
194 }
195
196 /// Parameter type accessors.
197 Type *getParamType(unsigned i) const {
198 assert(i < getNumParams() && "getParamType() out of range!");
199 return ContainedTys[i + 1];
200 }
201
202 /// Return the number of fixed parameters this function type requires.
203 /// This does not consider varargs.
204 unsigned getNumParams() const { return NumContainedTys - 1; }
205
206 /// Methods for support type inquiry through isa, cast, and dyn_cast.
207 static bool classof(const Type *T) {
208 return T->getTypeID() == FunctionTyID;
209 }
210};
211static_assert(alignof(FunctionType) >= alignof(Type *),
212 "Alignment sufficient for objects appended to FunctionType");
213
215 return cast<FunctionType>(this)->isVarArg();
216}
217
219 return cast<FunctionType>(this)->getParamType(i);
220}
221
223 return cast<FunctionType>(this)->getNumParams();
224}
225
226/// A handy container for a FunctionType+Callee-pointer pair, which can be
227/// passed around as a single entity. This assists in replacing the use of
228/// PointerType::getElementType() to access the function's type, since that's
229/// slated for removal as part of the [opaque pointer types] project.
231public:
232 // Allow implicit conversion from types which have a getFunctionType member
233 // (e.g. Function and InlineAsm).
234 template <typename T, typename U = decltype(&T::getFunctionType)>
236 : FnTy(Fn ? Fn->getFunctionType() : nullptr), Callee(Fn) {}
237
239 : FnTy(FnTy), Callee(Callee) {
240 assert((FnTy == nullptr) == (Callee == nullptr));
241 }
242
243 FunctionCallee(std::nullptr_t) {}
244
245 FunctionCallee() = default;
246
247 FunctionType *getFunctionType() { return FnTy; }
248
249 Value *getCallee() { return Callee; }
250
251 explicit operator bool() { return Callee; }
252
253private:
254 FunctionType *FnTy = nullptr;
255 Value *Callee = nullptr;
256};
257
258/// Class to represent struct types. There are two different kinds of struct
259/// types: Literal structs and Identified structs.
260///
261/// Literal struct types (e.g. { i32, i32 }) are uniqued structurally, and must
262/// always have a body when created. You can get one of these by using one of
263/// the StructType::get() forms.
264///
265/// Identified structs (e.g. %foo or %42) may optionally have a name and are not
266/// uniqued. The names for identified structs are managed at the LLVMContext
267/// level, so there can only be a single identified struct with a given name in
268/// a particular LLVMContext. Identified structs may also optionally be opaque
269/// (have no body specified). You get one of these by using one of the
270/// StructType::create() forms.
271///
272/// Independent of what kind of struct you have, the body of a struct type are
273/// laid out in memory consecutively with the elements directly one after the
274/// other (if the struct is packed) or (if not packed) with padding between the
275/// elements as defined by DataLayout (which is required to match what the code
276/// generator for a target expects).
277///
278class StructType : public Type {
279 StructType(LLVMContext &C) : Type(C, StructTyID) {}
280
281 enum {
282 /// This is the contents of the SubClassData field.
283 SCDB_HasBody = 1,
284 SCDB_Packed = 2,
285 SCDB_IsLiteral = 4,
286 SCDB_IsSized = 8,
287 SCDB_ContainsScalableVector = 16,
288 SCDB_NotContainsScalableVector = 32,
289 SCDB_ContainsNonGlobalTargetExtType = 64,
290 SCDB_NotContainsNonGlobalTargetExtType = 128,
291 SCDB_ContainsNonLocalTargetExtType = 64,
292 SCDB_NotContainsNonLocalTargetExtType = 128,
293 };
294
295 /// For a named struct that actually has a name, this is a pointer to the
296 /// symbol table entry (maintained by LLVMContext) for the struct.
297 /// This is null if the type is an literal struct or if it is a identified
298 /// type that has an empty name.
299 void *SymbolTableEntry = nullptr;
300
301public:
302 StructType(const StructType &) = delete;
303 StructType &operator=(const StructType &) = delete;
304
305 /// This creates an identified struct.
306 LLVM_ABI static StructType *create(LLVMContext &Context, StringRef Name);
307 LLVM_ABI static StructType *create(LLVMContext &Context);
308
309 LLVM_ABI static StructType *create(ArrayRef<Type *> Elements, StringRef Name,
310 bool isPacked = false);
311 LLVM_ABI static StructType *create(ArrayRef<Type *> Elements);
312 LLVM_ABI static StructType *create(LLVMContext &Context,
313 ArrayRef<Type *> Elements, StringRef Name,
314 bool isPacked = false);
315 LLVM_ABI static StructType *create(LLVMContext &Context,
316 ArrayRef<Type *> Elements);
317 template <class... Tys>
318 static std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *>
319 create(StringRef Name, Type *elt1, Tys *... elts) {
320 assert(elt1 && "Cannot create a struct type with no elements with this");
321 return create(ArrayRef<Type *>({elt1, elts...}), Name);
322 }
323
324 /// This static method is the primary way to create a literal StructType.
325 LLVM_ABI static StructType *
326 get(LLVMContext &Context, ArrayRef<Type *> Elements, bool isPacked = false);
327
328 /// Create an empty structure type.
329 LLVM_ABI static StructType *get(LLVMContext &Context, bool isPacked = false);
330
331 /// This static method is a convenience method for creating structure types by
332 /// specifying the elements as arguments. Note that this method always returns
333 /// a non-packed struct, and requires at least one element type.
334 template <class... Tys>
335 static std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *>
336 get(Type *elt1, Tys *... elts) {
337 assert(elt1 && "Cannot create a struct type with no elements with this");
338 LLVMContext &Ctx = elt1->getContext();
339 return StructType::get(Ctx, ArrayRef<Type *>({elt1, elts...}));
340 }
341
342 /// Return the type with the specified name, or null if there is none by that
343 /// name.
345
346 bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; }
347
348 /// Return true if this type is uniqued by structural equivalence, false if it
349 /// is a struct definition.
350 bool isLiteral() const { return (getSubclassData() & SCDB_IsLiteral) != 0; }
351
352 /// Return true if this is a type with an identity that has no body specified
353 /// yet. These prints as 'opaque' in .ll files.
354 bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; }
355
356 /// isSized - Return true if this is a sized type.
357 LLVM_ABI bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const;
358
359 /// Returns true if this struct contains a scalable vector.
361 using Type::isScalableTy;
362
363 /// Return true if this type is or contains a target extension type that
364 /// disallows being used as a global.
365 LLVM_ABI bool
368
369 /// Return true if this type is or contains a target extension type that
370 /// disallows being used as a local.
371 LLVM_ABI bool
374
375 /// Returns true if this struct contains homogeneous scalable vector types.
376 /// Note that the definition of homogeneous scalable vector type is not
377 /// recursive here. That means the following structure will return false
378 /// when calling this function.
379 /// {{<vscale x 2 x i32>, <vscale x 4 x i64>},
380 /// {<vscale x 2 x i32>, <vscale x 4 x i64>}}
382
383 /// Return true if this struct is non-empty and all element types are the
384 /// same.
386
387 /// Return true if this is a named struct that has a non-empty name.
388 bool hasName() const { return SymbolTableEntry != nullptr; }
389
390 /// Return the name for this struct type if it has an identity.
391 /// This may return an empty string for an unnamed struct type. Do not call
392 /// this on an literal type.
393 LLVM_ABI StringRef getName() const;
394
395 /// Change the name of this type to the specified name, or to a name with a
396 /// suffix if there is a collision. Do not call this on an literal type.
397 LLVM_ABI void setName(StringRef Name);
398
399 /// Specify a body for an opaque identified type, which must not make the type
400 /// recursive.
401 LLVM_ABI void setBody(ArrayRef<Type *> Elements, bool isPacked = false);
402
403 /// Specify a body for an opaque identified type or return an error if it
404 /// would make the type recursive.
406 bool isPacked = false);
407
408 /// Return an error if the body for an opaque identified type would make it
409 /// recursive.
411
412 /// Return true if the specified type is valid as a element type.
413 LLVM_ABI static bool isValidElementType(Type *ElemTy);
414
415 // Iterator access to the elements.
417
422 }
423
424 /// Return true if this is layout identical to the specified struct.
426
427 /// Random access to the elements
428 unsigned getNumElements() const { return NumContainedTys; }
429 Type *getElementType(unsigned N) const {
430 assert(N < NumContainedTys && "Element number out of range!");
431 return ContainedTys[N];
432 }
433 /// Given an index value into the type, return the type of the element.
434 LLVM_ABI Type *getTypeAtIndex(const Value *V) const;
435 Type *getTypeAtIndex(unsigned N) const { return getElementType(N); }
436 LLVM_ABI bool indexValid(const Value *V) const;
437 bool indexValid(unsigned Idx) const { return Idx < getNumElements(); }
438
439 /// Methods for support type inquiry through isa, cast, and dyn_cast.
440 static bool classof(const Type *T) {
441 return T->getTypeID() == StructTyID;
442 }
443};
444
446 return cast<StructType>(this)->getName();
447}
448
450 return cast<StructType>(this)->getNumElements();
451}
452
454 return cast<StructType>(this)->getElementType(N);
455}
456
457/// Class to represent array types.
458class ArrayType : public Type {
459 /// The element type of the array.
460 Type *ContainedType;
461 /// Number of elements in the array.
462 uint64_t NumElements;
463
464 ArrayType(Type *ElType, uint64_t NumEl);
465
466public:
467 ArrayType(const ArrayType &) = delete;
468 ArrayType &operator=(const ArrayType &) = delete;
469
470 uint64_t getNumElements() const { return NumElements; }
471 Type *getElementType() const { return ContainedType; }
472
473 /// This static method is the primary way to construct an ArrayType
474 LLVM_ABI static ArrayType *get(Type *ElementType, uint64_t NumElements);
475
476 /// Return true if the specified type is valid as a element type.
477 LLVM_ABI static bool isValidElementType(Type *ElemTy);
478
479 /// Methods for support type inquiry through isa, cast, and dyn_cast.
480 static bool classof(const Type *T) {
481 return T->getTypeID() == ArrayTyID;
482 }
483};
484
486 return cast<ArrayType>(this)->getNumElements();
487}
488
489/// Base class of all SIMD vector types
490class VectorType : public Type {
491 /// A fully specified VectorType is of the form <vscale x n x Ty>. 'n' is the
492 /// minimum number of elements of type Ty contained within the vector, and
493 /// 'vscale x' indicates that the total element count is an integer multiple
494 /// of 'n', where the multiple is either guaranteed to be one, or is
495 /// statically unknown at compile time.
496 ///
497 /// If the multiple is known to be 1, then the extra term is discarded in
498 /// textual IR:
499 ///
500 /// <4 x i32> - a vector containing 4 i32s
501 /// <vscale x 4 x i32> - a vector containing an unknown integer multiple
502 /// of 4 i32s
503
504 /// The element type of the vector.
505 Type *ContainedType;
506
507protected:
508 /// The element quantity of this vector. The meaning of this value depends
509 /// on the type of vector:
510 /// - For FixedVectorType = <ElementQuantity x ty>, there are
511 /// exactly ElementQuantity elements in this vector.
512 /// - For ScalableVectorType = <vscale x ElementQuantity x ty>,
513 /// there are vscale * ElementQuantity elements in this vector, where
514 /// vscale is a runtime-constant integer greater than 0.
515 const unsigned ElementQuantity;
516
517 LLVM_ABI VectorType(Type *ElType, unsigned EQ, Type::TypeID TID);
518
519public:
520 VectorType(const VectorType &) = delete;
521 VectorType &operator=(const VectorType &) = delete;
522
523 Type *getElementType() const { return ContainedType; }
524
525 /// This static method is the primary way to construct an VectorType.
526 LLVM_ABI static VectorType *get(Type *ElementType, ElementCount EC);
527
528 static VectorType *get(Type *ElementType, unsigned NumElements,
529 bool Scalable) {
530 return VectorType::get(ElementType,
531 ElementCount::get(NumElements, Scalable));
532 }
533
534 static VectorType *get(Type *ElementType, const VectorType *Other) {
535 return VectorType::get(ElementType, Other->getElementCount());
536 }
537
538 /// This static method gets a VectorType with the same number of elements as
539 /// the input type, and the element type is an integer type of the same width
540 /// as the input element type.
542 unsigned EltBits =
544 assert(EltBits && "Element size must be of a non-zero size");
545 Type *EltTy = IntegerType::get(VTy->getContext(), EltBits);
546 return VectorType::get(EltTy, VTy->getElementCount());
547 }
548
549 /// This static method is like getInteger except that the element types are
550 /// twice as wide as the elements in the input type.
552 assert(VTy->isIntOrIntVectorTy() && "VTy expected to be a vector of ints.");
553 auto *EltTy = cast<IntegerType>(VTy->getElementType());
554 return VectorType::get(EltTy->getExtendedType(), VTy->getElementCount());
555 }
556
557 // This static method gets a VectorType with the same number of elements as
558 // the input type, and the element type is an integer or float type which
559 // is half as wide as the elements in the input type.
561 Type *EltTy = VTy->getElementType();
562 if (EltTy->isFloatingPointTy()) {
563 switch (EltTy->getTypeID()) {
564 case DoubleTyID:
565 EltTy = Type::getFloatTy(VTy->getContext());
566 break;
567 case FloatTyID:
568 EltTy = Type::getHalfTy(VTy->getContext());
569 break;
570 default:
571 llvm_unreachable("Cannot create narrower fp vector element type");
572 }
573 } else {
574 EltTy = cast<IntegerType>(EltTy)->getTruncatedType();
575 }
576 return VectorType::get(EltTy, VTy->getElementCount());
577 }
578
579 // This static method returns a VectorType with a larger number of elements
580 // of a smaller type than the input element type. For example, a <4 x i64>
581 // subdivided twice would return <16 x i16>
582 static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs) {
583 for (int i = 0; i < NumSubdivs; ++i) {
586 }
587 return VTy;
588 }
589
590 /// This static method returns a VectorType with half as many elements as the
591 /// input type and the same element type.
593 auto EltCnt = VTy->getElementCount();
594 assert(EltCnt.isKnownEven() &&
595 "Cannot halve vector with odd number of elements.");
596 return VectorType::get(VTy->getElementType(),
597 EltCnt.divideCoefficientBy(2));
598 }
599
601 unsigned Denominator) {
602 auto EltCnt = VTy->getElementCount();
603 assert(EltCnt.isKnownMultipleOf(Denominator) &&
604 "Cannot take one-nth of a vector");
605 return VectorType::get(VTy->getScalarType(),
606 EltCnt.divideCoefficientBy(Denominator));
607 }
608
609 /// This static method returns a VectorType with twice as many elements as the
610 /// input type and the same element type.
612 auto EltCnt = VTy->getElementCount();
613 assert((EltCnt.getKnownMinValue() * 2ull) <= UINT_MAX &&
614 "Too many elements in vector");
615 return VectorType::get(VTy->getElementType(), EltCnt * 2);
616 }
617
618 /// This static method attempts to construct a VectorType with the same
619 /// size-in-bits as SizeTy but with an element type that matches the scalar
620 /// type of EltTy. The VectorType is returned on success, nullptr otherwise.
622 if (SizeTy->getScalarType() == EltTy->getScalarType())
623 return SizeTy;
624
625 unsigned EltSize = EltTy->getScalarSizeInBits();
626 if (!SizeTy->getPrimitiveSizeInBits().isKnownMultipleOf(EltSize))
627 return nullptr;
628
629 ElementCount EC = SizeTy->getElementCount()
631 .divideCoefficientBy(EltSize);
632 return VectorType::get(EltTy->getScalarType(), EC);
633 }
634
635 /// Return true if the specified type is valid as a element type.
636 LLVM_ABI static bool isValidElementType(Type *ElemTy);
637
638 /// Return an ElementCount instance to represent the (possibly scalable)
639 /// number of elements in the vector.
640 inline ElementCount getElementCount() const;
641
642 /// Methods for support type inquiry through isa, cast, and dyn_cast.
643 static bool classof(const Type *T) {
644 return T->getTypeID() == FixedVectorTyID ||
645 T->getTypeID() == ScalableVectorTyID;
646 }
647};
648
649/// Class to represent fixed width SIMD vectors
651protected:
652 FixedVectorType(Type *ElTy, unsigned NumElts)
653 : VectorType(ElTy, NumElts, FixedVectorTyID) {}
654
655public:
656 LLVM_ABI static FixedVectorType *get(Type *ElementType, unsigned NumElts);
657
658 static FixedVectorType *get(Type *ElementType, const FixedVectorType *FVTy) {
659 return get(ElementType, FVTy->getNumElements());
660 }
661
665
669
674
676 int NumSubdivs) {
678 VectorType::getSubdividedVectorType(VTy, NumSubdivs));
679 }
680
684
688
689 static bool classof(const Type *T) {
690 return T->getTypeID() == FixedVectorTyID;
691 }
692
693 unsigned getNumElements() const { return ElementQuantity; }
694};
695
696/// Class to represent scalable SIMD vectors
698protected:
699 ScalableVectorType(Type *ElTy, unsigned MinNumElts)
700 : VectorType(ElTy, MinNumElts, ScalableVectorTyID) {}
701
702public:
703 LLVM_ABI static ScalableVectorType *get(Type *ElementType,
704 unsigned MinNumElts);
705
706 static ScalableVectorType *get(Type *ElementType,
707 const ScalableVectorType *SVTy) {
708 return get(ElementType, SVTy->getMinNumElements());
709 }
710
714
715 static ScalableVectorType *
720
721 static ScalableVectorType *
726
728 int NumSubdivs) {
730 VectorType::getSubdividedVectorType(VTy, NumSubdivs));
731 }
732
733 static ScalableVectorType *
737
738 static ScalableVectorType *
743
744 /// Get the minimum number of elements in this vector. The actual number of
745 /// elements in the vector is an integer multiple of this value.
746 unsigned getMinNumElements() const { return ElementQuantity; }
747
748 static bool classof(const Type *T) {
749 return T->getTypeID() == ScalableVectorTyID;
750 }
751};
752
756
757/// Class to represent pointers.
758class PointerType : public Type {
759 explicit PointerType(LLVMContext &C, unsigned AddrSpace);
760
761public:
762 PointerType(const PointerType &) = delete;
763 PointerType &operator=(const PointerType &) = delete;
764
765 /// This constructs a pointer to an object of the specified type in a numbered
766 /// address space.
767 [[deprecated("PointerType::get with pointee type is pending removal. Use "
768 "Context overload.")]]
769 LLVM_ABI static PointerType *get(Type *ElementType, unsigned AddressSpace);
770 /// This constructs an opaque pointer to an object in a numbered address
771 /// space.
772 LLVM_ABI static PointerType *get(LLVMContext &C, unsigned AddressSpace);
773
774 /// This constructs a pointer to an object of the specified type in the
775 /// default address space (address space zero).
776 [[deprecated("PointerType::getUnqual with pointee type is pending removal. "
777 "Use Context overload.")]]
778 static PointerType *getUnqual(Type *ElementType) {
779 assert(ElementType && "Can't get a pointer to <null> type!");
780 assert(isValidElementType(ElementType) &&
781 "Invalid type for pointer element!");
782 return PointerType::getUnqual(ElementType->getContext());
783 }
784
785 /// This constructs an opaque pointer to an object in the
786 /// default address space (address space zero).
787 static PointerType *getUnqual(LLVMContext &C) {
788 return PointerType::get(C, 0);
789 }
790
791 /// Return true if the specified type is valid as a element type.
792 LLVM_ABI static bool isValidElementType(Type *ElemTy);
793
794 /// Return true if we can load or store from a pointer to this type.
795 LLVM_ABI static bool isLoadableOrStorableType(Type *ElemTy);
796
797 /// Return the address space of the Pointer type.
798 inline unsigned getAddressSpace() const { return getSubclassData(); }
799
800 /// Implement support type inquiry through isa, cast, and dyn_cast.
801 static bool classof(const Type *T) {
802 return T->getTypeID() == PointerTyID;
803 }
804};
805
807 assert(
809 "Original type expected to be a vector of integers or a scalar integer.");
810 if (auto *VTy = dyn_cast<VectorType>(this))
812 const_cast<VectorType *>(VTy));
813 return cast<IntegerType>(this)->getExtendedType();
814}
815
817 assert(
819 "Original type expected to be a vector of integers or a scalar integer.");
820 if (auto *VTy = dyn_cast<VectorType>(this))
822 const_cast<VectorType *>(VTy));
823 return cast<IntegerType>(this)->getTruncatedType();
824}
825
827 if (auto *VTy = dyn_cast<VectorType>(this))
828 return VectorType::get(EltTy, VTy->getElementCount());
829 return EltTy;
830}
831
832Type *Type::getWithNewBitWidth(unsigned NewBitWidth) const {
833 assert(
835 "Original type expected to be a vector of integers or a scalar integer.");
836 return getWithNewType(getIntNTy(getContext(), NewBitWidth));
837}
838
840 return cast<PointerType>(getScalarType())->getAddressSpace();
841}
842
843/// Class to represent target extensions types, which are generally
844/// unintrospectable from target-independent optimizations.
845///
846/// Target extension types have a string name, and optionally have type and/or
847/// integer parameters. The exact meaning of any parameters is dependent on the
848/// target.
849class TargetExtType : public Type {
850 TargetExtType(LLVMContext &C, StringRef Name, ArrayRef<Type *> Types,
851 ArrayRef<unsigned> Ints);
852
853 // These strings are ultimately owned by the context.
854 StringRef Name;
855 unsigned *IntParams;
856
857public:
858 TargetExtType(const TargetExtType &) = delete;
859 TargetExtType &operator=(const TargetExtType &) = delete;
860
861 /// Return a target extension type having the specified name and optional
862 /// type and integer parameters.
863 LLVM_ABI static TargetExtType *get(LLVMContext &Context, StringRef Name,
864 ArrayRef<Type *> Types = {},
865 ArrayRef<unsigned> Ints = {});
866
867 /// Return a target extension type having the specified name and optional
868 /// type and integer parameters, or an appropriate Error if it fails the
869 /// parameters check.
870 LLVM_ABI static Expected<TargetExtType *>
871 getOrError(LLVMContext &Context, StringRef Name, ArrayRef<Type *> Types = {},
872 ArrayRef<unsigned> Ints = {});
873
874 /// Check that a newly created target extension type has the expected number
875 /// of type parameters and integer parameters, returning the type itself if OK
876 /// or an appropriate Error if not.
877 LLVM_ABI static Expected<TargetExtType *> checkParams(TargetExtType *TTy);
878
879 /// Return the name for this target extension type. Two distinct target
880 /// extension types may have the same name if their type or integer parameters
881 /// differ.
882 StringRef getName() const { return Name; }
883
884 /// Return the type parameters for this particular target extension type. If
885 /// there are no parameters, an empty array is returned.
889
895
896 Type *getTypeParameter(unsigned i) const { return getContainedType(i); }
897 unsigned getNumTypeParameters() const { return getNumContainedTypes(); }
898
899 /// Return the integer parameters for this particular target extension type.
900 /// If there are no parameters, an empty array is returned.
902 return ArrayRef(IntParams, getNumIntParameters());
903 }
904
905 unsigned getIntParameter(unsigned i) const { return IntParams[i]; }
906 unsigned getNumIntParameters() const { return getSubclassData(); }
907
908 enum Property {
909 /// zeroinitializer is valid for this target extension type.
910 HasZeroInit = 1U << 0,
911 /// This type may be used as the value type of a global variable.
912 CanBeGlobal = 1U << 1,
913 /// This type may be allocated on the stack, either as the allocated type
914 /// of an alloca instruction or as a byval function parameter.
915 CanBeLocal = 1U << 2,
916 /// This type may be used as an element in a vector.
918 // This type can only be used in intrinsic arguments and return values.
919 /// In particular, it cannot be used in select and phi instructions.
920 IsTokenLike = 1U << 4,
921 };
922
923 /// Returns true if the target extension type contains the given property.
924 LLVM_ABI bool hasProperty(Property Prop) const;
925
926 /// Returns an underlying layout type for the target extension type. This
927 /// type can be used to query size and alignment information, if it is
928 /// appropriate (although note that the layout type may also be void). It is
929 /// not legal to bitcast between this type and the layout type, however.
930 LLVM_ABI Type *getLayoutType() const;
931
932 /// Methods for support type inquiry through isa, cast, and dyn_cast.
933 static bool classof(const Type *T) { return T->getTypeID() == TargetExtTyID; }
934};
935
937 return cast<TargetExtType>(this)->getName();
938}
939
940} // end namespace llvm
941
942#endif // LLVM_IR_DERIVEDTYPES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
#define T
This file contains some templates that are useful if you are working with the STL at all.
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
uint64_t getNumElements() const
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition Type.cpp:831
ArrayType & operator=(const ArrayType &)=delete
ArrayType(const ArrayType &)=delete
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Type * getElementType() const
Class to represent byte types.
@ MIN_BYTE_BITS
Minimum number of bits that can be specified.
@ MAX_BYTE_BITS
Maximum number of bits that can be specified Note that bit width is stored in the Type classes Subcla...
unsigned getBitWidth() const
Get the number of bits in this ByteType.
static LLVM_ABI ByteType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing a ByteType.
Definition Type.cpp:380
ByteType(LLVMContext &C, unsigned NumBits)
friend class LLVMContextImpl
LLVM_ABI APInt getMask() const
For example, this is 0xFF for an 8 bit byte, 0xFFFF for b16, etc.
Definition Type.cpp:408
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition TypeSize.h:315
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static FixedVectorType * getDoubleElementsVectorType(FixedVectorType *VTy)
static FixedVectorType * getInteger(FixedVectorType *VTy)
static FixedVectorType * getSubdividedVectorType(FixedVectorType *VTy, int NumSubdivs)
static FixedVectorType * getExtendedElementVectorType(FixedVectorType *VTy)
FixedVectorType(Type *ElTy, unsigned NumElts)
static FixedVectorType * get(Type *ElementType, const FixedVectorType *FVTy)
static FixedVectorType * getTruncatedElementVectorType(FixedVectorType *VTy)
static bool classof(const Type *T)
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition Type.cpp:869
static FixedVectorType * getHalfElementsVectorType(FixedVectorType *VTy)
FunctionCallee(std::nullptr_t)
FunctionType * getFunctionType()
FunctionCallee()=default
FunctionCallee(FunctionType *FnTy, Value *Callee)
Class to represent function types.
param_iterator param_begin() const
static LLVM_ABI bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
Definition Type.cpp:469
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type::subtype_iterator param_iterator
Type * getParamType(unsigned i) const
Parameter type accessors.
static LLVM_ABI bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
Definition Type.cpp:464
FunctionType(const FunctionType &)=delete
ArrayRef< Type * > params() const
FunctionType & operator=(const FunctionType &)=delete
bool isVarArg() const
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Type * getReturnType() const
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
param_iterator param_end() const
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.
Definition Type.cpp:350
uint64_t getSignBit() const
Return a uint64_t with just the most significant bit set (the sign bit, if the value is treated as a ...
LLVM_ABI APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
Definition Type.cpp:374
IntegerType * getExtendedType() const
Returns type twice as wide the input type.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
uint64_t getBitMask() const
Return a bitmask with ones set for all of the bits that can be set by an unsigned version of this typ...
friend class LLVMContextImpl
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
IntegerType * getTruncatedType() const
Returns type half as wide the input type.
IntegerType(LLVMContext &C, unsigned NumBits)
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
static LLVM_ABI bool isLoadableOrStorableType(Type *ElemTy)
Return true if we can load or store from a pointer to this type.
Definition Type.cpp:948
PointerType(const PointerType &)=delete
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
static bool classof(const Type *T)
Implement support type inquiry through isa, cast, and dyn_cast.
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition Type.cpp:942
PointerType & operator=(const PointerType &)=delete
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Class to represent scalable SIMD vectors.
static ScalableVectorType * get(Type *ElementType, const ScalableVectorType *SVTy)
static ScalableVectorType * getInteger(ScalableVectorType *VTy)
static LLVM_ABI ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition Type.cpp:891
static bool classof(const Type *T)
static ScalableVectorType * getExtendedElementVectorType(ScalableVectorType *VTy)
static ScalableVectorType * getHalfElementsVectorType(ScalableVectorType *VTy)
static ScalableVectorType * getSubdividedVectorType(ScalableVectorType *VTy, int NumSubdivs)
static ScalableVectorType * getDoubleElementsVectorType(ScalableVectorType *VTy)
unsigned getMinNumElements() const
Get the minimum number of elements in this vector.
ScalableVectorType(Type *ElTy, unsigned MinNumElts)
static ScalableVectorType * getTruncatedElementVectorType(ScalableVectorType *VTy)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Class to represent struct types.
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static std::enable_if_t< are_base_of< Type, Tys... >::value, StructType * > create(StringRef Name, Type *elt1, Tys *... elts)
LLVM_ABI bool indexValid(const Value *V) const
Definition Type.cpp:790
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition Type.cpp:479
element_iterator element_end() const
StructType(const StructType &)=delete
ArrayRef< Type * > elements() const
LLVM_ABI void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type, which must not make the type recursive.
Definition Type.cpp:600
LLVM_ABI bool containsHomogeneousScalableVectorTypes() const
Returns true if this struct contains homogeneous scalable vector types.
Definition Type.cpp:589
LLVM_ABI Error checkBody(ArrayRef< Type * > Elements)
Return an error if the body for an opaque identified type would make it recursive.
Definition Type.cpp:622
LLVM_ABI bool containsHomogeneousTypes() const
Return true if this struct is non-empty and all element types are the same.
Definition Type.cpp:595
element_iterator element_begin() const
static LLVM_ABI StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
Definition Type.cpp:804
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition Type.cpp:685
bool isPacked() const
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition Type.cpp:769
unsigned getNumElements() const
Random access to the elements.
LLVM_ABI bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
isSized - Return true if this is a sized type.
Definition Type.cpp:724
Type * getTypeAtIndex(unsigned N) const
StructType & operator=(const StructType &)=delete
LLVM_ABI void setName(StringRef Name)
Change the name of this type to the specified name, or to a name with a suffix if there is a collisio...
Definition Type.cpp:634
LLVM_ABI bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
Definition Type.cpp:775
LLVM_ABI bool isScalableTy() const
Definition Type.cpp:69
LLVM_ABI Error setBodyOrError(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type or return an error if it would make the type recursive.
Definition Type.cpp:604
LLVM_ABI Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
Definition Type.cpp:784
bool hasName() const
Return true if this is a named struct that has a non-empty name.
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition.
bool indexValid(unsigned Idx) const
LLVM_ABI bool containsNonLocalTargetExtType() const
Definition Type.cpp:101
LLVM_ABI bool containsNonGlobalTargetExtType() const
Definition Type.cpp:85
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
Type * getElementType(unsigned N) const
Type::subtype_iterator element_iterator
static std::enable_if_t< are_base_of< Type, Tys... >::value, StructType * > get(Type *elt1, Tys *... elts)
This static method is a convenience method for creating structure types by specifying the elements as...
LLVM_ABI StringRef getName() const
Return the name for this struct type if it has an identity.
Definition Type.cpp:762
ArrayRef< Type * > type_params() const
Return the type parameters for this particular target extension type.
unsigned getNumIntParameters() const
type_param_iterator type_param_end() const
Type::subtype_iterator type_param_iterator
static LLVM_ABI TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
Definition Type.cpp:974
Type * getTypeParameter(unsigned i) const
unsigned getNumTypeParameters() const
ArrayRef< unsigned > int_params() const
Return the integer parameters for this particular target extension type.
type_param_iterator type_param_begin() const
static LLVM_ABI Expected< TargetExtType * > checkParams(TargetExtType *TTy)
Check that a newly created target extension type has the expected number of type parameters and integ...
Definition Type.cpp:1008
unsigned getIntParameter(unsigned i) const
TargetExtType(const TargetExtType &)=delete
LLVM_ABI bool hasProperty(Property Prop) const
Returns true if the target extension type contains the given property.
Definition Type.cpp:1152
TargetExtType & operator=(const TargetExtType &)=delete
@ IsTokenLike
In particular, it cannot be used in select and phi instructions.
@ HasZeroInit
zeroinitializer is valid for this target extension type.
@ CanBeVectorElement
This type may be used as an element in a vector.
@ CanBeGlobal
This type may be used as the value type of a global variable.
@ CanBeLocal
This type may be allocated on the stack, either as the allocated type of an alloca instruction or as ...
StringRef getName() const
Return the name for this target extension type.
static LLVM_ABI Expected< TargetExtType * > getOrError(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters,...
Definition Type.cpp:980
LLVM_ABI Type * getLayoutType() const
Returns an underlying layout type for the target extension type.
Definition Type.cpp:1148
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM_ABI unsigned getIntegerBitWidth() const
LLVM_ABI Type * getStructElementType(unsigned N) const
LLVM_ABI Type * getTruncatedType() const
Given scalar/vector integer type, returns a type with elements half as wide as in the original type.
LLVM_ABI bool containsNonGlobalTargetExtType(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this type is or contains a target extension type that disallows being used as a global...
Definition Type.cpp:74
LLVM_ABI bool containsNonLocalTargetExtType(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this type is or contains a target extension type that disallows being used as a local.
Definition Type.cpp:90
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
Definition Type.cpp:61
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition Type.h:263
LLVM_ABI StringRef getStructName() const
Type *const * subtype_iterator
Definition Type.h:377
LLVM_ABI unsigned getStructNumElements() const
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVM_ABI uint64_t getArrayNumElements() const
TypeID
Definitions of all of the base types for the Type system.
Definition Type.h:55
@ FunctionTyID
Functions.
Definition Type.h:73
@ ArrayTyID
Arrays.
Definition Type.h:76
@ TargetExtTyID
Target extension type.
Definition Type.h:80
@ ScalableVectorTyID
Scalable SIMD vector type.
Definition Type.h:78
@ FloatTyID
32-bit floating point type
Definition Type.h:59
@ StructTyID
Structures.
Definition Type.h:75
@ IntegerTyID
Arbitrary bit width integers.
Definition Type.h:71
@ FixedVectorTyID
Fixed width SIMD vector type.
Definition Type.h:77
@ DoubleTyID
64-bit floating point type
Definition Type.h:60
@ ByteTyID
Arbitrary bit width bytes.
Definition Type.h:72
@ PointerTyID
Pointers.
Definition Type.h:74
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
Definition Type.h:403
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
Definition Type.h:108
LLVM_ABI StringRef getTargetExtName() const
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition Type.h:368
Type(LLVMContext &C, TypeID tid)
Definition Type.h:95
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition Type.cpp:197
LLVM_ABI Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
LLVM_ABI Type * getWithNewType(Type *EltTy) const
Given vector type, change the element type, whilst keeping the old number of elements.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition Type.h:130
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition Type.h:115
unsigned getSubclassData() const
Definition Type.h:99
LLVM_ABI bool isFunctionVarArg() const
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:232
void setSubclassData(unsigned val)
Definition Type.h:101
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Definition Type.h:186
LLVM_ABI unsigned getByteBitWidth() const
LLVM_ABI Type * getExtendedType() const
Given scalar/vector integer type, returns a type with elements twice as wide as in the original type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition Type.h:257
TypeID getTypeID() const
Return the type id for the type.
Definition Type.h:138
LLVM_ABI Type * getFunctionParamType(unsigned i) const
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:313
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
Definition Type.h:397
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:286
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:284
LLVM_ABI unsigned getFunctionNumParams() const
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
LLVM_ABI VectorType(Type *ElType, unsigned EQ, Type::TypeID TID)
Definition Type.cpp:841
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static VectorType * getOneNthElementsVectorType(VectorType *VTy, unsigned Denominator)
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
const unsigned ElementQuantity
The element quantity of this vector.
static VectorType * get(Type *ElementType, const VectorType *Other)
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
VectorType & operator=(const VectorType &)=delete
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
This static method returns a VectorType with twice as many elements as the input type and the same el...
static VectorType * getWithSizeAndScalar(VectorType *SizeTy, Type *EltTy)
This static method attempts to construct a VectorType with the same size-in-bits as SizeTy but with a...
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static VectorType * get(Type *ElementType, unsigned NumElements, bool Scalable)
VectorType(const VectorType &)=delete
Type * getElementType() const
constexpr bool isKnownMultipleOf(ScalarTy RHS) const
This function tells the caller whether the element count is known at compile time to be a multiple of...
Definition TypeSize.h:180
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:200
constexpr LeafTy multiplyCoefficientBy(ScalarTy RHS) const
Definition TypeSize.h:256
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
Definition TypeSize.h:252
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
@ Other
Any other memory.
Definition ModRef.h:68
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
std::conjunction< std::is_base_of< T, Ts >... > are_base_of
traits class for checking whether type T is a base class for all the given types in the variadic list...
Definition STLExtras.h:114
#define N
#define EQ(a, b)
Definition regexec.c:65