Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Intrinsics.cpp
Go to the documentation of this file.
1//===-- Intrinsics.cpp - Intrinsic Function Handling ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements functions required for supporting intrinsic functions.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/Intrinsics.h"
14#include "llvm/ADT/StringExtras.h"
15#include "llvm/ADT/StringTable.h"
16#include "llvm/IR/Function.h"
17#include "llvm/IR/IntrinsicsAArch64.h"
18#include "llvm/IR/IntrinsicsAMDGPU.h"
19#include "llvm/IR/IntrinsicsARM.h"
20#include "llvm/IR/IntrinsicsBPF.h"
21#include "llvm/IR/IntrinsicsHexagon.h"
22#include "llvm/IR/IntrinsicsLoongArch.h"
23#include "llvm/IR/IntrinsicsMips.h"
24#include "llvm/IR/IntrinsicsNVPTX.h"
25#include "llvm/IR/IntrinsicsPowerPC.h"
26#include "llvm/IR/IntrinsicsR600.h"
27#include "llvm/IR/IntrinsicsRISCV.h"
28#include "llvm/IR/IntrinsicsS390.h"
29#include "llvm/IR/IntrinsicsVE.h"
30#include "llvm/IR/IntrinsicsX86.h"
31#include "llvm/IR/IntrinsicsXCore.h"
32#include "llvm/IR/Module.h"
33#include "llvm/IR/Type.h"
34
35using namespacellvm;
36
37/// Table of string intrinsic names indexed by enum value.
38#define GET_INTRINSIC_NAME_TABLE
39#include "llvm/IR/IntrinsicImpl.inc"
40#undef GET_INTRINSIC_NAME_TABLE
41
42StringRefIntrinsic::getBaseName(IDid) {
43assert(id < num_intrinsics &&"Invalid intrinsic ID!");
44return IntrinsicNameTable[IntrinsicNameOffsetTable[id]];
45}
46
47StringRefIntrinsic::getName(IDid) {
48assert(id < num_intrinsics &&"Invalid intrinsic ID!");
49assert(!Intrinsic::isOverloaded(id) &&
50"This version of getName does not support overloading");
51returngetBaseName(id);
52}
53
54/// Returns a stable mangling for the type specified for use in the name
55/// mangling scheme used by 'any' types in intrinsic signatures. The mangling
56/// of named types is simply their name. Manglings for unnamed types consist
57/// of a prefix ('p' for pointers, 'a' for arrays, 'f_' for functions)
58/// combined with the mangling of their component types. A vararg function
59/// type will have a suffix of 'vararg'. Since function types can contain
60/// other function types, we close a function type mangling with suffix 'f'
61/// which can't be confused with it's prefix. This ensures we don't have
62/// collisions between two unrelated function types. Otherwise, you might
63/// parse ffXX as f(fXX) or f(fX)X. (X is a placeholder for any other type.)
64/// The HasUnnamedType boolean is set if an unnamed type was encountered,
65/// indicating that extra care must be taken to ensure a unique name.
66static std::stringgetMangledTypeStr(Type *Ty,bool &HasUnnamedType) {
67 std::string Result;
68if (PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
69 Result +="p" + utostr(PTyp->getAddressSpace());
70 }elseif (ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
71 Result +="a" + utostr(ATyp->getNumElements()) +
72getMangledTypeStr(ATyp->getElementType(), HasUnnamedType);
73 }elseif (StructType *STyp = dyn_cast<StructType>(Ty)) {
74if (!STyp->isLiteral()) {
75 Result +="s_";
76if (STyp->hasName())
77 Result += STyp->getName();
78else
79 HasUnnamedType =true;
80 }else {
81 Result +="sl_";
82for (auto *Elem : STyp->elements())
83 Result +=getMangledTypeStr(Elem, HasUnnamedType);
84 }
85// Ensure nested structs are distinguishable.
86 Result +="s";
87 }elseif (FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
88 Result +="f_" +getMangledTypeStr(FT->getReturnType(), HasUnnamedType);
89for (size_t i = 0; i < FT->getNumParams(); i++)
90 Result +=getMangledTypeStr(FT->getParamType(i), HasUnnamedType);
91if (FT->isVarArg())
92 Result +="vararg";
93// Ensure nested function types are distinguishable.
94 Result +="f";
95 }elseif (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
96ElementCount EC = VTy->getElementCount();
97if (EC.isScalable())
98 Result +="nx";
99 Result +="v" + utostr(EC.getKnownMinValue()) +
100getMangledTypeStr(VTy->getElementType(), HasUnnamedType);
101 }elseif (TargetExtType *TETy = dyn_cast<TargetExtType>(Ty)) {
102 Result +="t";
103 Result += TETy->getName();
104for (Type *ParamTy : TETy->type_params())
105 Result +="_" +getMangledTypeStr(ParamTy, HasUnnamedType);
106for (unsigned IntParam : TETy->int_params())
107 Result +="_" + utostr(IntParam);
108// Ensure nested target extension types are distinguishable.
109 Result +="t";
110 }elseif (Ty) {
111switch (Ty->getTypeID()) {
112default:
113llvm_unreachable("Unhandled type");
114caseType::VoidTyID:
115 Result +="isVoid";
116break;
117caseType::MetadataTyID:
118 Result +="Metadata";
119break;
120caseType::HalfTyID:
121 Result +="f16";
122break;
123caseType::BFloatTyID:
124 Result +="bf16";
125break;
126caseType::FloatTyID:
127 Result +="f32";
128break;
129caseType::DoubleTyID:
130 Result +="f64";
131break;
132caseType::X86_FP80TyID:
133 Result +="f80";
134break;
135caseType::FP128TyID:
136 Result +="f128";
137break;
138caseType::PPC_FP128TyID:
139 Result +="ppcf128";
140break;
141caseType::X86_AMXTyID:
142 Result +="x86amx";
143break;
144caseType::IntegerTyID:
145 Result +="i" + utostr(cast<IntegerType>(Ty)->getBitWidth());
146break;
147 }
148 }
149return Result;
150}
151
152static std::stringgetIntrinsicNameImpl(Intrinsic::ID Id,ArrayRef<Type *> Tys,
153Module *M,FunctionType *FT,
154bool EarlyModuleCheck) {
155
156assert(Id < Intrinsic::num_intrinsics &&"Invalid intrinsic ID!");
157assert((Tys.empty() ||Intrinsic::isOverloaded(Id)) &&
158"This version of getName is for overloaded intrinsics only");
159 (void)EarlyModuleCheck;
160assert((!EarlyModuleCheck || M ||
161 !any_of(Tys, [](Type *T) {return isa<PointerType>(T); })) &&
162"Intrinsic overloading on pointer types need to provide a Module");
163bool HasUnnamedType =false;
164 std::string Result(Intrinsic::getBaseName(Id));
165for (Type *Ty : Tys)
166 Result +="." +getMangledTypeStr(Ty, HasUnnamedType);
167if (HasUnnamedType) {
168assert(M &&"unnamed types need a module");
169if (!FT)
170 FT =Intrinsic::getType(M->getContext(), Id, Tys);
171else
172assert((FT ==Intrinsic::getType(M->getContext(), Id, Tys)) &&
173"Provided FunctionType must match arguments");
174return M->getUniqueIntrinsicName(Result, Id, FT);
175 }
176return Result;
177}
178
179std::stringIntrinsic::getName(ID Id,ArrayRef<Type *> Tys,Module *M,
180FunctionType *FT) {
181assert(M &&"We need to have a Module");
182returngetIntrinsicNameImpl(Id,Tys, M, FT,true);
183}
184
185std::stringIntrinsic::getNameNoUnnamedTypes(ID Id,ArrayRef<Type *> Tys) {
186returngetIntrinsicNameImpl(Id,Tys,nullptr,nullptr,false);
187}
188
189/// IIT_Info - These are enumerators that describe the entries returned by the
190/// getIntrinsicInfoTableEntries function.
191///
192/// Defined in Intrinsics.td.
193enumIIT_Info {
194#define GET_INTRINSIC_IITINFO
195#include "llvm/IR/IntrinsicImpl.inc"
196#undef GET_INTRINSIC_IITINFO
197};
198
199staticvoid
200DecodeIITType(unsigned &NextElt,ArrayRef<unsigned char> Infos,
201IIT_Info LastInfo,
202SmallVectorImpl<Intrinsic::IITDescriptor> &OutputTable) {
203using namespaceIntrinsic;
204
205bool IsScalableVector = (LastInfo == IIT_SCALABLE_VEC);
206
207IIT_InfoInfo =IIT_Info(Infos[NextElt++]);
208unsigned StructElts = 2;
209
210switch (Info) {
211case IIT_Done:
212 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Void, 0));
213return;
214case IIT_VARARG:
215 OutputTable.push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
216return;
217case IIT_MMX:
218 OutputTable.push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
219return;
220case IIT_AMX:
221 OutputTable.push_back(IITDescriptor::get(IITDescriptor::AMX, 0));
222return;
223case IIT_TOKEN:
224 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Token, 0));
225return;
226case IIT_METADATA:
227 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
228return;
229case IIT_F16:
230 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Half, 0));
231return;
232case IIT_BF16:
233 OutputTable.push_back(IITDescriptor::get(IITDescriptor::BFloat, 0));
234return;
235case IIT_F32:
236 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Float, 0));
237return;
238case IIT_F64:
239 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Double, 0));
240return;
241case IIT_F128:
242 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
243return;
244case IIT_PPCF128:
245 OutputTable.push_back(IITDescriptor::get(IITDescriptor::PPCQuad, 0));
246return;
247case IIT_I1:
248 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
249return;
250case IIT_I2:
251 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 2));
252return;
253case IIT_I4:
254 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 4));
255return;
256case IIT_AARCH64_SVCOUNT:
257 OutputTable.push_back(IITDescriptor::get(IITDescriptor::AArch64Svcount, 0));
258return;
259case IIT_I8:
260 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
261return;
262case IIT_I16:
263 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 16));
264return;
265case IIT_I32:
266 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
267return;
268case IIT_I64:
269 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
270return;
271case IIT_I128:
272 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 128));
273return;
274case IIT_V1:
275 OutputTable.push_back(IITDescriptor::getVector(1, IsScalableVector));
276DecodeIITType(NextElt, Infos,Info, OutputTable);
277return;
278case IIT_V2:
279 OutputTable.push_back(IITDescriptor::getVector(2, IsScalableVector));
280DecodeIITType(NextElt, Infos,Info, OutputTable);
281return;
282case IIT_V3:
283 OutputTable.push_back(IITDescriptor::getVector(3, IsScalableVector));
284DecodeIITType(NextElt, Infos,Info, OutputTable);
285return;
286case IIT_V4:
287 OutputTable.push_back(IITDescriptor::getVector(4, IsScalableVector));
288DecodeIITType(NextElt, Infos,Info, OutputTable);
289return;
290case IIT_V6:
291 OutputTable.push_back(IITDescriptor::getVector(6, IsScalableVector));
292DecodeIITType(NextElt, Infos,Info, OutputTable);
293return;
294case IIT_V8:
295 OutputTable.push_back(IITDescriptor::getVector(8, IsScalableVector));
296DecodeIITType(NextElt, Infos,Info, OutputTable);
297return;
298case IIT_V10:
299 OutputTable.push_back(IITDescriptor::getVector(10, IsScalableVector));
300DecodeIITType(NextElt, Infos,Info, OutputTable);
301return;
302case IIT_V16:
303 OutputTable.push_back(IITDescriptor::getVector(16, IsScalableVector));
304DecodeIITType(NextElt, Infos,Info, OutputTable);
305return;
306case IIT_V32:
307 OutputTable.push_back(IITDescriptor::getVector(32, IsScalableVector));
308DecodeIITType(NextElt, Infos,Info, OutputTable);
309return;
310case IIT_V64:
311 OutputTable.push_back(IITDescriptor::getVector(64, IsScalableVector));
312DecodeIITType(NextElt, Infos,Info, OutputTable);
313return;
314case IIT_V128:
315 OutputTable.push_back(IITDescriptor::getVector(128, IsScalableVector));
316DecodeIITType(NextElt, Infos,Info, OutputTable);
317return;
318case IIT_V256:
319 OutputTable.push_back(IITDescriptor::getVector(256, IsScalableVector));
320DecodeIITType(NextElt, Infos,Info, OutputTable);
321return;
322case IIT_V512:
323 OutputTable.push_back(IITDescriptor::getVector(512, IsScalableVector));
324DecodeIITType(NextElt, Infos,Info, OutputTable);
325return;
326case IIT_V1024:
327 OutputTable.push_back(IITDescriptor::getVector(1024, IsScalableVector));
328DecodeIITType(NextElt, Infos,Info, OutputTable);
329return;
330case IIT_EXTERNREF:
331 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 10));
332return;
333case IIT_FUNCREF:
334 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 20));
335return;
336case IIT_PTR:
337 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
338return;
339case IIT_ANYPTR:// [ANYPTR addrspace]
340 OutputTable.push_back(
341 IITDescriptor::get(IITDescriptor::Pointer, Infos[NextElt++]));
342return;
343case IIT_ARG: {
344unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
345 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Argument,ArgInfo));
346return;
347 }
348case IIT_EXTEND_ARG: {
349unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
350 OutputTable.push_back(
351 IITDescriptor::get(IITDescriptor::ExtendArgument,ArgInfo));
352return;
353 }
354case IIT_TRUNC_ARG: {
355unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
356 OutputTable.push_back(
357 IITDescriptor::get(IITDescriptor::TruncArgument,ArgInfo));
358return;
359 }
360case IIT_HALF_VEC_ARG: {
361unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
362 OutputTable.push_back(
363 IITDescriptor::get(IITDescriptor::HalfVecArgument,ArgInfo));
364return;
365 }
366case IIT_SAME_VEC_WIDTH_ARG: {
367unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
368 OutputTable.push_back(
369 IITDescriptor::get(IITDescriptor::SameVecWidthArgument,ArgInfo));
370return;
371 }
372case IIT_VEC_OF_ANYPTRS_TO_ELT: {
373unsignedshort ArgNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
374unsignedshort RefNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
375 OutputTable.push_back(
376 IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt, ArgNo, RefNo));
377return;
378 }
379case IIT_EMPTYSTRUCT:
380 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
381return;
382case IIT_STRUCT9:
383 ++StructElts;
384 [[fallthrough]];
385case IIT_STRUCT8:
386 ++StructElts;
387 [[fallthrough]];
388case IIT_STRUCT7:
389 ++StructElts;
390 [[fallthrough]];
391case IIT_STRUCT6:
392 ++StructElts;
393 [[fallthrough]];
394case IIT_STRUCT5:
395 ++StructElts;
396 [[fallthrough]];
397case IIT_STRUCT4:
398 ++StructElts;
399 [[fallthrough]];
400case IIT_STRUCT3:
401 ++StructElts;
402 [[fallthrough]];
403case IIT_STRUCT2: {
404 OutputTable.push_back(
405 IITDescriptor::get(IITDescriptor::Struct, StructElts));
406
407for (unsigned i = 0; i != StructElts; ++i)
408DecodeIITType(NextElt, Infos,Info, OutputTable);
409return;
410 }
411case IIT_SUBDIVIDE2_ARG: {
412unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
413 OutputTable.push_back(
414 IITDescriptor::get(IITDescriptor::Subdivide2Argument,ArgInfo));
415return;
416 }
417case IIT_SUBDIVIDE4_ARG: {
418unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
419 OutputTable.push_back(
420 IITDescriptor::get(IITDescriptor::Subdivide4Argument,ArgInfo));
421return;
422 }
423case IIT_VEC_ELEMENT: {
424unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
425 OutputTable.push_back(
426 IITDescriptor::get(IITDescriptor::VecElementArgument,ArgInfo));
427return;
428 }
429case IIT_SCALABLE_VEC: {
430DecodeIITType(NextElt, Infos,Info, OutputTable);
431return;
432 }
433case IIT_VEC_OF_BITCASTS_TO_INT: {
434unsignedArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
435 OutputTable.push_back(
436 IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt,ArgInfo));
437return;
438 }
439 }
440llvm_unreachable("unhandled");
441}
442
443#define GET_INTRINSIC_GENERATOR_GLOBAL
444#include "llvm/IR/IntrinsicImpl.inc"
445#undef GET_INTRINSIC_GENERATOR_GLOBAL
446
447voidIntrinsic::getIntrinsicInfoTableEntries(
448IDid,SmallVectorImpl<IITDescriptor> &T) {
449static_assert(sizeof(IIT_Table[0]) == 2,
450"Expect 16-bit entries in IIT_Table");
451// Check to see if the intrinsic's type was expressible by the table.
452uint16_t TableVal = IIT_Table[id - 1];
453
454// Decode the TableVal into an array of IITValues.
455SmallVector<unsigned char> IITValues;
456ArrayRef<unsigned char> IITEntries;
457unsigned NextElt = 0;
458if (TableVal >> 15) {
459// This is an offset into the IIT_LongEncodingTable.
460 IITEntries = IIT_LongEncodingTable;
461
462// Strip sentinel bit.
463 NextElt = TableVal & 0x7fff;
464 }else {
465// If the entry was encoded into a single word in the table itself, decode
466// it from an array of nibbles to an array of bytes.
467do {
468 IITValues.push_back(TableVal & 0xF);
469 TableVal >>= 4;
470 }while (TableVal);
471
472 IITEntries = IITValues;
473 NextElt = 0;
474 }
475
476// Okay, decode the table into the output vector of IITDescriptors.
477DecodeIITType(NextElt, IITEntries, IIT_Done,T);
478while (NextElt != IITEntries.size() && IITEntries[NextElt] != 0)
479DecodeIITType(NextElt, IITEntries, IIT_Done,T);
480}
481
482staticType *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
483ArrayRef<Type *> Tys,LLVMContext &Context) {
484using namespaceIntrinsic;
485
486 IITDescriptorD = Infos.front();
487 Infos = Infos.slice(1);
488
489switch (D.Kind) {
490case IITDescriptor::Void:
491returnType::getVoidTy(Context);
492case IITDescriptor::VarArg:
493returnType::getVoidTy(Context);
494case IITDescriptor::MMX:
495returnllvm::FixedVectorType::get(llvm::IntegerType::get(Context, 64), 1);
496case IITDescriptor::AMX:
497returnType::getX86_AMXTy(Context);
498case IITDescriptor::Token:
499returnType::getTokenTy(Context);
500case IITDescriptor::Metadata:
501returnType::getMetadataTy(Context);
502case IITDescriptor::Half:
503returnType::getHalfTy(Context);
504case IITDescriptor::BFloat:
505returnType::getBFloatTy(Context);
506case IITDescriptor::Float:
507returnType::getFloatTy(Context);
508case IITDescriptor::Double:
509returnType::getDoubleTy(Context);
510case IITDescriptor::Quad:
511returnType::getFP128Ty(Context);
512case IITDescriptor::PPCQuad:
513returnType::getPPC_FP128Ty(Context);
514case IITDescriptor::AArch64Svcount:
515returnTargetExtType::get(Context,"aarch64.svcount");
516
517case IITDescriptor::Integer:
518returnIntegerType::get(Context,D.Integer_Width);
519case IITDescriptor::Vector:
520return VectorType::get(DecodeFixedType(Infos, Tys, Context),
521D.Vector_Width);
522case IITDescriptor::Pointer:
523return PointerType::get(Context,D.Pointer_AddressSpace);
524case IITDescriptor::Struct: {
525SmallVector<Type *, 8> Elts;
526for (unsigned i = 0, e =D.Struct_NumElements; i != e; ++i)
527 Elts.push_back(DecodeFixedType(Infos, Tys, Context));
528returnStructType::get(Context, Elts);
529 }
530case IITDescriptor::Argument:
531return Tys[D.getArgumentNumber()];
532case IITDescriptor::ExtendArgument: {
533Type *Ty = Tys[D.getArgumentNumber()];
534if (VectorType *VTy = dyn_cast<VectorType>(Ty))
535return VectorType::getExtendedElementVectorType(VTy);
536
537returnIntegerType::get(Context, 2 * cast<IntegerType>(Ty)->getBitWidth());
538 }
539case IITDescriptor::TruncArgument: {
540Type *Ty = Tys[D.getArgumentNumber()];
541if (VectorType *VTy = dyn_cast<VectorType>(Ty))
542return VectorType::getTruncatedElementVectorType(VTy);
543
544IntegerType *ITy = cast<IntegerType>(Ty);
545assert(ITy->getBitWidth() % 2 == 0);
546returnIntegerType::get(Context, ITy->getBitWidth() / 2);
547 }
548case IITDescriptor::Subdivide2Argument:
549case IITDescriptor::Subdivide4Argument: {
550Type *Ty = Tys[D.getArgumentNumber()];
551VectorType *VTy = dyn_cast<VectorType>(Ty);
552assert(VTy &&"Expected an argument of Vector Type");
553int SubDivs =D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
554return VectorType::getSubdividedVectorType(VTy, SubDivs);
555 }
556case IITDescriptor::HalfVecArgument:
557return VectorType::getHalfElementsVectorType(
558 cast<VectorType>(Tys[D.getArgumentNumber()]));
559case IITDescriptor::SameVecWidthArgument: {
560Type *EltTy =DecodeFixedType(Infos, Tys, Context);
561Type *Ty = Tys[D.getArgumentNumber()];
562if (auto *VTy = dyn_cast<VectorType>(Ty))
563return VectorType::get(EltTy, VTy->getElementCount());
564return EltTy;
565 }
566case IITDescriptor::VecElementArgument: {
567Type *Ty = Tys[D.getArgumentNumber()];
568if (VectorType *VTy = dyn_cast<VectorType>(Ty))
569return VTy->getElementType();
570llvm_unreachable("Expected an argument of Vector Type");
571 }
572case IITDescriptor::VecOfBitcastsToInt: {
573Type *Ty = Tys[D.getArgumentNumber()];
574VectorType *VTy = dyn_cast<VectorType>(Ty);
575assert(VTy &&"Expected an argument of Vector Type");
576return VectorType::getInteger(VTy);
577 }
578case IITDescriptor::VecOfAnyPtrsToElt:
579// Return the overloaded type (which determines the pointers address space)
580return Tys[D.getOverloadArgNumber()];
581 }
582llvm_unreachable("unhandled");
583}
584
585FunctionType *Intrinsic::getType(LLVMContext &Context,IDid,
586ArrayRef<Type *> Tys) {
587SmallVector<IITDescriptor, 8> Table;
588getIntrinsicInfoTableEntries(id, Table);
589
590ArrayRef<IITDescriptor>TableRef = Table;
591Type *ResultTy =DecodeFixedType(TableRef,Tys, Context);
592
593SmallVector<Type *, 8> ArgTys;
594while (!TableRef.empty())
595 ArgTys.push_back(DecodeFixedType(TableRef,Tys, Context));
596
597// DecodeFixedType returns Void for IITDescriptor::Void and
598// IITDescriptor::VarArg If we see void type as the type of the last argument,
599// it is vararg intrinsic
600if (!ArgTys.empty() && ArgTys.back()->isVoidTy()) {
601 ArgTys.pop_back();
602return FunctionType::get(ResultTy, ArgTys,true);
603 }
604return FunctionType::get(ResultTy, ArgTys,false);
605}
606
607boolIntrinsic::isOverloaded(IDid) {
608#define GET_INTRINSIC_OVERLOAD_TABLE
609#include "llvm/IR/IntrinsicImpl.inc"
610#undef GET_INTRINSIC_OVERLOAD_TABLE
611}
612
613/// Table of per-target intrinsic name tables.
614#define GET_INTRINSIC_TARGET_DATA
615#include "llvm/IR/IntrinsicImpl.inc"
616#undef GET_INTRINSIC_TARGET_DATA
617
618boolIntrinsic::isTargetIntrinsic(Intrinsic::ID IID) {
619return IID > TargetInfos[0].Count;
620}
621
622/// Looks up Name in NameTable via binary search. NameTable must be sorted
623/// and all entries must start with "llvm.". If NameTable contains an exact
624/// match for Name or a prefix of Name followed by a dot, its index in
625/// NameTable is returned. Otherwise, -1 is returned.
626staticintlookupLLVMIntrinsicByName(ArrayRef<unsigned> NameOffsetTable,
627StringRefName,StringRefTarget ="") {
628assert(Name.starts_with("llvm.") &&"Unexpected intrinsic prefix");
629assert(Name.drop_front(5).starts_with(Target) &&"Unexpected target");
630
631// Do successive binary searches of the dotted name components. For
632// "llvm.gc.experimental.statepoint.p1i8.p1i32", we will find the range of
633// intrinsics starting with "llvm.gc", then "llvm.gc.experimental", then
634// "llvm.gc.experimental.statepoint", and then we will stop as the range is
635// size 1. During the search, we can skip the prefix that we already know is
636// identical. By using strncmp we consider names with differing suffixes to
637// be part of the equal range.
638size_t CmpEnd = 4;// Skip the "llvm" component.
639if (!Target.empty())
640 CmpEnd += 1 +Target.size();// skip the .target component.
641
642constunsigned *Low = NameOffsetTable.begin();
643constunsigned *High = NameOffsetTable.end();
644constunsigned *LastLow =Low;
645while (CmpEnd <Name.size() &&High -Low > 0) {
646size_t CmpStart = CmpEnd;
647 CmpEnd =Name.find('.', CmpStart + 1);
648 CmpEnd = CmpEnd ==StringRef::npos ?Name.size() : CmpEnd;
649auto Cmp = [CmpStart, CmpEnd](autoLHS,autoRHS) {
650// `equal_range` requires the comparison to work with either side being an
651// offset or the value. Detect which kind each side is to set up the
652// compared strings.
653StringRef LHSStr;
654ifconstexpr (std::is_integral_v<decltype(LHS)>) {
655 LHSStr = IntrinsicNameTable[LHS];
656 }else {
657 LHSStr =LHS;
658 }
659StringRef RHSStr;
660ifconstexpr (std::is_integral_v<decltype(RHS)>) {
661 RHSStr = IntrinsicNameTable[RHS];
662 }else {
663 RHSStr =RHS;
664 }
665return strncmp(LHSStr.data() + CmpStart, RHSStr.data() + CmpStart,
666 CmpEnd - CmpStart) < 0;
667 };
668 LastLow =Low;
669 std::tie(Low,High) = std::equal_range(Low,High,Name.data(), Cmp);
670 }
671if (High -Low > 0)
672 LastLow =Low;
673
674if (LastLow == NameOffsetTable.end())
675return -1;
676StringRef NameFound = IntrinsicNameTable[*LastLow];
677if (Name == NameFound ||
678 (Name.starts_with(NameFound) &&Name[NameFound.size()] =='.'))
679return LastLow - NameOffsetTable.begin();
680return -1;
681}
682
683/// Find the segment of \c IntrinsicNameOffsetTable for intrinsics with the same
684/// target as \c Name, or the generic table if \c Name is not target specific.
685///
686/// Returns the relevant slice of \c IntrinsicNameOffsetTable and the target
687/// name.
688static std::pair<ArrayRef<unsigned>,StringRef>
689findTargetSubtable(StringRefName) {
690assert(Name.starts_with("llvm."));
691
692ArrayRef<IntrinsicTargetInfo> Targets(TargetInfos);
693// Drop "llvm." and take the first dotted component. That will be the target
694// if this is target specific.
695StringRefTarget =Name.drop_front(5).split('.').first;
696auto It =partition_point(
697 Targets, [=](const IntrinsicTargetInfo &TI) {return TI.Name <Target; });
698// We've either found the target or just fall back to the generic set, which
699// is always first.
700constauto &TI = It != Targets.end() && It->Name ==Target ? *It : Targets[0];
701return {ArrayRef(&IntrinsicNameOffsetTable[1] + TI.Offset, TI.Count),
702 TI.Name};
703}
704
705/// This does the actual lookup of an intrinsic ID which matches the given
706/// function name.
707Intrinsic::IDIntrinsic::lookupIntrinsicID(StringRefName) {
708auto [NameOffsetTable,Target] =findTargetSubtable(Name);
709intIdx =lookupLLVMIntrinsicByName(NameOffsetTable,Name,Target);
710if (Idx == -1)
711returnIntrinsic::not_intrinsic;
712
713// Intrinsic IDs correspond to the location in IntrinsicNameTable, but we have
714// an index into a sub-table.
715int Adjust = NameOffsetTable.data() - IntrinsicNameOffsetTable;
716Intrinsic::IDID =static_cast<Intrinsic::ID>(Idx + Adjust);
717
718// If the intrinsic is not overloaded, require an exact match. If it is
719// overloaded, require either exact or prefix match.
720constauto MatchSize = IntrinsicNameTable[NameOffsetTable[Idx]].size();
721assert(Name.size() >= MatchSize &&"Expected either exact or prefix match");
722bool IsExactMatch =Name.size() == MatchSize;
723return IsExactMatch ||Intrinsic::isOverloaded(ID) ?ID
724 :Intrinsic::not_intrinsic;
725}
726
727/// This defines the "Intrinsic::getAttributes(ID id)" method.
728#define GET_INTRINSIC_ATTRIBUTES
729#include "llvm/IR/IntrinsicImpl.inc"
730#undef GET_INTRINSIC_ATTRIBUTES
731
732Function *Intrinsic::getOrInsertDeclaration(Module *M,IDid,
733ArrayRef<Type *> Tys) {
734// There can never be multiple globals with the same name of different types,
735// because intrinsics must be a specific type.
736auto *FT =getType(M->getContext(),id,Tys);
737return cast<Function>(
738 M->getOrInsertFunction(
739Tys.empty() ?getName(id) :getName(id,Tys, M, FT), FT)
740 .getCallee());
741}
742
743Function *Intrinsic::getDeclarationIfExists(constModule *M,IDid) {
744return M->getFunction(getName(id));
745}
746
747Function *Intrinsic::getDeclarationIfExists(Module *M,IDid,
748ArrayRef<Type *> Tys,
749FunctionType *FT) {
750return M->getFunction(getName(id,Tys, M, FT));
751}
752
753// This defines the "Intrinsic::getIntrinsicForClangBuiltin()" method.
754#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
755#include "llvm/IR/IntrinsicImpl.inc"
756#undef GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
757
758// This defines the "Intrinsic::getIntrinsicForMSBuiltin()" method.
759#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
760#include "llvm/IR/IntrinsicImpl.inc"
761#undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
762
763boolIntrinsic::isConstrainedFPIntrinsic(ID QID) {
764switch (QID) {
765#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
766 case Intrinsic::INTRINSIC:
767#include "llvm/IR/ConstrainedOps.def"
768#undef INSTRUCTION
769returntrue;
770default:
771returnfalse;
772 }
773}
774
775boolIntrinsic::hasConstrainedFPRoundingModeOperand(Intrinsic::ID QID) {
776switch (QID) {
777#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
778 case Intrinsic::INTRINSIC: \
779 return ROUND_MODE == 1;
780#include "llvm/IR/ConstrainedOps.def"
781#undef INSTRUCTION
782default:
783returnfalse;
784 }
785}
786
787usingDeferredIntrinsicMatchPair =
788 std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
789
790staticbool
791matchIntrinsicType(Type *Ty,ArrayRef<Intrinsic::IITDescriptor> &Infos,
792SmallVectorImpl<Type *> &ArgTys,
793SmallVectorImpl<DeferredIntrinsicMatchPair> &DeferredChecks,
794bool IsDeferredCheck) {
795using namespaceIntrinsic;
796
797// If we ran out of descriptors, there are too many arguments.
798if (Infos.empty())
799returntrue;
800
801// Do this before slicing off the 'front' part
802auto InfosRef = Infos;
803auto DeferCheck = [&DeferredChecks, &InfosRef](Type *T) {
804 DeferredChecks.emplace_back(T, InfosRef);
805returnfalse;
806 };
807
808 IITDescriptorD = Infos.front();
809 Infos = Infos.slice(1);
810
811switch (D.Kind) {
812case IITDescriptor::Void:
813return !Ty->isVoidTy();
814case IITDescriptor::VarArg:
815returntrue;
816case IITDescriptor::MMX: {
817FixedVectorType *VT = dyn_cast<FixedVectorType>(Ty);
818return !VT || VT->getNumElements() != 1 ||
819 !VT->getElementType()->isIntegerTy(64);
820 }
821case IITDescriptor::AMX:
822return !Ty->isX86_AMXTy();
823case IITDescriptor::Token:
824return !Ty->isTokenTy();
825case IITDescriptor::Metadata:
826return !Ty->isMetadataTy();
827case IITDescriptor::Half:
828return !Ty->isHalfTy();
829case IITDescriptor::BFloat:
830return !Ty->isBFloatTy();
831case IITDescriptor::Float:
832return !Ty->isFloatTy();
833case IITDescriptor::Double:
834return !Ty->isDoubleTy();
835case IITDescriptor::Quad:
836return !Ty->isFP128Ty();
837case IITDescriptor::PPCQuad:
838return !Ty->isPPC_FP128Ty();
839case IITDescriptor::Integer:
840return !Ty->isIntegerTy(D.Integer_Width);
841case IITDescriptor::AArch64Svcount:
842return !isa<TargetExtType>(Ty) ||
843 cast<TargetExtType>(Ty)->getName() !="aarch64.svcount";
844case IITDescriptor::Vector: {
845VectorType *VT = dyn_cast<VectorType>(Ty);
846return !VT || VT->getElementCount() !=D.Vector_Width ||
847matchIntrinsicType(VT->getElementType(), Infos, ArgTys,
848 DeferredChecks, IsDeferredCheck);
849 }
850case IITDescriptor::Pointer: {
851PointerType *PT = dyn_cast<PointerType>(Ty);
852return !PT || PT->getAddressSpace() !=D.Pointer_AddressSpace;
853 }
854
855case IITDescriptor::Struct: {
856StructType *ST = dyn_cast<StructType>(Ty);
857if (!ST || !ST->isLiteral() || ST->isPacked() ||
858 ST->getNumElements() !=D.Struct_NumElements)
859returntrue;
860
861for (unsigned i = 0, e =D.Struct_NumElements; i != e; ++i)
862if (matchIntrinsicType(ST->getElementType(i), Infos, ArgTys,
863 DeferredChecks, IsDeferredCheck))
864returntrue;
865returnfalse;
866 }
867
868case IITDescriptor::Argument:
869// If this is the second occurrence of an argument,
870// verify that the later instance matches the previous instance.
871if (D.getArgumentNumber() < ArgTys.size())
872return Ty != ArgTys[D.getArgumentNumber()];
873
874if (D.getArgumentNumber() > ArgTys.size() ||
875D.getArgumentKind() == IITDescriptor::AK_MatchType)
876return IsDeferredCheck || DeferCheck(Ty);
877
878assert(D.getArgumentNumber() == ArgTys.size() && !IsDeferredCheck &&
879"Table consistency error");
880 ArgTys.push_back(Ty);
881
882switch (D.getArgumentKind()) {
883case IITDescriptor::AK_Any:
884returnfalse;// Success
885case IITDescriptor::AK_AnyInteger:
886return !Ty->isIntOrIntVectorTy();
887case IITDescriptor::AK_AnyFloat:
888return !Ty->isFPOrFPVectorTy();
889case IITDescriptor::AK_AnyVector:
890return !isa<VectorType>(Ty);
891case IITDescriptor::AK_AnyPointer:
892return !isa<PointerType>(Ty);
893default:
894break;
895 }
896llvm_unreachable("all argument kinds not covered");
897
898case IITDescriptor::ExtendArgument: {
899// If this is a forward reference, defer the check for later.
900if (D.getArgumentNumber() >= ArgTys.size())
901return IsDeferredCheck || DeferCheck(Ty);
902
903Type *NewTy = ArgTys[D.getArgumentNumber()];
904if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
905 NewTy = VectorType::getExtendedElementVectorType(VTy);
906elseif (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
907 NewTy =IntegerType::get(ITy->getContext(), 2 * ITy->getBitWidth());
908else
909returntrue;
910
911return Ty != NewTy;
912 }
913case IITDescriptor::TruncArgument: {
914// If this is a forward reference, defer the check for later.
915if (D.getArgumentNumber() >= ArgTys.size())
916return IsDeferredCheck || DeferCheck(Ty);
917
918Type *NewTy = ArgTys[D.getArgumentNumber()];
919if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
920 NewTy = VectorType::getTruncatedElementVectorType(VTy);
921elseif (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
922 NewTy =IntegerType::get(ITy->getContext(), ITy->getBitWidth() / 2);
923else
924returntrue;
925
926return Ty != NewTy;
927 }
928case IITDescriptor::HalfVecArgument:
929// If this is a forward reference, defer the check for later.
930if (D.getArgumentNumber() >= ArgTys.size())
931return IsDeferredCheck || DeferCheck(Ty);
932return !isa<VectorType>(ArgTys[D.getArgumentNumber()]) ||
933 VectorType::getHalfElementsVectorType(
934 cast<VectorType>(ArgTys[D.getArgumentNumber()])) != Ty;
935case IITDescriptor::SameVecWidthArgument: {
936if (D.getArgumentNumber() >= ArgTys.size()) {
937// Defer check and subsequent check for the vector element type.
938 Infos = Infos.slice(1);
939return IsDeferredCheck || DeferCheck(Ty);
940 }
941auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
942auto *ThisArgType = dyn_cast<VectorType>(Ty);
943// Both must be vectors of the same number of elements or neither.
944if ((ReferenceType !=nullptr) != (ThisArgType !=nullptr))
945returntrue;
946Type *EltTy = Ty;
947if (ThisArgType) {
948if (ReferenceType->getElementCount() != ThisArgType->getElementCount())
949returntrue;
950 EltTy = ThisArgType->getElementType();
951 }
952returnmatchIntrinsicType(EltTy, Infos, ArgTys, DeferredChecks,
953 IsDeferredCheck);
954 }
955case IITDescriptor::VecOfAnyPtrsToElt: {
956unsigned RefArgNumber =D.getRefArgNumber();
957if (RefArgNumber >= ArgTys.size()) {
958if (IsDeferredCheck)
959returntrue;
960// If forward referencing, already add the pointer-vector type and
961// defer the checks for later.
962 ArgTys.push_back(Ty);
963return DeferCheck(Ty);
964 }
965
966if (!IsDeferredCheck) {
967assert(D.getOverloadArgNumber() == ArgTys.size() &&
968"Table consistency error");
969 ArgTys.push_back(Ty);
970 }
971
972// Verify the overloaded type "matches" the Ref type.
973// i.e. Ty is a vector with the same width as Ref.
974// Composed of pointers to the same element type as Ref.
975auto *ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
976auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
977if (!ThisArgVecTy || !ReferenceType ||
978 (ReferenceType->getElementCount() != ThisArgVecTy->getElementCount()))
979returntrue;
980return !ThisArgVecTy->getElementType()->isPointerTy();
981 }
982case IITDescriptor::VecElementArgument: {
983if (D.getArgumentNumber() >= ArgTys.size())
984return IsDeferredCheck ?true : DeferCheck(Ty);
985auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
986return !ReferenceType || Ty !=ReferenceType->getElementType();
987 }
988case IITDescriptor::Subdivide2Argument:
989case IITDescriptor::Subdivide4Argument: {
990// If this is a forward reference, defer the check for later.
991if (D.getArgumentNumber() >= ArgTys.size())
992return IsDeferredCheck || DeferCheck(Ty);
993
994Type *NewTy = ArgTys[D.getArgumentNumber()];
995if (auto *VTy = dyn_cast<VectorType>(NewTy)) {
996int SubDivs =D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
997 NewTy = VectorType::getSubdividedVectorType(VTy, SubDivs);
998return Ty != NewTy;
999 }
1000returntrue;
1001 }
1002case IITDescriptor::VecOfBitcastsToInt: {
1003if (D.getArgumentNumber() >= ArgTys.size())
1004return IsDeferredCheck || DeferCheck(Ty);
1005auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
1006auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1007if (!ThisArgVecTy || !ReferenceType)
1008returntrue;
1009return ThisArgVecTy != VectorType::getInteger(ReferenceType);
1010 }
1011 }
1012llvm_unreachable("unhandled");
1013}
1014
1015Intrinsic::MatchIntrinsicTypesResult
1016Intrinsic::matchIntrinsicSignature(FunctionType *FTy,
1017ArrayRef<Intrinsic::IITDescriptor> &Infos,
1018SmallVectorImpl<Type *> &ArgTys) {
1019SmallVector<DeferredIntrinsicMatchPair, 2> DeferredChecks;
1020if (matchIntrinsicType(FTy->getReturnType(), Infos, ArgTys, DeferredChecks,
1021false))
1022returnMatchIntrinsicTypes_NoMatchRet;
1023
1024unsigned NumDeferredReturnChecks = DeferredChecks.size();
1025
1026for (auto *Ty : FTy->params())
1027if (matchIntrinsicType(Ty, Infos, ArgTys, DeferredChecks,false))
1028returnMatchIntrinsicTypes_NoMatchArg;
1029
1030for (unsignedI = 0, E = DeferredChecks.size();I != E; ++I) {
1031DeferredIntrinsicMatchPair &Check = DeferredChecks[I];
1032if (matchIntrinsicType(Check.first,Check.second, ArgTys, DeferredChecks,
1033true))
1034returnI < NumDeferredReturnChecks ?MatchIntrinsicTypes_NoMatchRet
1035 :MatchIntrinsicTypes_NoMatchArg;
1036 }
1037
1038returnMatchIntrinsicTypes_Match;
1039}
1040
1041boolIntrinsic::matchIntrinsicVarArg(
1042bool isVarArg,ArrayRef<Intrinsic::IITDescriptor> &Infos) {
1043// If there are no descriptors left, then it can't be a vararg.
1044if (Infos.empty())
1045return isVarArg;
1046
1047// There should be only one descriptor remaining at this point.
1048if (Infos.size() != 1)
1049returntrue;
1050
1051// Check and verify the descriptor.
1052IITDescriptorD = Infos.front();
1053 Infos = Infos.slice(1);
1054if (D.Kind == IITDescriptor::VarArg)
1055return !isVarArg;
1056
1057returntrue;
1058}
1059
1060boolIntrinsic::getIntrinsicSignature(Intrinsic::IDID,FunctionType *FT,
1061SmallVectorImpl<Type *> &ArgTys) {
1062if (!ID)
1063returnfalse;
1064
1065SmallVector<Intrinsic::IITDescriptor, 8> Table;
1066getIntrinsicInfoTableEntries(ID, Table);
1067ArrayRef<Intrinsic::IITDescriptor>TableRef = Table;
1068
1069if (Intrinsic::matchIntrinsicSignature(FT,TableRef, ArgTys) !=
1070 Intrinsic::MatchIntrinsicTypesResult::MatchIntrinsicTypes_Match) {
1071returnfalse;
1072 }
1073if (Intrinsic::matchIntrinsicVarArg(FT->isVarArg(),TableRef))
1074returnfalse;
1075returntrue;
1076}
1077
1078boolIntrinsic::getIntrinsicSignature(Function *F,
1079SmallVectorImpl<Type *> &ArgTys) {
1080returngetIntrinsicSignature(F->getIntrinsicID(),F->getFunctionType(),
1081 ArgTys);
1082}
1083
1084std::optional<Function *>Intrinsic::remangleIntrinsicFunction(Function *F) {
1085SmallVector<Type *, 4> ArgTys;
1086if (!getIntrinsicSignature(F, ArgTys))
1087return std::nullopt;
1088
1089Intrinsic::IDID =F->getIntrinsicID();
1090StringRefName =F->getName();
1091 std::string WantedName =
1092Intrinsic::getName(ID, ArgTys,F->getParent(),F->getFunctionType());
1093if (Name == WantedName)
1094return std::nullopt;
1095
1096Function *NewDecl = [&] {
1097if (auto *ExistingGV =F->getParent()->getNamedValue(WantedName)) {
1098if (auto *ExistingF = dyn_cast<Function>(ExistingGV))
1099if (ExistingF->getFunctionType() ==F->getFunctionType())
1100return ExistingF;
1101
1102// The name already exists, but is not a function or has the wrong
1103// prototype. Make place for the new one by renaming the old version.
1104// Either this old version will be removed later on or the module is
1105// invalid and we'll get an error.
1106 ExistingGV->setName(WantedName +".renamed");
1107 }
1108returnIntrinsic::getOrInsertDeclaration(F->getParent(),ID, ArgTys);
1109 }();
1110
1111 NewDecl->setCallingConv(F->getCallingConv());
1112assert(NewDecl->getFunctionType() ==F->getFunctionType() &&
1113"Shouldn't change the signature");
1114return NewDecl;
1115}
StringTable.h
true
basic Basic Alias true
Definition:BasicAliasAnalysis.cpp:1981
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Info
Analysis containing CSE Info
Definition:CSEInfo.cpp:27
Idx
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
Definition:DeadArgumentElimination.cpp:353
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Check
#define Check(C,...)
Definition:GenericConvergenceVerifierImpl.h:34
Function.h
Module.h
Module.h This file contains the declarations for the Module class.
Type.h
matchIntrinsicType
static bool matchIntrinsicType(Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
Definition:Intrinsics.cpp:791
getIntrinsicNameImpl
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef< Type * > Tys, Module *M, FunctionType *FT, bool EarlyModuleCheck)
Definition:Intrinsics.cpp:152
DeferredIntrinsicMatchPair
std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > > DeferredIntrinsicMatchPair
Definition:Intrinsics.cpp:788
findTargetSubtable
static std::pair< ArrayRef< unsigned >, StringRef > findTargetSubtable(StringRef Name)
Find the segment of IntrinsicNameOffsetTable for intrinsics with the same target as Name,...
Definition:Intrinsics.cpp:689
DecodeIITType
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, IIT_Info LastInfo, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
Definition:Intrinsics.cpp:200
IIT_Info
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
Definition:Intrinsics.cpp:193
DecodeFixedType
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
Definition:Intrinsics.cpp:482
lookupLLVMIntrinsicByName
static int lookupLLVMIntrinsicByName(ArrayRef< unsigned > NameOffsetTable, StringRef Name, StringRef Target="")
Looks up Name in NameTable via binary search.
Definition:Intrinsics.cpp:626
getMangledTypeStr
static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType)
Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' ty...
Definition:Intrinsics.cpp:66
Intrinsics.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
High
uint64_t High
Definition:NVVMIntrRange.cpp:51
getName
static StringRef getName(Value *V)
Definition:ProvenanceAnalysisEvaluator.cpp:20
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringExtras.h
This file contains some functions that are useful when dealing with strings.
getType
static SymbolRef::Type getType(const Symbol *Sym)
Definition:TapiFile.cpp:39
getBitWidth
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Definition:ValueTracking.cpp:93
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
ArrayType
Definition:ItaniumDemangle.h:785
FunctionType
Definition:ItaniumDemangle.h:823
PointerType
Definition:ItaniumDemangle.h:627
ReferenceType
Definition:ItaniumDemangle.h:677
T
VectorType
Definition:ItaniumDemangle.h:1173
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::front
const T & front() const
front - Get the first element.
Definition:ArrayRef.h:171
llvm::ArrayRef::end
iterator end() const
Definition:ArrayRef.h:157
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::ArrayRef::begin
iterator begin() const
Definition:ArrayRef.h:156
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition:ArrayRef.h:163
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition:ArrayRef.h:198
llvm::ElementCount
Definition:TypeSize.h:300
llvm::FixedVectorType
Class to represent fixed width SIMD vectors.
Definition:DerivedTypes.h:563
llvm::FixedVectorType::getNumElements
unsigned getNumElements() const
Definition:DerivedTypes.h:606
llvm::FixedVectorType::get
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition:Type.cpp:791
llvm::FunctionType
Class to represent function types.
Definition:DerivedTypes.h:105
llvm::FunctionType::params
ArrayRef< Type * > params() const
Definition:DerivedTypes.h:132
llvm::FunctionType::isVarArg
bool isVarArg() const
Definition:DerivedTypes.h:125
llvm::FunctionType::getReturnType
Type * getReturnType() const
Definition:DerivedTypes.h:126
llvm::Function
Definition:Function.h:63
llvm::Function::getFunctionType
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition:Function.h:216
llvm::Function::setCallingConv
void setCallingConv(CallingConv::ID CC)
Definition:Function.h:281
llvm::IntegerType
Class to represent integer types.
Definition:DerivedTypes.h:42
llvm::IntegerType::get
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition:Type.cpp:311
llvm::IntegerType::getBitWidth
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition:DerivedTypes.h:74
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition:SmallVector.h:937
llvm::SmallVectorTemplateBase::pop_back
void pop_back()
Definition:SmallVector.h:425
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::back
reference back()
Definition:SmallVector.h:308
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition:StringRef.h:150
llvm::StringRef::data
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition:StringRef.h:144
llvm::StringRef::npos
static constexpr size_t npos
Definition:StringRef.h:53
llvm::StructType
Class to represent struct types.
Definition:DerivedTypes.h:218
llvm::StructType::get
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:406
llvm::TargetExtType
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition:DerivedTypes.h:744
llvm::TargetExtType::get
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
Definition:Type.cpp:895
llvm::Target
Target - Wrapper for Target specific information.
Definition:TargetRegistry.h:144
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::getHalfTy
static Type * getHalfTy(LLVMContext &C)
llvm::Type::getDoubleTy
static Type * getDoubleTy(LLVMContext &C)
llvm::Type::getBFloatTy
static Type * getBFloatTy(LLVMContext &C)
llvm::Type::isIntOrIntVectorTy
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition:Type.h:243
llvm::Type::isFloatTy
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition:Type.h:153
llvm::Type::getX86_AMXTy
static Type * getX86_AMXTy(LLVMContext &C)
llvm::Type::isBFloatTy
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition:Type.h:145
llvm::Type::getMetadataTy
static Type * getMetadataTy(LLVMContext &C)
llvm::Type::X86_AMXTyID
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition:Type.h:66
llvm::Type::HalfTyID
@ HalfTyID
16-bit floating point type
Definition:Type.h:56
llvm::Type::VoidTyID
@ VoidTyID
type with no size
Definition:Type.h:63
llvm::Type::FloatTyID
@ FloatTyID
32-bit floating point type
Definition:Type.h:58
llvm::Type::IntegerTyID
@ IntegerTyID
Arbitrary bit width integers.
Definition:Type.h:70
llvm::Type::BFloatTyID
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition:Type.h:57
llvm::Type::DoubleTyID
@ DoubleTyID
64-bit floating point type
Definition:Type.h:59
llvm::Type::X86_FP80TyID
@ X86_FP80TyID
80-bit floating point type (X87)
Definition:Type.h:60
llvm::Type::PPC_FP128TyID
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition:Type.h:62
llvm::Type::MetadataTyID
@ MetadataTyID
Metadata.
Definition:Type.h:65
llvm::Type::FP128TyID
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition:Type.h:61
llvm::Type::isPPC_FP128Ty
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition:Type.h:165
llvm::Type::isFP128Ty
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition:Type.h:162
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
llvm::Type::getFP128Ty
static Type * getFP128Ty(LLVMContext &C)
llvm::Type::isHalfTy
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition:Type.h:142
llvm::Type::isDoubleTy
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition:Type.h:156
llvm::Type::getTokenTy
static Type * getTokenTy(LLVMContext &C)
llvm::Type::isX86_AMXTy
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition:Type.h:200
llvm::Type::getFloatTy
static Type * getFloatTy(LLVMContext &C)
llvm::Type::isIntegerTy
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition:Type.h:237
llvm::Type::getTypeID
TypeID getTypeID() const
Return the type id for the type.
Definition:Type.h:136
llvm::Type::isTokenTy
bool isTokenTy() const
Return true if this is 'token'.
Definition:Type.h:234
llvm::Type::isFPOrFPVectorTy
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition:Type.h:225
llvm::Type::getPPC_FP128Ty
static Type * getPPC_FP128Ty(LLVMContext &C)
llvm::Type::isVoidTy
bool isVoidTy() const
Return true if this is 'void'.
Definition:Type.h:139
llvm::Type::isMetadataTy
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition:Type.h:231
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition:Value.cpp:377
llvm::VectorType::getElementType
Type * getElementType() const
Definition:DerivedTypes.h:460
uint16_t
unsigned
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition:CallingConv.h:24
llvm::Intrinsic::Tys
ID ArrayRef< Type * > Tys
Definition:Intrinsics.h:102
llvm::Intrinsic::getOrInsertDeclaration
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
Definition:Intrinsics.cpp:732
llvm::Intrinsic::matchIntrinsicSignature
MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys)
Match the specified function type with the type constraints specified by the .td file.
Definition:Intrinsics.cpp:1016
llvm::Intrinsic::id
ID id
Definition:Intrinsics.h:102
llvm::Intrinsic::getIntrinsicInfoTableEntries
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
Definition:Intrinsics.cpp:447
llvm::Intrinsic::MatchIntrinsicTypesResult
MatchIntrinsicTypesResult
Definition:Intrinsics.h:229
llvm::Intrinsic::MatchIntrinsicTypes_Match
@ MatchIntrinsicTypes_Match
Definition:Intrinsics.h:230
llvm::Intrinsic::MatchIntrinsicTypes_NoMatchRet
@ MatchIntrinsicTypes_NoMatchRet
Definition:Intrinsics.h:231
llvm::Intrinsic::MatchIntrinsicTypes_NoMatchArg
@ MatchIntrinsicTypes_NoMatchArg
Definition:Intrinsics.h:232
llvm::Intrinsic::not_intrinsic
@ not_intrinsic
Definition:Intrinsics.h:44
llvm::Intrinsic::getNameNoUnnamedTypes
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
Definition:Intrinsics.cpp:185
llvm::Intrinsic::remangleIntrinsicFunction
std::optional< Function * > remangleIntrinsicFunction(Function *F)
Definition:Intrinsics.cpp:1084
llvm::Intrinsic::hasConstrainedFPRoundingModeOperand
bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take ...
Definition:Intrinsics.cpp:775
llvm::Intrinsic::getName
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition:Intrinsics.cpp:47
llvm::Intrinsic::isConstrainedFPIntrinsic
bool isConstrainedFPIntrinsic(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics".
Definition:Intrinsics.cpp:763
llvm::Intrinsic::ID
unsigned ID
Definition:GenericSSAContext.h:28
llvm::Intrinsic::lookupIntrinsicID
ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Definition:Intrinsics.cpp:707
llvm::Intrinsic::getDeclarationIfExists
Function * getDeclarationIfExists(Module *M, ID id, ArrayRef< Type * > Tys, FunctionType *FT=nullptr)
This version supports overloaded intrinsics.
Definition:Intrinsics.cpp:747
llvm::Intrinsic::getBaseName
StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
Definition:Intrinsics.cpp:42
llvm::Intrinsic::isOverloaded
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Definition:Intrinsics.cpp:607
llvm::Intrinsic::getType
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys={})
Return the function type for an intrinsic.
Definition:Intrinsics.cpp:585
llvm::Intrinsic::getIntrinsicSignature
bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
Definition:Intrinsics.cpp:1060
llvm::Intrinsic::isTargetIntrinsic
bool isTargetIntrinsic(ID IID)
isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.
Definition:Intrinsics.cpp:618
llvm::Intrinsic::matchIntrinsicVarArg
bool matchIntrinsicVarArg(bool isVarArg, ArrayRef< IITDescriptor > &Infos)
Verify if the intrinsic has variable arguments.
Definition:Intrinsics.cpp:1041
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::ThreadPriority::Low
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
llvm::partition_point
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
Definition:STLExtras.h:2050
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1746
llvm::ArgInfo
Helper struct shared between Function Specialization and SCCP Solver.
Definition:SCCPSolver.h:41
llvm::Intrinsic::IITDescriptor
This is a type descriptor which explains the type requirements of an intrinsic.
Definition:Intrinsics.h:131

Generated on Thu Jul 17 2025 12:30:12 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp