Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
ExternalFunctions.cpp
Go to the documentation of this file.
1//===-- ExternalFunctions.cpp - Implement External Functions --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains both code to deal with invoking "external" functions, but
10// also contains code that implements "exported" external functions.
11//
12// There are currently two mechanisms for handling external functions in the
13// Interpreter. The first is to implement lle_* wrapper functions that are
14// specific to well-known library functions which manually translate the
15// arguments from GenericValues and make the call. If such a wrapper does
16// not exist, and libffi is available, then the Interpreter will attempt to
17// invoke the function using libffi, after finding its address.
18//
19//===----------------------------------------------------------------------===//
20
21#include "Interpreter.h"
22#include "llvm/ADT/APInt.h"
23#include "llvm/ADT/ArrayRef.h"
24#include "llvm/Config/config.h"// Detect libffi
25#include "llvm/ExecutionEngine/GenericValue.h"
26#include "llvm/IR/DataLayout.h"
27#include "llvm/IR/DerivedTypes.h"
28#include "llvm/IR/Function.h"
29#include "llvm/IR/Type.h"
30#include "llvm/Support/Casting.h"
31#include "llvm/Support/DynamicLibrary.h"
32#include "llvm/Support/ErrorHandling.h"
33#include "llvm/Support/Mutex.h"
34#include "llvm/Support/raw_ostream.h"
35#include <cassert>
36#include <cmath>
37#include <csignal>
38#include <cstdint>
39#include <cstdio>
40#include <cstring>
41#include <map>
42#include <mutex>
43#include <string>
44#include <utility>
45#include <vector>
46
47#ifdef HAVE_FFI_CALL
48#ifdef HAVE_FFI_H
49#include <ffi.h>
50#define USE_LIBFFI
51#elif HAVE_FFI_FFI_H
52#include <ffi/ffi.h>
53#define USE_LIBFFI
54#endif
55#endif
56
57using namespacellvm;
58
59namespace{
60
61typedefGenericValue (*ExFunc)(FunctionType *,ArrayRef<GenericValue>);
62typedef void (*RawFunc)();
63
64structFunctions {
65sys::Mutex Lock;
66 std::map<const Function *, ExFunc> ExportedFunctions;
67 std::map<std::string, ExFunc> FuncNames;
68#ifdef USE_LIBFFI
69 std::map<const Function *, RawFunc> RawFunctions;
70#endif
71};
72
73Functions &getFunctions() {
74static FunctionsF;
75returnF;
76}
77
78}// anonymous namespace
79
80staticInterpreter *TheInterpreter;
81
82staticchargetTypeID(Type *Ty) {
83switch (Ty->getTypeID()) {
84caseType::VoidTyID:return'V';
85caseType::IntegerTyID:
86switch (cast<IntegerType>(Ty)->getBitWidth()) {
87case 1:return'o';
88case 8:return'B';
89case 16:return'S';
90case 32:return'I';
91case 64:return'L';
92default:return'N';
93 }
94caseType::FloatTyID:return'F';
95caseType::DoubleTyID:return'D';
96caseType::PointerTyID:return'P';
97caseType::FunctionTyID:return'M';
98caseType::StructTyID:return'T';
99caseType::ArrayTyID:return'A';
100default:return'U';
101 }
102}
103
104// Try to find address of external function given a Function object.
105// Please note, that interpreter doesn't know how to assemble a
106// real call in general case (this is JIT job), that's why it assumes,
107// that all external functions has the same (and pretty "general") signature.
108// The typical example of such functions are "lle_X_" ones.
109static ExFunclookupFunction(constFunction *F) {
110// Function not found, look it up... start by figuring out what the
111// composite function name should be.
112 std::string ExtName ="lle_";
113FunctionType *FT =F->getFunctionType();
114 ExtName +=getTypeID(FT->getReturnType());
115for (Type *T : FT->params())
116 ExtName +=getTypeID(T);
117 ExtName += ("_" +F->getName()).str();
118
119auto &Fns = getFunctions();
120sys::ScopedLock Writer(Fns.Lock);
121 ExFunc FnPtr = Fns.FuncNames[ExtName];
122if (!FnPtr)
123 FnPtr = Fns.FuncNames[("lle_X_" +F->getName()).str()];
124if (!FnPtr)// Try calling a generic function... if it exists...
125 FnPtr = (ExFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol(
126 ("lle_X_" +F->getName()).str());
127if (FnPtr)
128 Fns.ExportedFunctions.insert(std::make_pair(F, FnPtr));// Cache for later
129return FnPtr;
130}
131
132#ifdef USE_LIBFFI
133static ffi_type *ffiTypeFor(Type *Ty) {
134switch (Ty->getTypeID()) {
135caseType::VoidTyID:return &ffi_type_void;
136caseType::IntegerTyID:
137switch (cast<IntegerType>(Ty)->getBitWidth()) {
138case 8:return &ffi_type_sint8;
139case 16:return &ffi_type_sint16;
140case 32:return &ffi_type_sint32;
141case 64:return &ffi_type_sint64;
142 }
143llvm_unreachable("Unhandled integer type bitwidth");
144caseType::FloatTyID:return &ffi_type_float;
145caseType::DoubleTyID:return &ffi_type_double;
146caseType::PointerTyID:return &ffi_type_pointer;
147default:break;
148 }
149// TODO: Support other types such as StructTyID, ArrayTyID, OpaqueTyID, etc.
150report_fatal_error("Type could not be mapped for use with libffi.");
151return NULL;
152}
153
154staticvoid *ffiValueFor(Type *Ty,constGenericValue &AV,
155void *ArgDataPtr) {
156switch (Ty->getTypeID()) {
157caseType::IntegerTyID:
158switch (cast<IntegerType>(Ty)->getBitWidth()) {
159case 8: {
160 int8_t *I8Ptr = (int8_t *) ArgDataPtr;
161 *I8Ptr = (int8_t) AV.IntVal.getZExtValue();
162return ArgDataPtr;
163 }
164case 16: {
165 int16_t *I16Ptr = (int16_t *) ArgDataPtr;
166 *I16Ptr = (int16_t) AV.IntVal.getZExtValue();
167return ArgDataPtr;
168 }
169case 32: {
170 int32_t *I32Ptr = (int32_t *) ArgDataPtr;
171 *I32Ptr = (int32_t) AV.IntVal.getZExtValue();
172return ArgDataPtr;
173 }
174case 64: {
175 int64_t *I64Ptr = (int64_t *) ArgDataPtr;
176 *I64Ptr = (int64_t) AV.IntVal.getZExtValue();
177return ArgDataPtr;
178 }
179 }
180llvm_unreachable("Unhandled integer type bitwidth");
181caseType::FloatTyID: {
182float *FloatPtr = (float *) ArgDataPtr;
183 *FloatPtr = AV.FloatVal;
184return ArgDataPtr;
185 }
186caseType::DoubleTyID: {
187double *DoublePtr = (double *) ArgDataPtr;
188 *DoublePtr = AV.DoubleVal;
189return ArgDataPtr;
190 }
191caseType::PointerTyID: {
192void **PtrPtr = (void **) ArgDataPtr;
193 *PtrPtr =GVTOP(AV);
194return ArgDataPtr;
195 }
196default:break;
197 }
198// TODO: Support other types such as StructTyID, ArrayTyID, OpaqueTyID, etc.
199report_fatal_error("Type value could not be mapped for use with libffi.");
200return NULL;
201}
202
203staticbool ffiInvoke(RawFunc Fn,Function *F,ArrayRef<GenericValue> ArgVals,
204constDataLayout &TD,GenericValue &Result) {
205 ffi_cif cif;
206FunctionType *FTy =F->getFunctionType();
207constunsigned NumArgs =F->arg_size();
208
209// TODO: We don't have type information about the remaining arguments, because
210// this information is never passed into ExecutionEngine::runFunction().
211if (ArgVals.size() > NumArgs &&F->isVarArg()) {
212report_fatal_error("Calling external var arg function '" +F->getName()
213 +"' is not supported by the Interpreter.");
214 }
215
216unsigned ArgBytes = 0;
217
218 std::vector<ffi_type*>args(NumArgs);
219for (Function::const_arg_iteratorA =F->arg_begin(), E =F->arg_end();
220A != E; ++A) {
221constunsigned ArgNo =A->getArgNo();
222Type *ArgTy = FTy->getParamType(ArgNo);
223args[ArgNo] = ffiTypeFor(ArgTy);
224 ArgBytes += TD.getTypeStoreSize(ArgTy);
225 }
226
227SmallVector<uint8_t, 128> ArgData;
228 ArgData.resize(ArgBytes);
229uint8_t *ArgDataPtr = ArgData.data();
230SmallVector<void*, 16>values(NumArgs);
231for (Function::const_arg_iteratorA =F->arg_begin(), E =F->arg_end();
232A != E; ++A) {
233constunsigned ArgNo =A->getArgNo();
234Type *ArgTy = FTy->getParamType(ArgNo);
235values[ArgNo] = ffiValueFor(ArgTy, ArgVals[ArgNo], ArgDataPtr);
236 ArgDataPtr += TD.getTypeStoreSize(ArgTy);
237 }
238
239Type *RetTy = FTy->getReturnType();
240 ffi_type *rtype = ffiTypeFor(RetTy);
241
242if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NumArgs, rtype,args.data()) ==
243 FFI_OK) {
244SmallVector<uint8_t, 128> ret;
245if (RetTy->getTypeID() !=Type::VoidTyID)
246 ret.resize(TD.getTypeStoreSize(RetTy));
247 ffi_call(&cif, Fn, ret.data(),values.data());
248switch (RetTy->getTypeID()) {
249caseType::IntegerTyID:
250switch (cast<IntegerType>(RetTy)->getBitWidth()) {
251case 8:Result.IntVal =APInt(8 , *(int8_t *) ret.data());break;
252case 16:Result.IntVal =APInt(16, *(int16_t*) ret.data());break;
253case 32:Result.IntVal =APInt(32, *(int32_t*) ret.data());break;
254case 64:Result.IntVal =APInt(64, *(int64_t*) ret.data());break;
255 }
256break;
257caseType::FloatTyID:Result.FloatVal = *(float *) ret.data();break;
258caseType::DoubleTyID:Result.DoubleVal = *(double*) ret.data();break;
259caseType::PointerTyID:Result.PointerVal = *(void **) ret.data();break;
260default:break;
261 }
262returntrue;
263 }
264
265returnfalse;
266}
267#endif// USE_LIBFFI
268
269GenericValueInterpreter::callExternalFunction(Function *F,
270ArrayRef<GenericValue> ArgVals) {
271TheInterpreter =this;
272
273auto &Fns = getFunctions();
274 std::unique_lock<sys::Mutex> Guard(Fns.Lock);
275
276// Do a lookup to see if the function is in our cache... this should just be a
277// deferred annotation!
278 std::map<const Function *, ExFunc>::iterator FI =
279 Fns.ExportedFunctions.find(F);
280if (ExFunc Fn = (FI == Fns.ExportedFunctions.end()) ?lookupFunction(F)
281 : FI->second) {
282 Guard.unlock();
283return Fn(F->getFunctionType(), ArgVals);
284 }
285
286#ifdef USE_LIBFFI
287 std::map<const Function *, RawFunc>::iterator RF = Fns.RawFunctions.find(F);
288 RawFunc RawFn;
289if (RF == Fns.RawFunctions.end()) {
290 RawFn = (RawFunc)(intptr_t)
291sys::DynamicLibrary::SearchForAddressOfSymbol(std::string(F->getName()));
292if (!RawFn)
293 RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F);
294if (RawFn != 0)
295 Fns.RawFunctions.insert(std::make_pair(F, RawFn));// Cache for later
296 }else {
297 RawFn = RF->second;
298 }
299
300 Guard.unlock();
301
302GenericValue Result;
303if (RawFn != 0 && ffiInvoke(RawFn,F, ArgVals,getDataLayout(), Result))
304return Result;
305#endif// USE_LIBFFI
306
307if (F->getName() =="__main")
308errs() <<"Tried to execute an unknown external function: "
309 << *F->getType() <<" __main\n";
310else
311report_fatal_error("Tried to execute an unknown external function: " +
312F->getName());
313#ifndef USE_LIBFFI
314errs() <<"Recompiling LLVM with --enable-libffi might help.\n";
315#endif
316returnGenericValue();
317}
318
319//===----------------------------------------------------------------------===//
320// Functions "exported" to the running application...
321//
322
323// void atexit(Function*)
324staticGenericValuelle_X_atexit(FunctionType *FT,
325ArrayRef<GenericValue> Args) {
326assert(Args.size() == 1);
327TheInterpreter->addAtExitHandler((Function*)GVTOP(Args[0]));
328GenericValue GV;
329 GV.IntVal = 0;
330return GV;
331}
332
333// void exit(int)
334staticGenericValuelle_X_exit(FunctionType *FT,ArrayRef<GenericValue> Args) {
335TheInterpreter->exitCalled(Args[0]);
336returnGenericValue();
337}
338
339// void abort(void)
340staticGenericValuelle_X_abort(FunctionType *FT,ArrayRef<GenericValue> Args) {
341//FIXME: should we report or raise here?
342//report_fatal_error("Interpreted program raised SIGABRT");
343 raise (SIGABRT);
344returnGenericValue();
345}
346
347// Silence warnings about sprintf. (See also
348// https://github.com/llvm/llvm-project/issues/58086)
349#if defined(__clang__)
350#pragma clang diagnostic push
351#pragma clang diagnostic ignored "-Wdeprecated-declarations"
352#endif
353// int sprintf(char *, const char *, ...) - a very rough implementation to make
354// output useful.
355staticGenericValuelle_X_sprintf(FunctionType *FT,
356ArrayRef<GenericValue> Args) {
357char *OutputBuffer = (char *)GVTOP(Args[0]);
358constchar *FmtStr = (constchar *)GVTOP(Args[1]);
359unsigned ArgNo = 2;
360
361// printf should return # chars printed. This is completely incorrect, but
362// close enough for now.
363GenericValue GV;
364 GV.IntVal =APInt(32, strlen(FmtStr));
365while (true) {
366switch (*FmtStr) {
367case 0:return GV;// Null terminator...
368default:// Normal nonspecial character
369 sprintf(OutputBuffer++,"%c", *FmtStr++);
370break;
371case'\\': {// Handle escape codes
372 sprintf(OutputBuffer,"%c%c", *FmtStr, *(FmtStr+1));
373 FmtStr += 2;OutputBuffer += 2;
374break;
375 }
376case'%': {// Handle format specifiers
377char FmtBuf[100] ="", Buffer[1000] ="";
378char *FB = FmtBuf;
379 *FB++ = *FmtStr++;
380charLast = *FB++ = *FmtStr++;
381unsigned HowLong = 0;
382while (Last !='c' &&Last !='d' &&Last !='i' &&Last !='u' &&
383Last !='o' &&Last !='x' &&Last !='X' &&Last !='e' &&
384Last !='E' &&Last !='g' &&Last !='G' &&Last !='f' &&
385Last !='p' &&Last !='s' &&Last !='%') {
386if (Last =='l' ||Last =='L') HowLong++;// Keep track of l's
387Last = *FB++ = *FmtStr++;
388 }
389 *FB = 0;
390
391switch (Last) {
392case'%':
393 memcpy(Buffer,"%", 2);break;
394case'c':
395 sprintf(Buffer, FmtBuf,uint32_t(Args[ArgNo++].IntVal.getZExtValue()));
396break;
397case'd':case'i':
398case'u':case'o':
399case'x':case'X':
400if (HowLong >= 1) {
401if (HowLong == 1 &&
402TheInterpreter->getDataLayout().getPointerSizeInBits() == 64 &&
403sizeof(long) <sizeof(int64_t)) {
404// Make sure we use %lld with a 64 bit argument because we might be
405// compiling LLI on a 32 bit compiler.
406unsignedSize = strlen(FmtBuf);
407 FmtBuf[Size] = FmtBuf[Size-1];
408 FmtBuf[Size+1] = 0;
409 FmtBuf[Size-1] ='l';
410 }
411 sprintf(Buffer, FmtBuf, Args[ArgNo++].IntVal.getZExtValue());
412 }else
413 sprintf(Buffer, FmtBuf,uint32_t(Args[ArgNo++].IntVal.getZExtValue()));
414break;
415case'e':case'E':case'g':case'G':case'f':
416 sprintf(Buffer, FmtBuf, Args[ArgNo++].DoubleVal);break;
417case'p':
418 sprintf(Buffer, FmtBuf, (void*)GVTOP(Args[ArgNo++]));break;
419case's':
420 sprintf(Buffer, FmtBuf, (char*)GVTOP(Args[ArgNo++]));break;
421default:
422errs() <<"<unknown printf code '" << *FmtStr <<"'!>";
423 ArgNo++;break;
424 }
425size_t Len = strlen(Buffer);
426 memcpy(OutputBuffer, Buffer, Len + 1);
427OutputBuffer += Len;
428 }
429break;
430 }
431 }
432return GV;
433}
434#if defined(__clang__)
435#pragma clang diagnostic pop
436#endif
437
438// int printf(const char *, ...) - a very rough implementation to make output
439// useful.
440staticGenericValuelle_X_printf(FunctionType *FT,
441ArrayRef<GenericValue> Args) {
442char Buffer[10000];
443 std::vector<GenericValue> NewArgs;
444 NewArgs.push_back(PTOGV((void*)&Buffer[0]));
445llvm::append_range(NewArgs, Args);
446GenericValue GV =lle_X_sprintf(FT, NewArgs);
447outs() << Buffer;
448return GV;
449}
450
451// int sscanf(const char *format, ...);
452staticGenericValuelle_X_sscanf(FunctionType *FT,
453ArrayRef<GenericValue>args) {
454assert(args.size() < 10 &&"Only handle up to 10 args to sscanf right now!");
455
456char *Args[10];
457for (unsigned i = 0; i <args.size(); ++i)
458 Args[i] = (char*)GVTOP(args[i]);
459
460GenericValue GV;
461 GV.IntVal =APInt(32, sscanf(Args[0], Args[1], Args[2], Args[3], Args[4],
462 Args[5], Args[6], Args[7], Args[8], Args[9]));
463return GV;
464}
465
466// int scanf(const char *format, ...);
467staticGenericValuelle_X_scanf(FunctionType *FT,ArrayRef<GenericValue>args) {
468assert(args.size() < 10 &&"Only handle up to 10 args to scanf right now!");
469
470char *Args[10];
471for (unsigned i = 0; i <args.size(); ++i)
472 Args[i] = (char*)GVTOP(args[i]);
473
474GenericValue GV;
475 GV.IntVal =APInt(32, scanf( Args[0], Args[1], Args[2], Args[3], Args[4],
476 Args[5], Args[6], Args[7], Args[8], Args[9]));
477return GV;
478}
479
480// int fprintf(FILE *, const char *, ...) - a very rough implementation to make
481// output useful.
482staticGenericValuelle_X_fprintf(FunctionType *FT,
483ArrayRef<GenericValue> Args) {
484assert(Args.size() >= 2);
485char Buffer[10000];
486 std::vector<GenericValue> NewArgs;
487 NewArgs.push_back(PTOGV(Buffer));
488 NewArgs.insert(NewArgs.end(), Args.begin()+1, Args.end());
489GenericValue GV =lle_X_sprintf(FT, NewArgs);
490
491 fputs(Buffer, (FILE *)GVTOP(Args[0]));
492return GV;
493}
494
495staticGenericValuelle_X_memset(FunctionType *FT,
496ArrayRef<GenericValue> Args) {
497int val = (int)Args[1].IntVal.getSExtValue();
498size_t len = (size_t)Args[2].IntVal.getZExtValue();
499 memset((void *)GVTOP(Args[0]), val, len);
500// llvm.memset.* returns void, lle_X_* returns GenericValue,
501// so here we return GenericValue with IntVal set to zero
502GenericValue GV;
503 GV.IntVal = 0;
504return GV;
505}
506
507staticGenericValuelle_X_memcpy(FunctionType *FT,
508ArrayRef<GenericValue> Args) {
509 memcpy(GVTOP(Args[0]),GVTOP(Args[1]),
510 (size_t)(Args[2].IntVal.getLimitedValue()));
511
512// llvm.memcpy* returns void, lle_X_* returns GenericValue,
513// so here we return GenericValue with IntVal set to zero
514GenericValue GV;
515 GV.IntVal = 0;
516return GV;
517}
518
519void Interpreter::initializeExternalFunctions() {
520auto &Fns = getFunctions();
521sys::ScopedLock Writer(Fns.Lock);
522 Fns.FuncNames["lle_X_atexit"] =lle_X_atexit;
523 Fns.FuncNames["lle_X_exit"] =lle_X_exit;
524 Fns.FuncNames["lle_X_abort"] =lle_X_abort;
525
526 Fns.FuncNames["lle_X_printf"] =lle_X_printf;
527 Fns.FuncNames["lle_X_sprintf"] =lle_X_sprintf;
528 Fns.FuncNames["lle_X_sscanf"] =lle_X_sscanf;
529 Fns.FuncNames["lle_X_scanf"] =lle_X_scanf;
530 Fns.FuncNames["lle_X_fprintf"] =lle_X_fprintf;
531 Fns.FuncNames["lle_X_memset"] =lle_X_memset;
532 Fns.FuncNames["lle_X_memcpy"] =lle_X_memcpy;
533}
APInt.h
This file implements a class to represent arbitrary precision integral constant values and operations...
ArrayRef.h
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Casting.h
DataLayout.h
RetTy
return RetTy
Definition:DeadArgumentElimination.cpp:361
values
Mark the given Function as meaning that it cannot be changed in any way mark any values that are used as this function s parameters or by its return values(according to Uses) live as well. void DeadArgumentEliminationPass
Definition:DeadArgumentElimination.cpp:685
DerivedTypes.h
DynamicLibrary.h
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
lookupFunction
static ExFunc lookupFunction(const Function *F)
Definition:ExternalFunctions.cpp:109
TheInterpreter
static Interpreter * TheInterpreter
Definition:ExternalFunctions.cpp:80
lle_X_memset
static GenericValue lle_X_memset(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:495
getTypeID
static char getTypeID(Type *Ty)
Definition:ExternalFunctions.cpp:82
lle_X_fprintf
static GenericValue lle_X_fprintf(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:482
lle_X_scanf
static GenericValue lle_X_scanf(FunctionType *FT, ArrayRef< GenericValue > args)
Definition:ExternalFunctions.cpp:467
lle_X_printf
static GenericValue lle_X_printf(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:440
lle_X_memcpy
static GenericValue lle_X_memcpy(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:507
lle_X_atexit
static GenericValue lle_X_atexit(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:324
lle_X_sscanf
static GenericValue lle_X_sscanf(FunctionType *FT, ArrayRef< GenericValue > args)
Definition:ExternalFunctions.cpp:452
lle_X_abort
static GenericValue lle_X_abort(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:340
lle_X_exit
static GenericValue lle_X_exit(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:334
lle_X_sprintf
static GenericValue lle_X_sprintf(FunctionType *FT, ArrayRef< GenericValue > Args)
Definition:ExternalFunctions.cpp:355
GenericValue.h
Function.h
Type.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
Mutex.h
args
nvptx lower args
Definition:NVPTXLowerArgs.cpp:199
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
getBitWidth
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Definition:ValueTracking.cpp:93
FunctionType
Definition:ItaniumDemangle.h:823
OutputBuffer
Definition:Utility.h:32
T
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::APInt::getZExtValue
uint64_t getZExtValue() const
Get zero extended value.
Definition:APInt.h:1520
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition:Argument.h:31
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DataLayout::getPointerSizeInBits
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
Definition:DataLayout.h:364
llvm::DataLayout::getTypeStoreSize
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
Definition:DataLayout.h:421
llvm::ExecutionEngine::getDataLayout
const DataLayout & getDataLayout() const
Definition:ExecutionEngine.h:196
llvm::ExecutionEngine::getPointerToGlobalIfAvailable
void * getPointerToGlobalIfAvailable(StringRef S)
getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has a...
Definition:ExecutionEngine.cpp:284
llvm::Function
Definition:Function.h:63
llvm::Interpreter
Definition:Interpreter.h:74
llvm::Interpreter::addAtExitHandler
void addAtExitHandler(Function *F)
Definition:Interpreter.h:179
llvm::Interpreter::exitCalled
void exitCalled(GenericValue GV)
Definition:Execution.cpp:839
llvm::Interpreter::callExternalFunction
GenericValue callExternalFunction(Function *F, ArrayRef< GenericValue > ArgVals)
Definition:ExternalFunctions.cpp:269
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition:SmallVector.h:638
llvm::SmallVectorTemplateCommon::data
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition:SmallVector.h:286
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::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::FunctionTyID
@ FunctionTyID
Functions.
Definition:Type.h:71
llvm::Type::ArrayTyID
@ ArrayTyID
Arrays.
Definition:Type.h:74
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::StructTyID
@ StructTyID
Structures.
Definition:Type.h:73
llvm::Type::IntegerTyID
@ IntegerTyID
Arbitrary bit width integers.
Definition:Type.h:70
llvm::Type::DoubleTyID
@ DoubleTyID
64-bit floating point type
Definition:Type.h:59
llvm::Type::PointerTyID
@ PointerTyID
Pointers.
Definition:Type.h:72
llvm::Type::getTypeID
TypeID getTypeID() const
Return the type id for the type.
Definition:Type.h:136
llvm::sys::DynamicLibrary::SearchForAddressOfSymbol
static void * SearchForAddressOfSymbol(const char *symbolName)
This function will search through all previously loaded dynamic libraries for the symbol symbolName.
Definition:DynamicLibrary.cpp:218
llvm::sys::SmartMutex< false >
uint32_t
uint8_t
Interpreter.h
ErrorHandling.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
llvm::sys::ScopedLock
SmartScopedLock< false > ScopedLock
Definition:Mutex.h:71
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::outs
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Definition:raw_ostream.cpp:895
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition:STLExtras.h:2115
llvm::PTOGV
GenericValue PTOGV(void *P)
Definition:GenericValue.h:49
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition:Error.cpp:167
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition:raw_ostream.cpp:907
llvm::PseudoProbeReservedId::Last
@ Last
llvm::GVTOP
void * GVTOP(const GenericValue &GV)
Definition:GenericValue.h:50
raw_ostream.h
llvm::GenericValue
Definition:GenericValue.h:23
llvm::GenericValue::FloatVal
float FloatVal
Definition:GenericValue.h:30
llvm::GenericValue::DoubleVal
double DoubleVal
Definition:GenericValue.h:29
llvm::GenericValue::IntVal
APInt IntVal
Definition:GenericValue.h:35

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

©2009-2025 Movatter.jp