LLVM 20.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"
16#include "llvm/ADT/SetVector.h"
18#include "llvm/ADT/StringMap.h"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/IR/Constant.h"
21#include "llvm/IR/Constants.h"
23#include "llvm/IR/LLVMContext.h"
24#include "llvm/IR/Value.h"
26#include "llvm/Support/Error.h"
30#include <cassert>
31#include <utility>
32
33using namespace llvm;
34
35//===----------------------------------------------------------------------===//
36// Type Class Implementation
37//===----------------------------------------------------------------------===//
38
39Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) {
40 switch (IDNumber) {
41 case VoidTyID : return getVoidTy(C);
42 case HalfTyID : return getHalfTy(C);
43 case BFloatTyID : return getBFloatTy(C);
44 case FloatTyID : return getFloatTy(C);
45 case DoubleTyID : return getDoubleTy(C);
46 case X86_FP80TyID : return getX86_FP80Ty(C);
47 case FP128TyID : return getFP128Ty(C);
48 case PPC_FP128TyID : return getPPC_FP128Ty(C);
49 case LabelTyID : return getLabelTy(C);
50 case MetadataTyID : return getMetadataTy(C);
51 case X86_AMXTyID : return getX86_AMXTy(C);
52 case TokenTyID : return getTokenTy(C);
53 default:
54 return nullptr;
55 }
56}
57
58bool Type::isIntegerTy(unsigned Bitwidth) const {
59 return isIntegerTy() && cast<IntegerType>(this)->getBitWidth() == Bitwidth;
60}
61
62bool Type::isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const {
63 if (const auto *ATy = dyn_cast<ArrayType>(this))
64 return ATy->getElementType()->isScalableTy(Visited);
65 if (const auto *STy = dyn_cast<StructType>(this))
66 return STy->isScalableTy(Visited);
67 return getTypeID() == ScalableVectorTyID || isScalableTargetExtTy();
68}
69
70bool Type::isScalableTy() const {
72 return isScalableTy(Visited);
73}
74
75bool Type::containsNonGlobalTargetExtType(
76 SmallPtrSetImpl<const Type *> &Visited) const {
77 if (const auto *ATy = dyn_cast<ArrayType>(this))
78 return ATy->getElementType()->containsNonGlobalTargetExtType(Visited);
79 if (const auto *STy = dyn_cast<StructType>(this))
80 return STy->containsNonGlobalTargetExtType(Visited);
81 if (auto *TT = dyn_cast<TargetExtType>(this))
82 return !TT->hasProperty(TargetExtType::CanBeGlobal);
83 return false;
84}
85
86bool Type::containsNonGlobalTargetExtType() const {
88 return containsNonGlobalTargetExtType(Visited);
89}
90
91bool Type::containsNonLocalTargetExtType(
92 SmallPtrSetImpl<const Type *> &Visited) const {
93 if (const auto *ATy = dyn_cast<ArrayType>(this))
94 return ATy->getElementType()->containsNonLocalTargetExtType(Visited);
95 if (const auto *STy = dyn_cast<StructType>(this))
96 return STy->containsNonLocalTargetExtType(Visited);
97 if (auto *TT = dyn_cast<TargetExtType>(this))
98 return !TT->hasProperty(TargetExtType::CanBeLocal);
99 return false;
100}
101
102bool Type::containsNonLocalTargetExtType() const {
104 return containsNonLocalTargetExtType(Visited);
105}
106
107const fltSemantics &Type::getFltSemantics() const {
108 switch (getTypeID()) {
109 case HalfTyID: return APFloat::IEEEhalf();
110 case BFloatTyID: return APFloat::BFloat();
111 case FloatTyID: return APFloat::IEEEsingle();
112 case DoubleTyID: return APFloat::IEEEdouble();
113 case X86_FP80TyID: return APFloat::x87DoubleExtended();
114 case FP128TyID: return APFloat::IEEEquad();
115 case PPC_FP128TyID: return APFloat::PPCDoubleDouble();
116 default: llvm_unreachable("Invalid floating type");
117 }
118}
119
120bool Type::isIEEE() const {
121 return APFloat::getZero(getFltSemantics()).isIEEE();
122}
123
124bool Type::isScalableTargetExtTy() const {
125 if (auto *TT = dyn_cast<TargetExtType>(this))
126 return isa<ScalableVectorType>(TT->getLayoutType());
127 return false;
128}
129
130Type *Type::getFloatingPointTy(LLVMContext &C, const fltSemantics &S) {
131 Type *Ty;
132 if (&S == &APFloat::IEEEhalf())
133 Ty = Type::getHalfTy(C);
134 else if (&S == &APFloat::BFloat())
135 Ty = Type::getBFloatTy(C);
136 else if (&S == &APFloat::IEEEsingle())
137 Ty = Type::getFloatTy(C);
138 else if (&S == &APFloat::IEEEdouble())
139 Ty = Type::getDoubleTy(C);
140 else if (&S == &APFloat::x87DoubleExtended())
141 Ty = Type::getX86_FP80Ty(C);
142 else if (&S == &APFloat::IEEEquad())
143 Ty = Type::getFP128Ty(C);
144 else {
145 assert(&S == &APFloat::PPCDoubleDouble() && "Unknown FP format");
146 Ty = Type::getPPC_FP128Ty(C);
147 }
148 return Ty;
149}
150
151bool Type::isRISCVVectorTupleTy() const {
152 if (!isTargetExtTy())
153 return false;
154
155 return cast<TargetExtType>(this)->getName() == "riscv.vector.tuple";
156}
157
158bool Type::canLosslesslyBitCastTo(Type *Ty) const {
159 // Identity cast means no change so return true
160 if (this == Ty)
161 return true;
162
163 // They are not convertible unless they are at least first class types
164 if (!this->isFirstClassType() || !Ty->isFirstClassType())
165 return false;
166
167 // Vector -> Vector conversions are always lossless if the two vector types
168 // have the same size, otherwise not.
169 if (isa<VectorType>(this) && isa<VectorType>(Ty))
170 return getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits();
171
172 // 8192-bit fixed width vector types can be losslessly converted to x86amx.
173 if (((isa<FixedVectorType>(this)) && Ty->isX86_AMXTy()) &&
174 getPrimitiveSizeInBits().getFixedValue() == 8192)
175 return true;
176 if ((isX86_AMXTy() && isa<FixedVectorType>(Ty)) &&
178 return true;
179
180 // Conservatively assume we can't losslessly convert between pointers with
181 // different address spaces.
182 return false;
183}
184
185bool Type::isEmptyTy() const {
186 if (auto *ATy = dyn_cast<ArrayType>(this)) {
187 unsigned NumElements = ATy->getNumElements();
188 return NumElements == 0 || ATy->getElementType()->isEmptyTy();
189 }
190
191 if (auto *STy = dyn_cast<StructType>(this)) {
192 unsigned NumElements = STy->getNumElements();
193 for (unsigned i = 0; i < NumElements; ++i)
194 if (!STy->getElementType(i)->isEmptyTy())
195 return false;
196 return true;
197 }
198
199 return false;
200}
201
202TypeSize Type::getPrimitiveSizeInBits() const {
203 switch (getTypeID()) {
204 case Type::HalfTyID:
205 return TypeSize::getFixed(16);
206 case Type::BFloatTyID:
207 return TypeSize::getFixed(16);
208 case Type::FloatTyID:
209 return TypeSize::getFixed(32);
210 case Type::DoubleTyID:
211 return TypeSize::getFixed(64);
212 case Type::X86_FP80TyID:
213 return TypeSize::getFixed(80);
214 case Type::FP128TyID:
215 return TypeSize::getFixed(128);
216 case Type::PPC_FP128TyID:
217 return TypeSize::getFixed(128);
218 case Type::X86_AMXTyID:
219 return TypeSize::getFixed(8192);
220 case Type::IntegerTyID:
221 return TypeSize::getFixed(cast<IntegerType>(this)->getBitWidth());
222 case Type::FixedVectorTyID:
223 case Type::ScalableVectorTyID: {
224 const VectorType *VTy = cast<VectorType>(this);
225 ElementCount EC = VTy->getElementCount();
226 TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits();
227 assert(!ETS.isScalable() && "Vector type should have fixed-width elements");
228 return {ETS.getFixedValue() * EC.getKnownMinValue(), EC.isScalable()};
229 }
230 default:
231 return TypeSize::getFixed(0);
232 }
233}
234
235unsigned Type::getScalarSizeInBits() const {
236 // It is safe to assume that the scalar types have a fixed size.
237 return getScalarType()->getPrimitiveSizeInBits().getFixedValue();
238}
239
240int Type::getFPMantissaWidth() const {
241 if (auto *VTy = dyn_cast<VectorType>(this))
242 return VTy->getElementType()->getFPMantissaWidth();
243 assert(isFloatingPointTy() && "Not a floating point type!");
244 if (getTypeID() == HalfTyID) return 11;
245 if (getTypeID() == BFloatTyID) return 8;
246 if (getTypeID() == FloatTyID) return 24;
247 if (getTypeID() == DoubleTyID) return 53;
248 if (getTypeID() == X86_FP80TyID) return 64;
249 if (getTypeID() == FP128TyID) return 113;
250 assert(getTypeID() == PPC_FP128TyID && "unknown fp type");
251 return -1;
252}
253
254bool Type::isSizedDerivedType(SmallPtrSetImpl<Type*> *Visited) const {
255 if (auto *ATy = dyn_cast<ArrayType>(this))
256 return ATy->getElementType()->isSized(Visited);
257
258 if (auto *VTy = dyn_cast<VectorType>(this))
259 return VTy->getElementType()->isSized(Visited);
260
261 if (auto *TTy = dyn_cast<TargetExtType>(this))
262 return TTy->getLayoutType()->isSized(Visited);
263
264 return cast<StructType>(this)->isSized(Visited);
265}
266
267//===----------------------------------------------------------------------===//
268// Primitive 'Type' data
269//===----------------------------------------------------------------------===//
270
271Type *Type::getVoidTy(LLVMContext &C) { return &C.pImpl->VoidTy; }
272Type *Type::getLabelTy(LLVMContext &C) { return &C.pImpl->LabelTy; }
273Type *Type::getHalfTy(LLVMContext &C) { return &C.pImpl->HalfTy; }
274Type *Type::getBFloatTy(LLVMContext &C) { return &C.pImpl->BFloatTy; }
275Type *Type::getFloatTy(LLVMContext &C) { return &C.pImpl->FloatTy; }
276Type *Type::getDoubleTy(LLVMContext &C) { return &C.pImpl->DoubleTy; }
277Type *Type::getMetadataTy(LLVMContext &C) { return &C.pImpl->MetadataTy; }
278Type *Type::getTokenTy(LLVMContext &C) { return &C.pImpl->TokenTy; }
279Type *Type::getX86_FP80Ty(LLVMContext &C) { return &C.pImpl->X86_FP80Ty; }
280Type *Type::getFP128Ty(LLVMContext &C) { return &C.pImpl->FP128Ty; }
281Type *Type::getPPC_FP128Ty(LLVMContext &C) { return &C.pImpl->PPC_FP128Ty; }
282Type *Type::getX86_AMXTy(LLVMContext &C) { return &C.pImpl->X86_AMXTy; }
283
284IntegerType *Type::getInt1Ty(LLVMContext &C) { return &C.pImpl->Int1Ty; }
285IntegerType *Type::getInt8Ty(LLVMContext &C) { return &C.pImpl->Int8Ty; }
286IntegerType *Type::getInt16Ty(LLVMContext &C) { return &C.pImpl->Int16Ty; }
287IntegerType *Type::getInt32Ty(LLVMContext &C) { return &C.pImpl->Int32Ty; }
288IntegerType *Type::getInt64Ty(LLVMContext &C) { return &C.pImpl->Int64Ty; }
289IntegerType *Type::getInt128Ty(LLVMContext &C) { return &C.pImpl->Int128Ty; }
290
291IntegerType *Type::getIntNTy(LLVMContext &C, unsigned N) {
292 return IntegerType::get(C, N);
293}
294
295Type *Type::getWasm_ExternrefTy(LLVMContext &C) {
296 // opaque pointer in addrspace(10)
297 static PointerType *Ty = PointerType::get(C, 10);
298 return Ty;
299}
300
301Type *Type::getWasm_FuncrefTy(LLVMContext &C) {
302 // opaque pointer in addrspace(20)
303 static PointerType *Ty = PointerType::get(C, 20);
304 return Ty;
305}
306
307//===----------------------------------------------------------------------===//
308// IntegerType Implementation
309//===----------------------------------------------------------------------===//
310
311IntegerType *IntegerType::get(LLVMContext &C, unsigned NumBits) {
312 assert(NumBits >= MIN_INT_BITS && "bitwidth too small");
313 assert(NumBits <= MAX_INT_BITS && "bitwidth too large");
314
315 // Check for the built-in integer types
316 switch (NumBits) {
317 case 1: return cast<IntegerType>(Type::getInt1Ty(C));
318 case 8: return cast<IntegerType>(Type::getInt8Ty(C));
319 case 16: return cast<IntegerType>(Type::getInt16Ty(C));
320 case 32: return cast<IntegerType>(Type::getInt32Ty(C));
321 case 64: return cast<IntegerType>(Type::getInt64Ty(C));
322 case 128: return cast<IntegerType>(Type::getInt128Ty(C));
323 default:
324 break;
325 }
326
327 IntegerType *&Entry = C.pImpl->IntegerTypes[NumBits];
328
329 if (!Entry)
330 Entry = new (C.pImpl->Alloc) IntegerType(C, NumBits);
331
332 return Entry;
333}
334
335APInt IntegerType::getMask() const { return APInt::getAllOnes(getBitWidth()); }
336
337//===----------------------------------------------------------------------===//
338// FunctionType Implementation
339//===----------------------------------------------------------------------===//
340
342 bool IsVarArgs)
343 : Type(Result->getContext(), FunctionTyID) {
344 Type **SubTys = reinterpret_cast<Type**>(this+1);
345 assert(isValidReturnType(Result) && "invalid return type for function");
346 setSubclassData(IsVarArgs);
347
348 SubTys[0] = Result;
349
350 for (unsigned i = 0, e = Params.size(); i != e; ++i) {
351 assert(isValidArgumentType(Params[i]) &&
352 "Not a valid type for function argument!");
353 SubTys[i+1] = Params[i];
354 }
355
356 ContainedTys = SubTys;
357 NumContainedTys = Params.size() + 1; // + 1 for result type
358}
359
360// This is the factory function for the FunctionType class.
361FunctionType *FunctionType::get(Type *ReturnType,
362 ArrayRef<Type*> Params, bool isVarArg) {
363 LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
364 const FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg);
365 FunctionType *FT;
366 // Since we only want to allocate a fresh function type in case none is found
367 // and we don't want to perform two lookups (one for checking if existent and
368 // one for inserting the newly allocated one), here we instead lookup based on
369 // Key and update the reference to the function type in-place to a newly
370 // allocated one if not found.
371 auto Insertion = pImpl->FunctionTypes.insert_as(nullptr, Key);
372 if (Insertion.second) {
373 // The function type was not found. Allocate one and update FunctionTypes
374 // in-place.
375 FT = (FunctionType *)pImpl->Alloc.Allocate(
376 sizeof(FunctionType) + sizeof(Type *) * (Params.size() + 1),
377 alignof(FunctionType));
378 new (FT) FunctionType(ReturnType, Params, isVarArg);
379 *Insertion.first = FT;
380 } else {
381 // The function type was found. Just return it.
382 FT = *Insertion.first;
383 }
384 return FT;
385}
386
387FunctionType *FunctionType::get(Type *Result, bool isVarArg) {
388 return get(Result, {}, isVarArg);
389}
390
391bool FunctionType::isValidReturnType(Type *RetTy) {
392 return !RetTy->isFunctionTy() && !RetTy->isLabelTy() &&
393 !RetTy->isMetadataTy();
394}
395
396bool FunctionType::isValidArgumentType(Type *ArgTy) {
397 return ArgTy->isFirstClassType();
398}
399
400//===----------------------------------------------------------------------===//
401// StructType Implementation
402//===----------------------------------------------------------------------===//
403
404// Primitive Constructors.
405
406StructType *StructType::get(LLVMContext &Context, ArrayRef<Type*> ETypes,
407 bool isPacked) {
408 LLVMContextImpl *pImpl = Context.pImpl;
409 const AnonStructTypeKeyInfo::KeyTy Key(ETypes, isPacked);
410
411 StructType *ST;
412 // Since we only want to allocate a fresh struct type in case none is found
413 // and we don't want to perform two lookups (one for checking if existent and
414 // one for inserting the newly allocated one), here we instead lookup based on
415 // Key and update the reference to the struct type in-place to a newly
416 // allocated one if not found.
417 auto Insertion = pImpl->AnonStructTypes.insert_as(nullptr, Key);
418 if (Insertion.second) {
419 // The struct type was not found. Allocate one and update AnonStructTypes
420 // in-place.
421 ST = new (Context.pImpl->Alloc) StructType(Context);
422 ST->setSubclassData(SCDB_IsLiteral); // Literal struct.
423 ST->setBody(ETypes, isPacked);
424 *Insertion.first = ST;
425 } else {
426 // The struct type was found. Just return it.
427 ST = *Insertion.first;
428 }
429
430 return ST;
431}
432
433bool StructType::isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const {
434 if ((getSubclassData() & SCDB_ContainsScalableVector) != 0)
435 return true;
436
437 if ((getSubclassData() & SCDB_NotContainsScalableVector) != 0)
438 return false;
439
440 if (!Visited.insert(this).second)
441 return false;
442
443 for (Type *Ty : elements()) {
444 if (Ty->isScalableTy(Visited)) {
445 const_cast<StructType *>(this)->setSubclassData(
446 getSubclassData() | SCDB_ContainsScalableVector);
447 return true;
448 }
449 }
450
451 // For structures that are opaque, return false but do not set the
452 // SCDB_NotContainsScalableVector flag since it may gain scalable vector type
453 // when it becomes non-opaque.
454 if (!isOpaque())
455 const_cast<StructType *>(this)->setSubclassData(
456 getSubclassData() | SCDB_NotContainsScalableVector);
457 return false;
458}
459
460bool StructType::containsNonGlobalTargetExtType(
461 SmallPtrSetImpl<const Type *> &Visited) const {
462 if ((getSubclassData() & SCDB_ContainsNonGlobalTargetExtType) != 0)
463 return true;
464
465 if ((getSubclassData() & SCDB_NotContainsNonGlobalTargetExtType) != 0)
466 return false;
467
468 if (!Visited.insert(this).second)
469 return false;
470
471 for (Type *Ty : elements()) {
472 if (Ty->containsNonGlobalTargetExtType(Visited)) {
473 const_cast<StructType *>(this)->setSubclassData(
474 getSubclassData() | SCDB_ContainsNonGlobalTargetExtType);
475 return true;
476 }
477 }
478
479 // For structures that are opaque, return false but do not set the
480 // SCDB_NotContainsNonGlobalTargetExtType flag since it may gain non-global
481 // target extension types when it becomes non-opaque.
482 if (!isOpaque())
483 const_cast<StructType *>(this)->setSubclassData(
484 getSubclassData() | SCDB_NotContainsNonGlobalTargetExtType);
485 return false;
486}
487
488bool StructType::containsNonLocalTargetExtType(
489 SmallPtrSetImpl<const Type *> &Visited) const {
490 if ((getSubclassData() & SCDB_ContainsNonLocalTargetExtType) != 0)
491 return true;
492
493 if ((getSubclassData() & SCDB_NotContainsNonLocalTargetExtType) != 0)
494 return false;
495
496 if (!Visited.insert(this).second)
497 return false;
498
499 for (Type *Ty : elements()) {
500 if (Ty->containsNonLocalTargetExtType(Visited)) {
501 const_cast<StructType *>(this)->setSubclassData(
502 getSubclassData() | SCDB_ContainsNonLocalTargetExtType);
503 return true;
504 }
505 }
506
507 // For structures that are opaque, return false but do not set the
508 // SCDB_NotContainsNonLocalTargetExtType flag since it may gain non-local
509 // target extension types when it becomes non-opaque.
510 if (!isOpaque())
511 const_cast<StructType *>(this)->setSubclassData(
512 getSubclassData() | SCDB_NotContainsNonLocalTargetExtType);
513 return false;
514}
515
516bool StructType::containsHomogeneousScalableVectorTypes() const {
517 if (getNumElements() <= 0 || !isa<ScalableVectorType>(elements().front()))
518 return false;
519 return containsHomogeneousTypes();
520}
521
522bool StructType::containsHomogeneousTypes() const {
523 ArrayRef<Type *> ElementTys = elements();
524 return !ElementTys.empty() && all_equal(ElementTys);
525}
526
527void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) {
528 cantFail(setBodyOrError(Elements, isPacked));
529}
530
531Error StructType::setBodyOrError(ArrayRef<Type *> Elements, bool isPacked) {
532 assert(isOpaque() && "Struct body already set!");
533
534 if (auto E = checkBody(Elements))
535 return E;
536
537 setSubclassData(getSubclassData() | SCDB_HasBody);
538 if (isPacked)
539 setSubclassData(getSubclassData() | SCDB_Packed);
540
541 NumContainedTys = Elements.size();
542 ContainedTys = Elements.empty()
543 ? nullptr
544 : Elements.copy(getContext().pImpl->Alloc).data();
545
546 return Error::success();
547}
548
549Error StructType::checkBody(ArrayRef<Type *> Elements) {
550 SmallSetVector<Type *, 4> Worklist(Elements.begin(), Elements.end());
551 for (unsigned I = 0; I < Worklist.size(); ++I) {
552 Type *Ty = Worklist[I];
553 if (Ty == this)
554 return createStringError(Twine("identified structure type '") +
555 getName() + "' is recursive");
556 Worklist.insert(Ty->subtype_begin(), Ty->subtype_end());
557 }
558 return Error::success();
559}
560
561void StructType::setName(StringRef Name) {
562 if (Name == getName()) return;
563
564 StringMap<StructType *> &SymbolTable = getContext().pImpl->NamedStructTypes;
565
567
568 // If this struct already had a name, remove its symbol table entry. Don't
569 // delete the data yet because it may be part of the new name.
571 SymbolTable.remove((EntryTy *)SymbolTableEntry);
572
573 // If this is just removing the name, we're done.
574 if (Name.empty()) {
575 if (SymbolTableEntry) {
576 // Delete the old string data.
577 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.getAllocator());
578 SymbolTableEntry = nullptr;
579 }
580 return;
581 }
582
583 // Look up the entry for the name.
584 auto IterBool =
585 getContext().pImpl->NamedStructTypes.insert(std::make_pair(Name, this));
586
587 // While we have a name collision, try a random rename.
588 if (!IterBool.second) {
589 SmallString<64> TempStr(Name);
590 TempStr.push_back('.');
591 raw_svector_ostream TmpStream(TempStr);
592 unsigned NameSize = Name.size();
593
594 do {
595 TempStr.resize(NameSize + 1);
596 TmpStream << getContext().pImpl->NamedStructTypesUniqueID++;
597
598 IterBool = getContext().pImpl->NamedStructTypes.insert(
599 std::make_pair(TmpStream.str(), this));
600 } while (!IterBool.second);
601 }
602
603 // Delete the old string data.
605 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.getAllocator());
606 SymbolTableEntry = &*IterBool.first;
607}
608
609//===----------------------------------------------------------------------===//
610// StructType Helper functions.
611
612StructType *StructType::create(LLVMContext &Context, StringRef Name) {
613 StructType *ST = new (Context.pImpl->Alloc) StructType(Context);
614 if (!Name.empty())
615 ST->setName(Name);
616 return ST;
617}
618
619StructType *StructType::get(LLVMContext &Context, bool isPacked) {
620 return get(Context, {}, isPacked);
621}
622
623StructType *StructType::create(LLVMContext &Context, ArrayRef<Type*> Elements,
624 StringRef Name, bool isPacked) {
625 StructType *ST = create(Context, Name);
626 ST->setBody(Elements, isPacked);
627 return ST;
628}
629
630StructType *StructType::create(LLVMContext &Context, ArrayRef<Type*> Elements) {
631 return create(Context, Elements, StringRef());
632}
633
634StructType *StructType::create(LLVMContext &Context) {
635 return create(Context, StringRef());
636}
637
638StructType *StructType::create(ArrayRef<Type*> Elements, StringRef Name,
639 bool isPacked) {
640 assert(!Elements.empty() &&
641 "This method may not be invoked with an empty list");
642 return create(Elements[0]->getContext(), Elements, Name, isPacked);
643}
644
645StructType *StructType::create(ArrayRef<Type*> Elements) {
646 assert(!Elements.empty() &&
647 "This method may not be invoked with an empty list");
648 return create(Elements[0]->getContext(), Elements, StringRef());
649}
650
651bool StructType::isSized(SmallPtrSetImpl<Type*> *Visited) const {
652 if ((getSubclassData() & SCDB_IsSized) != 0)
653 return true;
654 if (isOpaque())
655 return false;
656
657 if (Visited && !Visited->insert(const_cast<StructType*>(this)).second)
658 return false;
659
660 // Okay, our struct is sized if all of the elements are, but if one of the
661 // elements is opaque, the struct isn't sized *yet*, but may become sized in
662 // the future, so just bail out without caching.
663 // The ONLY special case inside a struct that is considered sized is when the
664 // elements are homogeneous of a scalable vector type.
665 if (containsHomogeneousScalableVectorTypes()) {
666 const_cast<StructType *>(this)->setSubclassData(getSubclassData() |
667 SCDB_IsSized);
668 return true;
669 }
670 for (Type *Ty : elements()) {
671 // If the struct contains a scalable vector type, don't consider it sized.
672 // This prevents it from being used in loads/stores/allocas/GEPs. The ONLY
673 // special case right now is a structure of homogenous scalable vector
674 // types and is handled by the if-statement before this for-loop.
675 if (Ty->isScalableTy())
676 return false;
677 if (!Ty->isSized(Visited))
678 return false;
679 }
680
681 // Here we cheat a bit and cast away const-ness. The goal is to memoize when
682 // we find a sized type, as types can only move from opaque to sized, not the
683 // other way.
684 const_cast<StructType*>(this)->setSubclassData(
685 getSubclassData() | SCDB_IsSized);
686 return true;
687}
688
689StringRef StructType::getName() const {
690 assert(!isLiteral() && "Literal structs never have names");
691 if (!SymbolTableEntry) return StringRef();
692
693 return ((StringMapEntry<StructType*> *)SymbolTableEntry)->getKey();
694}
695
696bool StructType::isValidElementType(Type *ElemTy) {
697 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
698 !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy() &&
699 !ElemTy->isTokenTy();
700}
701
702bool StructType::isLayoutIdentical(StructType *Other) const {
703 if (this == Other) return true;
704
705 if (isPacked() != Other->isPacked())
706 return false;
707
708 return elements() == Other->elements();
709}
710
711Type *StructType::getTypeAtIndex(const Value *V) const {
712 unsigned Idx = (unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
713 assert(indexValid(Idx) && "Invalid structure index!");
714 return getElementType(Idx);
715}
716
717bool StructType::indexValid(const Value *V) const {
718 // Structure indexes require (vectors of) 32-bit integer constants. In the
719 // vector case all of the indices must be equal.
720 if (!V->getType()->isIntOrIntVectorTy(32))
721 return false;
722 if (isa<ScalableVectorType>(V->getType()))
723 return false;
724 const Constant *C = dyn_cast<Constant>(V);
725 if (C && V->getType()->isVectorTy())
726 C = C->getSplatValue();
727 const ConstantInt *CU = dyn_cast_or_null<ConstantInt>(C);
728 return CU && CU->getZExtValue() < getNumElements();
729}
730
731StructType *StructType::getTypeByName(LLVMContext &C, StringRef Name) {
732 return C.pImpl->NamedStructTypes.lookup(Name);
733}
734
735//===----------------------------------------------------------------------===//
736// ArrayType Implementation
737//===----------------------------------------------------------------------===//
738
739ArrayType::ArrayType(Type *ElType, uint64_t NumEl)
740 : Type(ElType->getContext(), ArrayTyID), ContainedType(ElType),
741 NumElements(NumEl) {
742 ContainedTys = &ContainedType;
743 NumContainedTys = 1;
744}
745
746ArrayType *ArrayType::get(Type *ElementType, uint64_t NumElements) {
747 assert(isValidElementType(ElementType) && "Invalid type for array element!");
748
749 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
750 ArrayType *&Entry =
751 pImpl->ArrayTypes[std::make_pair(ElementType, NumElements)];
752
753 if (!Entry)
754 Entry = new (pImpl->Alloc) ArrayType(ElementType, NumElements);
755 return Entry;
756}
757
758bool ArrayType::isValidElementType(Type *ElemTy) {
759 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
760 !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy() &&
761 !ElemTy->isTokenTy() && !ElemTy->isX86_AMXTy();
762}
763
764//===----------------------------------------------------------------------===//
765// VectorType Implementation
766//===----------------------------------------------------------------------===//
767
768VectorType::VectorType(Type *ElType, unsigned EQ, Type::TypeID TID)
769 : Type(ElType->getContext(), TID), ContainedType(ElType),
770 ElementQuantity(EQ) {
771 ContainedTys = &ContainedType;
772 NumContainedTys = 1;
773}
774
775VectorType *VectorType::get(Type *ElementType, ElementCount EC) {
776 if (EC.isScalable())
777 return ScalableVectorType::get(ElementType, EC.getKnownMinValue());
778 else
779 return FixedVectorType::get(ElementType, EC.getKnownMinValue());
780}
781
782bool VectorType::isValidElementType(Type *ElemTy) {
783 return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() ||
784 ElemTy->isPointerTy() || ElemTy->getTypeID() == TypedPointerTyID;
785}
786
787//===----------------------------------------------------------------------===//
788// FixedVectorType Implementation
789//===----------------------------------------------------------------------===//
790
791FixedVectorType *FixedVectorType::get(Type *ElementType, unsigned NumElts) {
792 assert(NumElts > 0 && "#Elements of a VectorType must be greater than 0");
793 assert(isValidElementType(ElementType) && "Element type of a VectorType must "
794 "be an integer, floating point, or "
795 "pointer type.");
796
797 auto EC = ElementCount::getFixed(NumElts);
798
799 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
800 VectorType *&Entry = ElementType->getContext()
801 .pImpl->VectorTypes[std::make_pair(ElementType, EC)];
802
803 if (!Entry)
804 Entry = new (pImpl->Alloc) FixedVectorType(ElementType, NumElts);
805 return cast<FixedVectorType>(Entry);
806}
807
808//===----------------------------------------------------------------------===//
809// ScalableVectorType Implementation
810//===----------------------------------------------------------------------===//
811
812ScalableVectorType *ScalableVectorType::get(Type *ElementType,
813 unsigned MinNumElts) {
814 assert(MinNumElts > 0 && "#Elements of a VectorType must be greater than 0");
815 assert(isValidElementType(ElementType) && "Element type of a VectorType must "
816 "be an integer, floating point, or "
817 "pointer type.");
818
819 auto EC = ElementCount::getScalable(MinNumElts);
820
821 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
822 VectorType *&Entry = ElementType->getContext()
823 .pImpl->VectorTypes[std::make_pair(ElementType, EC)];
824
825 if (!Entry)
826 Entry = new (pImpl->Alloc) ScalableVectorType(ElementType, MinNumElts);
827 return cast<ScalableVectorType>(Entry);
828}
829
830//===----------------------------------------------------------------------===//
831// PointerType Implementation
832//===----------------------------------------------------------------------===//
833
834PointerType *PointerType::get(Type *EltTy, unsigned AddressSpace) {
835 assert(EltTy && "Can't get a pointer to <null> type!");
836 assert(isValidElementType(EltTy) && "Invalid type for pointer element!");
837
838 // Automatically convert typed pointers to opaque pointers.
839 return get(EltTy->getContext(), AddressSpace);
840}
841
842PointerType *PointerType::get(LLVMContext &C, unsigned AddressSpace) {
843 LLVMContextImpl *CImpl = C.pImpl;
844
845 // Since AddressSpace #0 is the common case, we special case it.
847 : CImpl->PointerTypes[AddressSpace];
848
849 if (!Entry)
850 Entry = new (CImpl->Alloc) PointerType(C, AddressSpace);
851 return Entry;
852}
853
854PointerType::PointerType(LLVMContext &C, unsigned AddrSpace)
855 : Type(C, PointerTyID) {
856 setSubclassData(AddrSpace);
857}
858
859PointerType *Type::getPointerTo(unsigned AddrSpace) const {
860 return PointerType::get(const_cast<Type*>(this), AddrSpace);
861}
862
863bool PointerType::isValidElementType(Type *ElemTy) {
864 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
865 !ElemTy->isMetadataTy() && !ElemTy->isTokenTy() &&
866 !ElemTy->isX86_AMXTy();
867}
868
869bool PointerType::isLoadableOrStorableType(Type *ElemTy) {
870 return isValidElementType(ElemTy) && !ElemTy->isFunctionTy();
871}
872
873//===----------------------------------------------------------------------===//
874// TargetExtType Implementation
875//===----------------------------------------------------------------------===//
876
877TargetExtType::TargetExtType(LLVMContext &C, StringRef Name,
879 : Type(C, TargetExtTyID), Name(C.pImpl->Saver.save(Name)) {
880 NumContainedTys = Types.size();
881
882 // Parameter storage immediately follows the class in allocation.
883 Type **Params = reinterpret_cast<Type **>(this + 1);
884 ContainedTys = Params;
885 for (Type *T : Types)
886 *Params++ = T;
887
888 setSubclassData(Ints.size());
889 unsigned *IntParamSpace = reinterpret_cast<unsigned *>(Params);
890 IntParams = IntParamSpace;
891 for (unsigned IntParam : Ints)
892 *IntParamSpace++ = IntParam;
893}
894
895TargetExtType *TargetExtType::get(LLVMContext &C, StringRef Name,
896 ArrayRef<Type *> Types,
897 ArrayRef<unsigned> Ints) {
898 return cantFail(getOrError(C, Name, Types, Ints));
899}
900
901Expected<TargetExtType *> TargetExtType::getOrError(LLVMContext &C,
903 ArrayRef<Type *> Types,
904 ArrayRef<unsigned> Ints) {
905 const TargetExtTypeKeyInfo::KeyTy Key(Name, Types, Ints);
907 // Since we only want to allocate a fresh target type in case none is found
908 // and we don't want to perform two lookups (one for checking if existent and
909 // one for inserting the newly allocated one), here we instead lookup based on
910 // Key and update the reference to the target type in-place to a newly
911 // allocated one if not found.
912 auto [Iter, Inserted] = C.pImpl->TargetExtTypes.insert_as(nullptr, Key);
913 if (Inserted) {
914 // The target type was not found. Allocate one and update TargetExtTypes
915 // in-place.
916 TT = (TargetExtType *)C.pImpl->Alloc.Allocate(
917 sizeof(TargetExtType) + sizeof(Type *) * Types.size() +
918 sizeof(unsigned) * Ints.size(),
919 alignof(TargetExtType));
920 new (TT) TargetExtType(C, Name, Types, Ints);
921 *Iter = TT;
922 return checkParams(TT);
923 }
924
925 // The target type was found. Just return it.
926 return *Iter;
927}
928
929Expected<TargetExtType *> TargetExtType::checkParams(TargetExtType *TTy) {
930 // Opaque types in the AArch64 name space.
931 if (TTy->Name == "aarch64.svcount" &&
932 (TTy->getNumTypeParameters() != 0 || TTy->getNumIntParameters() != 0))
933 return createStringError(
934 "target extension type aarch64.svcount should have no parameters");
935
936 // Opaque types in the RISC-V name space.
937 if (TTy->Name == "riscv.vector.tuple" &&
938 (TTy->getNumTypeParameters() != 1 || TTy->getNumIntParameters() != 1))
939 return createStringError(
940 "target extension type riscv.vector.tuple should have one "
941 "type parameter and one integer parameter");
942
943 // Opaque types in the AMDGPU name space.
944 if (TTy->Name == "amdgcn.named.barrier" &&
945 (TTy->getNumTypeParameters() != 0 || TTy->getNumIntParameters() != 1)) {
946 return createStringError("target extension type amdgcn.named.barrier "
947 "should have no type parameters "
948 "and one integer parameter");
949 }
950
951 return TTy;
952}
953
954namespace {
955struct TargetTypeInfo {
956 Type *LayoutType;
957 uint64_t Properties;
958
959 template <typename... ArgTys>
960 TargetTypeInfo(Type *LayoutType, ArgTys... Properties)
961 : LayoutType(LayoutType), Properties((0 | ... | Properties)) {}
962};
963} // anonymous namespace
964
965static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) {
966 LLVMContext &C = Ty->getContext();
967 StringRef Name = Ty->getName();
968 if (Name == "spirv.Image")
969 return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::CanBeGlobal,
970 TargetExtType::CanBeLocal);
971 if (Name.starts_with("spirv."))
972 return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::HasZeroInit,
973 TargetExtType::CanBeGlobal,
974 TargetExtType::CanBeLocal);
975
976 // Opaque types in the AArch64 name space.
977 if (Name == "aarch64.svcount")
978 return TargetTypeInfo(ScalableVectorType::get(Type::getInt1Ty(C), 16),
979 TargetExtType::HasZeroInit,
980 TargetExtType::CanBeLocal);
981
982 // RISC-V vector tuple type. The layout is represented as the type that needs
983 // the same number of vector registers(VREGS) as this tuple type, represented
984 // as <vscale x (RVVBitsPerBlock * VREGS / 8) x i8>.
985 if (Name == "riscv.vector.tuple") {
986 unsigned TotalNumElts =
987 std::max(cast<ScalableVectorType>(Ty->getTypeParameter(0))
988 ->getMinNumElements(),
989 RISCV::RVVBitsPerBlock / 8) *
990 Ty->getIntParameter(0);
991 return TargetTypeInfo(
992 ScalableVectorType::get(Type::getInt8Ty(C), TotalNumElts),
993 TargetExtType::CanBeLocal, TargetExtType::HasZeroInit);
994 }
995
996 // DirectX resources
997 if (Name.starts_with("dx."))
998 return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::CanBeGlobal,
999 TargetExtType::CanBeLocal);
1000
1001 // Opaque types in the AMDGPU name space.
1002 if (Name == "amdgcn.named.barrier") {
1003 return TargetTypeInfo(FixedVectorType::get(Type::getInt32Ty(C), 4),
1004 TargetExtType::CanBeGlobal);
1005 }
1006
1007 return TargetTypeInfo(Type::getVoidTy(C));
1008}
1009
1010Type *TargetExtType::getLayoutType() const {
1011 return getTargetTypeInfo(this).LayoutType;
1012}
1013
1014bool TargetExtType::hasProperty(Property Prop) const {
1015 uint64_t Properties = getTargetTypeInfo(this).Properties;
1016 return (Properties & Prop) == Prop;
1017}
This file defines the StringMap class.
static const fltSemantics * getFltSemantics(unsigned Size)
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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
std::optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1313
static char getTypeID(Type *Ty)
#define I(x, y, z)
Definition: MD5.cpp:58
const Type::TypeID FloatTyID
Type::TypeID TypeID
const Type::TypeID DoubleTyID
#define T
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned getNumElements(Type *Ty)
static bool isValidElementType(Type *Ty)
Predicate for the element types that the SLP vectorizer supports.
static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty)
Definition: Type.cpp:965
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallString class.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
ArrayType(const Node *Base_, Node *Dimension_)
FunctionType(const Node *Ret_, NodeArray Params_, Qualifiers CVQuals_, FunctionRefQual RefQual_, const Node *ExceptionSpec_)
PointerType(const Node *Pointee_)
VectorType(const Node *BaseType_, const Node *Dimension_)
Class for arbitrary precision integers.
Definition: APInt.h:78
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:168
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:163
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:83
This is an important base class in LLVM.
Definition: Constant.h:42
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
Class to represent fixed width SIMD vectors.
Definition: DerivedTypes.h:563
Class to represent integer types.
Definition: DerivedTypes.h:42
StructTypeSet AnonStructTypes
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
BumpPtrAllocator Alloc
DenseMap< unsigned, PointerType * > PointerTypes
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 scalable SIMD vectors.
Definition: DerivedTypes.h:610
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:363
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:384
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:519
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:370
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
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:128
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
Definition: StringMap.h:414
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Class to represent struct types.
Definition: DerivedTypes.h:218
Symbol info for RuntimeDyld.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:744
unsigned getNumIntParameters() const
Definition: DerivedTypes.h:802
Type * getTypeParameter(unsigned i) const
Definition: DerivedTypes.h:792
unsigned getNumTypeParameters() const
Definition: DerivedTypes.h:793
unsigned getIntParameter(unsigned i) const
Definition: DerivedTypes.h:801
StringRef getName() const
Return the name for this target extension type.
Definition: DerivedTypes.h:778
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
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.
bool isLabelTy() const
Return true if this is 'label'.
Definition: Type.h:228
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:264
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...
TypeID
Definitions of all of the base types for the Type system.
Definition: Type.h:54
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
Definition: Type.h:289
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:310
bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
void setSubclassData(unsigned val)
Definition: Type.h:99
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Definition: Type.h:184
subtype_iterator subtype_begin() const
Definition: Type.h:366
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:200
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:255
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:237
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:136
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:234
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
subtype_iterator subtype_end() const
Definition: Type.h:367
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:231
LLVM Value Representation.
Definition: Value.h:74
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:226
constexpr ScalarTy getFixedValue() const
Definition: TypeSize.h:202
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:171
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:691
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Key
PAL metadata keys.
@ NameSize
Definition: COFF.h:57
@ Entry
Definition: COFF.h:844
ElementType
The element type of an SRV or UAV resource.
Definition: DXILABI.h:58
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1291
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:756
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.
Definition: STLExtras.h:2087
#define N
#define EQ(a, b)
Definition: regexec.c:112