clang 23.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 "CIRGenTypeCache.h"
20#include "CIRGenTypes.h"
21#include "CIRGenVTables.h"
22#include "CIRGenValue.h"
23
24#include "clang/AST/CharUnits.h"
27
28#include "TargetInfo.h"
29#include "mlir/IR/Builders.h"
30#include "mlir/IR/BuiltinOps.h"
31#include "mlir/IR/MLIRContext.h"
32#include "clang/AST/Decl.h"
36#include "llvm/ADT/StringRef.h"
37#include "llvm/TargetParser/Triple.h"
38
39namespace clang {
40class ASTContext;
41class CodeGenOptions;
42class Decl;
43class GlobalDecl;
44class LangOptions;
45class TargetInfo;
46class VarDecl;
47
48namespace CIRGen {
49
50class CIRGenFunction;
51class CIRGenCXXABI;
52
53enum ForDefinition_t : bool { NotForDefinition = false, ForDefinition = true };
54
55/// This class organizes the cross-function state that is used while generating
56/// CIR code.
57class CIRGenModule : public CIRGenTypeCache {
58 CIRGenModule(CIRGenModule &) = delete;
59 CIRGenModule &operator=(CIRGenModule &) = delete;
60
61public:
62 CIRGenModule(mlir::MLIRContext &mlirContext, clang::ASTContext &astContext,
63 const clang::CodeGenOptions &cgo,
65
67
68private:
69 mutable std::unique_ptr<TargetCIRGenInfo> theTargetCIRGenInfo;
70
71 CIRGenBuilderTy builder;
72
73 /// Hold Clang AST information.
74 clang::ASTContext &astContext;
75
76 const clang::LangOptions &langOpts;
77
78 const clang::CodeGenOptions &codeGenOpts;
79
80 /// A "module" matches a c/cpp source file: containing a list of functions.
81 mlir::ModuleOp theModule;
82
84
85 const clang::TargetInfo &target;
86
87 std::unique_ptr<CIRGenCXXABI> abi;
88
89 CIRGenTypes genTypes;
90
91 /// Holds information about C++ vtables.
92 CIRGenVTables vtables;
93
94 /// Holds the CUDA runtime
95 std::unique_ptr<CIRGenCUDARuntime> cudaRuntime;
96
97 /// Per-function codegen information. Updated everytime emitCIR is called
98 /// for FunctionDecls's.
99 CIRGenFunction *curCGF = nullptr;
100
102
103 llvm::DenseSet<clang::GlobalDecl> diagnosedConflictingDefinitions;
104
105 void createCUDARuntime();
106
107 /// A helper for constructAttributeList that handles return attributes.
108 void constructFunctionReturnAttributes(const CIRGenFunctionInfo &info,
109 const Decl *targetDecl, bool isThunk,
110 mlir::NamedAttrList &retAttrs);
111 /// A helper for constructAttributeList that handles argument attributes.
112 void constructFunctionArgumentAttributes(
113 const CIRGenFunctionInfo &info, bool isThunk,
115 /// A helper function for constructAttributeList that determines whether a
116 /// return value might have been discarded.
117 bool mayDropFunctionReturn(const ASTContext &context, QualType retTy);
118 /// A helper function for constructAttributeList that determines whether
119 /// `noundef` on a return is possible.
120 bool hasStrictReturn(QualType retTy, const Decl *targetDecl);
121
122 llvm::DenseMap<const Expr *, mlir::Operation *>
123 materializedGlobalTemporaryMap;
124
125public:
126 mlir::ModuleOp getModule() const { return theModule; }
127 CIRGenBuilderTy &getBuilder() { return builder; }
128 clang::ASTContext &getASTContext() const { return astContext; }
129 const clang::TargetInfo &getTarget() const { return target; }
130 const clang::CodeGenOptions &getCodeGenOpts() const { return codeGenOpts; }
131 clang::DiagnosticsEngine &getDiags() const { return diags; }
132 CIRGenTypes &getTypes() { return genTypes; }
133 const clang::LangOptions &getLangOpts() const { return langOpts; }
134
135 CIRGenCXXABI &getCXXABI() const { return *abi; }
136 mlir::MLIRContext &getMLIRContext() { return *builder.getContext(); }
137
139 // FIXME(cir): instead of creating a CIRDataLayout every time, set it as an
140 // attribute for the CIRModule class.
141 return cir::CIRDataLayout(theModule);
142 }
143
144 /// -------
145 /// Handling globals
146 /// -------
147
148 mlir::Operation *lastGlobalOp = nullptr;
149
150 /// Keep a map between lambda fields and names, this needs to be per module
151 /// since lambdas might get generated later as part of defered work, and since
152 /// the pointers are supposed to be uniqued, should be fine. Revisit this if
153 /// it ends up taking too much memory.
154 llvm::DenseMap<const clang::FieldDecl *, llvm::StringRef> lambdaFieldToName;
155 /// Map BlockAddrInfoAttr (function name, label name) to the corresponding CIR
156 /// LabelOp. This provides the main lookup table used to resolve block
157 /// addresses into their label operations.
158 llvm::DenseMap<cir::BlockAddrInfoAttr, cir::LabelOp> blockAddressInfoToLabel;
159 /// Map CIR BlockAddressOps directly to their resolved LabelOps.
160 /// Used once a block address has been successfully lowered to a label.
161 llvm::MapVector<cir::BlockAddressOp, cir::LabelOp> blockAddressToLabel;
162 /// Track CIR BlockAddressOps that cannot be resolved immediately
163 /// because their LabelOp has not yet been emitted. These entries
164 /// are solved later once the corresponding label is available.
165 llvm::DenseSet<cir::BlockAddressOp> unresolvedBlockAddressToLabel;
166 cir::LabelOp lookupBlockAddressInfo(cir::BlockAddrInfoAttr blockInfo);
167 void mapBlockAddress(cir::BlockAddrInfoAttr blockInfo, cir::LabelOp label);
168 void mapUnresolvedBlockAddress(cir::BlockAddressOp op);
169 void mapResolvedBlockAddress(cir::BlockAddressOp op, cir::LabelOp);
170 void updateResolvedBlockAddress(cir::BlockAddressOp op,
171 cir::LabelOp newLabel);
172 /// Tell the consumer that this variable has been instantiated.
174
175 llvm::DenseMap<const Decl *, cir::GlobalOp> staticLocalDeclMap;
176 llvm::DenseMap<const VarDecl *, cir::GlobalOp> initializerConstants;
177
178 mlir::Operation *getGlobalValue(llvm::StringRef ref);
179
180 cir::GlobalOp getStaticLocalDeclAddress(const VarDecl *d) {
181 return staticLocalDeclMap[d];
182 }
183
184 void setStaticLocalDeclAddress(const VarDecl *d, cir::GlobalOp c) {
186 }
187
188 cir::GlobalOp getOrCreateStaticVarDecl(const VarDecl &d,
189 cir::GlobalLinkageKind linkage);
190
191 Address createUnnamedGlobalFrom(const VarDecl &d, mlir::Attribute constAttr,
192 CharUnits align);
193
194 /// If the specified mangled name is not in the module, create and return an
195 /// mlir::GlobalOp value
196 cir::GlobalOp getOrCreateCIRGlobal(llvm::StringRef mangledName, mlir::Type ty,
197 LangAS langAS, const VarDecl *d,
198 ForDefinition_t isForDefinition);
199
200 cir::GlobalOp getOrCreateCIRGlobal(const VarDecl *d, mlir::Type ty,
201 ForDefinition_t isForDefinition);
202
203 static cir::GlobalOp createGlobalOp(CIRGenModule &cgm, mlir::Location loc,
204 llvm::StringRef name, mlir::Type t,
205 bool isConstant = false,
206 mlir::Operation *insertPoint = nullptr);
207
208 /// Add a global constructor or destructor to the module.
209 /// The priority is optional, if not specified, the default priority is used.
210 void addGlobalCtor(cir::FuncOp ctor,
211 std::optional<int> priority = std::nullopt);
212 void addGlobalDtor(cir::FuncOp dtor,
213 std::optional<int> priority = std::nullopt);
214
216 // In C23 (N3096) $6.7.10:
217 // """
218 // If any object is initialized with an empty initializer, then it is
219 // subject to default initialization:
220 // - if it is an aggregate, every member is initialized (recursively)
221 // according to these rules, and any padding is initialized to zero bits;
222 // - if it is a union, the first named member is initialized (recursively)
223 // according to these rules, and any padding is initialized to zero bits.
224 //
225 // If the aggregate or union contains elements or members that are
226 // aggregates or unions, these rules apply recursively to the subaggregates
227 // or contained unions.
228 //
229 // If there are fewer initializers in a brace-enclosed list than there are
230 // elements or members of an aggregate, or fewer characters in a string
231 // literal used to initialize an array of known size than there are elements
232 // in the array, the remainder of the aggregate is subject to default
233 // initialization.
234 // """
235 //
236 // The standard seems ambiguous in the following two areas:
237 // 1. For a union type with empty initializer, if the first named member is
238 // not the largest member, then the bytes comes after the first named member
239 // but before padding are left unspecified. An example is:
240 // union U { int a; long long b;};
241 // union U u = {}; // The first 4 bytes are 0, but 4-8 bytes are left
242 // unspecified.
243 //
244 // 2. It only mentions padding for empty initializer, but doesn't mention
245 // padding for a non empty initialization list. And if the aggregation or
246 // union contains elements or members that are aggregates or unions, and
247 // some are non empty initializers, while others are empty initializers,
248 // the padding initialization is unclear. An example is:
249 // struct S1 { int a; long long b; };
250 // struct S2 { char c; struct S1 s1; };
251 // // The values for paddings between s2.c and s2.s1.a, between s2.s1.a
252 // and s2.s1.b are unclear.
253 // struct S2 s2 = { 'c' };
254 //
255 // Here we choose to zero initiailize left bytes of a union type because
256 // projects like the Linux kernel are relying on this behavior. If we don't
257 // explicitly zero initialize them, the undef values can be optimized to
258 // return garbage data. We also choose to zero initialize paddings for
259 // aggregates and unions, no matter they are initialized by empty
260 // initializers or non empty initializers. This can provide a consistent
261 // behavior. So projects like the Linux kernel can rely on it.
262 return !getLangOpts().CPlusPlus;
263 }
264
265 llvm::StringMap<unsigned> cgGlobalNames;
266 std::string getUniqueGlobalName(const std::string &baseName);
267
268 /// Return the mlir::Value for the address of the given global variable.
269 /// If Ty is non-null and if the global doesn't exist, then it will be created
270 /// with the specified type instead of whatever the normal requested type
271 /// would be. If IsForDefinition is true, it is guaranteed that an actual
272 /// global with type Ty will be returned, not conversion of a variable with
273 /// the same mangled name but some other type.
274 mlir::Value
275 getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty = {},
276 ForDefinition_t isForDefinition = NotForDefinition);
277
278 /// Get or create a thunk function with the given name and type.
279 cir::FuncOp getAddrOfThunk(StringRef name, mlir::Type fnTy, GlobalDecl gd);
280
281 /// Return the mlir::GlobalViewAttr for the address of the given global.
282 cir::GlobalViewAttr getAddrOfGlobalVarAttr(const VarDecl *d);
283
285 const CXXRecordDecl *derivedClass,
286 llvm::iterator_range<CastExpr::path_const_iterator> path);
287
288 /// Get the CIR attributes and calling convention to use for a particular
289 /// function type.
290 ///
291 /// \param name - The function name.
292 /// \param info - The function type information.
293 /// \param calleeInfo - The callee information these attributes are being
294 /// constructed for. If valid, the attributes applied to this decl may
295 /// contribute to the function attributes and calling convention.
296 /// \param attrs [out] - On return, the attribute list to use.
297 /// \param callingConv [out] - On return, the calling convention to use.
298 /// \param sideEffect [out] - On return, the side effect type of the
299 /// attributes.
300 /// \param attrOnCallSite - Whether or not the attributes are on a call site.
301 /// \param isThunk - Whether the function is a thunk.
303 llvm::StringRef name, const CIRGenFunctionInfo &info,
304 CIRGenCalleeInfo calleeInfo, mlir::NamedAttrList &attrs,
306 mlir::NamedAttrList &retAttrs, cir::CallingConv &callingConv,
307 cir::SideEffect &sideEffect, bool attrOnCallSite, bool isThunk);
308 /// Helper function for constructAttributeList/others. Builds a set of
309 /// function attributes to add to a function based on language opts, codegen
310 /// opts, and some small properties.
311 void addDefaultFunctionAttributes(StringRef name, bool hasOptNoneAttr,
312 bool attrOnCallSite,
313 mlir::NamedAttrList &attrs);
314
315 /// Will return a global variable of the given type. If a variable with a
316 /// different type already exists then a new variable with the right type
317 /// will be created and all uses of the old variable will be replaced with a
318 /// bitcast to the new variable.
320 mlir::Location loc, llvm::StringRef name, mlir::Type ty,
321 cir::GlobalLinkageKind linkage, clang::CharUnits alignment);
322
323 void emitVTable(const CXXRecordDecl *rd);
324
325 /// Return the appropriate linkage for the vtable, VTT, and type information
326 /// of the given class.
327 cir::GlobalLinkageKind getVTableLinkage(const CXXRecordDecl *rd);
328
329 /// Get the address of the RTTI descriptor for the given type.
330 mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc, QualType ty,
331 bool forEH = false);
332
333 static mlir::SymbolTable::Visibility getMLIRVisibility(Visibility v) {
334 switch (v) {
336 return mlir::SymbolTable::Visibility::Public;
337 case HiddenVisibility:
338 return mlir::SymbolTable::Visibility::Private;
340 // The distinction between ProtectedVisibility and DefaultVisibility is
341 // that symbols with ProtectedVisibility, while visible to the dynamic
342 // linker like DefaultVisibility, are guaranteed to always dynamically
343 // resolve to a symbol in the current shared object. There is currently no
344 // equivalent MLIR visibility, so we fall back on the fact that the symbol
345 // is visible.
346 return mlir::SymbolTable::Visibility::Public;
347 }
348 llvm_unreachable("unknown visibility!");
349 }
350
351 llvm::DenseMap<mlir::Attribute, cir::GlobalOp> constantStringMap;
352
353 /// Return a constant array for the given string.
354 mlir::Attribute getConstantArrayFromStringLiteral(const StringLiteral *e);
355
356 /// Return a global symbol reference to a constant array for the given string
357 /// literal.
358 cir::GlobalOp getGlobalForStringLiteral(const StringLiteral *s,
359 llvm::StringRef name = ".str");
360
361 /// Return a global symbol reference to a constant array for the given string
362 /// literal.
363 cir::GlobalViewAttr
365 llvm::StringRef name = ".str");
366
367 /// Returns the address space for temporary allocations in the language. This
368 /// ensures that the allocated variable's address space matches the
369 /// expectations of the AST, rather than using the target's allocation address
370 /// space, which may lead to type mismatches in other parts of the IR.
372
373 /// Set attributes which are common to any form of a global definition (alias,
374 /// Objective-C method, function, global variable).
375 ///
376 /// NOTE: This should only be called for definitions.
377 void setCommonAttributes(GlobalDecl gd, mlir::Operation *op);
378
380
381 /// Helpers to convert the presumed location of Clang's SourceLocation to an
382 /// MLIR Location.
383 mlir::Location getLoc(clang::SourceLocation cLoc);
384 mlir::Location getLoc(clang::SourceRange cRange);
385
386 /// Return the best known alignment for an unknown pointer to a
387 /// particular class.
389
390 /// FIXME: this could likely be a common helper and not necessarily related
391 /// with codegen.
393 LValueBaseInfo *baseInfo = nullptr);
394
395 /// Returns the minimum object size for an object of the given class type
396 /// (or a class derived from it).
398
399 /// Returns the minimum object size for an object of the given type.
405
406 /// TODO: Add TBAAAccessInfo
408 const CXXRecordDecl *baseDecl,
409 CharUnits expectedTargetAlign);
410
411 /// Returns the assumed alignment of a virtual base of a class.
413 const CXXRecordDecl *derived,
414 const CXXRecordDecl *vbase);
415
416 cir::FuncOp
418 const CIRGenFunctionInfo *fnInfo = nullptr,
419 cir::FuncType fnType = nullptr, bool dontDefer = false,
420 ForDefinition_t isForDefinition = NotForDefinition) {
421 return getAddrAndTypeOfCXXStructor(gd, fnInfo, fnType, dontDefer,
422 isForDefinition)
423 .second;
424 }
425
426 std::pair<cir::FuncType, cir::FuncOp> getAddrAndTypeOfCXXStructor(
427 clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo = nullptr,
428 cir::FuncType fnType = nullptr, bool dontDefer = false,
429 ForDefinition_t isForDefinition = NotForDefinition);
430
431 mlir::Type getVTableComponentType();
432 CIRGenVTables &getVTables() { return vtables; }
433
435 return vtables.getItaniumVTableContext();
436 }
438 return vtables.getItaniumVTableContext();
439 }
440
441 /// This contains all the decls which have definitions but which are deferred
442 /// for emission and therefore should only be output if they are actually
443 /// used. If a decl is in this, then it is known to have not been referenced
444 /// yet.
445 std::map<llvm::StringRef, clang::GlobalDecl> deferredDecls;
446
447 // This is a list of deferred decls which we have seen that *are* actually
448 // referenced. These get code generated when the module is done.
449 std::vector<clang::GlobalDecl> deferredDeclsToEmit;
451 deferredDeclsToEmit.emplace_back(GD);
452 }
453
455
456 /// Determine whether the definition must be emitted; if this returns \c
457 /// false, the definition can be emitted lazily if it's used.
458 bool mustBeEmitted(const clang::ValueDecl *d);
459
460 /// Determine whether the definition can be emitted eagerly, or should be
461 /// delayed until the end of the translation unit. This is relevant for
462 /// definitions whose linkage can change, e.g. implicit function
463 /// instantiations which may later be explicitly instantiated.
465
466 bool verifyModule() const;
467
468 /// Return the address of the given function. If funcType is non-null, then
469 /// this function will use the specified type if it has to create it.
470 // TODO: this is a bit weird as `GetAddr` given we give back a FuncOp?
471 cir::FuncOp
472 getAddrOfFunction(clang::GlobalDecl gd, mlir::Type funcType = nullptr,
473 bool forVTable = false, bool dontDefer = false,
474 ForDefinition_t isForDefinition = NotForDefinition);
475
476 mlir::Operation *
478 ForDefinition_t isForDefinition = NotForDefinition);
479
480 // Return whether RTTI information should be emitted for this target.
481 bool shouldEmitRTTI(bool forEH = false) {
482 return (forEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice &&
483 !(getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice &&
484 getTriple().isNVPTX());
485 }
486
487 /// Emit type info if type of an expression is a variably modified
488 /// type. Also emit proper debug info for cast types.
490 CIRGenFunction *cgf = nullptr);
491
492 /// Emit code for a single global function or variable declaration. Forward
493 /// declarations are emitted lazily.
495
496 void emitAliasForGlobal(llvm::StringRef mangledName, mlir::Operation *op,
497 GlobalDecl aliasGD, cir::FuncOp aliasee,
498 cir::GlobalLinkageKind linkage);
499
500 mlir::Type convertType(clang::QualType type);
501
502 /// Set the visibility for the given global.
503 void setGlobalVisibility(mlir::Operation *op, const NamedDecl *d) const;
504 void setDSOLocal(mlir::Operation *op) const;
505 void setDSOLocal(cir::CIRGlobalValueInterface gv) const;
506
507 /// Set visibility, dllimport/dllexport and dso_local.
508 /// This must be called after dllimport/dllexport is set.
509 void setGVProperties(mlir::Operation *op, const NamedDecl *d) const;
510 void setGVPropertiesAux(mlir::Operation *op, const NamedDecl *d) const;
511
512 /// Set TLS mode for the given operation based on the given variable
513 /// declaration.
514 void setTLSMode(mlir::Operation *op, const VarDecl &d);
515
516 /// Get TLS mode from CodeGenOptions.
517 cir::TLS_Model getDefaultCIRTLSModel() const;
518
519 /// Set function attributes for a function declaration.
520 void setFunctionAttributes(GlobalDecl gd, cir::FuncOp f,
521 bool isIncompleteFunction, bool isThunk);
522
523 /// Set the CIR function attributes (Sext, zext, etc).
525 cir::FuncOp func, bool isThunk);
526
527 /// Set extra attributes (inline, etc.) for a function.
529 cir::FuncOp f);
530
532 mlir::Operation *op = nullptr);
533 void emitGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op);
535 bool isTentative = false);
536
537 /// Emit the function that initializes the specified global
538 void emitCXXGlobalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr,
539 bool performInit);
540
541 void emitCXXGlobalVarDeclInitFunc(const VarDecl *vd, cir::GlobalOp addr,
542 bool performInit);
543
547 template <typename BeforeOpTy, typename DataClauseTy>
548 void emitGlobalOpenACCDeclareDataOperands(const Expr *varOperand,
549 DataClauseTy dataClause,
550 OpenACCModifierKind modifiers,
551 bool structured, bool implicit,
552 bool requiresDtor);
553 // Each of the acc.routine operations must have a unique name, so we just use
554 // an integer counter. This is how Flang does it, so it seems reasonable.
555 unsigned routineCounter = 0;
556 void emitOpenACCRoutineDecl(const clang::FunctionDecl *funcDecl,
557 cir::FuncOp func, SourceLocation pragmaLoc,
559
567
568 // C++ related functions.
569 void emitDeclContext(const DeclContext *dc);
570
571 /// Return the result of value-initializing the given type, i.e. a null
572 /// expression of the given type.
573 mlir::Value emitNullConstant(QualType t, mlir::Location loc);
574
575 mlir::TypedAttr emitNullConstantAttr(QualType t);
576
577 /// Return a null constant appropriate for zero-initializing a base class with
578 /// the given type. This is usually, but not always, an LLVM null constant.
579 mlir::TypedAttr emitNullConstantForBase(const CXXRecordDecl *record);
580
581 mlir::Value emitMemberPointerConstant(const UnaryOperator *e);
582
583 llvm::StringRef getMangledName(clang::GlobalDecl gd);
584 // This function is to support the OpenACC 'bind' clause, which names an
585 // alternate name for the function to be called by. This function mangles
586 // `attachedFunction` as-if its name was actually `bindName` (that is, with
587 // the same signature). It has some additional complications, as the 'bind'
588 // target is always going to be a global function, so member functions need an
589 // explicit instead of implicit 'this' parameter, and thus gets mangled
590 // differently.
591 std::string getOpenACCBindMangledName(const IdentifierInfo *bindName,
592 const FunctionDecl *attachedFunction);
593
594 void emitTentativeDefinition(const VarDecl *d);
595
596 // Make sure that this type is translated.
597 void updateCompletedType(const clang::TagDecl *td);
598
599 // Produce code for this constructor/destructor. This method doesn't try to
600 // apply any ABI rules about which other constructors/destructors are needed
601 // or if they are alias to each other.
603
604 bool lookupRepresentativeDecl(llvm::StringRef mangledName,
605 clang::GlobalDecl &gd) const;
606
607 bool supportsCOMDAT() const;
608 void maybeSetTrivialComdat(const clang::Decl &d, mlir::Operation *op);
609
610 static void setInitializer(cir::GlobalOp &op, mlir::Attribute value);
611
612 // Whether a global variable should be emitted by CUDA/HIP host/device
613 // related attributes.
614 bool shouldEmitCUDAGlobalVar(const VarDecl *global) const;
615
616 void replaceUsesOfNonProtoTypeWithRealFunction(mlir::Operation *old,
617 cir::FuncOp newFn);
618
619 cir::FuncOp
620 getOrCreateCIRFunction(llvm::StringRef mangledName, mlir::Type funcType,
621 clang::GlobalDecl gd, bool forVTable,
622 bool dontDefer = false, bool isThunk = false,
623 ForDefinition_t isForDefinition = NotForDefinition,
624 mlir::ArrayAttr extraAttrs = {});
625
626 cir::FuncOp createCIRFunction(mlir::Location loc, llvm::StringRef name,
627 cir::FuncType funcType,
628 const clang::FunctionDecl *funcDecl);
629
630 /// Create a CIR function with builtin attribute set.
631 cir::FuncOp createCIRBuiltinFunction(mlir::Location loc, llvm::StringRef name,
632 cir::FuncType ty,
633 const clang::FunctionDecl *fd);
634
635 /// Mark the function as a special member (e.g. constructor, destructor)
636 void setCXXSpecialMemberAttr(cir::FuncOp funcOp,
637 const clang::FunctionDecl *funcDecl);
638
639 cir::FuncOp createRuntimeFunction(cir::FuncType ty, llvm::StringRef name,
640 mlir::ArrayAttr = {}, bool isLocal = false,
641 bool assumeConvergent = false);
642
643 static constexpr const char *builtinCoroId = "__builtin_coro_id";
644 static constexpr const char *builtinCoroAlloc = "__builtin_coro_alloc";
645 static constexpr const char *builtinCoroBegin = "__builtin_coro_begin";
646 static constexpr const char *builtinCoroEnd = "__builtin_coro_end";
647
648 /// Given a builtin id for a function like "__builtin_fabsf", return a
649 /// Function* for "fabsf".
650 cir::FuncOp getBuiltinLibFunction(const FunctionDecl *fd, unsigned builtinID);
651
653 assert(cudaRuntime != nullptr);
654 return *cudaRuntime;
655 }
656
657 mlir::IntegerAttr getSize(CharUnits size) {
658 return builder.getSizeFromCharUnits(size);
659 }
660
661 /// Emit any needed decls for which code generation was deferred.
662 void emitDeferred();
663
664 /// Helper for `emitDeferred` to apply actual codegen.
665 void emitGlobalDecl(const clang::GlobalDecl &d);
666
667 const llvm::Triple &getTriple() const { return target.getTriple(); }
668
669 // Finalize CIR code generation.
670 void release();
671
672 /// Returns a pointer to a global variable representing a temporary with
673 /// static or thread storage duration.
674 mlir::Operation *getAddrOfGlobalTemporary(const MaterializeTemporaryExpr *mte,
675 const Expr *init);
676
677 /// -------
678 /// Visibility and Linkage
679 /// -------
680
681 static mlir::SymbolTable::Visibility
682 getMLIRVisibilityFromCIRLinkage(cir::GlobalLinkageKind GLK);
683 static cir::VisibilityKind getGlobalVisibilityKindFromClangVisibility(
684 clang::VisibilityAttr::VisibilityType visibility);
685 cir::VisibilityAttr getGlobalVisibilityAttrFromDecl(const Decl *decl);
686 cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd);
687 static mlir::SymbolTable::Visibility getMLIRVisibility(cir::GlobalOp op);
688 cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd,
689 GVALinkage linkage,
690 bool isConstantVariable);
691 void setFunctionLinkage(GlobalDecl gd, cir::FuncOp f) {
692 cir::GlobalLinkageKind l = getFunctionLinkage(gd);
693 f.setLinkageAttr(cir::GlobalLinkageKindAttr::get(&getMLIRContext(), l));
694 mlir::SymbolTable::setSymbolVisibility(f,
696 }
697
698 cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd,
699 bool isConstant);
700
701 void addReplacement(llvm::StringRef name, mlir::Operation *op);
702
703 /// Helpers to emit "not yet implemented" error diagnostics
704 DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef);
705
706 template <typename T>
707 DiagnosticBuilder errorNYI(SourceLocation loc, llvm::StringRef feature,
708 const T &name) {
709 unsigned diagID =
710 diags.getCustomDiagID(DiagnosticsEngine::Error,
711 "ClangIR code gen Not Yet Implemented: %0: %1");
712 return diags.Report(loc, diagID) << feature << name;
713 }
714
715 DiagnosticBuilder errorNYI(mlir::Location loc, llvm::StringRef feature) {
716 // TODO: Convert the location to a SourceLocation
717 unsigned diagID = diags.getCustomDiagID(
718 DiagnosticsEngine::Error, "ClangIR code gen Not Yet Implemented: %0");
719 return diags.Report(diagID) << feature;
720 }
721
722 DiagnosticBuilder errorNYI(llvm::StringRef feature) const {
723 // TODO: Make a default location? currSrcLoc?
724 unsigned diagID = diags.getCustomDiagID(
725 DiagnosticsEngine::Error, "ClangIR code gen Not Yet Implemented: %0");
726 return diags.Report(diagID) << feature;
727 }
728
729 DiagnosticBuilder errorNYI(SourceRange, llvm::StringRef);
730
731 template <typename T>
732 DiagnosticBuilder errorNYI(SourceRange loc, llvm::StringRef feature,
733 const T &name) {
734 return errorNYI(loc.getBegin(), feature, name) << loc;
735 }
736
737 /// Emit a general error that something can't be done.
738 void error(SourceLocation loc, llvm::StringRef error);
739
740 /// Print out an error that codegen doesn't support the specified stmt yet.
741 void errorUnsupported(const Stmt *s, llvm::StringRef type);
742
743 /// Print out an error that codegen doesn't support the specified decl yet.
744 void errorUnsupported(const Decl *d, llvm::StringRef type);
745
746private:
747 // An ordered map of canonical GlobalDecls to their mangled names.
748 llvm::MapVector<clang::GlobalDecl, llvm::StringRef> mangledDeclNames;
749 llvm::StringMap<clang::GlobalDecl, llvm::BumpPtrAllocator> manglings;
750
751 // FIXME: should we use llvm::TrackingVH<mlir::Operation> here?
752 llvm::MapVector<StringRef, mlir::Operation *> replacements;
753 /// Call replaceAllUsesWith on all pairs in replacements.
754 void applyReplacements();
755
756 /// A helper function to replace all uses of OldF to NewF that replace
757 /// the type of pointer arguments. This is not needed to tradtional
758 /// pipeline since LLVM has opaque pointers but CIR not.
759 void replacePointerTypeArgs(cir::FuncOp oldF, cir::FuncOp newF);
760
761 void setNonAliasAttributes(GlobalDecl gd, mlir::Operation *op);
762
763 /// Map source language used to a CIR attribute.
764 std::optional<cir::SourceLanguage> getCIRSourceLanguage() const;
765};
766} // namespace CIRGen
767
768} // namespace clang
769
770#endif // LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H
Defines the SourceManager interface.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:226
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
void updateResolvedBlockAddress(cir::BlockAddressOp op, cir::LabelOp newLabel)
void emitCXXGlobalVarDeclInit(const VarDecl *varDecl, cir::GlobalOp addr, bool performInit)
Emit the function that initializes the specified global.
void replaceUsesOfNonProtoTypeWithRealFunction(mlir::Operation *old, cir::FuncOp newFn)
This function is called when we implement a function with no prototype, e.g.
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)
void setGlobalVisibility(mlir::Operation *op, const NamedDecl *d) const
Set the visibility for the given global.
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.
clang::ASTContext & getASTContext() const
cir::FuncOp getAddrOfCXXStructor(clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo=nullptr, cir::FuncType fnType=nullptr, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
CIRGenCUDARuntime & getCUDARuntime()
cir::FuncOp createRuntimeFunction(cir::FuncType ty, llvm::StringRef name, mlir::ArrayAttr={}, bool isLocal=false, bool assumeConvergent=false)
llvm::DenseMap< cir::BlockAddrInfoAttr, cir::LabelOp > blockAddressInfoToLabel
Map BlockAddrInfoAttr (function name, label name) to the corresponding CIR LabelOp.
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 emitOMPCapturedExpr(const OMPCapturedExprDecl *d)
llvm::DenseMap< const VarDecl *, cir::GlobalOp > initializerConstants
void mapUnresolvedBlockAddress(cir::BlockAddressOp op)
bool mustBeEmitted(const clang::ValueDecl *d)
Determine whether the definition must be emitted; if this returns false, the definition can be emitte...
void emitGlobalOpenACCDeclareDecl(const clang::OpenACCDeclareDecl *cd)
mlir::IntegerAttr getSize(CharUnits size)
void addDefaultFunctionAttributes(StringRef name, bool hasOptNoneAttr, bool attrOnCallSite, mlir::NamedAttrList &attrs)
Helper function for constructAttributeList/others.
DiagnosticBuilder errorNYI(SourceRange loc, llvm::StringRef feature, const T &name)
CIRGenBuilderTy & getBuilder()
void setDSOLocal(mlir::Operation *op) const
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::GlobalOp getOrCreateCIRGlobal(llvm::StringRef mangledName, mlir::Type ty, LangAS langAS, const VarDecl *d, ForDefinition_t isForDefinition)
If the specified mangled name is not in the module, create and return an mlir::GlobalOp value.
cir::FuncOp createCIRBuiltinFunction(mlir::Location loc, llvm::StringRef name, cir::FuncType ty, const clang::FunctionDecl *fd)
Create a CIR function with builtin attribute set.
llvm::DenseMap< const Decl *, cir::GlobalOp > staticLocalDeclMap
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.
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)
void mapResolvedBlockAddress(cir::BlockAddressOp op, cir::LabelOp)
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.
mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc, QualType ty, bool forEH=false)
Get the address of the RTTI descriptor for the given type.
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
mlir::TypedAttr emitNullConstantForBase(const CXXRecordDecl *record)
Return a null constant appropriate for zero-initializing a base class with the given type.
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
static mlir::SymbolTable::Visibility getMLIRVisibility(Visibility v)
void emitTentativeDefinition(const VarDecl *d)
CharUnits getMinimumObjectSize(QualType ty)
Returns the minimum object size for an object of the given type.
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.
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::ArrayAttr extraAttrs={})
void emitGlobalVarDefinition(const clang::VarDecl *vd, bool isTentative=false)
cir::FuncOp getAddrOfThunk(StringRef name, mlir::Type fnTy, GlobalDecl gd)
Get or create a thunk function with the given name and type.
void setTLSMode(mlir::Operation *op, const VarDecl &d)
Set TLS mode for the given operation based on the given variable declaration.
DiagnosticBuilder errorNYI(mlir::Location loc, llvm::StringRef feature)
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.
mlir::TypedAttr emitNullConstantAttr(QualType t)
void emitAliasForGlobal(llvm::StringRef mangledName, mlir::Operation *op, GlobalDecl aliasGD, cir::FuncOp aliasee, cir::GlobalLinkageKind linkage)
mlir::Value emitMemberPointerConstant(const UnaryOperator *e)
void emitGlobalOpenACCDecl(const clang::OpenACCConstructDecl *cd)
void emitExplicitCastExprType(const ExplicitCastExpr *e, CIRGenFunction *cgf=nullptr)
Emit type info if type of an expression is a variably modified type.
const cir::CIRDataLayout getDataLayout() const
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.
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.
cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd)
void updateCompletedType(const clang::TagDecl *td)
const clang::CodeGenOptions & getCodeGenOpts() const
const clang::LangOptions & getLangOpts() const
void constructAttributeList(llvm::StringRef name, const CIRGenFunctionInfo &info, CIRGenCalleeInfo calleeInfo, mlir::NamedAttrList &attrs, llvm::MutableArrayRef< mlir::NamedAttrList > argAttrs, mlir::NamedAttrList &retAttrs, cir::CallingConv &callingConv, cir::SideEffect &sideEffect, bool attrOnCallSite, bool isThunk)
Get the CIR attributes and calling convention to use for a particular function type.
void emitOpenACCRoutineDecl(const clang::FunctionDecl *funcDecl, cir::FuncOp func, SourceLocation pragmaLoc, ArrayRef< const OpenACCClause * > clauses)
static constexpr const char * builtinCoroAlloc
cir::TLS_Model getDefaultCIRTLSModel() const
Get TLS mode from CodeGenOptions.
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.
void addDeferredDeclToEmit(clang::GlobalDecl GD)
bool shouldEmitCUDAGlobalVar(const VarDecl *global) const
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)
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.
llvm::DenseSet< cir::BlockAddressOp > unresolvedBlockAddressToLabel
Track CIR BlockAddressOps that cannot be resolved immediately because their LabelOp has not yet been ...
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
static cir::VisibilityKind getGlobalVisibilityKindFromClangVisibility(clang::VisibilityAttr::VisibilityType visibility)
llvm::StringMap< unsigned > cgGlobalNames
void setCXXSpecialMemberAttr(cir::FuncOp funcOp, const clang::FunctionDecl *funcDecl)
Mark the function as a special member (e.g. constructor, destructor)
mlir::Operation * getGlobalValue(llvm::StringRef ref)
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
cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd, GVALinkage linkage, bool isConstantVariable)
mlir::MLIRContext & getMLIRContext()
mlir::Operation * getAddrOfGlobal(clang::GlobalDecl gd, ForDefinition_t isForDefinition=NotForDefinition)
DiagnosticBuilder errorNYI(llvm::StringRef feature) const
static cir::GlobalOp createGlobalOp(CIRGenModule &cgm, mlir::Location loc, llvm::StringRef name, mlir::Type t, bool isConstant=false, mlir::Operation *insertPoint=nullptr)
void maybeSetTrivialComdat(const clang::Decl &d, mlir::Operation *op)
cir::GlobalOp getStaticLocalDeclAddress(const VarDecl *d)
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.
llvm::MapVector< cir::BlockAddressOp, cir::LabelOp > blockAddressToLabel
Map CIR BlockAddressOps directly to their resolved LabelOps.
bool lookupRepresentativeDecl(llvm::StringRef mangledName, clang::GlobalDecl &gd) const
void emitDeclContext(const DeclContext *dc)
static constexpr const char * builtinCoroBegin
static constexpr const char * builtinCoroId
void emitGlobal(clang::GlobalDecl gd)
Emit code for a single global function or variable declaration.
cir::LabelOp lookupBlockAddressInfo(cir::BlockAddrInfoAttr blockInfo)
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)
cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd, bool isConstant)
void mapBlockAddress(cir::BlockAddrInfoAttr blockInfo, cir::LabelOp label)
static constexpr const char * builtinCoroEnd
void setCIRFunctionAttributesForDefinition(const clang::FunctionDecl *fd, cir::FuncOp f)
Set extra attributes (inline, etc.) for a function.
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)
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...
void emitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *d)
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)
mlir::Attribute getConstantArrayFromStringLiteral(const StringLiteral *e)
Return a constant array for the given string.
cir::VisibilityAttr getGlobalVisibilityAttrFromDecl(const Decl *decl)
void setCommonAttributes(GlobalDecl gd, mlir::Operation *op)
Set attributes which are common to any form of a global definition (alias, Objective-C method,...
clang::CharUnits getNaturalTypeAlignment(clang::QualType t, LValueBaseInfo *baseInfo=nullptr)
FIXME: this could likely be a common helper and not necessarily related with codegen.
This class organizes the cross-module state that is used while lowering AST types to CIR types.
Definition CIRGenTypes.h:48
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
CharUnits - 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...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
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:780
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
ExplicitCastExpr - An explicit cast written in the source code.
Definition Expr.h:3931
This represents one expression.
Definition Expr.h:112
Represents a function declaration or definition.
Definition Decl.h:2000
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:57
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...
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4921
This represents a decl that may have a name.
Definition Decl.h:274
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:937
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:86
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1802
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
Exposes information about the current target.
Definition TargetInfo.h:226
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:2247
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:926
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.
The JSON file list parser is used to communicate input to InstallAPI.
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