clang 24.0.0git
CIRGenModule.h
Go to the documentation of this file.
1//===--- CIRGenModule.h - Per-Module state for CIR gen ----------*- 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 is the internal per-translation-unit state used for CIR translation.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H
14#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H
15
16#include "CIRGenBuilder.h"
17#include "CIRGenCUDARuntime.h"
18#include "CIRGenCall.h"
19#include "CIRGenOpenMPRuntime.h"
20#include "CIRGenTBAA.h"
21#include "CIRGenTypeCache.h"
22#include "CIRGenTypes.h"
23#include "CIRGenVTables.h"
24#include "CIRGenValue.h"
25
26#include "clang/AST/CharUnits.h"
29
30#include "TargetInfo.h"
31#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
32#include "mlir/IR/Builders.h"
33#include "mlir/IR/BuiltinOps.h"
34#include "mlir/IR/MLIRContext.h"
35#include "clang/AST/Decl.h"
40#include "llvm/ADT/SetVector.h"
41#include "llvm/ADT/SmallPtrSet.h"
42#include "llvm/ADT/StringMap.h"
43#include "llvm/ADT/StringRef.h"
44#include "llvm/TargetParser/Triple.h"
45
46namespace clang {
47class ASTContext;
48class CodeGenOptions;
49class Decl;
50class GlobalDecl;
51class LangOptions;
55class TargetInfo;
56class VarDecl;
57
58namespace CIRGen {
59
60class CIRGenFunction;
61class CIRGenCXXABI;
62
63enum ForDefinition_t : bool { NotForDefinition = false, ForDefinition = true };
64
65/// This class organizes the cross-function state that is used while generating
66/// CIR code.
67class CIRGenModule : public CIRGenTypeCache {
68 CIRGenModule(CIRGenModule &) = delete;
69 CIRGenModule &operator=(CIRGenModule &) = delete;
70
71public:
72 CIRGenModule(mlir::MLIRContext &mlirContext, clang::ASTContext &astContext,
73 const clang::CodeGenOptions &cgo,
75
77
78private:
79 mutable std::unique_ptr<TargetCIRGenInfo> theTargetCIRGenInfo;
80
81 CIRGenBuilderTy builder;
82
83 /// Hold Clang AST information.
84 clang::ASTContext &astContext;
85
86 const clang::LangOptions &langOpts;
87
88 /// Seeded from langOpts and then pushed and popped by clang::atomic.
89 clang::AtomicOptions atomicOpts;
90
91 const clang::CodeGenOptions &codeGenOpts;
92
93 /// A "module" matches a c/cpp source file: containing a list of functions.
94 mlir::OwningOpRef<mlir::ModuleOp> theModule;
95
96 /// Cached data layout for the module. Built lazily: the layout spec is
97 /// attached after construction, in CIRGenerator::Initialize.
98 mutable std::optional<cir::CIRDataLayout> dataLayout;
99
101
102 const clang::TargetInfo &target;
103
104 std::unique_ptr<CIRGenCXXABI> abi;
105
106 CIRGenTypes genTypes;
107
108 /// Holds information about C++ vtables.
109 CIRGenVTables vtables;
110
111 /// Holds the CUDA runtime
112 std::unique_ptr<CIRGenCUDARuntime> cudaRuntime;
113
114 /// Holds the OpenMP runtime
115 std::unique_ptr<CIRGenOpenMPRuntime> openMPRuntime;
116
117 /// Holds the TBAA information, if TBAA is enabled.
118 std::unique_ptr<CIRGenTBAA> tbaa;
119
120 /// Per-function codegen information. Updated everytime emitCIR is called
121 /// for FunctionDecls's.
122 CIRGenFunction *curCGF = nullptr;
123
125
126 /// Accumulated record layout entries, materialized in release().
127 llvm::SmallVector<mlir::NamedAttribute> recordLayoutEntries;
128
129 /// Whether C++20 named modules get their own module initializer function,
130 /// which requires the Itanium mangling of the initializer name.
131 bool cxx20ModuleInits = false;
132
133 /// The complete set of modules that have been imported.
134 llvm::SetVector<clang::Module *> importedModules;
135
136 /// The location of the first import declaration of each imported module.
137 llvm::DenseMap<clang::Module *, clang::SourceLocation> moduleImportLocs;
138
139 /// The set of modules for which the module initializers have been emitted.
140 llvm::SmallPtrSet<clang::Module *, 16> emittedModuleInitializers;
141
142 /// The Itanium-mangled name of the initializer function of a C++20 named
143 /// module.
144 std::string getModuleInitializerName(clang::Module *mod);
145
146 llvm::DenseSet<clang::GlobalDecl> diagnosedConflictingDefinitions;
147
148 /// Symbols created as the target of a weakref. They are extern_weak until
149 /// something names them in a way that is not itself weak, such as an
150 /// ordinary declaration or definition of the target.
152
153 /// -------
154 /// Annotations
155 /// -------
156
157 /// We store each annotation as an attribute of GlobalOp and FuncOp rather
158 /// than collecting them into a single module-level list. The deferred map
159 /// lets us attach annotations at the end of codegen so the most up-to-date
160 /// ValueDecl (which carries all inherited annotations) is used.
161
162 /// Used for uniquing of annotation arguments.
163 llvm::DenseMap<unsigned, mlir::ArrayAttr> annotationArgs;
164
165 /// Store deferred function annotations so they can be emitted at the end
166 /// with the most up to date ValueDecl that will have all the inherited
167 /// annotations.
168 llvm::DenseMap<llvm::StringRef, const clang::ValueDecl *> deferredAnnotations;
169
170 /// A queue of (optional) vtables to consider emitting.
171 std::vector<const CXXRecordDecl *> deferredVTables;
172
173 /// Cache of type ids for virtual member function pointer types.
174 llvm::DenseMap<QualType, mlir::StringAttr> virtualMetadataIdMap;
175
176 /// A queue of (optional) vtables that may be emitted opportunistically.
177 std::vector<const CXXRecordDecl *> opportunisticVTables;
178
179 void createCUDARuntime();
180 void createOpenMPRuntime();
181 void setOpenCLVersionAttr(llvm::StringRef attrName, unsigned version);
182
183 /// A helper for constructAttributeList that handles return attributes.
184 void constructFunctionReturnAttributes(const CIRGenFunctionInfo &info,
185 const Decl *targetDecl, bool isThunk,
186 mlir::NamedAttrList &retAttrs);
187 /// A helper for constructAttributeList that handles argument attributes.
188 void constructFunctionArgumentAttributes(
189 const CIRGenFunctionInfo &info, clang::GlobalDecl calleeDecl,
190 bool isThunk, bool attrOnCallSite,
192 /// A helper function for constructAttributeList that determines whether a
193 /// return value might have been discarded.
194 bool mayDropFunctionReturn(const ASTContext &context, QualType retTy);
195 /// A helper function for constructAttributeList that determines whether
196 /// `noundef` on a return is possible.
197 bool hasStrictReturn(QualType retTy, const Decl *targetDecl);
198
199 llvm::DenseMap<const Expr *, mlir::Operation *>
200 materializedGlobalTemporaryMap;
201
202public:
203 mlir::ModuleOp getModule() const { return *theModule; }
204 CIRGenBuilderTy &getBuilder() { return builder; }
205
206 /// Queue a record layout entry for materialization in release().
207 void addRecordLayout(mlir::StringAttr name, cir::RecordLayoutAttr attr) {
208 recordLayoutEntries.push_back(mlir::NamedAttribute(name, attr));
209 }
210 clang::ASTContext &getASTContext() const { return astContext; }
211 const clang::TargetInfo &getTarget() const { return target; }
212 const clang::CodeGenOptions &getCodeGenOpts() const { return codeGenOpts; }
213 clang::DiagnosticsEngine &getDiags() const { return diags; }
214 CIRGenTypes &getTypes() { return genTypes; }
215 const clang::LangOptions &getLangOpts() const { return langOpts; }
216
217 /// The atomic options in effect at the point currently being emitted.
218 /// clang::atomic adjusts these for the extent of the statement it is attached
219 /// to, so they are module state rather than a fixed language option.
220 clang::AtomicOptions getAtomicOpts() const { return atomicOpts; }
221 void setAtomicOpts(clang::AtomicOptions opts) { atomicOpts = opts; }
222
223 CIRGenCXXABI &getCXXABI() const { return *abi; }
224 mlir::MLIRContext &getMLIRContext() { return *builder.getContext(); }
225
227 if (!dataLayout)
228 dataLayout.emplace(getModule());
229 return *dataLayout;
230 }
231
232 /// -------
233 /// Handling globals
234 /// -------
235
236 mlir::Operation *lastGlobalOp = nullptr;
237
238 /// Keep a map between lambda fields and names, this needs to be per module
239 /// since lambdas might get generated later as part of defered work, and since
240 /// the pointers are supposed to be uniqued, should be fine. Revisit this if
241 /// it ends up taking too much memory.
242 llvm::DenseMap<const clang::FieldDecl *, llvm::StringRef> lambdaFieldToName;
243
244 /// Add a global value to the llvmUsed list.
245 void addUsedGlobal(cir::CIRGlobalValueInterface gv);
246
247 /// Add a global value to the llvmCompilerUsed list.
248 void addCompilerUsedGlobal(cir::CIRGlobalValueInterface gv);
249
250 /// Add a global to a list to be added to the llvm.compiler.used metadata.
251 void addUsedOrCompilerUsedGlobal(cir::CIRGlobalValueInterface gv);
252
253 /// Emit llvm.used and llvm.compiler.used globals.
254 void emitLLVMUsed();
255
256 /// Tell the consumer that this variable has been instantiated.
258
259 llvm::DenseMap<const Decl *, cir::GlobalOp> staticLocalDeclMap;
260 llvm::DenseMap<const VarDecl *, cir::GlobalOp> initializerConstants;
261
262 /// Cache for O(1) symbol lookups by name, replacing the O(N) linear scan
263 /// in SymbolTable::lookupSymbolIn that getGlobalValue used previously.
264 llvm::StringMap<mlir::Operation *> symbolLookupCache;
265
266 mlir::Operation *getGlobalValue(llvm::StringRef ref);
267
268 /// O(1) lookup of a FuncOp by name in the symbol cache.
269 /// Returns nullptr if the name is not found or is not a FuncOp.
270 cir::FuncOp lookupFuncOp(llvm::StringRef name) {
271 auto *op = getGlobalValue(name);
272 return op ? mlir::dyn_cast<cir::FuncOp>(op) : cir::FuncOp{};
273 }
274
275 void insertGlobalSymbol(mlir::Operation *op) {
276 if (auto sym = mlir::dyn_cast<mlir::SymbolOpInterface>(op))
277 symbolLookupCache[sym.getName()] = op;
278 }
279 void eraseGlobalSymbol(mlir::Operation *op) {
280 if (auto sym = mlir::dyn_cast<mlir::SymbolOpInterface>(op)) {
281 auto it = symbolLookupCache.find(sym.getName());
282 if (it != symbolLookupCache.end() && it->second == op)
283 symbolLookupCache.erase(it);
284 }
285 }
286
287 cir::GlobalOp getStaticLocalDeclAddress(const VarDecl *d) {
288 return staticLocalDeclMap[d];
289 }
290
291 void setStaticLocalDeclAddress(const VarDecl *d, cir::GlobalOp c) {
292 staticLocalDeclMap[d] = c;
293 }
294
295 cir::GlobalOp getOrCreateStaticVarDecl(const VarDecl &d,
296 cir::GlobalLinkageKind linkage);
297
298 Address createUnnamedGlobalFrom(const VarDecl &d, mlir::Attribute constAttr,
299 CharUnits align);
300
301 /// If the specified mangled name is not in the module, create and return an
302 /// mlir::GlobalOp value
303 cir::GlobalOp getOrCreateCIRGlobal(llvm::StringRef mangledName, mlir::Type ty,
304 LangAS langAS, mlir::Location loc,
305 const VarDecl *d,
306 ForDefinition_t isForDefinition);
307
308 cir::GlobalOp getOrCreateCIRGlobal(const VarDecl *d, mlir::Type ty,
309 ForDefinition_t isForDefinition);
310
311 /// Return the symbol that a weakref declaration refers to: the cir.func or
312 /// cir.global named by its alias target, declared extern_weak if it did not
313 /// already exist.
314 mlir::Operation *getWeakRefReference(const clang::ValueDecl *vd);
315
316 cir::GlobalOp
317 createGlobalOp(mlir::Location loc, llvm::StringRef name, mlir::Type t,
318 bool isConstant = false,
319 mlir::ptr::MemorySpaceAttrInterface addrSpace = {},
320 mlir::Operation *insertPoint = nullptr);
321
322 /// Add a global constructor or destructor to the module.
323 /// The priority is optional, if not specified, the default priority is used.
324 void addGlobalCtor(cir::FuncOp ctor,
325 std::optional<int> priority = std::nullopt);
326 void addGlobalDtor(cir::FuncOp dtor,
327 std::optional<int> priority = std::nullopt);
328
330 // In C23 (N3096) $6.7.10:
331 // """
332 // If any object is initialized with an empty initializer, then it is
333 // subject to default initialization:
334 // - if it is an aggregate, every member is initialized (recursively)
335 // according to these rules, and any padding is initialized to zero bits;
336 // - if it is a union, the first named member is initialized (recursively)
337 // according to these rules, and any padding is initialized to zero bits.
338 //
339 // If the aggregate or union contains elements or members that are
340 // aggregates or unions, these rules apply recursively to the subaggregates
341 // or contained unions.
342 //
343 // If there are fewer initializers in a brace-enclosed list than there are
344 // elements or members of an aggregate, or fewer characters in a string
345 // literal used to initialize an array of known size than there are elements
346 // in the array, the remainder of the aggregate is subject to default
347 // initialization.
348 // """
349 //
350 // The standard seems ambiguous in the following two areas:
351 // 1. For a union type with empty initializer, if the first named member is
352 // not the largest member, then the bytes comes after the first named member
353 // but before padding are left unspecified. An example is:
354 // union U { int a; long long b;};
355 // union U u = {}; // The first 4 bytes are 0, but 4-8 bytes are left
356 // unspecified.
357 //
358 // 2. It only mentions padding for empty initializer, but doesn't mention
359 // padding for a non empty initialization list. And if the aggregation or
360 // union contains elements or members that are aggregates or unions, and
361 // some are non empty initializers, while others are empty initializers,
362 // the padding initialization is unclear. An example is:
363 // struct S1 { int a; long long b; };
364 // struct S2 { char c; struct S1 s1; };
365 // // The values for paddings between s2.c and s2.s1.a, between s2.s1.a
366 // and s2.s1.b are unclear.
367 // struct S2 s2 = { 'c' };
368 //
369 // Here we choose to zero initiailize left bytes of a union type because
370 // projects like the Linux kernel are relying on this behavior. If we don't
371 // explicitly zero initialize them, the undef values can be optimized to
372 // return garbage data. We also choose to zero initialize paddings for
373 // aggregates and unions, no matter they are initialized by empty
374 // initializers or non empty initializers. This can provide a consistent
375 // behavior. So projects like the Linux kernel can rely on it.
376 return !getLangOpts().CPlusPlus;
377 }
378
379 llvm::StringMap<unsigned> cgGlobalNames;
380 std::string getUniqueGlobalName(const std::string &baseName);
381
382 /// Return the mlir::Value for the address of the given global variable.
383 /// If Ty is non-null and if the global doesn't exist, then it will be created
384 /// with the specified type instead of whatever the normal requested type
385 /// would be. If IsForDefinition is true, it is guaranteed that an actual
386 /// global with type Ty will be returned, not conversion of a variable with
387 /// the same mangled name but some other type.
388 mlir::Value
389 getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty = {},
390 ForDefinition_t isForDefinition = NotForDefinition);
391
392 /// Cast \p addr, the address of the global \p vd, to the address space of
393 /// the declared type of \p vd if they differ.
394 mlir::Value castGlobalToDeclAddrSpace(mlir::Value addr, const VarDecl &vd);
395
396 /// Get or create a thunk function with the given name and type.
397 cir::FuncOp getAddrOfThunk(StringRef name, mlir::Type fnTy, GlobalDecl gd);
398
399 /// Return the mlir::GlobalViewAttr for the address of the given global.
400 cir::GlobalViewAttr getAddrOfGlobalVarAttr(const VarDecl *d);
401
402 /// Get the GlobalOp of a template parameter object.
403 cir::GlobalOp
405 // Get the GlobalOp of a source_location object.
406 cir::GlobalOp
408
410 const CXXRecordDecl *derivedClass,
411 llvm::iterator_range<CastExpr::path_const_iterator> path);
412
413 /// Get the CIR attributes and calling convention to use for a particular
414 /// function type.
415 ///
416 /// \param name - The function name.
417 /// \param info - The function type information.
418 /// \param calleeInfo - The callee information these attributes are being
419 /// constructed for. If valid, the attributes applied to this decl may
420 /// contribute to the function attributes and calling convention.
421 /// \param attrs [out] - On return, the attribute list to use.
422 /// \param callingConv [out] - On return, the calling convention to use.
423 /// \param attrOnCallSite - Whether or not the attributes are on a call site.
424 /// \param isThunk - Whether the function is a thunk.
426 llvm::StringRef name, const CIRGenFunctionInfo &info,
427 CIRGenCalleeInfo calleeInfo, mlir::NamedAttrList &attrs,
429 mlir::NamedAttrList &retAttrs, cir::CallingConv &callingConv,
430 bool attrOnCallSite, bool isThunk);
431 /// Helper function for constructAttributeList/others. Builds a set of
432 /// function attributes to add to a function based on language opts, codegen
433 /// opts, and some small properties.
434 void addDefaultFunctionAttributes(StringRef name, bool hasOptNoneAttr,
435 bool attrOnCallSite,
436 mlir::NamedAttrList &attrs);
437
438 /// Returns the frame pointer kind to record on functions and on the module,
439 /// or std::nullopt when \p kind is CodeGenOptions::FramePointerKind::None,
440 /// the default, which is left implicit.
441 static std::optional<cir::FramePointerKind>
443
444 /// Will return a global variable of the given type. If a variable with a
445 /// different type already exists then a new variable with the right type
446 /// will be created and all uses of the old variable will be replaced with a
447 /// bitcast to the new variable.
449 mlir::Location loc, llvm::StringRef name, mlir::Type ty,
450 cir::GlobalLinkageKind linkage, clang::CharUnits alignment);
451
452 void emitVTable(const CXXRecordDecl *rd);
453
454 /// Return the appropriate linkage for the vtable, VTT, and type information
455 /// of the given class.
456 cir::GlobalLinkageKind getVTableLinkage(const CXXRecordDecl *rd);
457
458 /// Get the address of the RTTI descriptor for the given type.
459 mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc, QualType ty,
460 bool forEH = false);
461
462 static cir::VisibilityKind getCIRVisibilityKind(Visibility v) {
463 switch (v) {
465 return cir::VisibilityKind::Default;
466 case HiddenVisibility:
467 return cir::VisibilityKind::Hidden;
469 return cir::VisibilityKind::Protected;
470 }
471
472 llvm_unreachable("unknown visibility!");
473 }
474
475 llvm::DenseMap<mlir::Attribute, cir::GlobalOp> constantStringMap;
476 llvm::DenseMap<const UnnamedGlobalConstantDecl *, cir::GlobalOp>
478 llvm::DenseMap<const CompoundLiteralExpr *, cir::GlobalOp>
480
481 cir::GlobalOp
486 cir::GlobalOp gv) {
487 [[maybe_unused]] bool ok = emittedCompoundLiterals.insert({e, gv}).second;
488 assert(ok && "compound literal global already emitted");
489 }
490
491 /// Return a constant array for the given string.
492 mlir::Attribute getConstantArrayFromStringLiteral(const StringLiteral *e);
493
494 /// Return a global symbol reference to a constant array for the given string
495 /// literal.
496 cir::GlobalOp getGlobalForStringLiteral(const StringLiteral *s,
497 llvm::StringRef name = ".str");
498
499 /// Return a global symbol reference to a constant array for the given string
500 /// literal.
501 cir::GlobalViewAttr
503 llvm::StringRef name = ".str");
504
505 /// Create a private constant global holding the null-terminated string
506 /// \p str, mirroring llvm::IRBuilder::CreateGlobalString.
507 cir::GlobalOp createGlobalString(mlir::Location loc, llvm::StringRef str,
508 llvm::StringRef name);
509
510 /// Returns the address space for temporary allocations in the language. This
511 /// ensures that the allocated variable's address space matches the
512 /// expectations of the AST, rather than using the target's allocation address
513 /// space, which may lead to type mismatches in other parts of the IR.
515
516 /// Return the AST address space of the underlying global variable for D, as
517 /// determined by its declaration. Normally this is the same as the address
518 /// space of D's type, but in CUDA, address spaces are associated with
519 /// declarations, not types. If D is nullptr, return the default address
520 /// space for global variable.
521 ///
522 /// For languages without explicit address spaces, if D has default address
523 /// space, target-specific global or constant address space may be returned.
525
526 /// Return the CIR address space attribute for a global in \p as, honoring
527 /// the target address space map where the LangAS fold would lose it.
528 mlir::ptr::MemorySpaceAttrInterface getGlobalCIRAddressSpace(LangAS as);
529
530 /// Set attributes which are common to any form of a global definition (alias,
531 /// Objective-C method, function, global variable).
532 ///
533 /// NOTE: This should only be called for definitions.
534 void setCommonAttributes(GlobalDecl gd, mlir::Operation *op);
535
537
538 /// Helpers to convert the presumed location of Clang's SourceLocation to an
539 /// MLIR Location.
540 mlir::Location getLoc(clang::SourceLocation cLoc);
541 mlir::Location getLoc(clang::SourceRange cRange);
542
543 /// Return the best known alignment for an unknown pointer to a
544 /// particular class.
546
547 /// FIXME: this could likely be a common helper and not necessarily related
548 /// with codegen.
550 LValueBaseInfo *baseInfo = nullptr,
551 TBAAAccessInfo *tbaaInfo = nullptr,
552 bool forPointeeType = false);
555 LValueBaseInfo *baseInfo = nullptr,
556 TBAAAccessInfo *tbaaInfo = nullptr);
557
558 /// Returns the minimum object size for an object of the given class type
559 /// (or a class derived from it).
561
562 /// Returns the minimum object size for an object of the given type.
568
569 /// Returns the type descriptor used to describe accesses to objects of the
570 /// given type, or null if TBAA is disabled.
572
573 /// Returns the TBAA information that describes an access to an object of the
574 /// given type.
576
577 /// Returns the type descriptor that describes the given base access type, or
578 /// null if the type is not suitable for use in TBAA access tags.
580
581 /// Returns the TBAA access tag for the given memory access.
582 cir::TBAATagAttr getTBAAAccessTagInfo(TBAAAccessInfo tbaaInfo);
583
584 /// Returns the merged TBAA information for the purpose of type casts.
586 TBAAAccessInfo targetInfo);
587
588 /// Returns the merged TBAA information for the purpose of conditional
589 /// operator.
591 TBAAAccessInfo infoB);
592
593 /// Returns the TBAA information for an access with a given base lvalue.
595 if (base.getTBAAInfo().isMayAlias())
597 return getTBAAAccessInfo(accessType);
598 }
599
600 /// Attaches the TBAA access tag of \p tbaaInfo to the load or store \p op.
601 template <typename OpTy>
603 static_assert(llvm::is_one_of<OpTy, cir::LoadOp, cir::StoreOp>::value,
604 "expected a load or a store");
605 if (cir::TBAATagAttr tag = getTBAAAccessTagInfo(tbaaInfo))
606 op.setTbaaAttr(tag);
607 }
608
609 /// TODO: Add TBAAAccessInfo
611 const CXXRecordDecl *baseDecl,
612 CharUnits expectedTargetAlign);
613
614 /// Returns the assumed alignment of a virtual base of a class.
616 const CXXRecordDecl *derived,
617 const CXXRecordDecl *vbase);
618
619 cir::FuncOp
621 const CIRGenFunctionInfo *fnInfo = nullptr,
622 cir::FuncType fnType = nullptr, bool dontDefer = false,
623 ForDefinition_t isForDefinition = NotForDefinition) {
624 return getAddrAndTypeOfCXXStructor(gd, fnInfo, fnType, dontDefer,
625 isForDefinition)
626 .second;
627 }
628
629 std::pair<cir::FuncType, cir::FuncOp> getAddrAndTypeOfCXXStructor(
630 clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo = nullptr,
631 cir::FuncType fnType = nullptr, bool dontDefer = false,
632 ForDefinition_t isForDefinition = NotForDefinition);
633
634 /// List of global values which are required to be present in the object file;
635 /// This is used for forcing visibility of symbols which may otherwise be
636 /// optimized out.
637 std::vector<cir::CIRGlobalValueInterface> llvmUsed;
638 std::vector<cir::CIRGlobalValueInterface> llvmCompilerUsed;
639
640 mlir::Type getVTableComponentType();
641 CIRGenVTables &getVTables() { return vtables; }
642
644 return vtables.getItaniumVTableContext();
645 }
647 return vtables.getItaniumVTableContext();
648 }
649
650 /// This contains all the decls which have definitions but which are deferred
651 /// for emission and therefore should only be output if they are actually
652 /// used. If a decl is in this, then it is known to have not been referenced
653 /// yet.
654 std::map<llvm::StringRef, clang::GlobalDecl> deferredDecls;
655
656 // This is a list of deferred decls which we have seen that *are* actually
657 // referenced. These get code generated when the module is done.
658 std::vector<clang::GlobalDecl> deferredDeclsToEmit;
660 deferredDeclsToEmit.emplace_back(GD);
661 }
662
664
665 /// Determine whether the definition must be emitted; if this returns \c
666 /// false, the definition can be emitted lazily if it's used.
667 bool mustBeEmitted(const clang::ValueDecl *d);
668
669 /// Check if `fd` ends up calling itself directly through asm label or
670 /// builtin-pointer-to-self trickery (e.g., glibc's `extern inline` libc
671 /// wrappers that call `__builtin_strrchr`, which the codegen lowers to a
672 /// call on the same asm-named symbol). Emitting an
673 /// `available_externally` body for such a function feeds the LLVM
674 /// Decide whether to emit the body of `gd` to CIR. Returns false for
675 /// available_externally functions that are trivially recursive (PR9614).
676 /// Mirrors classic CodeGen's `CodeGenModule::shouldEmitFunction`.
678
679 /// Determine whether the definition can be emitted eagerly, or should be
680 /// delayed until the end of the translation unit. This is relevant for
681 /// definitions whose linkage can change, e.g. implicit function
682 /// instantiations which may later be explicitly instantiated.
684
685 bool verifyModule() const;
686
687 /// Return the address of the given function. If funcType is non-null, then
688 /// this function will use the specified type if it has to create it.
689 // TODO: this is a bit weird as `GetAddr` given we give back a FuncOp?
690 cir::FuncOp
691 getAddrOfFunction(clang::GlobalDecl gd, mlir::Type funcType = nullptr,
692 bool forVTable = false, bool dontDefer = false,
693 ForDefinition_t isForDefinition = NotForDefinition);
694
695 mlir::Operation *
697 ForDefinition_t isForDefinition = NotForDefinition);
698
699 /// Return a function pointer for a reference to the given function.
700 /// This correctly handles weak references, but does not apply a
701 /// pointer signature.
702 cir::FuncOp getRawFunctionPointer(GlobalDecl GD);
703
704 /// Return the ABI-correct function pointer value for a reference
705 /// to the given function. This will apply a pointer signature if
706 /// necessary, caching the result for the given function.
707 cir::FuncOp getFunctionPointer(GlobalDecl GD);
708
709 /// Return true if a vtable with the given linkage may have more than one
710 /// address in the program, in which case its address is insignificant and it
711 /// can be marked unnamed_addr.
712 bool mayVTableBeDuplicated(cir::GlobalLinkageKind linkage) const;
713
714 /// Attach !type metadata to \p vtable.
715 void emitVTableTypeMetadata(const CXXRecordDecl *rd, cir::GlobalOp vtable,
716 const VTableLayout &vtLayout);
717
718 /// Type metadata entry \p typeId for \p t at \p offset.
719 cir::TypeMetadataAttr createTypeMetadata(QualType t, CharUnits offset,
720 mlir::StringAttr typeId);
721
722 /// Type id of the virtual member function pointer type \p t.
723 mlir::StringAttr getVirtualMemPtrTypeId(QualType t);
724
725 // Return whether RTTI information should be emitted for this target.
726 bool shouldEmitRTTI(bool forEH = false) {
727 return (forEH || getLangOpts().RTTI) &&
728 (!getLangOpts().isTargetDevice() || !getTriple().isGPU());
729 }
730
731 /// Emit type info if type of an expression is a variably modified
732 /// type. Also emit proper debug info for cast types.
734 CIRGenFunction *cgf = nullptr);
735
737 deferredVTables.push_back(rd);
738 }
739
740 /// Emit code for a single global function or variable declaration. Forward
741 /// declarations are emitted lazily.
743
744 /// Emit `aliasGD` as an alias of `aliasee`, replacing any existing
745 /// declaration `op`, and return the alias.
746 cir::FuncOp emitAliasForGlobal(llvm::StringRef mangledName,
747 mlir::Operation *op, GlobalDecl aliasGD,
748 cir::FuncOp aliasee,
749 cir::GlobalLinkageKind linkage);
750
751 /// Emit a definition for an `__attribute__((alias))` declaration.
753
754 mlir::Type convertType(clang::QualType type);
755
756 /// Set the visibility for the given global.
757 void setGlobalVisibility(cir::CIRGlobalValueInterface gv,
758 const NamedDecl *d) const;
759 void setDSOLocal(mlir::Operation *op) const;
760 void setDSOLocal(cir::CIRGlobalValueInterface gv) const;
761
762 /// Set visibility, dllimport/dllexport and dso_local.
763 /// This must be called after dllimport/dllexport is set.
764 void setGVProperties(mlir::Operation *op, const NamedDecl *d) const;
765 void setGVPropertiesAux(mlir::Operation *op, const NamedDecl *d) const;
766
767 /// Set TLS mode for the given operation based on the given variable
768 /// declaration. If `isExtendingDecl` is true, then the operation is a
769 /// temporary whose lifetime is extended by the variable declared by `d`.
770 void setTLSMode(mlir::Operation *op, const VarDecl &d,
771 bool isExtendingDecl = false);
772
773 /// Get TLS mode from CodeGenOptions.
774 cir::TLSModel getDefaultCIRTLSModel() const;
775
776 /// Set function attributes for a function declaration.
777 void setFunctionAttributes(GlobalDecl gd, cir::FuncOp f,
778 bool isIncompleteFunction, bool isThunk);
779
780 /// Set the CIR function attributes (Sext, zext, etc).
782 cir::FuncOp func, bool isThunk);
783
784 /// Set extra attributes (inline, etc.) for a function.
786 cir::FuncOp f);
787
788 /// Generate OpenCL kernel argument metadata for a kernel function.
789 void emitOpenCLKernelArgMetadata(cir::FuncOp func,
790 const clang::FunctionDecl *fd);
791
793 mlir::Operation *op = nullptr);
794 void emitGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op);
795
796 /// Emit the SYCL kernel caller offload entry point function generated for a
797 /// function declared with the sycl_kernel_entry_point attribute.
798 void emitSYCLKernelCaller(const clang::FunctionDecl *kernelEntryPointFn,
799 clang::ASTContext &ctx);
800
801 void addSYCLModuleIdAttr(cir::FuncOp fn);
803 bool isTentative = false);
804
805 /// Helper function for the below two that will create the
806 /// constructor/destructor in specified regions, rather than in the GlobalOp.
807 void emitCXXSpecialVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr,
808 bool performInit, mlir::Region &ctorRegion,
809 mlir::Region &dtorRegion);
810 /// Emit the function that initializes the specified static-local variable.
811 void emitCXXStaticLocalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr,
812 bool performInit);
813 /// Emit the function that initializes the specified global
814 void emitCXXGlobalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr,
815 bool performInit);
816
817 void setGlobalTlsReferences(const VarDecl &vd, cir::GlobalOp globalOp);
818 void emitCXXGlobalVarDeclInitFunc(const VarDecl *vd, cir::GlobalOp addr,
819 bool performInit);
820
824 template <typename BeforeOpTy, typename DataClauseTy>
825 void emitGlobalOpenACCDeclareDataOperands(const Expr *varOperand,
826 DataClauseTy dataClause,
827 OpenACCModifierKind modifiers,
828 bool structured, bool implicit,
829 bool requiresDtor);
830 // Each of the acc.routine operations must have a unique name, so we just use
831 // an integer counter. This is how Flang does it, so it seems reasonable.
832 unsigned routineCounter = 0;
833 void emitOpenACCRoutineDecl(const clang::FunctionDecl *funcDecl,
834 cir::FuncOp func, SourceLocation pragmaLoc,
836
844
845 // C++ related functions.
846 void emitDeclContext(const DeclContext *dc);
847
848 /// Return the result of value-initializing the given type, i.e. a null
849 /// expression of the given type.
850 mlir::Value emitNullConstant(QualType t, mlir::Location loc);
851
852 mlir::TypedAttr emitNullConstantAttr(QualType t);
853
854 /// Get target specific null pointer.
855 mlir::Value getNullPointer(cir::PointerType ptrTy, QualType qt,
856 mlir::Location loc);
857
858 /// Return a null constant appropriate for zero-initializing a base class with
859 /// the given type. This is usually, but not always, an LLVM null constant.
860 mlir::TypedAttr emitNullConstantForBase(const CXXRecordDecl *record);
861
862 mlir::Value emitMemberPointerConstant(const UnaryOperator *e);
863 /// Returns a null attribute to represent either a null method or null data
864 /// member, depending on the type of mpt.
865 mlir::TypedAttr emitNullMemberAttr(QualType t, const MemberPointerType *mpt);
866
867 /// Build a GEP-style field-index path from \p destClass to \p decl.
868 /// \p decl may be a FieldDecl, or an IndirectFieldDecl(in the case of an
869 /// anonymous struct/union).
870 /// Returns std::nullopt and emits errorNYI for virtual-base paths.
871 std::optional<llvm::SmallVector<int32_t>>
872 buildMemberPath(const CXXRecordDecl *destClass, const ValueDecl *decl);
873
874 /// Returns true if \p field is a potentially-overlapping field with no CIR
875 /// field index (e.g. a [[no_unique_address]] member that is empty for both
876 /// layout and the ABI). Such fields have no entry in the CIR record, so a
877 /// pointer-to-data-member to them is represented by an explicit byte offset
878 /// (#cir.data_member_offset) rather than a field-index path.
879 bool isEmptyFieldForMemberPointer(const FieldDecl *field);
880
881 llvm::StringRef getMangledName(clang::GlobalDecl gd);
882 // This function is to support the OpenACC 'bind' clause, which names an
883 // alternate name for the function to be called by. This function mangles
884 // `attachedFunction` as-if its name was actually `bindName` (that is, with
885 // the same signature). It has some additional complications, as the 'bind'
886 // target is always going to be a global function, so member functions need an
887 // explicit instead of implicit 'this' parameter, and thus gets mangled
888 // differently.
889 std::string getOpenACCBindMangledName(const IdentifierInfo *bindName,
890 const FunctionDecl *attachedFunction);
891
892 void emitTentativeDefinition(const VarDecl *d);
893
894 // Make sure that this type is translated.
895 void updateCompletedType(const clang::TagDecl *td);
896
897 // Produce code for this constructor/destructor. This method doesn't try to
898 // apply any ABI rules about which other constructors/destructors are needed
899 // or if they are alias to each other.
901
902 bool lookupRepresentativeDecl(llvm::StringRef mangledName,
903 clang::GlobalDecl &gd) const;
904
905 bool supportsCOMDAT() const;
906 void maybeSetTrivialComdat(const clang::Decl &d, mlir::Operation *op);
907
908 static void setInitializer(cir::GlobalOp &op, mlir::Attribute value);
909
910 /// Print the postfix for externalized static variable or kernels for single
911 /// source offloading languages CUDA and HIP. The unique postfix is created
912 /// using either the CUID argument, or the file's UniqueID and active macros.
913 /// The fallback method without a CUID requires that the offloading toolchain
914 /// does not define separate macros via the -cc1 options.
915 void printPostfixForExternalizedDecl(llvm::raw_ostream &os, const Decl *d);
916
917 /// Replace all uses of the old global with the new global, updating types
918 /// and references as needed. Erases the old global when done.
919 void replaceGlobal(cir::GlobalOp oldGV, cir::GlobalOp newGV);
920
921 void replaceUsesOfNonProtoTypeWithRealFunction(mlir::Operation *old,
922 cir::FuncOp newFn);
923
924 cir::FuncOp
925 getOrCreateCIRFunction(llvm::StringRef mangledName, mlir::Type funcType,
926 clang::GlobalDecl gd, bool forVTable,
927 bool dontDefer = false, bool isThunk = false,
928 ForDefinition_t isForDefinition = NotForDefinition,
929 mlir::NamedAttrList extraAttrs = {});
930
931 cir::FuncOp getOrCreateCIRFunction(llvm::StringRef mangledName,
932 mlir::Type funcType, clang::GlobalDecl gd,
933 bool forVTable,
934 mlir::NamedAttrList extraAttrs) {
935 return getOrCreateCIRFunction(mangledName, funcType, gd, forVTable,
936 /*dontDefer=*/false, /*isThunk=*/false,
937 NotForDefinition, extraAttrs);
938 }
939
940 cir::FuncOp createCIRFunction(mlir::Location loc, llvm::StringRef name,
941 cir::FuncType funcType,
942 const clang::FunctionDecl *funcDecl);
943
944 /// Create a CIR function with builtin attribute set.
945 cir::FuncOp createCIRBuiltinFunction(mlir::Location loc, llvm::StringRef name,
946 cir::FuncType ty,
947 const clang::FunctionDecl *fd);
948
949 /// Record the func_info tag for a function, either a C++ special member
950 /// form (constructor, destructor, assignment) or a known standard library
951 /// entity that passes can recognize without the AST.
952 void setFuncInfoAttr(cir::FuncOp funcOp, const clang::FunctionDecl *funcDecl);
953
954 cir::FuncOp createRuntimeFunction(cir::FuncType ty, llvm::StringRef name,
955 mlir::NamedAttrList extraAttrs = {},
956 bool isLocal = false,
957 bool assumeConvergent = false);
958
959 /// Given a builtin id for a function like "__builtin_fabsf", return a
960 /// Function* for "fabsf".
961 cir::FuncOp getBuiltinLibFunction(const FunctionDecl *fd, unsigned builtinID);
962
964 assert(cudaRuntime != nullptr);
965 return *cudaRuntime;
966 }
967
969 assert(openMPRuntime != nullptr);
970 return *openMPRuntime;
971 }
972
975
976 mlir::IntegerAttr getSize(CharUnits size) {
977 return builder.getSizeFromCharUnits(size);
978 }
979
980 /// Emit any needed decls for which code generation was deferred.
981 void emitDeferred();
982
984 /// Emit any vtables which we deferred and still have a use for.
985 void emitDeferredVTables();
986
987 /// Try to emit external vtables as available_externally if they have emitted
988 /// all inlined virtual functions. It runs after EmitDeferred() and therefore
989 /// is not allowed to create new references to things that need to be emitted
990 /// lazily.
992
993 /// Helper for `emitDeferred` to apply actual codegen.
994 void emitGlobalDecl(const clang::GlobalDecl &d);
995
996 const llvm::Triple &getTriple() const { return target.getTriple(); }
997
998 // Finalize CIR code generation.
999 void release();
1000
1001 /// Returns a pointer to a global variable representing a temporary with
1002 /// static or thread storage duration.
1003 mlir::Operation *getAddrOfGlobalTemporary(const MaterializeTemporaryExpr *mte,
1004 const Expr *init);
1005
1006 /// -------
1007 /// Visibility and Linkage
1008 /// -------
1009
1010 static mlir::SymbolTable::Visibility
1011 getMLIRVisibilityFromCIRLinkage(cir::GlobalLinkageKind GLK);
1012 cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd);
1013 static mlir::SymbolTable::Visibility getMLIRVisibility(cir::GlobalOp op);
1014 cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd,
1015 GVALinkage linkage);
1016 void setFunctionLinkage(GlobalDecl gd, cir::FuncOp f) {
1017 cir::GlobalLinkageKind l = getFunctionLinkage(gd);
1018 f.setLinkageAttr(cir::GlobalLinkageKindAttr::get(&getMLIRContext(), l));
1019 mlir::SymbolTable::setSymbolVisibility(f,
1021 }
1022
1023 cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd);
1024
1025 void addReplacement(llvm::StringRef name, mlir::Operation *op);
1026
1027 /// Helpers to emit "not yet implemented" error diagnostics
1028 DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef);
1029
1030 template <typename T>
1031 DiagnosticBuilder errorNYI(SourceLocation loc, llvm::StringRef feature,
1032 const T &name) {
1033 unsigned diagID =
1034 diags.getCustomDiagID(DiagnosticsEngine::Error,
1035 "ClangIR code gen Not Yet Implemented: %0: %1");
1036 return diags.Report(loc, diagID) << feature << name;
1037 }
1038
1039 DiagnosticBuilder errorNYI(mlir::Location loc, llvm::StringRef feature) {
1040 // TODO: Convert the location to a SourceLocation
1041 unsigned diagID = diags.getCustomDiagID(
1042 DiagnosticsEngine::Error, "ClangIR code gen Not Yet Implemented: %0");
1043 return diags.Report(diagID) << feature;
1044 }
1045
1046 DiagnosticBuilder errorNYI(llvm::StringRef feature) const {
1047 // TODO: Make a default location? currSrcLoc?
1048 unsigned diagID = diags.getCustomDiagID(
1049 DiagnosticsEngine::Error, "ClangIR code gen Not Yet Implemented: %0");
1050 return diags.Report(diagID) << feature;
1051 }
1052
1053 DiagnosticBuilder errorNYI(SourceRange, llvm::StringRef);
1054
1055 template <typename T>
1056 DiagnosticBuilder errorNYI(SourceRange loc, llvm::StringRef feature,
1057 const T &name) {
1058 return errorNYI(loc.getBegin(), feature, name) << loc;
1059 }
1060
1061 /// Emit a general error that something can't be done.
1062 void error(SourceLocation loc, llvm::StringRef error);
1063
1064 /// Print out an error that codegen doesn't support the specified stmt yet.
1065 void errorUnsupported(const Stmt *s, llvm::StringRef type);
1066
1067 /// Print out an error that codegen doesn't support the specified decl yet.
1068 void errorUnsupported(const Decl *d, llvm::StringRef type);
1069
1070 /// Emits AMDGPU specific Metadata.
1071 void emitAMDGPUMetadata();
1072
1073 /// Build (or fetch from the dedup cache) the args ArrayAttr for an
1074 /// annotation. Returns the empty ArrayAttr when the annotation has none.
1075 mlir::ArrayAttr getOrCreateAnnotationArgs(const clang::AnnotateAttr *attr);
1076
1077 /// Create cir::AnnotationAttr for a single AnnotateAttr.
1078 cir::AnnotationAttr emitAnnotateAttr(const clang::AnnotateAttr *aa);
1079
1080 /// Add global annotations for a global value (GlobalOp or FuncOp).
1081 void addGlobalAnnotations(const clang::ValueDecl *d, mlir::Operation *gv);
1082
1083private:
1084 /// Search \p currentClass and its non-virtual base subobjects for \p field,
1085 /// appending CIR field indices along the path from \p currentClass.
1086 bool findFieldMemberPath(const CXXRecordDecl *currentClass,
1087 const FieldDecl *field,
1089
1090 // An ordered map of canonical GlobalDecls to their mangled names.
1091 llvm::MapVector<clang::GlobalDecl, llvm::StringRef> mangledDeclNames;
1092 llvm::StringMap<clang::GlobalDecl, llvm::BumpPtrAllocator> manglings;
1093
1094 // FIXME: should we use llvm::TrackingVH<mlir::Operation> here?
1095 llvm::MapVector<StringRef, mlir::Operation *> replacements;
1096 /// Call replaceAllUsesWith on all pairs in replacements.
1097 void applyReplacements();
1098
1099 bool getCPUAndFeaturesAttributes(GlobalDecl gd,
1100 llvm::StringMap<std::string> &attrs,
1101 bool setTargetFeatures = true);
1102 void setNonAliasAttributes(GlobalDecl gd, mlir::Operation *op);
1103
1104 /// Map source language used to a CIR attribute.
1105 std::optional<cir::SourceLanguage> getCIRSourceLanguage() const;
1106
1107 /// Emit all the global annotations.
1108 void emitGlobalAnnotations();
1109};
1110} // namespace CIRGen
1111
1112} // namespace clang
1113
1114#endif // LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H
Defines some OpenACC-specific enums and functions.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Defines the SourceManager interface.
Base class of the TBAA type descriptor attributes.
Definition CIRAttrs.h:48
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:246
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Implements C++ ABI-specific code generation functions.
Abstract information about a function or function prototype.
Definition CIRGenCall.h:27
cir::GlobalOp getAddrOfUnnamedGlobalConstantDecl(const UnnamedGlobalConstantDecl *gcd)
mlir::Value getNullPointer(cir::PointerType ptrTy, QualType qt, mlir::Location loc)
Get target specific null pointer.
void setGlobalVisibility(cir::CIRGlobalValueInterface gv, const NamedDecl *d) const
Set the visibility for the given global.
void addUsedOrCompilerUsedGlobal(cir::CIRGlobalValueInterface gv)
Add a global to a list to be added to the llvm.compiler.used metadata.
void emitCXXGlobalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr, bool performInit)
Emit the function that initializes the specified global.
void setFuncInfoAttr(cir::FuncOp funcOp, const clang::FunctionDecl *funcDecl)
Record the func_info tag for a function, either a C++ special member form (constructor,...
void replaceUsesOfNonProtoTypeWithRealFunction(mlir::Operation *old, cir::FuncOp newFn)
This function is called when we implement a function with no prototype, e.g.
bool shouldEmitFunction(clang::GlobalDecl gd)
Check if fd ends up calling itself directly through asm label or builtin-pointer-to-self trickery (e....
llvm::StringRef getMangledName(clang::GlobalDecl gd)
cir::GlobalOp getOrCreateStaticVarDecl(const VarDecl &d, cir::GlobalLinkageKind linkage)
CharUnits computeNonVirtualBaseClassOffset(const CXXRecordDecl *derivedClass, llvm::iterator_range< CastExpr::path_const_iterator > path)
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
void emitDeferred()
Emit any needed decls for which code generation was deferred.
cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd)
clang::ASTContext & getASTContext() const
mlir::Operation * getWeakRefReference(const clang::ValueDecl *vd)
Return the symbol that a weakref declaration refers to: the cir.func or cir.global named by its alias...
bool isPaddedAtomicType(QualType type)
void insertGlobalSymbol(mlir::Operation *op)
cir::FuncOp getAddrOfCXXStructor(clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo=nullptr, cir::FuncType fnType=nullptr, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
CIRGenCUDARuntime & getCUDARuntime()
void emitTopLevelDecl(clang::Decl *decl)
CharUnits getDynamicOffsetAlignment(CharUnits actualBaseAlign, const CXXRecordDecl *baseDecl, CharUnits expectedTargetAlign)
TODO: Add TBAAAccessInfo.
void emitGlobalOpenACCDeclareDataOperands(const Expr *varOperand, DataClauseTy dataClause, OpenACCModifierKind modifiers, bool structured, bool implicit, bool requiresDtor)
void emitOMPDeclareMapper(const OMPDeclareMapperDecl *d)
void addReplacement(llvm::StringRef name, mlir::Operation *op)
mlir::Type convertType(clang::QualType type)
bool shouldEmitRTTI(bool forEH=false)
cir::GlobalOp getGlobalForStringLiteral(const StringLiteral *s, llvm::StringRef name=".str")
Return a global symbol reference to a constant array for the given string literal.
void addSYCLModuleIdAttr(cir::FuncOp fn)
std::vector< cir::CIRGlobalValueInterface > llvmUsed
List of global values which are required to be present in the object file; This is used for forcing v...
cir::TBAATagAttr getTBAAAccessTagInfo(TBAAAccessInfo tbaaInfo)
Returns the TBAA access tag for the given memory access.
void emitOMPCapturedExpr(const OMPCapturedExprDecl *d)
clang::AtomicOptions getAtomicOpts() const
The atomic options in effect at the point currently being emitted.
llvm::DenseMap< const VarDecl *, cir::GlobalOp > initializerConstants
llvm::DenseMap< const CompoundLiteralExpr *, cir::GlobalOp > emittedCompoundLiterals
std::optional< llvm::SmallVector< int32_t > > buildMemberPath(const CXXRecordDecl *destClass, const ValueDecl *decl)
Build a GEP-style field-index path from destClass to decl.
bool mustBeEmitted(const clang::ValueDecl *d)
Determine whether the definition must be emitted; if this returns false, the definition can be emitte...
clang::CharUnits getNaturalTypeAlignment(clang::QualType t, LValueBaseInfo *baseInfo=nullptr, TBAAAccessInfo *tbaaInfo=nullptr, bool forPointeeType=false)
FIXME: this could likely be a common helper and not necessarily related with codegen.
void emitGlobalOpenACCDeclareDecl(const clang::OpenACCDeclareDecl *cd)
mlir::IntegerAttr getSize(CharUnits size)
cir::TLSModel getDefaultCIRTLSModel() const
Get TLS mode from CodeGenOptions.
void addDefaultFunctionAttributes(StringRef name, bool hasOptNoneAttr, bool attrOnCallSite, mlir::NamedAttrList &attrs)
Helper function for constructAttributeList/others.
void decorateOperationWithTBAA(OpTy op, TBAAAccessInfo tbaaInfo)
Attaches the TBAA access tag of tbaaInfo to the load or store op.
void setGlobalTlsReferences(const VarDecl &vd, cir::GlobalOp globalOp)
void emitOpenCLKernelArgMetadata(cir::FuncOp func, const clang::FunctionDecl *fd)
Generate OpenCL kernel argument metadata for a kernel function.
DiagnosticBuilder errorNYI(SourceRange loc, llvm::StringRef feature, const T &name)
CIRGenBuilderTy & getBuilder()
void setDSOLocal(mlir::Operation *op) const
void emitCXXStaticLocalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr, bool performInit)
Emit the function that initializes the specified static-local variable.
std::string getUniqueGlobalName(const std::string &baseName)
std::pair< cir::FuncType, cir::FuncOp > getAddrAndTypeOfCXXStructor(clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo=nullptr, cir::FuncType fnType=nullptr, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
ItaniumVTableContext & getItaniumVTableContext()
void setGVProperties(mlir::Operation *op, const NamedDecl *d) const
Set visibility, dllimport/dllexport and dso_local.
cir::FuncOp createCIRBuiltinFunction(mlir::Location loc, llvm::StringRef name, cir::FuncType ty, const clang::FunctionDecl *fd)
Create a CIR function with builtin attribute set.
cir::GlobalOp getAddrOfTemplateParamObject(const TemplateParamObjectDecl *tpo)
Get the GlobalOp of a template parameter object.
llvm::DenseMap< const Decl *, cir::GlobalOp > staticLocalDeclMap
TBAAAccessInfo getTBAAAccessInfo(QualType accessType)
Returns the TBAA information that describes an access to an object of the given type.
cir::FuncOp lookupFuncOp(llvm::StringRef name)
O(1) lookup of a FuncOp by name in the symbol cache.
void emitGlobalOpenACCRoutineDecl(const clang::OpenACCRoutineDecl *cd)
clang::CharUnits getClassPointerAlignment(const clang::CXXRecordDecl *rd)
Return the best known alignment for an unknown pointer to a particular class.
void handleCXXStaticMemberVarInstantiation(VarDecl *vd)
Tell the consumer that this variable has been instantiated.
llvm::DenseMap< const UnnamedGlobalConstantDecl *, cir::GlobalOp > unnamedGlobalConstantDeclMap
std::vector< cir::CIRGlobalValueInterface > llvmCompilerUsed
cir::FuncOp getRawFunctionPointer(GlobalDecl GD)
Return a function pointer for a reference to the given function.
cir::FuncOp emitAliasForGlobal(llvm::StringRef mangledName, mlir::Operation *op, GlobalDecl aliasGD, cir::FuncOp aliasee, cir::GlobalLinkageKind linkage)
Emit aliasGD as an alias of aliasee, replacing any existing declaration op, and return the alias.
CharUnits getMinimumClassObjectSize(const CXXRecordDecl *cd)
Returns the minimum object size for an object of the given class type (or a class derived from it).
void emitOMPRequiresDecl(const OMPRequiresDecl *d)
void emitGlobalDefinition(clang::GlobalDecl gd, mlir::Operation *op=nullptr)
clang::DiagnosticsEngine & getDiags() const
CharUnits getVBaseAlignment(CharUnits derivedAlign, const CXXRecordDecl *derived, const CXXRecordDecl *vbase)
Returns the assumed alignment of a virtual base of a class.
cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd, GVALinkage linkage)
mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc, QualType ty, bool forEH=false)
Get the address of the RTTI descriptor for the given type.
cir::GlobalOp createGlobalString(mlir::Location loc, llvm::StringRef str, llvm::StringRef name)
Create a private constant global holding the null-terminated string str, mirroring llvm::IRBuilder::C...
void setFunctionAttributes(GlobalDecl gd, cir::FuncOp f, bool isIncompleteFunction, bool isThunk)
Set function attributes for a function declaration.
static mlir::SymbolTable::Visibility getMLIRVisibilityFromCIRLinkage(cir::GlobalLinkageKind GLK)
const ItaniumVTableContext & getItaniumVTableContext() const
const clang::TargetInfo & getTarget() const
static mlir::SymbolTable::Visibility getMLIRVisibility(cir::GlobalOp op)
mlir::TypedAttr emitNullConstantForBase(const CXXRecordDecl *record)
Return a null constant appropriate for zero-initializing a base class with the given type.
void emitVTableTypeMetadata(const CXXRecordDecl *rd, cir::GlobalOp vtable, const VTableLayout &vtLayout)
Attach !type metadata to vtable.
void setCIRFunctionAttributes(GlobalDecl gd, const CIRGenFunctionInfo &info, cir::FuncOp func, bool isThunk)
Set the CIR function attributes (Sext, zext, etc).
cir::FuncOp getBuiltinLibFunction(const FunctionDecl *fd, unsigned builtinID)
Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
const llvm::Triple & getTriple() const
void emitTentativeDefinition(const VarDecl *d)
const cir::CIRDataLayout & getDataLayout() const
CharUnits getMinimumObjectSize(QualType ty)
Returns the minimum object size for an object of the given type.
void emitAliasDefinition(GlobalDecl gd)
Emit a definition for an __attribute__((alias)) declaration.
void addUsedGlobal(cir::CIRGlobalValueInterface gv)
Add a global value to the llvmUsed list.
cir::GlobalOp createOrReplaceCXXRuntimeVariable(mlir::Location loc, llvm::StringRef name, mlir::Type ty, cir::GlobalLinkageKind linkage, clang::CharUnits alignment)
Will return a global variable of the given type.
void emitOMPAllocateDecl(const OMPAllocateDecl *d)
void error(SourceLocation loc, llvm::StringRef error)
Emit a general error that something can't be done.
void emitGlobalDecl(const clang::GlobalDecl &d)
Helper for emitDeferred to apply actual codegen.
void emitGlobalVarDefinition(const clang::VarDecl *vd, bool isTentative=false)
static std::optional< cir::FramePointerKind > getFramePointerKind(CodeGenOptions::FramePointerKind kind)
Returns the frame pointer kind to record on functions and on the module, or std::nullopt when kind is...
cir::FuncOp createRuntimeFunction(cir::FuncType ty, llvm::StringRef name, mlir::NamedAttrList extraAttrs={}, bool isLocal=false, bool assumeConvergent=false)
cir::FuncOp getAddrOfThunk(StringRef name, mlir::Type fnTy, GlobalDecl gd)
Get or create a thunk function with the given name and type.
DiagnosticBuilder errorNYI(mlir::Location loc, llvm::StringRef feature)
void addRecordLayout(mlir::StringAttr name, cir::RecordLayoutAttr attr)
Queue a record layout entry for materialization in release().
cir::FuncOp getAddrOfFunction(clang::GlobalDecl gd, mlir::Type funcType=nullptr, bool forVTable=false, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
Return the address of the given function.
cir::TypeMetadataAttr createTypeMetadata(QualType t, CharUnits offset, mlir::StringAttr typeId)
Type metadata entry typeId for t at offset.
mlir::TypedAttr emitNullConstantAttr(QualType t)
cir::TBAATypeDescriptorAttr getTBAATypeInfo(QualType qty)
Returns the type descriptor used to describe accesses to objects of the given type,...
void emitLLVMUsed()
Emit llvm.used and llvm.compiler.used globals.
mlir::Value emitMemberPointerConstant(const UnaryOperator *e)
void emitGlobalOpenACCDecl(const clang::OpenACCConstructDecl *cd)
TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo sourceInfo, TBAAAccessInfo targetInfo)
Returns the merged TBAA information for the purpose of type casts.
LangAS getGlobalVarAddressSpace(const VarDecl *decl)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
void setTLSMode(mlir::Operation *op, const VarDecl &d, bool isExtendingDecl=false)
Set TLS mode for the given operation based on the given variable declaration.
void emitExplicitCastExprType(const ExplicitCastExpr *e, CIRGenFunction *cgf=nullptr)
Emit type info if type of an expression is a variably modified type.
void eraseGlobalSymbol(mlir::Operation *op)
mlir::Operation * getAddrOfGlobalTemporary(const MaterializeTemporaryExpr *mte, const Expr *init)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
std::map< llvm::StringRef, clang::GlobalDecl > deferredDecls
This contains all the decls which have definitions but which are deferred for emission and therefore ...
void errorUnsupported(const Stmt *s, llvm::StringRef type)
Print out an error that codegen doesn't support the specified stmt yet.
mlir::Value getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty={}, ForDefinition_t isForDefinition=NotForDefinition)
Return the mlir::Value for the address of the given global variable.
llvm::StringMap< mlir::Operation * > symbolLookupCache
Cache for O(1) symbol lookups by name, replacing the O(N) linear scan in SymbolTable::lookupSymbolIn ...
static void setInitializer(cir::GlobalOp &op, mlir::Attribute value)
cir::GlobalViewAttr getAddrOfGlobalVarAttr(const VarDecl *d)
Return the mlir::GlobalViewAttr for the address of the given global.
void addGlobalCtor(cir::FuncOp ctor, std::optional< int > priority=std::nullopt)
Add a global constructor or destructor to the module.
mlir::ArrayAttr getOrCreateAnnotationArgs(const clang::AnnotateAttr *attr)
Build (or fetch from the dedup cache) the args ArrayAttr for an annotation.
mlir::StringAttr getVirtualMemPtrTypeId(QualType t)
Type id of the virtual member function pointer type t.
cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd)
void updateCompletedType(const clang::TagDecl *td)
const clang::CodeGenOptions & getCodeGenOpts() const
void emitDeferredVTables()
Emit any vtables which we deferred and still have a use for.
const clang::LangOptions & getLangOpts() const
void printPostfixForExternalizedDecl(llvm::raw_ostream &os, const Decl *d)
Print the postfix for externalized static variable or kernels for single source offloading languages ...
bool mayVTableBeDuplicated(cir::GlobalLinkageKind linkage) const
Return true if a vtable with the given linkage may have more than one address in the program,...
cir::FuncOp getOrCreateCIRFunction(llvm::StringRef mangledName, mlir::Type funcType, clang::GlobalDecl gd, bool forVTable, bool dontDefer=false, bool isThunk=false, ForDefinition_t isForDefinition=NotForDefinition, mlir::NamedAttrList extraAttrs={})
void emitOpenACCRoutineDecl(const clang::FunctionDecl *funcDecl, cir::FuncOp func, SourceLocation pragmaLoc, ArrayRef< const OpenACCClause * > clauses)
void emitVTablesOpportunistically()
Try to emit external vtables as available_externally if they have emitted all inlined virtual functio...
cir::GlobalOp createGlobalOp(mlir::Location loc, llvm::StringRef name, mlir::Type t, bool isConstant=false, mlir::ptr::MemorySpaceAttrInterface addrSpace={}, mlir::Operation *insertPoint=nullptr)
void addGlobalDtor(cir::FuncOp dtor, std::optional< int > priority=std::nullopt)
Add a function to the list that will be called when the module is unloaded.
clang::CharUnits getNaturalPointeeTypeAlignment(clang::QualType t, LValueBaseInfo *baseInfo=nullptr, TBAAAccessInfo *tbaaInfo=nullptr)
mlir::Value castGlobalToDeclAddrSpace(mlir::Value addr, const VarDecl &vd)
Cast addr, the address of the global vd, to the address space of the declared type of vd if they diff...
void addDeferredDeclToEmit(clang::GlobalDecl GD)
void setAtomicOpts(clang::AtomicOptions opts)
cir::FuncOp createCIRFunction(mlir::Location loc, llvm::StringRef name, cir::FuncType funcType, const clang::FunctionDecl *funcDecl)
const TargetCIRGenInfo & getTargetCIRGenInfo()
void emitCXXGlobalVarDeclInitFunc(const VarDecl *vd, cir::GlobalOp addr, bool performInit)
static cir::VisibilityKind getCIRVisibilityKind(Visibility v)
void addDeferredVTable(const CXXRecordDecl *rd)
void setStaticLocalDeclAddress(const VarDecl *d, cir::GlobalOp c)
void setGVPropertiesAux(mlir::Operation *op, const NamedDecl *d) const
LangAS getLangTempAllocaAddressSpace() const
Returns the address space for temporary allocations in the language.
cir::FuncOp codegenCXXStructor(clang::GlobalDecl gd)
mlir::Location getLoc(clang::SourceLocation cLoc)
Helpers to convert the presumed location of Clang's SourceLocation to an MLIR Location.
llvm::DenseMap< mlir::Attribute, cir::GlobalOp > constantStringMap
mlir::Operation * lastGlobalOp
cir::FuncOp getFunctionPointer(GlobalDecl GD)
Return the ABI-correct function pointer value for a reference to the given function.
void setCIRFunctionAttributesForDefinition(const clang::Decl *decl, cir::FuncOp f)
Set extra attributes (inline, etc.) for a function.
void replaceGlobal(cir::GlobalOp oldGV, cir::GlobalOp newGV)
Replace all uses of the old global with the new global, updating types and references as needed.
llvm::StringMap< unsigned > cgGlobalNames
mlir::TypedAttr emitNullMemberAttr(QualType t, const MemberPointerType *mpt)
Returns a null attribute to represent either a null method or null data member, depending on the type...
mlir::Operation * getGlobalValue(llvm::StringRef ref)
cir::GlobalOp getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *e)
mlir::Value emitNullConstant(QualType t, mlir::Location loc)
Return the result of value-initializing the given type, i.e.
void emitOMPDeclareReduction(const OMPDeclareReductionDecl *d)
mlir::ModuleOp getModule() const
void addCompilerUsedGlobal(cir::CIRGlobalValueInterface gv)
Add a global value to the llvmCompilerUsed list.
mlir::MLIRContext & getMLIRContext()
void emitSYCLKernelCaller(const clang::FunctionDecl *kernelEntryPointFn, clang::ASTContext &ctx)
Emit the SYCL kernel caller offload entry point function generated for a function declared with the s...
mlir::Operation * getAddrOfGlobal(clang::GlobalDecl gd, ForDefinition_t isForDefinition=NotForDefinition)
DiagnosticBuilder errorNYI(llvm::StringRef feature) const
void maybeSetTrivialComdat(const clang::Decl &d, mlir::Operation *op)
cir::GlobalOp getStaticLocalDeclAddress(const VarDecl *d)
bool isEmptyFieldForMemberPointer(const FieldDecl *field)
Returns true if field is a potentially-overlapping field with no CIR field index (e....
CIRGenCXXABI & getCXXABI() const
cir::GlobalViewAttr getAddrOfConstantStringFromLiteral(const StringLiteral *s, llvm::StringRef name=".str")
Return a global symbol reference to a constant array for the given string literal.
void setAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *e, cir::GlobalOp gv)
bool lookupRepresentativeDecl(llvm::StringRef mangledName, clang::GlobalDecl &gd) const
void emitDeclContext(const DeclContext *dc)
mlir::ptr::MemorySpaceAttrInterface getGlobalCIRAddressSpace(LangAS as)
Return the CIR address space attribute for a global in as, honoring the target address space map wher...
cir::FuncOp getOrCreateCIRFunction(llvm::StringRef mangledName, mlir::Type funcType, clang::GlobalDecl gd, bool forVTable, mlir::NamedAttrList extraAttrs)
void emitGlobal(clang::GlobalDecl gd)
Emit code for a single global function or variable declaration.
cir::TBAATypeDescriptorAttr getTBAABaseTypeInfo(QualType qty)
Returns the type descriptor that describes the given base access type, or null if the type is not sui...
bool mayBeEmittedEagerly(const clang::ValueDecl *d)
Determine whether the definition can be emitted eagerly, or should be delayed until the end of the tr...
llvm::DenseMap< const clang::FieldDecl *, llvm::StringRef > lambdaFieldToName
Keep a map between lambda fields and names, this needs to be per module since lambdas might get gener...
DiagnosticBuilder errorNYI(SourceLocation loc, llvm::StringRef feature, const T &name)
void constructAttributeList(llvm::StringRef name, const CIRGenFunctionInfo &info, CIRGenCalleeInfo calleeInfo, mlir::NamedAttrList &attrs, llvm::MutableArrayRef< mlir::NamedAttrList > argAttrs, mlir::NamedAttrList &retAttrs, cir::CallingConv &callingConv, bool attrOnCallSite, bool isThunk)
Get the CIR attributes and calling convention to use for a particular function type.
void addGlobalAnnotations(const clang::ValueDecl *d, mlir::Operation *gv)
Add global annotations for a global value (GlobalOp or FuncOp).
std::string getOpenACCBindMangledName(const IdentifierInfo *bindName, const FunctionDecl *attachedFunction)
void emitGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op)
CIRGenVTables & getVTables()
void setFunctionLinkage(GlobalDecl gd, cir::FuncOp f)
TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo infoA, TBAAAccessInfo infoB)
Returns the merged TBAA information for the purpose of conditional operator.
cir::GlobalOp getOrCreateCIRGlobal(llvm::StringRef mangledName, mlir::Type ty, LangAS langAS, mlir::Location loc, const VarDecl *d, ForDefinition_t isForDefinition)
If the specified mangled name is not in the module, create and return an mlir::GlobalOp value.
std::vector< clang::GlobalDecl > deferredDeclsToEmit
void emitVTable(const CXXRecordDecl *rd)
This is a callback from Sema to tell us that a particular vtable is required to be emitted in this tr...
cir::AnnotationAttr emitAnnotateAttr(const clang::AnnotateAttr *aa)
Create cir::AnnotationAttr for a single AnnotateAttr.
TBAAAccessInfo getTBAAInfoForSubobject(LValue base, QualType accessType)
Returns the TBAA information for an access with a given base lvalue.
void emitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *d)
CIRGenOpenMPRuntime & getOpenMPRuntime()
void emitAMDGPUMetadata()
Emits AMDGPU specific Metadata.
void emitOMPGroupPrivateDecl(const OMPGroupPrivateDecl *d)
cir::GlobalLinkageKind getVTableLinkage(const CXXRecordDecl *rd)
Return the appropriate linkage for the vtable, VTT, and type information of the given class.
Address createUnnamedGlobalFrom(const VarDecl &d, mlir::Attribute constAttr, CharUnits align)
void emitCXXSpecialVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr, bool performInit, mlir::Region &ctorRegion, mlir::Region &dtorRegion)
Helper function for the below two that will create the constructor/destructor in specified regions,...
mlir::Attribute getConstantArrayFromStringLiteral(const StringLiteral *e)
Return a constant array for the given string.
void setCommonAttributes(GlobalDecl gd, mlir::Operation *op)
Set attributes which are common to any form of a global definition (alias, Objective-C method,...
This class organizes the cross-module state that is used while lowering AST types to CIR types.
Definition CIRGenTypes.h:51
TBAAAccessInfo getTBAAInfo() const
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3674
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1468
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:782
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:240
ExplicitCastExpr - An explicit cast written in the source code.
Definition Expr.h:3997
This represents one expression.
Definition Expr.h:114
Represents a member of a struct/union/class.
Definition Decl.h:3346
Represents a function declaration or definition.
Definition Decl.h:2082
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:60
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isTargetDevice() const
True when compiling for an offloading target device.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4974
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3752
Describes a module or submodule.
Definition Module.h:340
This represents a decl that may have a name.
Definition Decl.h:276
This represents 'pragma omp allocate ...' directive.
Definition DeclOpenMP.h:536
Pseudo declaration for capturing expressions.
Definition DeclOpenMP.h:445
This represents 'pragma omp declare mapper ...' directive.
Definition DeclOpenMP.h:349
This represents 'pragma omp declare reduction ...' directive.
Definition DeclOpenMP.h:239
This represents 'pragma omp groupprivate ...' directive.
Definition DeclOpenMP.h:173
This represents 'pragma omp requires...' directive.
Definition DeclOpenMP.h:479
This represents 'pragma omp threadprivate ...' directive.
Definition DeclOpenMP.h:110
A (possibly-)qualified type.
Definition TypeBase.h:938
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition Stmt.h:85
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3904
Exposes information about the current target.
Definition TargetInfo.h:228
A template parameter object.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition Type.h:26
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2313
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4525
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:714
Represents a variable declaration or definition.
Definition Decl.h:934
Defines the clang::TargetInfo interface.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Top level wrappers for InstallAPI frontend operations.
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition Linkage.h:72
OpenACCModifierKind
LangAS
Defines the address space values used by the address space qualifier of QualType.
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition Visibility.h:34
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
Definition Visibility.h:37
@ ProtectedVisibility
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
Definition Visibility.h:42
@ DefaultVisibility
Objects with "default" visibility are seen by the dynamic linker and act like normal objects.
Definition Visibility.h:46
Describes a memory access in terms of TBAA.
Definition CIRGenTBAA.h:44
static TBAAAccessInfo getMayAliasInfo()
Definition CIRGenTBAA.h:62