LLVM 17.0.0git
Type.cpp
Go to the documentation of this file.
1//===- Type.cpp - Implement the Type class --------------------------------===//
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 implements the Type class for the IR library.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/Type.h"
14#include "LLVMContextImpl.h"
15#include "llvm/ADT/APInt.h"
17#include "llvm/ADT/StringMap.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/IR/Constant.h"
20#include "llvm/IR/Constants.h"
22#include "llvm/IR/LLVMContext.h"
23#include "llvm/IR/Value.h"
27#include <cassert>
28#include <utility>
29
30using namespace llvm;
31
32//===----------------------------------------------------------------------===//
33// Type Class Implementation
34//===----------------------------------------------------------------------===//
35
37 switch (IDNumber) {
38 case VoidTyID : return getVoidTy(C);
39 case HalfTyID : return getHalfTy(C);
40 case BFloatTyID : return getBFloatTy(C);
41 case FloatTyID : return getFloatTy(C);
42 case DoubleTyID : return getDoubleTy(C);
43 case X86_FP80TyID : return getX86_FP80Ty(C);
44 case FP128TyID : return getFP128Ty(C);
45 case PPC_FP128TyID : return getPPC_FP128Ty(C);
46 case LabelTyID : return getLabelTy(C);
47 case MetadataTyID : return getMetadataTy(C);
48 case X86_MMXTyID : return getX86_MMXTy(C);
49 case X86_AMXTyID : return getX86_AMXTy(C);
50 case TokenTyID : return getTokenTy(C);
51 default:
52 return nullptr;
53 }
54}
55
56bool Type::isIntegerTy(unsigned Bitwidth) const {
57 return isIntegerTy() && cast<IntegerType>(this)->getBitWidth() == Bitwidth;
58}
59
60bool Type::isOpaquePointerTy() const {
61 if (auto *PTy = dyn_cast<PointerType>(this))
62 return PTy->isOpaque();
63 return false;
64}
65
66bool Type::isScalableTy() const {
67 if (const auto *STy = dyn_cast<StructType>(this)) {
69 return STy->containsScalableVectorType(&Visited);
70 }
72}
73
75 switch (getTypeID()) {
76 case HalfTyID: return APFloat::IEEEhalf();
77 case BFloatTyID: return APFloat::BFloat();
78 case FloatTyID: return APFloat::IEEEsingle();
79 case DoubleTyID: return APFloat::IEEEdouble();
81 case FP128TyID: return APFloat::IEEEquad();
83 default: llvm_unreachable("Invalid floating type");
84 }
85}
86
87bool Type::isIEEE() const {
89}
90
91bool Type::isScalableTargetExtTy() const {
92 if (auto *TT = dyn_cast<TargetExtType>(this))
93 return isa<ScalableVectorType>(TT->getLayoutType());
94 return false;
95}
96
98 Type *Ty;
99 if (&S == &APFloat::IEEEhalf())
100 Ty = Type::getHalfTy(C);
101 else if (&S == &APFloat::BFloat())
102 Ty = Type::getBFloatTy(C);
103 else if (&S == &APFloat::IEEEsingle())
104 Ty = Type::getFloatTy(C);
105 else if (&S == &APFloat::IEEEdouble())
106 Ty = Type::getDoubleTy(C);
107 else if (&S == &APFloat::x87DoubleExtended())
109 else if (&S == &APFloat::IEEEquad())
110 Ty = Type::getFP128Ty(C);
111 else {
112 assert(&S == &APFloat::PPCDoubleDouble() && "Unknown FP format");
114 }
115 return Ty;
116}
117
118bool Type::canLosslesslyBitCastTo(Type *Ty) const {
119 // Identity cast means no change so return true
120 if (this == Ty)
121 return true;
122
123 // They are not convertible unless they are at least first class types
124 if (!this->isFirstClassType() || !Ty->isFirstClassType())
125 return false;
126
127 // Vector -> Vector conversions are always lossless if the two vector types
128 // have the same size, otherwise not.
129 if (isa<VectorType>(this) && isa<VectorType>(Ty))
131
132 // 64-bit fixed width vector types can be losslessly converted to x86mmx.
133 if (((isa<FixedVectorType>(this)) && Ty->isX86_MMXTy()) &&
134 getPrimitiveSizeInBits().getFixedValue() == 64)
135 return true;
136 if ((isX86_MMXTy() && isa<FixedVectorType>(Ty)) &&
138 return true;
139
140 // 8192-bit fixed width vector types can be losslessly converted to x86amx.
141 if (((isa<FixedVectorType>(this)) && Ty->isX86_AMXTy()) &&
142 getPrimitiveSizeInBits().getFixedValue() == 8192)
143 return true;
144 if ((isX86_AMXTy() && isa<FixedVectorType>(Ty)) &&
146 return true;
147
148 // At this point we have only various mismatches of the first class types
149 // remaining and ptr->ptr. Just select the lossless conversions. Everything
150 // else is not lossless. Conservatively assume we can't losslessly convert
151 // between pointers with different address spaces.
152 if (auto *PTy = dyn_cast<PointerType>(this)) {
153 if (auto *OtherPTy = dyn_cast<PointerType>(Ty))
154 return PTy->getAddressSpace() == OtherPTy->getAddressSpace();
155 return false;
156 }
157 return false; // Other types have no identity values
158}
159
160bool Type::isEmptyTy() const {
161 if (auto *ATy = dyn_cast<ArrayType>(this)) {
162 unsigned NumElements = ATy->getNumElements();
163 return NumElements == 0 || ATy->getElementType()->isEmptyTy();
164 }
165
166 if (auto *STy = dyn_cast<StructType>(this)) {
167 unsigned NumElements = STy->getNumElements();
168 for (unsigned i = 0; i < NumElements; ++i)
169 if (!STy->getElementType(i)->isEmptyTy())
170 return false;
171 return true;
172 }
173
174 return false;
175}
176
178 switch (getTypeID()) {
179 case Type::HalfTyID: return TypeSize::Fixed(16);
180 case Type::BFloatTyID: return TypeSize::Fixed(16);
181 case Type::FloatTyID: return TypeSize::Fixed(32);
182 case Type::DoubleTyID: return TypeSize::Fixed(64);
183 case Type::X86_FP80TyID: return TypeSize::Fixed(80);
184 case Type::FP128TyID: return TypeSize::Fixed(128);
185 case Type::PPC_FP128TyID: return TypeSize::Fixed(128);
186 case Type::X86_MMXTyID: return TypeSize::Fixed(64);
187 case Type::X86_AMXTyID: return TypeSize::Fixed(8192);
189 return TypeSize::Fixed(cast<IntegerType>(this)->getBitWidth());
192 const VectorType *VTy = cast<VectorType>(this);
193 ElementCount EC = VTy->getElementCount();
194 TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits();
195 assert(!ETS.isScalable() && "Vector type should have fixed-width elements");
196 return {ETS.getFixedValue() * EC.getKnownMinValue(), EC.isScalable()};
197 }
198 default: return TypeSize::Fixed(0);
199 }
200}
201
202unsigned Type::getScalarSizeInBits() const {
203 // It is safe to assume that the scalar types have a fixed size.
205}
206
207int Type::getFPMantissaWidth() const {
208 if (auto *VTy = dyn_cast<VectorType>(this))
209 return VTy->getElementType()->getFPMantissaWidth();
210 assert(isFloatingPointTy() && "Not a floating point type!");
211 if (getTypeID() == HalfTyID) return 11;
212 if (getTypeID() == BFloatTyID) return 8;
213 if (getTypeID() == FloatTyID) return 24;
214 if (getTypeID() == DoubleTyID) return 53;
215 if (getTypeID() == X86_FP80TyID) return 64;
216 if (getTypeID() == FP128TyID) return 113;
217 assert(getTypeID() == PPC_FP128TyID && "unknown fp type");
218 return -1;
219}
220
221bool Type::isSizedDerivedType(SmallPtrSetImpl<Type*> *Visited) const {
222 if (auto *ATy = dyn_cast<ArrayType>(this))
223 return ATy->getElementType()->isSized(Visited);
224
225 if (auto *VTy = dyn_cast<VectorType>(this))
226 return VTy->getElementType()->isSized(Visited);
227
228 if (auto *TTy = dyn_cast<TargetExtType>(this))
229 return TTy->getLayoutType()->isSized(Visited);
230
231 return cast<StructType>(this)->isSized(Visited);
232}
233
234//===----------------------------------------------------------------------===//
235// Primitive 'Type' data
236//===----------------------------------------------------------------------===//
237
238Type *Type::getVoidTy(LLVMContext &C) { return &C.pImpl->VoidTy; }
239Type *Type::getLabelTy(LLVMContext &C) { return &C.pImpl->LabelTy; }
240Type *Type::getHalfTy(LLVMContext &C) { return &C.pImpl->HalfTy; }
241Type *Type::getBFloatTy(LLVMContext &C) { return &C.pImpl->BFloatTy; }
242Type *Type::getFloatTy(LLVMContext &C) { return &C.pImpl->FloatTy; }
243Type *Type::getDoubleTy(LLVMContext &C) { return &C.pImpl->DoubleTy; }
244Type *Type::getMetadataTy(LLVMContext &C) { return &C.pImpl->MetadataTy; }
245Type *Type::getTokenTy(LLVMContext &C) { return &C.pImpl->TokenTy; }
246Type *Type::getX86_FP80Ty(LLVMContext &C) { return &C.pImpl->X86_FP80Ty; }
247Type *Type::getFP128Ty(LLVMContext &C) { return &C.pImpl->FP128Ty; }
248Type *Type::getPPC_FP128Ty(LLVMContext &C) { return &C.pImpl->PPC_FP128Ty; }
249Type *Type::getX86_MMXTy(LLVMContext &C) { return &C.pImpl->X86_MMXTy; }
250Type *Type::getX86_AMXTy(LLVMContext &C) { return &C.pImpl->X86_AMXTy; }
251
252IntegerType *Type::getInt1Ty(LLVMContext &C) { return &C.pImpl->Int1Ty; }
253IntegerType *Type::getInt8Ty(LLVMContext &C) { return &C.pImpl->Int8Ty; }
254IntegerType *Type::getInt16Ty(LLVMContext &C) { return &C.pImpl->Int16Ty; }
255IntegerType *Type::getInt32Ty(LLVMContext &C) { return &C.pImpl->Int32Ty; }
256IntegerType *Type::getInt64Ty(LLVMContext &C) { return &C.pImpl->Int64Ty; }
257IntegerType *Type::getInt128Ty(LLVMContext &C) { return &C.pImpl->Int128Ty; }
258
260 return IntegerType::get(C, N);
261}
262
264 return getHalfTy(C)->getPointerTo(AS);
265}
266
268 return getBFloatTy(C)->getPointerTo(AS);
269}
270
272 return getFloatTy(C)->getPointerTo(AS);
273}
274
276 return getDoubleTy(C)->getPointerTo(AS);
277}
278
280 return getX86_FP80Ty(C)->getPointerTo(AS);
281}
282
284 return getFP128Ty(C)->getPointerTo(AS);
285}
286
288 return getPPC_FP128Ty(C)->getPointerTo(AS);
289}
290
292 return getX86_MMXTy(C)->getPointerTo(AS);
293}
294
296 return getX86_AMXTy(C)->getPointerTo(AS);
297}
298
299PointerType *Type::getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS) {
300 return getIntNTy(C, N)->getPointerTo(AS);
301}
302
304 return getInt1Ty(C)->getPointerTo(AS);
305}
306
308 return getInt8Ty(C)->getPointerTo(AS);
309}
310
312 return getInt16Ty(C)->getPointerTo(AS);
313}
314
316 return getInt32Ty(C)->getPointerTo(AS);
317}
318
320 return getInt64Ty(C)->getPointerTo(AS);
321}
322
324 // opaque pointer in addrspace(10)
325 static PointerType *Ty = PointerType::get(C, 10);
326 return Ty;
327}
328
330 // opaque pointer in addrspace(20)
331 static PointerType *Ty = PointerType::get(C, 20);
332 return Ty;
333}
334
335//===----------------------------------------------------------------------===//
336// IntegerType Implementation
337//===----------------------------------------------------------------------===//
338
340 assert(NumBits >= MIN_INT_BITS && "bitwidth too small");
341 assert(NumBits <= MAX_INT_BITS && "bitwidth too large");
342
343 // Check for the built-in integer types
344 switch (NumBits) {
345 case 1: return cast<IntegerType>(Type::getInt1Ty(C));
346 case 8: return cast<IntegerType>(Type::getInt8Ty(C));
347 case 16: return cast<IntegerType>(Type::getInt16Ty(C));
348 case 32: return cast<IntegerType>(Type::getInt32Ty(C));
349 case 64: return cast<IntegerType>(Type::getInt64Ty(C));
350 case 128: return cast<IntegerType>(Type::getInt128Ty(C));
351 default:
352 break;
353 }
354
355 IntegerType *&Entry = C.pImpl->IntegerTypes[NumBits];
356
357 if (!Entry)
358 Entry = new (C.pImpl->Alloc) IntegerType(C, NumBits);
359
360 return Entry;
361}
362
364
365//===----------------------------------------------------------------------===//
366// FunctionType Implementation
367//===----------------------------------------------------------------------===//
368
369FunctionType::FunctionType(Type *Result, ArrayRef<Type*> Params,
370 bool IsVarArgs)
371 : Type(Result->getContext(), FunctionTyID) {
372 Type **SubTys = reinterpret_cast<Type**>(this+1);
373 assert(isValidReturnType(Result) && "invalid return type for function");
374 setSubclassData(IsVarArgs);
375
376 SubTys[0] = Result;
377
378 for (unsigned i = 0, e = Params.size(); i != e; ++i) {
379 assert(isValidArgumentType(Params[i]) &&
380 "Not a valid type for function argument!");
381 SubTys[i+1] = Params[i];
382 }
383
384 ContainedTys = SubTys;
385 NumContainedTys = Params.size() + 1; // + 1 for result type
386}
387
388// This is the factory function for the FunctionType class.
390 ArrayRef<Type*> Params, bool isVarArg) {
391 LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
392 const FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg);
393 FunctionType *FT;
394 // Since we only want to allocate a fresh function type in case none is found
395 // and we don't want to perform two lookups (one for checking if existent and
396 // one for inserting the newly allocated one), here we instead lookup based on
397 // Key and update the reference to the function type in-place to a newly
398 // allocated one if not found.
399 auto Insertion = pImpl->FunctionTypes.insert_as(nullptr, Key);
400 if (Insertion.second) {
401 // The function type was not found. Allocate one and update FunctionTypes
402 // in-place.
403 FT = (FunctionType *)pImpl->Alloc.Allocate(
404 sizeof(FunctionType) + sizeof(Type *) * (Params.size() + 1),
405 alignof(FunctionType));
406 new (FT) FunctionType(ReturnType, Params, isVarArg);
407 *Insertion.first = FT;
408 } else {
409 // The function type was found. Just return it.
410 FT = *Insertion.first;
411 }
412 return FT;
413}
414
415FunctionType *FunctionType::get(Type *Result, bool isVarArg) {
416 return get(Result, std::nullopt, isVarArg);
417}
418
420 return !RetTy->isFunctionTy() && !RetTy->isLabelTy() &&
421 !RetTy->isMetadataTy();
422}
423
425 return ArgTy->isFirstClassType();
426}
427
428//===----------------------------------------------------------------------===//
429// StructType Implementation
430//===----------------------------------------------------------------------===//
431
432// Primitive Constructors.
433
435 bool isPacked) {
437 const AnonStructTypeKeyInfo::KeyTy Key(ETypes, isPacked);
438
439 StructType *ST;
440 // Since we only want to allocate a fresh struct type in case none is found
441 // and we don't want to perform two lookups (one for checking if existent and
442 // one for inserting the newly allocated one), here we instead lookup based on
443 // Key and update the reference to the struct type in-place to a newly
444 // allocated one if not found.
445 auto Insertion = pImpl->AnonStructTypes.insert_as(nullptr, Key);
446 if (Insertion.second) {
447 // The struct type was not found. Allocate one and update AnonStructTypes
448 // in-place.
449 ST = new (Context.pImpl->Alloc) StructType(Context);
450 ST->setSubclassData(SCDB_IsLiteral); // Literal struct.
451 ST->setBody(ETypes, isPacked);
452 *Insertion.first = ST;
453 } else {
454 // The struct type was found. Just return it.
455 ST = *Insertion.first;
456 }
457
458 return ST;
459}
460
462 SmallPtrSetImpl<Type *> *Visited) const {
463 if ((getSubclassData() & SCDB_ContainsScalableVector) != 0)
464 return true;
465
466 if ((getSubclassData() & SCDB_NotContainsScalableVector) != 0)
467 return false;
468
469 if (Visited && !Visited->insert(const_cast<StructType *>(this)).second)
470 return false;
471
472 for (Type *Ty : elements()) {
473 if (isa<ScalableVectorType>(Ty)) {
474 const_cast<StructType *>(this)->setSubclassData(
475 getSubclassData() | SCDB_ContainsScalableVector);
476 return true;
477 }
478 if (auto *STy = dyn_cast<StructType>(Ty)) {
479 if (STy->containsScalableVectorType(Visited)) {
480 const_cast<StructType *>(this)->setSubclassData(
481 getSubclassData() | SCDB_ContainsScalableVector);
482 return true;
483 }
484 }
485 }
486
487 // For structures that are opaque, return false but do not set the
488 // SCDB_NotContainsScalableVector flag since it may gain scalable vector type
489 // when it becomes non-opaque.
490 if (!isOpaque())
491 const_cast<StructType *>(this)->setSubclassData(
492 getSubclassData() | SCDB_NotContainsScalableVector);
493 return false;
494}
495
497 Type *FirstTy = getNumElements() > 0 ? elements()[0] : nullptr;
498 if (!FirstTy || !isa<ScalableVectorType>(FirstTy))
499 return false;
500 for (Type *Ty : elements())
501 if (Ty != FirstTy)
502 return false;
503 return true;
504}
505
506void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) {
507 assert(isOpaque() && "Struct body already set!");
508
509 setSubclassData(getSubclassData() | SCDB_HasBody);
510 if (isPacked)
511 setSubclassData(getSubclassData() | SCDB_Packed);
512
513 NumContainedTys = Elements.size();
514
515 if (Elements.empty()) {
516 ContainedTys = nullptr;
517 return;
518 }
519
520 ContainedTys = Elements.copy(getContext().pImpl->Alloc).data();
521}
522
524 if (Name == getName()) return;
525
527
529
530 // If this struct already had a name, remove its symbol table entry. Don't
531 // delete the data yet because it may be part of the new name.
533 SymbolTable.remove((EntryTy *)SymbolTableEntry);
534
535 // If this is just removing the name, we're done.
536 if (Name.empty()) {
537 if (SymbolTableEntry) {
538 // Delete the old string data.
539 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.getAllocator());
540 SymbolTableEntry = nullptr;
541 }
542 return;
543 }
544
545 // Look up the entry for the name.
546 auto IterBool =
547 getContext().pImpl->NamedStructTypes.insert(std::make_pair(Name, this));
548
549 // While we have a name collision, try a random rename.
550 if (!IterBool.second) {
551 SmallString<64> TempStr(Name);
552 TempStr.push_back('.');
553 raw_svector_ostream TmpStream(TempStr);
554 unsigned NameSize = Name.size();
555
556 do {
557 TempStr.resize(NameSize + 1);
558 TmpStream << getContext().pImpl->NamedStructTypesUniqueID++;
559
560 IterBool = getContext().pImpl->NamedStructTypes.insert(
561 std::make_pair(TmpStream.str(), this));
562 } while (!IterBool.second);
563 }
564
565 // Delete the old string data.
567 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.getAllocator());
568 SymbolTableEntry = &*IterBool.first;
569}
570
571//===----------------------------------------------------------------------===//
572// StructType Helper functions.
573
576 if (!Name.empty())
577 ST->setName(Name);
578 return ST;
579}
580
581StructType *StructType::get(LLVMContext &Context, bool isPacked) {
582 return get(Context, std::nullopt, isPacked);
583}
584
586 StringRef Name, bool isPacked) {
588 ST->setBody(Elements, isPacked);
589 return ST;
590}
591
593 return create(Context, Elements, StringRef());
594}
595
597 return create(Context, StringRef());
598}
599
601 bool isPacked) {
602 assert(!Elements.empty() &&
603 "This method may not be invoked with an empty list");
604 return create(Elements[0]->getContext(), Elements, Name, isPacked);
605}
606
608 assert(!Elements.empty() &&
609 "This method may not be invoked with an empty list");
610 return create(Elements[0]->getContext(), Elements, StringRef());
611}
612
614 if ((getSubclassData() & SCDB_IsSized) != 0)
615 return true;
616 if (isOpaque())
617 return false;
618
619 if (Visited && !Visited->insert(const_cast<StructType*>(this)).second)
620 return false;
621
622 // Okay, our struct is sized if all of the elements are, but if one of the
623 // elements is opaque, the struct isn't sized *yet*, but may become sized in
624 // the future, so just bail out without caching.
625 // The ONLY special case inside a struct that is considered sized is when the
626 // elements are homogeneous of a scalable vector type.
628 const_cast<StructType *>(this)->setSubclassData(getSubclassData() |
629 SCDB_IsSized);
630 return true;
631 }
632 for (Type *Ty : elements()) {
633 // If the struct contains a scalable vector type, don't consider it sized.
634 // This prevents it from being used in loads/stores/allocas/GEPs. The ONLY
635 // special case right now is a structure of homogenous scalable vector
636 // types and is handled by the if-statement before this for-loop.
637 if (Ty->isScalableTy())
638 return false;
639 if (!Ty->isSized(Visited))
640 return false;
641 }
642
643 // Here we cheat a bit and cast away const-ness. The goal is to memoize when
644 // we find a sized type, as types can only move from opaque to sized, not the
645 // other way.
646 const_cast<StructType*>(this)->setSubclassData(
647 getSubclassData() | SCDB_IsSized);
648 return true;
649}
650
652 assert(!isLiteral() && "Literal structs never have names");
653 if (!SymbolTableEntry) return StringRef();
654
655 return ((StringMapEntry<StructType*> *)SymbolTableEntry)->getKey();
656}
657
659 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
660 !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy() &&
661 !ElemTy->isTokenTy();
662}
663
665 if (this == Other) return true;
666
667 if (isPacked() != Other->isPacked())
668 return false;
669
670 return elements() == Other->elements();
671}
672
674 unsigned Idx = (unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
675 assert(indexValid(Idx) && "Invalid structure index!");
676 return getElementType(Idx);
677}
678
679bool StructType::indexValid(const Value *V) const {
680 // Structure indexes require (vectors of) 32-bit integer constants. In the
681 // vector case all of the indices must be equal.
682 if (!V->getType()->isIntOrIntVectorTy(32))
683 return false;
684 if (isa<ScalableVectorType>(V->getType()))
685 return false;
686 const Constant *C = dyn_cast<Constant>(V);
687 if (C && V->getType()->isVectorTy())
688 C = C->getSplatValue();
689 const ConstantInt *CU = dyn_cast_or_null<ConstantInt>(C);
690 return CU && CU->getZExtValue() < getNumElements();
691}
692
694 return C.pImpl->NamedStructTypes.lookup(Name);
695}
696
697//===----------------------------------------------------------------------===//
698// ArrayType Implementation
699//===----------------------------------------------------------------------===//
700
701ArrayType::ArrayType(Type *ElType, uint64_t NumEl)
702 : Type(ElType->getContext(), ArrayTyID), ContainedType(ElType),
703 NumElements(NumEl) {
704 ContainedTys = &ContainedType;
705 NumContainedTys = 1;
706}
707
708ArrayType *ArrayType::get(Type *ElementType, uint64_t NumElements) {
709 assert(isValidElementType(ElementType) && "Invalid type for array element!");
710
711 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
712 ArrayType *&Entry =
713 pImpl->ArrayTypes[std::make_pair(ElementType, NumElements)];
714
715 if (!Entry)
716 Entry = new (pImpl->Alloc) ArrayType(ElementType, NumElements);
717 return Entry;
718}
719
721 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
722 !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy() &&
723 !ElemTy->isTokenTy() && !ElemTy->isX86_AMXTy() &&
724 !isa<ScalableVectorType>(ElemTy);
725}
726
727//===----------------------------------------------------------------------===//
728// VectorType Implementation
729//===----------------------------------------------------------------------===//
730
732 : Type(ElType->getContext(), TID), ContainedType(ElType),
733 ElementQuantity(EQ) {
734 ContainedTys = &ContainedType;
735 NumContainedTys = 1;
736}
737
739 if (EC.isScalable())
740 return ScalableVectorType::get(ElementType, EC.getKnownMinValue());
741 else
742 return FixedVectorType::get(ElementType, EC.getKnownMinValue());
743}
744
746 return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() ||
747 ElemTy->isPointerTy() || ElemTy->getTypeID() == TypedPointerTyID;
748}
749
750//===----------------------------------------------------------------------===//
751// FixedVectorType Implementation
752//===----------------------------------------------------------------------===//
753
754FixedVectorType *FixedVectorType::get(Type *ElementType, unsigned NumElts) {
755 assert(NumElts > 0 && "#Elements of a VectorType must be greater than 0");
756 assert(isValidElementType(ElementType) && "Element type of a VectorType must "
757 "be an integer, floating point, or "
758 "pointer type.");
759
760 auto EC = ElementCount::getFixed(NumElts);
761
762 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
763 VectorType *&Entry = ElementType->getContext()
764 .pImpl->VectorTypes[std::make_pair(ElementType, EC)];
765
766 if (!Entry)
767 Entry = new (pImpl->Alloc) FixedVectorType(ElementType, NumElts);
768 return cast<FixedVectorType>(Entry);
769}
770
771//===----------------------------------------------------------------------===//
772// ScalableVectorType Implementation
773//===----------------------------------------------------------------------===//
774
776 unsigned MinNumElts) {
777 assert(MinNumElts > 0 && "#Elements of a VectorType must be greater than 0");
778 assert(isValidElementType(ElementType) && "Element type of a VectorType must "
779 "be an integer, floating point, or "
780 "pointer type.");
781
782 auto EC = ElementCount::getScalable(MinNumElts);
783
784 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
785 VectorType *&Entry = ElementType->getContext()
786 .pImpl->VectorTypes[std::make_pair(ElementType, EC)];
787
788 if (!Entry)
789 Entry = new (pImpl->Alloc) ScalableVectorType(ElementType, MinNumElts);
790 return cast<ScalableVectorType>(Entry);
791}
792
793//===----------------------------------------------------------------------===//
794// PointerType Implementation
795//===----------------------------------------------------------------------===//
796
798 assert(EltTy && "Can't get a pointer to <null> type!");
799 assert(isValidElementType(EltTy) && "Invalid type for pointer element!");
800
801 LLVMContextImpl *CImpl = EltTy->getContext().pImpl;
802
803 // Automatically convert typed pointers to opaque pointers.
804 if (CImpl->getOpaquePointers())
805 return get(EltTy->getContext(), AddressSpace);
806
807 PointerType *&Entry =
808 CImpl->LegacyPointerTypes[std::make_pair(EltTy, AddressSpace)];
809
810 if (!Entry)
811 Entry = new (CImpl->Alloc) PointerType(EltTy, AddressSpace);
812 return Entry;
813}
814
816 LLVMContextImpl *CImpl = C.pImpl;
817 assert(CImpl->getOpaquePointers() &&
818 "Can only create opaque pointers in opaque pointer mode");
819
820 // Since AddressSpace #0 is the common case, we special case it.
821 PointerType *&Entry = AddressSpace == 0 ? CImpl->AS0PointerType
822 : CImpl->PointerTypes[AddressSpace];
823
824 if (!Entry)
825 Entry = new (CImpl->Alloc) PointerType(C, AddressSpace);
826 return Entry;
827}
828
829PointerType::PointerType(Type *E, unsigned AddrSpace)
830 : Type(E->getContext(), PointerTyID), PointeeTy(E) {
831 ContainedTys = &PointeeTy;
832 NumContainedTys = 1;
833 setSubclassData(AddrSpace);
834}
835
836PointerType::PointerType(LLVMContext &C, unsigned AddrSpace)
837 : Type(C, PointerTyID), PointeeTy(nullptr) {
838 setSubclassData(AddrSpace);
839}
840
841PointerType *Type::getPointerTo(unsigned AddrSpace) const {
842 return PointerType::get(const_cast<Type*>(this), AddrSpace);
843}
844
846 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
847 !ElemTy->isMetadataTy() && !ElemTy->isTokenTy() &&
848 !ElemTy->isX86_AMXTy();
849}
850
852 return isValidElementType(ElemTy) && !ElemTy->isFunctionTy();
853}
854
855//===----------------------------------------------------------------------===//
856// TargetExtType Implementation
857//===----------------------------------------------------------------------===//
858
859TargetExtType::TargetExtType(LLVMContext &C, StringRef Name,
861 : Type(C, TargetExtTyID), Name(C.pImpl->Saver.save(Name)) {
862 NumContainedTys = Types.size();
863
864 // Parameter storage immediately follows the class in allocation.
865 Type **Params = reinterpret_cast<Type **>(this + 1);
866 ContainedTys = Params;
867 for (Type *T : Types)
868 *Params++ = T;
869
870 setSubclassData(Ints.size());
871 unsigned *IntParamSpace = reinterpret_cast<unsigned *>(Params);
872 IntParams = IntParamSpace;
873 for (unsigned IntParam : Ints)
874 *IntParamSpace++ = IntParam;
875}
876
878 ArrayRef<Type *> Types,
879 ArrayRef<unsigned> Ints) {
880 const TargetExtTypeKeyInfo::KeyTy Key(Name, Types, Ints);
881 TargetExtType *TT;
882 // Since we only want to allocate a fresh target type in case none is found
883 // and we don't want to perform two lookups (one for checking if existent and
884 // one for inserting the newly allocated one), here we instead lookup based on
885 // Key and update the reference to the target type in-place to a newly
886 // allocated one if not found.
887 auto Insertion = C.pImpl->TargetExtTypes.insert_as(nullptr, Key);
888 if (Insertion.second) {
889 // The target type was not found. Allocate one and update TargetExtTypes
890 // in-place.
891 TT = (TargetExtType *)C.pImpl->Alloc.Allocate(
892 sizeof(TargetExtType) + sizeof(Type *) * Types.size() +
893 sizeof(unsigned) * Ints.size(),
894 alignof(TargetExtType));
895 new (TT) TargetExtType(C, Name, Types, Ints);
896 *Insertion.first = TT;
897 } else {
898 // The target type was found. Just return it.
899 TT = *Insertion.first;
900 }
901 return TT;
902}
903
904namespace {
905struct TargetTypeInfo {
906 Type *LayoutType;
907 uint64_t Properties;
908
909 template <typename... ArgTys>
910 TargetTypeInfo(Type *LayoutType, ArgTys... Properties)
911 : LayoutType(LayoutType), Properties((0 | ... | Properties)) {}
912};
913} // anonymous namespace
914
915static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) {
916 LLVMContext &C = Ty->getContext();
917 StringRef Name = Ty->getName();
918 if (Name.startswith("spirv."))
919 return TargetTypeInfo(Type::getInt8PtrTy(C, 0), TargetExtType::HasZeroInit,
921
922 // Opaque types in the AArch64 name space.
923 if (Name == "aarch64.svcount")
924 return TargetTypeInfo(ScalableVectorType::get(Type::getInt1Ty(C), 16));
925
926 return TargetTypeInfo(Type::getVoidTy(C));
927}
928
930 return getTargetTypeInfo(this).LayoutType;
931}
932
934 uint64_t Properties = getTargetTypeInfo(this).Properties;
935 return (Properties & Prop) == Prop;
936}
This file defines the StringMap class.
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
return RetTy
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
std::string Name
LLVMContext & Context
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty)
Definition: Type.cpp:915
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
bool isIEEE() const
Definition: APFloat.h:1287
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Definition: APFloat.h:931
Class for arbitrary precision integers.
Definition: APInt.h:75
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
Definition: APInt.h:214
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:163
Class to represent array types.
Definition: DerivedTypes.h:368
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition: Type.cpp:720
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Definition: Type.cpp:708
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:148
This is the shared class of boolean and integer constants.
Definition: Constants.h:78
This is an important base class in LLVM.
Definition: Constant.h:41
static constexpr ElementCount getScalable(ScalarTy MinVal)
Definition: TypeSize.h:294
static constexpr ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:291
Class to represent fixed width SIMD vectors.
Definition: DerivedTypes.h:536
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition: Type.cpp:754
Class to represent function types.
Definition: DerivedTypes.h:103
static bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
Definition: Type.cpp:424
static bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
Definition: Type.cpp:419
bool isVarArg() const
Definition: DerivedTypes.h:123
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Class to represent integer types.
Definition: DerivedTypes.h:40
@ MIN_INT_BITS
Minimum number of bits that can be specified.
Definition: DerivedTypes.h:51
@ MAX_INT_BITS
Maximum number of bits that can be specified.
Definition: DerivedTypes.h:52
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:339
APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
Definition: Type.cpp:363
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:72
StructTypeSet AnonStructTypes
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
BumpPtrAllocator Alloc
DenseMap< std::pair< Type *, ElementCount >, VectorType * > VectorTypes
DenseMap< std::pair< Type *, unsigned >, PointerType * > LegacyPointerTypes
DenseMap< unsigned, PointerType * > PointerTypes
StringMap< StructType * > NamedStructTypes
PointerType * AS0PointerType
FunctionTypeSet FunctionTypes
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:69
Class to represent pointers.
Definition: DerivedTypes.h:643
static bool isLoadableOrStorableType(Type *ElemTy)
Return true if we can load or store from a pointer to this type.
Definition: Type.cpp:851
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition: Type.cpp:845
Class to represent scalable SIMD vectors.
Definition: DerivedTypes.h:583
static ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition: Type.cpp:775
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:344
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:365
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
void resize(size_type N)
Definition: SmallVector.h:642
void push_back(const T &Elt)
Definition: SmallVector.h:416
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:111
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
Definition: StringMap.h:379
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Class to represent struct types.
Definition: DerivedTypes.h:213
bool indexValid(const Value *V) const
Definition: Type.cpp:679
static 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:434
ArrayRef< Type * > elements() const
Definition: DerivedTypes.h:330
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type.
Definition: Type.cpp:506
bool containsHomogeneousScalableVectorTypes() const
Returns true if this struct contains homogeneous scalable vector types.
Definition: Type.cpp:496
static 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:693
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition: Type.cpp:574
bool isPacked() const
Definition: DerivedTypes.h:275
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition: Type.cpp:658
unsigned getNumElements() const
Random access to the elements.
Definition: DerivedTypes.h:338
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
isSized - Return true if this is a sized type.
Definition: Type.cpp:613
bool containsScalableVectorType(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Returns true if this struct contains a scalable vector.
Definition: Type.cpp:461
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:523
bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
Definition: Type.cpp:664
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
Definition: Type.cpp:673
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition.
Definition: DerivedTypes.h:279
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
Definition: DerivedTypes.h:283
Type * getElementType(unsigned N) const
Definition: DerivedTypes.h:339
StringRef getName() const
Return the name for this struct type if it has an identity.
Definition: Type.cpp:651
Symbol info for RuntimeDyld.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:750
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types=std::nullopt, ArrayRef< unsigned > Ints=std::nullopt)
Return a target extension type having the specified name and optional type and integer parameters.
Definition: Type.cpp:877
bool hasProperty(Property Prop) const
Returns true if the target extension type contains the given property.
Definition: Type.cpp:933
@ HasZeroInit
zeroinitializer is valid for this target extension type.
Definition: DerivedTypes.h:799
@ CanBeGlobal
This type may be used as the value type of a global variable.
Definition: DerivedTypes.h:801
StringRef getName() const
Return the name for this target extension type.
Definition: DerivedTypes.h:771
Type * getLayoutType() const
Returns an underlying layout type for the target extension type.
Definition: Type.cpp:929
static constexpr TypeSize Fixed(ScalarTy ExactSize)
Definition: TypeSize.h:331
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getFP128PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getPPC_FP128PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
const fltSemantics & getFltSemantics() const
static Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
static PointerType * getHalfPtrTy(LLVMContext &C, unsigned AS=0)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getX86_FP80Ty(LLVMContext &C)
static PointerType * getX86_FP80PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getX86_MMXPtrTy(LLVMContext &C, unsigned AS=0)
bool isLabelTy() const
Return true if this is 'label'.
Definition: Type.h:220
static Type * getBFloatTy(LLVMContext &C)
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:256
static PointerType * getBFloatPtrTy(LLVMContext &C, unsigned AS=0)
static IntegerType * getInt1Ty(LLVMContext &C)
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
static Type * getX86_AMXTy(LLVMContext &C)
static Type * getMetadataTy(LLVMContext &C)
TypeID
Definitions of all of the base types for the Type system.
Definition: Type.h:54
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
Definition: Type.h:66
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition: Type.h:67
@ TypedPointerTyID
Typed pointer used by some GPU targets.
Definition: Type.h:78
@ HalfTyID
16-bit floating point type
Definition: Type.h:56
@ VoidTyID
type with no size
Definition: Type.h:63
@ ScalableVectorTyID
Scalable SIMD vector type.
Definition: Type.h:77
@ LabelTyID
Labels.
Definition: Type.h:64
@ FloatTyID
32-bit floating point type
Definition: Type.h:58
@ IntegerTyID
Arbitrary bit width integers.
Definition: Type.h:71
@ FixedVectorTyID
Fixed width SIMD vector type.
Definition: Type.h:76
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition: Type.h:57
@ DoubleTyID
64-bit floating point type
Definition: Type.h:59
@ X86_FP80TyID
80-bit floating point type (X87)
Definition: Type.h:60
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:62
@ MetadataTyID
Metadata.
Definition: Type.h:65
@ TokenTyID
Tokens.
Definition: Type.h:68
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition: Type.h:61
bool isX86_MMXTy() const
Return true if this is X86 MMX.
Definition: Type.h:201
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
Definition: Type.h:107
static Type * getX86_MMXTy(LLVMContext &C)
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static Type * getVoidTy(LLVMContext &C)
static Type * getLabelTy(LLVMContext &C)
bool isScalableTargetExtTy() const
Return true if this is a target extension type with a scalable layout.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
Definition: Type.h:281
static Type * getFP128Ty(LLVMContext &C)
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:302
static IntegerType * getInt16Ty(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:129
static Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
Return a type based on an identifier.
int getFPMantissaWidth() const
Return the width of the mantissa of this type.
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition: Type.h:114
unsigned getSubclassData() const
Definition: Type.h:98
static IntegerType * getInt8Ty(LLVMContext &C)
bool isIEEE() const
Return whether the type is IEEE compatible, as defined by the eponymous method in APFloat.
static IntegerType * getInt128Ty(LLVMContext &C)
static PointerType * getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS=0)
static PointerType * getX86_AMXPtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getDoublePtrTy(LLVMContext &C, unsigned AS=0)
void setSubclassData(unsigned val)
Definition: Type.h:100
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getTokenTy(LLVMContext &C)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Definition: Type.h:185
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:204
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:247
bool isScalableTy() const
Return true if this is a scalable vector type or a target extension type with a scalable layout.
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'.
static IntegerType * getInt32Ty(LLVMContext &C)
static PointerType * getFloatPtrTy(LLVMContext &C, unsigned AS=0)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:229
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:137
static Type * getWasm_FuncrefTy(LLVMContext &C)
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:226
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
static PointerType * getInt16PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getPPC_FP128Ty(LLVMContext &C)
bool isOpaquePointerTy() const
True if this is an instance of an opaque PointerType.
static Type * getWasm_ExternrefTy(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:140
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition: Type.h:348
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:223
LLVM Value Representation.
Definition: Value.h:74
Base class of all SIMD vector types.
Definition: DerivedTypes.h:400
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition: Type.cpp:745
VectorType(Type *ElType, unsigned EQ, Type::TypeID TID)
Definition: Type.cpp:731
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:738
std::pair< iterator, bool > insert_as(const ValueT &V, const LookupKeyT &LookupKey)
Alternative version of insert that uses a different (and possibly less expensive) key type.
Definition: DenseSet.h:219
constexpr ScalarTy getFixedValue() const
Definition: TypeSize.h:182
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:166
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:672
StringRef str() const
Return a StringRef for the vector contents.
Definition: raw_ostream.h:697
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Key
PAL metadata keys.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
constexpr size_t NameSize
Definition: XCOFF.h:29
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AddressSpace
Definition: NVPTXBaseInfo.h:21
#define N
#define EQ(a, b)
Definition: regexec.c:112
static const fltSemantics & IEEEsingle() LLVM_READNONE
Definition: APFloat.cpp:244
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
Definition: APFloat.cpp:247
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
Definition: APFloat.cpp:257
static const fltSemantics & IEEEquad() LLVM_READNONE
Definition: APFloat.cpp:246
static const fltSemantics & IEEEdouble() LLVM_READNONE
Definition: APFloat.cpp:245
static const fltSemantics & IEEEhalf() LLVM_READNONE
Definition: APFloat.cpp:242
static const fltSemantics & BFloat() LLVM_READNONE
Definition: APFloat.cpp:243