clang 23.0.0git
CIRGenBuilder.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
10#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
11
12#include "Address.h"
13#include "CIRGenRecordLayout.h"
14#include "CIRGenTypeCache.h"
15#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
16#include "mlir/IR/Attributes.h"
17#include "mlir/IR/Builders.h"
18#include "mlir/IR/BuiltinAttributes.h"
19#include "mlir/Support/LLVM.h"
22
25#include "llvm/ADT/APFloat.h"
26#include "llvm/ADT/STLExtras.h"
27#include "llvm/IR/FPEnv.h"
28
29namespace clang::CIRGen {
30
32 const CIRGenTypeCache &typeCache;
33 bool isFPConstrained = false;
34 llvm::fp::ExceptionBehavior defaultConstrainedExcept = llvm::fp::ebStrict;
35 llvm::RoundingMode defaultConstrainedRounding = llvm::RoundingMode::Dynamic;
36
37 llvm::StringMap<unsigned> recordNames;
38 llvm::StringMap<unsigned> globalsVersioning;
39
40public:
41 CIRGenBuilderTy(mlir::MLIRContext &mlirContext, const CIRGenTypeCache &tc)
42 : CIRBaseBuilderTy(mlirContext), typeCache(tc) {}
43
44 /// Get a cir::ConstArrayAttr for a string literal.
45 /// Note: This is different from what is returned by
46 /// mlir::Builder::getStringAttr() which is an mlir::StringAttr.
47 mlir::Attribute getString(llvm::StringRef str, mlir::Type eltTy,
48 std::optional<size_t> size,
49 bool ensureNullTerm = true) {
50 size_t finalSize = size.value_or(str.size());
51
52 size_t lastNonZeroPos = str.find_last_not_of('\0');
53 // If the string is full of null bytes, emit a #cir.zero rather than
54 // a #cir.const_array.
55 if (lastNonZeroPos == llvm::StringRef::npos) {
56 auto arrayTy = cir::ArrayType::get(eltTy, finalSize);
57 return cir::ZeroAttr::get(arrayTy);
58 }
59
60 // We emit trailing zeros for all trailing zeros, so the null-terminator in
61 // a constant is always in trailing zeros, and the null-terminator is
62 // skipped in the CIR representation.
63 size_t trailingZerosNum = finalSize - lastNonZeroPos - 1;
64 auto truncatedArrayTy =
65 cir::ArrayType::get(eltTy, finalSize - trailingZerosNum);
66 auto strAttr = mlir::StringAttr::get(str.drop_back(trailingZerosNum),
67 truncatedArrayTy);
68
69 // Most C strings are null terminated, so if we are ensuring there is one,
70 // grow the array size by 1 to add a trailing zero if necessary. The 'auto'
71 // calculation of trailing zeros (the difference between the provided string
72 // and the type) will ensure we get the count correct.
73 finalSize += (ensureNullTerm && trailingZerosNum == 0);
74
75 auto fullArrayTy = cir::ArrayType::get(eltTy, finalSize);
76 return cir::ConstArrayAttr::get(fullArrayTy, strAttr);
77 }
78
79 cir::ConstArrayAttr getConstArray(mlir::Attribute attrs,
80 cir::ArrayType arrayTy) const {
81 return cir::ConstArrayAttr::get(arrayTy, attrs);
82 }
83
84 mlir::Attribute getConstRecordOrZeroAttr(mlir::ArrayAttr arrayAttr,
85 bool packed = false,
86 bool padded = false,
87 mlir::Type type = {});
88
89 cir::ConstRecordAttr getAnonConstRecord(mlir::ArrayAttr arrayAttr,
90 bool packed = false,
91 bool padded = false,
92 mlir::Type ty = {}) {
94 for (auto &f : arrayAttr) {
95 auto ta = mlir::cast<mlir::TypedAttr>(f);
96 members.push_back(ta.getType());
97 }
98
99 if (!ty)
100 ty = getAnonRecordTy(members, packed, padded);
101
102 auto sTy = mlir::cast<cir::RecordType>(ty);
103 return cir::ConstRecordAttr::get(sTy, arrayAttr);
104 }
105
106 cir::TypeInfoAttr getTypeInfo(mlir::ArrayAttr fieldsAttr) {
107 cir::ConstRecordAttr anonRecord = getAnonConstRecord(fieldsAttr);
108 return cir::TypeInfoAttr::get(anonRecord.getType(), fieldsAttr);
109 }
110
111 std::string getUniqueAnonRecordName() { return getUniqueRecordName("anon"); }
112
113 std::string getUniqueRecordName(const std::string &baseName) {
114 auto it = recordNames.find(baseName);
115 if (it == recordNames.end()) {
116 recordNames[baseName] = 0;
117 return baseName;
118 }
119
120 return baseName + "." + std::to_string(recordNames[baseName]++);
121 }
122
123 //
124 // Floating point specific helpers
125 // -------------------------------
126 //
127
128 /// Enable/Disable use of constrained floating point math. When enabled the
129 /// CreateF<op>() calls instead create constrained floating point intrinsic
130 /// calls. Fast math flags are unaffected by this setting.
131 void setIsFPConstrained(bool isCon) { isFPConstrained = isCon; }
132
133 /// Query for the use of constrained floating point math
134 bool getIsFPConstrained() const { return isFPConstrained; }
135
136 /// Set the exception handling to be used with constrained floating point
137 void setDefaultConstrainedExcept(llvm::fp::ExceptionBehavior newExcept) {
138 assert(llvm::convertExceptionBehaviorToStr(newExcept) &&
139 "Garbage strict exception behavior!");
140 defaultConstrainedExcept = newExcept;
141 }
142
143 /// Get the exception handling used with constrained floating point
144 llvm::fp::ExceptionBehavior getDefaultConstrainedExcept() const {
145 return defaultConstrainedExcept;
146 }
147
148 /// Set the rounding mode handling to be used with constrained floating point
149 void setDefaultConstrainedRounding(llvm::RoundingMode newRounding) {
150 assert(llvm::convertRoundingModeToStr(newRounding) &&
151 "Garbage strict rounding mode!");
152 defaultConstrainedRounding = newRounding;
153 }
154
155 /// Get the rounding mode handling used with constrained floating point
156 llvm::RoundingMode getDefaultConstrainedRounding() const {
157 return defaultConstrainedRounding;
158 }
159
160 cir::LongDoubleType getLongDoubleTy(const llvm::fltSemantics &format) const {
161 if (&format == &llvm::APFloat::IEEEdouble())
162 return cir::LongDoubleType::get(getContext(), typeCache.doubleTy);
163 if (&format == &llvm::APFloat::x87DoubleExtended())
164 return cir::LongDoubleType::get(getContext(), typeCache.fP80Ty);
165 if (&format == &llvm::APFloat::IEEEquad())
166 return cir::LongDoubleType::get(getContext(), typeCache.fP128Ty);
167 if (&format == &llvm::APFloat::PPCDoubleDouble())
168 llvm_unreachable("NYI: PPC double-double format for long double");
169 llvm_unreachable("Unsupported format for long double");
170 }
171
172 mlir::Type getPtrToVPtrType() {
173 return getPointerTo(cir::VPtrType::get(getContext()));
174 }
175
176 cir::FuncType getFuncType(llvm::ArrayRef<mlir::Type> params, mlir::Type retTy,
177 bool isVarArg = false) {
178 return cir::FuncType::get(params, retTy, isVarArg);
179 }
180
181 /// Get a CIR record kind from a AST declaration tag.
182 /// Returns true if the tag kind represents a C++ class (as opposed to a
183 /// plain struct).
186 }
187
188 /// Returns true if the tag kind is a union.
191 }
192
193 /// Get a CIR named record type.
194 ///
195 /// If a record already exists and is complete, but the client tries to fetch
196 /// it with a different set of attributes, this method will crash.
198 bool packed, bool padded,
199 llvm::StringRef name) {
200 const auto nameAttr = getStringAttr(name);
202
203 // Create or get the struct type (named anonymous struct helper — always
204 // struct, never class or union at this call site).
205 auto type = cir::StructType::get(getContext(), members, nameAttr, packed,
206 padded, /*is_class=*/false);
207
208 // If we found an existing type, verify that either it is incomplete or
209 // it matches the requested attributes.
210 assert(!type.isIncomplete() ||
211 (type.getMembers() == members && type.getPacked() == packed &&
212 type.getPadded() == padded));
213
214 // Complete an incomplete record or ensure the existing complete record
215 // matches the requested attributes.
216 type.complete(members, packed, padded);
217
218 return type;
219 }
220
221 cir::RecordType getCompleteRecordType(mlir::ArrayAttr fields,
222 bool packed = false,
223 bool padded = false,
224 llvm::StringRef name = "");
225
226 /// Get an incomplete CIR record type. If we have a complete record
227 /// declaration, we may create an incomplete type and then add the
228 /// members, so \p rd here may be complete.
230 const clang::RecordDecl *rd) {
231 const mlir::StringAttr nameAttr = getStringAttr(name);
232 if (rd && tagKindIsUnion(rd->getTagKind()))
233 return cir::UnionType::get(getContext(), nameAttr);
234 bool is_class = rd && tagKindIsClass(rd->getTagKind());
235 return cir::StructType::get(getContext(), nameAttr, is_class);
236 }
237
238 //
239 // Operation creation helpers
240 // --------------------------
241 //
242 cir::MemCpyOp createMemCpy(mlir::Location loc, mlir::Value dst,
243 mlir::Value src, mlir::Value len) {
244 return cir::MemCpyOp::create(*this, loc, dst, src, len);
245 }
246
247 cir::MemMoveOp createMemMove(mlir::Location loc, mlir::Value dst,
248 mlir::Value src, mlir::Value len) {
249 return cir::MemMoveOp::create(*this, loc, dst, src, len);
250 }
251
252 cir::MemSetOp createMemSet(mlir::Location loc, mlir::Value dst,
253 mlir::Value val, mlir::Value len) {
254 assert(val.getType() == getUInt8Ty());
255 return cir::MemSetOp::create(*this, loc, dst, {}, val, len);
256 }
257
258 cir::MemSetOp createMemSet(mlir::Location loc, Address dst, mlir::Value val,
259 mlir::Value len) {
260 mlir::IntegerAttr align = getAlignmentAttr(dst.getAlignment());
261 assert(val.getType() == getUInt8Ty());
262 return cir::MemSetOp::create(*this, loc, dst.getPointer(), align, val, len);
263 }
264 // ---------------------------
265
266 cir::DataMemberAttr getDataMemberAttr(cir::DataMemberType ty,
267 unsigned memberIndex) {
268 return cir::DataMemberAttr::get(ty, memberIndex);
269 }
270
271 cir::DataMemberAttr getNullDataMemberAttr(cir::DataMemberType ty) {
272 return cir::DataMemberAttr::get(ty);
273 }
274
275 // Return true if the value is a null constant such as null pointer, (+0.0)
276 // for floating-point or zero initializer
277 bool isNullValue(mlir::Attribute attr) const {
278 if (mlir::isa<cir::ZeroAttr>(attr))
279 return true;
280
281 if (const auto ptrVal = mlir::dyn_cast<cir::ConstPtrAttr>(attr))
282 return ptrVal.isNullValue();
283
284 if (const auto intVal = mlir::dyn_cast<cir::IntAttr>(attr))
285 return intVal.isNullValue();
286
287 if (const auto boolVal = mlir::dyn_cast<cir::BoolAttr>(attr))
288 return !boolVal.getValue();
289
290 if (auto fpAttr = mlir::dyn_cast<cir::FPAttr>(attr)) {
291 auto fpVal = fpAttr.getValue();
292 bool ignored;
293 llvm::APFloat fv(+0.0);
294 fv.convert(fpVal.getSemantics(), llvm::APFloat::rmNearestTiesToEven,
295 &ignored);
296 return fv.bitwiseIsEqual(fpVal);
297 }
298 if (const auto recordVal = mlir::dyn_cast<cir::ConstRecordAttr>(attr)) {
299 for (const auto elt : recordVal.getMembers()) {
300 // FIXME(cir): the record's ID should not be considered a member.
301 if (mlir::isa<mlir::StringAttr>(elt))
302 continue;
303 if (!isNullValue(elt))
304 return false;
305 }
306 return true;
307 }
308
309 if (const auto arrayVal = mlir::dyn_cast<cir::ConstArrayAttr>(attr)) {
310 if (mlir::isa<mlir::StringAttr>(arrayVal.getElts()))
311 return false;
312
313 return llvm::all_of(
314 mlir::cast<mlir::ArrayAttr>(arrayVal.getElts()),
315 [&](const mlir::Attribute &elt) { return isNullValue(elt); });
316 }
317 return false;
318 }
319
320 //
321 // Type helpers
322 // ------------
323 //
324 cir::IntType getUIntNTy(int n) {
325 switch (n) {
326 case 8:
327 return getUInt8Ty();
328 case 16:
329 return getUInt16Ty();
330 case 32:
331 return getUInt32Ty();
332 case 64:
333 return getUInt64Ty();
334 default:
335 return cir::IntType::get(getContext(), n, false);
336 }
337 }
338
339 cir::IntType getSIntNTy(int n) {
340 switch (n) {
341 case 8:
342 return getSInt8Ty();
343 case 16:
344 return getSInt16Ty();
345 case 32:
346 return getSInt32Ty();
347 case 64:
348 return getSInt64Ty();
349 default:
350 return cir::IntType::get(getContext(), n, true);
351 }
352 }
353
354 cir::VoidType getVoidTy() { return typeCache.voidTy; }
355
356 cir::IntType getSInt8Ty() { return typeCache.sInt8Ty; }
357 cir::IntType getSInt16Ty() { return typeCache.sInt16Ty; }
358 cir::IntType getSInt32Ty() { return typeCache.sInt32Ty; }
359 cir::IntType getSInt64Ty() { return typeCache.sInt64Ty; }
360
361 cir::IntType getUInt8Ty() { return typeCache.uInt8Ty; }
362 cir::IntType getUInt16Ty() { return typeCache.uInt16Ty; }
363 cir::IntType getUInt32Ty() { return typeCache.uInt32Ty; }
364 cir::IntType getUInt64Ty() { return typeCache.uInt64Ty; }
365
366 cir::FP16Type getFp16Ty() { return typeCache.fP16Ty; }
367 cir::BF16Type getBfloat6Ty() { return typeCache.bFloat16Ty; }
368 cir::SingleType getSingleTy() { return typeCache.floatTy; }
369 cir::DoubleType getDoubleTy() { return typeCache.doubleTy; }
370
371 cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal);
372
373 cir::ConstantOp getConstInt(mlir::Location loc, llvm::APInt intVal,
374 bool isUnsigned = true);
375
376 cir::ConstantOp getConstInt(mlir::Location loc, mlir::Type t, uint64_t c);
377
378 cir::ConstantOp getConstFP(mlir::Location loc, mlir::Type t,
379 llvm::APFloat fpVal);
380
381 bool isInt8Ty(mlir::Type i) {
382 return i == typeCache.uInt8Ty || i == typeCache.sInt8Ty;
383 }
384 bool isInt16Ty(mlir::Type i) {
385 return i == typeCache.uInt16Ty || i == typeCache.sInt16Ty;
386 }
387 bool isInt32Ty(mlir::Type i) {
388 return i == typeCache.uInt32Ty || i == typeCache.sInt32Ty;
389 }
390 bool isInt64Ty(mlir::Type i) {
391 return i == typeCache.uInt64Ty || i == typeCache.sInt64Ty;
392 }
393 bool isInt(mlir::Type i) { return mlir::isa<cir::IntType>(i); }
394
395 cir::IntType getExtendedIntTy(cir::IntType ty, bool isSigned) {
396 switch (ty.getWidth()) {
397 case 8:
398 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
399 case 16:
400 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
401 case 32:
402 return isSigned ? typeCache.sInt64Ty : typeCache.uInt64Ty;
403 default:
404 llvm_unreachable("NYI");
405 }
406 }
407
408 cir::IntType getTruncatedIntTy(cir::IntType ty, bool isSigned) {
409 switch (ty.getWidth()) {
410 case 16:
411 return isSigned ? typeCache.sInt8Ty : typeCache.uInt8Ty;
412 case 32:
413 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
414 case 64:
415 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
416 default:
417 llvm_unreachable("NYI");
418 }
419 }
420
421 cir::VectorType
422 getExtendedOrTruncatedElementVectorType(cir::VectorType vt, bool isExtended,
423 bool isSigned = false) {
424 auto elementTy = mlir::dyn_cast_or_null<cir::IntType>(vt.getElementType());
425 assert(elementTy && "expected int vector");
426 return cir::VectorType::get(isExtended
427 ? getExtendedIntTy(elementTy, isSigned)
428 : getTruncatedIntTy(elementTy, isSigned),
429 vt.getSize());
430 }
431
432 // Fetch the type representing a pointer to unsigned int8 values.
433 cir::PointerType getUInt8PtrTy() { return typeCache.uInt8PtrTy; }
434
435 /// Get a CIR anonymous struct type.
437 bool packed = false, bool padded = false) {
439 return cir::StructType::get(getContext(), members, packed, padded,
440 /*is_class=*/false);
441 }
442
443 //===--------------------------------------------------------------------===//
444 // Constant creation helpers
445 //===--------------------------------------------------------------------===//
446 cir::ConstantOp getSInt32(int32_t c, mlir::Location loc) {
447 return getConstantInt(loc, getSInt32Ty(), c);
448 }
449 cir::ConstantOp getUInt32(uint32_t c, mlir::Location loc) {
450 return getConstantInt(loc, getUInt32Ty(), c);
451 }
452 cir::ConstantOp getSInt64(uint64_t c, mlir::Location loc) {
453 return getConstantInt(loc, getSInt64Ty(), c);
454 }
455 cir::ConstantOp getUInt64(uint64_t c, mlir::Location loc) {
456 return getConstantInt(loc, getUInt64Ty(), c);
457 }
458
459 cir::ConstantOp getZero(mlir::Location loc, mlir::Type ty) {
460 // TODO: dispatch creation for primitive types.
461 assert((mlir::isa<cir::RecordType>(ty) || mlir::isa<cir::ArrayType>(ty) ||
462 mlir::isa<cir::VectorType>(ty)) &&
463 "NYI for other types");
464 return cir::ConstantOp::create(*this, loc, cir::ZeroAttr::get(ty));
465 }
466
467 //===--------------------------------------------------------------------===//
468 // UnaryOp creation helpers
469 //===--------------------------------------------------------------------===//
470 mlir::Value createNeg(mlir::Location loc, mlir::Value value,
471 bool nsw = false) {
472
473 if (auto intTy = mlir::dyn_cast<cir::IntType>(value.getType())) {
474 // Source is a unsigned integer: first cast it to signed.
475 if (intTy.isUnsigned())
476 value = createIntCast(value, getSIntNTy(intTy.getWidth()));
477 return createMinus(loc, value, nsw);
478 }
479
480 llvm_unreachable("negation for the given type is NYI");
481 }
482
483 //===--------------------------------------------------------------------===//
484 // CastOp creation helpers
485 //===--------------------------------------------------------------------===//
486
487 // TODO: split this to createFPExt/createFPTrunc when we have dedicated cast
488 // operations.
489 mlir::Value createFloatingCast(mlir::Value v, mlir::Type destType) {
491
492 return cir::CastOp::create(*this, v.getLoc(), destType,
493 cir::CastKind::floating, v);
494 }
495
496 mlir::Value createDynCast(mlir::Location loc, mlir::Value src,
497 cir::PointerType destType, bool isRefCast,
498 cir::DynamicCastInfoAttr info) {
499 auto castKind =
500 isRefCast ? cir::DynamicCastKind::Ref : cir::DynamicCastKind::Ptr;
501 return cir::DynamicCastOp::create(*this, loc, destType, castKind, src, info,
502 /*relative_layout=*/false);
503 }
504
505 mlir::Value createDynCastToVoid(mlir::Location loc, mlir::Value src,
506 bool vtableUseRelativeLayout) {
507 // TODO(cir): consider address space here.
509 cir::PointerType destTy = getVoidPtrTy();
510 return cir::DynamicCastOp::create(
511 *this, loc, destTy, cir::DynamicCastKind::Ptr, src,
512 cir::DynamicCastInfoAttr{}, vtableUseRelativeLayout);
513 }
514
515 //===--------------------------------------------------------------------===//
516 // Address creation helpers
517 //===--------------------------------------------------------------------===//
518 Address createBaseClassAddr(mlir::Location loc, Address addr,
519 mlir::Type destType, unsigned offset,
520 bool assumeNotNull) {
521 if (destType == addr.getElementType())
522 return addr;
523
524 auto ptrTy = getPointerTo(destType);
525 auto baseAddr =
526 cir::BaseClassAddrOp::create(*this, loc, ptrTy, addr.getPointer(),
527 mlir::APInt(64, offset), assumeNotNull);
528 return Address(baseAddr, destType, addr.getAlignment());
529 }
530
531 Address createDerivedClassAddr(mlir::Location loc, Address addr,
532 mlir::Type destType, unsigned offset,
533 bool assumeNotNull) {
534 if (destType == addr.getElementType())
535 return addr;
536
537 cir::PointerType ptrTy = getPointerTo(destType);
538 auto derivedAddr =
539 cir::DerivedClassAddrOp::create(*this, loc, ptrTy, addr.getPointer(),
540 mlir::APInt(64, offset), assumeNotNull);
541 return Address(derivedAddr, destType, addr.getAlignment());
542 }
543
544 //===--------------------------------------------------------------------===//
545 // Virtual Address creation helpers
546 //===--------------------------------------------------------------------===//
547 mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy,
548 mlir::Value addr, uint64_t offset) {
549 return cir::VTTAddrPointOp::create(*this, loc, retTy,
550 mlir::FlatSymbolRefAttr{}, addr, offset);
551 }
552
553 mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy,
554 mlir::FlatSymbolRefAttr sym, uint64_t offset) {
555 return cir::VTTAddrPointOp::create(*this, loc, retTy, sym, mlir::Value{},
556 offset);
557 }
558
559 //===--------------------------------------------------------------------===//
560 // Other creation helpers
561 //===--------------------------------------------------------------------===//
562 cir::IsFPClassOp createIsFPClass(mlir::Location loc, mlir::Value src,
563 cir::FPClassTest flags) {
564 return cir::IsFPClassOp::create(*this, loc, src, flags);
565 }
566
567 /// Cast the element type of the given address to a different type,
568 /// preserving information like the alignment.
569 Address createElementBitCast(mlir::Location loc, Address addr,
570 mlir::Type destType) {
571 if (destType == addr.getElementType())
572 return addr;
573
574 auto ptrTy = getPointerTo(destType);
575 return Address(createBitcast(loc, addr.getPointer(), ptrTy), destType,
576 addr.getAlignment());
577 }
578
579 cir::LoadOp createLoad(mlir::Location loc, Address addr,
580 bool isVolatile = false) {
581 mlir::IntegerAttr align = getAlignmentAttr(addr.getAlignment());
582 return cir::LoadOp::create(*this, loc, addr.getPointer(), /*isDeref=*/false,
583 isVolatile, /*alignment=*/align,
584 /*sync_scope=*/cir::SyncScopeKindAttr{},
585 /*mem_order=*/cir::MemOrderAttr{});
586 }
587
588 cir::LoadOp createAlignedLoad(mlir::Location loc, mlir::Type ty,
589 mlir::Value ptr, llvm::MaybeAlign align) {
590 if (ty != mlir::cast<cir::PointerType>(ptr.getType()).getPointee())
591 ptr = createPtrBitcast(ptr, ty);
592 uint64_t alignment = align ? align->value() : 0;
593 mlir::IntegerAttr alignAttr = getAlignmentAttr(alignment);
594 return cir::LoadOp::create(*this, loc, ptr, /*isDeref=*/false,
595 /*isVolatile=*/false, alignAttr,
596 /*sync_scope=*/cir::SyncScopeKindAttr{},
597 /*mem_order=*/cir::MemOrderAttr{});
598 }
599
600 cir::LoadOp
601 createAlignedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr,
603 return createAlignedLoad(loc, ty, ptr, align.getAsAlign());
604 }
605
606 cir::StoreOp createStore(mlir::Location loc, mlir::Value val, Address dst,
607 bool isVolatile = false,
608 mlir::IntegerAttr align = {},
609 cir::SyncScopeKindAttr scope = {},
610 cir::MemOrderAttr order = {}) {
611 if (!align)
612 align = getAlignmentAttr(dst.getAlignment());
613 return CIRBaseBuilderTy::createStore(loc, val, dst.getPointer(), isVolatile,
614 align, scope, order);
615 }
616
617 /// Create a cir.complex.real_ptr operation that derives a pointer to the real
618 /// part of the complex value pointed to by the specified pointer value.
619 mlir::Value createComplexRealPtr(mlir::Location loc, mlir::Value value) {
620 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
621 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
622 return cir::ComplexRealPtrOp::create(
623 *this, loc, getPointerTo(srcComplexTy.getElementType()), value);
624 }
625
626 Address createComplexRealPtr(mlir::Location loc, Address addr) {
627 return Address{createComplexRealPtr(loc, addr.getPointer()),
628 addr.getAlignment()};
629 }
630
631 /// Create a cir.complex.imag_ptr operation that derives a pointer to the
632 /// imaginary part of the complex value pointed to by the specified pointer
633 /// value.
634 mlir::Value createComplexImagPtr(mlir::Location loc, mlir::Value value) {
635 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
636 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
637 return cir::ComplexImagPtrOp::create(
638 *this, loc, getPointerTo(srcComplexTy.getElementType()), value);
639 }
640
641 Address createComplexImagPtr(mlir::Location loc, Address addr) {
642 return Address{createComplexImagPtr(loc, addr.getPointer()),
643 addr.getAlignment()};
644 }
645
646 using CIRBaseBuilderTy::createGetMember;
647 Address createGetMember(mlir::Location loc, Address base,
648 llvm::StringRef name, unsigned index) {
649 auto recordTy = mlir::cast<cir::RecordType>(base.getElementType());
650
651 assert(index < recordTy.getMembers().size() &&
652 "member index out of bounds");
653 mlir::Type memberTy = recordTy.getMembers()[index];
654 mlir::Type memberPtrTy = getPointerTo(memberTy);
655
656 auto moduleOp =
657 getInsertionBlock()->getParentOp()->getParentOfType<mlir::ModuleOp>();
658 mlir::DataLayout layout(moduleOp);
659 auto memberOffset =
660 CharUnits::fromQuantity(recordTy.getElementOffset(layout, index));
661
662 mlir::Value memberPtr =
663 createGetMember(loc, memberPtrTy, base.getBasePointer(), name, index);
664 return Address(memberPtr, memberTy,
665 base.getAlignment().alignmentAtOffset(memberOffset),
666 base.isKnownNonNull());
667 }
668
669 cir::GetRuntimeMemberOp createGetIndirectMember(mlir::Location loc,
670 mlir::Value objectPtr,
671 mlir::Value memberPtr) {
672 auto memberPtrTy = mlir::cast<cir::DataMemberType>(memberPtr.getType());
673
674 // TODO(cir): consider address space.
676 cir::PointerType resultTy = getPointerTo(memberPtrTy.getMemberTy());
677
678 return cir::GetRuntimeMemberOp::create(*this, loc, resultTy, objectPtr,
679 memberPtr);
680 }
681
682 /// Create a cir.ptr_stride operation to get access to an array element.
683 /// \p idx is the index of the element to access, \p shouldDecay is true if
684 /// the result should decay to a pointer to the element type.
685 mlir::Value getArrayElement(mlir::Location arrayLocBegin,
686 mlir::Location arrayLocEnd, mlir::Value arrayPtr,
687 mlir::Type eltTy, mlir::Value idx,
688 bool shouldDecay);
689
690 /// Returns a decayed pointer to the first element of the array
691 /// pointed to by \p arrayPtr.
692 mlir::Value maybeBuildArrayDecay(mlir::Location loc, mlir::Value arrayPtr,
693 mlir::Type eltTy);
694
695 // Convert byte offset to sequence of high-level indices suitable for
696 // GlobalViewAttr. Ideally we shouldn't deal with low-level offsets at all
697 // but currently some parts of Clang AST, which we don't want to touch just
698 // yet, return them.
700 int64_t offset, mlir::Type ty, cir::CIRDataLayout layout,
702
703 // Convert high-level indices (e.g. from GlobalViewAttr) to byte offset.
705 mlir::Type ty,
707
708 /// Creates a versioned global variable. If the symbol is already taken, an ID
709 /// will be appended to the symbol. The returned global must always be queried
710 /// for its name so it can be referenced correctly.
711 [[nodiscard]] cir::GlobalOp
712 createVersionedGlobal(mlir::ModuleOp module, mlir::Location loc,
713 mlir::StringRef name, mlir::Type type, bool isConstant,
714 cir::GlobalLinkageKind linkage,
715 mlir::ptr::MemorySpaceAttrInterface addrSpace = {}) {
716 // Create a unique name if the given name is already taken.
717 std::string uniqueName;
718 if (unsigned version = globalsVersioning[name.str()]++)
719 uniqueName = name.str() + "." + std::to_string(version);
720 else
721 uniqueName = name.str();
722
723 return createGlobal(module, loc, uniqueName, type, isConstant, linkage,
724 addrSpace);
725 }
726
727 cir::StackSaveOp createStackSave(mlir::Location loc, mlir::Type ty) {
728 return cir::StackSaveOp::create(*this, loc, ty);
729 }
730
731 cir::StackRestoreOp createStackRestore(mlir::Location loc, mlir::Value v) {
732 return cir::StackRestoreOp::create(*this, loc, v);
733 }
734
736 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
737 const llvm::APSInt &ltRes, const llvm::APSInt &eqRes,
738 const llvm::APSInt &gtRes, cir::CmpOrdering ordering) {
739 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
740 ltRes.getBitWidth() == gtRes.getBitWidth() &&
741 "the three comparison results must have the same bit width");
742 assert((ordering == cir::CmpOrdering::Strong ||
743 ordering == cir::CmpOrdering::Weak) &&
744 "total ordering must be strong or weak");
745 cir::IntType cmpResultTy = getSIntNTy(ltRes.getBitWidth());
746 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
747 getContext(), ordering, ltRes.getSExtValue(), eqRes.getSExtValue(),
748 gtRes.getSExtValue());
749 return cir::CmpThreeWayOp::create(*this, loc, cmpResultTy, lhs, rhs,
750 infoAttr);
751 }
752
754 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
755 const llvm::APSInt &ltRes, const llvm::APSInt &eqRes,
756 const llvm::APSInt &gtRes, const llvm::APSInt &unorderedRes) {
757 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
758 ltRes.getBitWidth() == gtRes.getBitWidth() &&
759 ltRes.getBitWidth() == unorderedRes.getBitWidth() &&
760 "the four comparison results must have the same bit width");
761 cir::IntType cmpResultTy = getSIntNTy(ltRes.getBitWidth());
762 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
763 getContext(), ltRes.getSExtValue(), eqRes.getSExtValue(),
764 gtRes.getSExtValue(), unorderedRes.getSExtValue());
765 return cir::CmpThreeWayOp::create(*this, loc, cmpResultTy, lhs, rhs,
766 infoAttr);
767 }
768
769 mlir::Value createSetBitfield(mlir::Location loc, mlir::Type resultType,
770 Address dstAddr, mlir::Type storageType,
771 mlir::Value src, const CIRGenBitFieldInfo &info,
772 bool isLvalueVolatile, bool useVolatile) {
773 unsigned offset = useVolatile ? info.volatileOffset : info.offset;
774
775 // If using AAPCS and the field is volatile, load with the size of the
776 // declared field
777 storageType =
778 useVolatile ? cir::IntType::get(storageType.getContext(),
779 info.volatileStorageSize, info.isSigned)
780 : storageType;
781 return cir::SetBitfieldOp::create(
782 *this, loc, resultType, dstAddr.getPointer(), storageType, src,
783 info.name, info.size, offset, info.isSigned, isLvalueVolatile,
784 dstAddr.getAlignment().getAsAlign().value());
785 }
786
787 mlir::Value createGetBitfield(mlir::Location loc, mlir::Type resultType,
788 Address addr, mlir::Type storageType,
789 const CIRGenBitFieldInfo &info,
790 bool isLvalueVolatile, bool useVolatile) {
791 unsigned offset = useVolatile ? info.volatileOffset : info.offset;
792
793 // If using AAPCS and the field is volatile, load with the size of the
794 // declared field
795 storageType =
796 useVolatile ? cir::IntType::get(storageType.getContext(),
797 info.volatileStorageSize, info.isSigned)
798 : storageType;
799 return cir::GetBitfieldOp::create(*this, loc, resultType, addr.getPointer(),
800 storageType, info.name, info.size, offset,
801 info.isSigned, isLvalueVolatile,
802 addr.getAlignment().getAsAlign().value());
803 }
804
805 mlir::Value createMaskedLoad(mlir::Location loc, mlir::Type ty,
806 mlir::Value ptr, llvm::Align alignment,
807 mlir::Value mask, mlir::Value passThru) {
808 assert(mlir::isa<cir::VectorType>(ty) && "Type should be vector");
809 assert(mask && "Mask should not be all-ones (null)");
810
811 if (!passThru)
812 passThru = this->getConstant(loc, cir::PoisonAttr::get(ty));
813
814 auto alignAttr =
815 this->getI64IntegerAttr(static_cast<int64_t>(alignment.value()));
816
817 return cir::VecMaskedLoadOp::create(*this, loc, ty, ptr, mask, passThru,
818 alignAttr);
819 }
820
821 cir::VecShuffleOp
822 createVecShuffle(mlir::Location loc, mlir::Value vec1, mlir::Value vec2,
824 auto vecType = mlir::cast<cir::VectorType>(vec1.getType());
825 auto resultTy =
826 cir::VectorType::get(vecType.getElementType(), maskAttrs.size());
827 return cir::VecShuffleOp::create(*this, loc, resultTy, vec1, vec2,
828 getArrayAttr(maskAttrs));
829 }
830
831 cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1,
832 mlir::Value vec2,
834 auto maskAttrs = llvm::to_vector_of<mlir::Attribute>(
835 llvm::map_range(mask, [&](int32_t idx) {
836 return cir::IntAttr::get(getSInt32Ty(), idx);
837 }));
838 return createVecShuffle(loc, vec1, vec2, maskAttrs);
839 }
840
841 cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1,
843 /// Create a unary shuffle. The second vector operand of the IR instruction
844 /// is poison.
845 cir::ConstantOp poison =
846 getConstant(loc, cir::PoisonAttr::get(vec1.getType()));
847 return createVecShuffle(loc, vec1, poison, mask);
848 }
849
850 template <typename... Operands>
851 mlir::Value emitIntrinsicCallOp(mlir::Location loc, const llvm::StringRef str,
852 const mlir::Type &resTy, Operands &&...op) {
853 return cir::LLVMIntrinsicCallOp::create(*this, loc,
854 this->getStringAttr(str), resTy,
855 std::forward<Operands>(op)...)
856 .getResult();
857 }
858};
859
860} // namespace clang::CIRGen
861
862#endif
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr)
cir::PointerType getPointerTo(mlir::Type ty)
mlir::Value createPtrBitcast(mlir::Value src, mlir::Type newPointeeTy)
mlir::Value createIntCast(mlir::Value src, mlir::Type newTy)
mlir::Value createBitcast(mlir::Value src, mlir::Type newTy)
CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
mlir::IntegerAttr getAlignmentAttr(clang::CharUnits alignment)
mlir::Value createMinus(mlir::Location loc, mlir::Value input, bool nsw=false)
cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, int64_t value)
cir::PointerType getVoidPtrTy(clang::LangAS langAS=clang::LangAS::Default)
cir::GlobalOp createGlobal(mlir::ModuleOp mlirModule, mlir::Location loc, mlir::StringRef name, mlir::Type type, bool isConstant, cir::GlobalLinkageKind linkage, mlir::ptr::MemorySpaceAttrInterface addrSpace)
C++ view class that accepts both !cir.struct and !cir.union types.
Definition CIRTypes.h:93
bool isKnownNonNull() const
Whether the pointer is known not to be null.
Definition Address.h:168
mlir::Value getPointer() const
Definition Address.h:98
mlir::Type getElementType() const
Definition Address.h:125
clang::CharUnits getAlignment() const
Definition Address.h:138
mlir::Value getBasePointer() const
Definition Address.h:103
cir::MemMoveOp createMemMove(mlir::Location loc, mlir::Value dst, mlir::Value src, mlir::Value len)
cir::RecordType getCompleteNamedRecordType(llvm::ArrayRef< mlir::Type > members, bool packed, bool padded, llvm::StringRef name)
Get a CIR named record type.
cir::StackSaveOp createStackSave(mlir::Location loc, mlir::Type ty)
cir::TypeInfoAttr getTypeInfo(mlir::ArrayAttr fieldsAttr)
cir::CmpThreeWayOp createThreeWayCmpTotalOrdering(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, const llvm::APSInt &ltRes, const llvm::APSInt &eqRes, const llvm::APSInt &gtRes, cir::CmpOrdering ordering)
mlir::Value createComplexRealPtr(mlir::Location loc, mlir::Value value)
Create a cir.complex.real_ptr operation that derives a pointer to the real part of the complex value ...
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1, mlir::Value vec2, llvm::ArrayRef< int64_t > mask)
cir::ConstantOp getUInt64(uint64_t c, mlir::Location loc)
mlir::Value emitIntrinsicCallOp(mlir::Location loc, const llvm::StringRef str, const mlir::Type &resTy, Operands &&...op)
cir::IntType getSIntNTy(int n)
cir::ConstRecordAttr getAnonConstRecord(mlir::ArrayAttr arrayAttr, bool packed=false, bool padded=false, mlir::Type ty={})
cir::ConstantOp getSInt64(uint64_t c, mlir::Location loc)
cir::IntType getTruncatedIntTy(cir::IntType ty, bool isSigned)
cir::RecordType getIncompleteRecordTy(llvm::StringRef name, const clang::RecordDecl *rd)
Get an incomplete CIR record type.
cir::ConstantOp getUInt32(uint32_t c, mlir::Location loc)
Address createGetMember(mlir::Location loc, Address base, llvm::StringRef name, unsigned index)
void setDefaultConstrainedRounding(llvm::RoundingMode newRounding)
Set the rounding mode handling to be used with constrained floating point.
cir::MemCpyOp createMemCpy(mlir::Location loc, mlir::Value dst, mlir::Value src, mlir::Value len)
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1, mlir::Value vec2, llvm::ArrayRef< mlir::Attribute > maskAttrs)
mlir::Value createNeg(mlir::Location loc, mlir::Value value, bool nsw=false)
cir::PointerType getUInt8PtrTy()
std::string getUniqueRecordName(const std::string &baseName)
mlir::Attribute getConstRecordOrZeroAttr(mlir::ArrayAttr arrayAttr, bool packed=false, bool padded=false, mlir::Type type={})
cir::CmpThreeWayOp createThreeWayCmpPartialOrdering(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, const llvm::APSInt &ltRes, const llvm::APSInt &eqRes, const llvm::APSInt &gtRes, const llvm::APSInt &unorderedRes)
mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy, mlir::FlatSymbolRefAttr sym, uint64_t offset)
mlir::Value createMaskedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr, llvm::Align alignment, mlir::Value mask, mlir::Value passThru)
Address createBaseClassAddr(mlir::Location loc, Address addr, mlir::Type destType, unsigned offset, bool assumeNotNull)
mlir::Value createComplexImagPtr(mlir::Location loc, mlir::Value value)
Create a cir.complex.imag_ptr operation that derives a pointer to the imaginary part of the complex v...
mlir::Value maybeBuildArrayDecay(mlir::Location loc, mlir::Value arrayPtr, mlir::Type eltTy)
Returns a decayed pointer to the first element of the array pointed to by arrayPtr.
cir::LoadOp createAlignedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr, llvm::MaybeAlign align)
cir::ConstantOp getConstFP(mlir::Location loc, mlir::Type t, llvm::APFloat fpVal)
mlir::Value createFloatingCast(mlir::Value v, mlir::Type destType)
cir::FuncType getFuncType(llvm::ArrayRef< mlir::Type > params, mlir::Type retTy, bool isVarArg=false)
cir::MemSetOp createMemSet(mlir::Location loc, Address dst, mlir::Value val, mlir::Value len)
cir::IntType getExtendedIntTy(cir::IntType ty, bool isSigned)
Address createDerivedClassAddr(mlir::Location loc, Address addr, mlir::Type destType, unsigned offset, bool assumeNotNull)
static bool tagKindIsUnion(const clang::TagTypeKind kind)
Returns true if the tag kind is a union.
uint64_t computeOffsetFromGlobalViewIndices(const cir::CIRDataLayout &layout, mlir::Type ty, llvm::ArrayRef< int64_t > indices)
cir::GetRuntimeMemberOp createGetIndirectMember(mlir::Location loc, mlir::Value objectPtr, mlir::Value memberPtr)
llvm::RoundingMode getDefaultConstrainedRounding() const
Get the rounding mode handling used with constrained floating point.
Address createElementBitCast(mlir::Location loc, Address addr, mlir::Type destType)
Cast the element type of the given address to a different type, preserving information like the align...
void setDefaultConstrainedExcept(llvm::fp::ExceptionBehavior newExcept)
Set the exception handling to be used with constrained floating point.
static bool tagKindIsClass(const clang::TagTypeKind kind)
Get a CIR record kind from a AST declaration tag.
mlir::Value createDynCastToVoid(mlir::Location loc, mlir::Value src, bool vtableUseRelativeLayout)
cir::ConstantOp getZero(mlir::Location loc, mlir::Type ty)
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1, llvm::ArrayRef< int64_t > mask)
mlir::Value createDynCast(mlir::Location loc, mlir::Value src, cir::PointerType destType, bool isRefCast, cir::DynamicCastInfoAttr info)
llvm::fp::ExceptionBehavior getDefaultConstrainedExcept() const
Get the exception handling used with constrained floating point.
mlir::Value createGetBitfield(mlir::Location loc, mlir::Type resultType, Address addr, mlir::Type storageType, const CIRGenBitFieldInfo &info, bool isLvalueVolatile, bool useVolatile)
cir::StructType getAnonRecordTy(llvm::ArrayRef< mlir::Type > members, bool packed=false, bool padded=false)
Get a CIR anonymous struct type.
bool isNullValue(mlir::Attribute attr) const
cir::StackRestoreOp createStackRestore(mlir::Location loc, mlir::Value v)
mlir::Value createSetBitfield(mlir::Location loc, mlir::Type resultType, Address dstAddr, mlir::Type storageType, mlir::Value src, const CIRGenBitFieldInfo &info, bool isLvalueVolatile, bool useVolatile)
Address createComplexRealPtr(mlir::Location loc, Address addr)
cir::GlobalOp createVersionedGlobal(mlir::ModuleOp module, mlir::Location loc, mlir::StringRef name, mlir::Type type, bool isConstant, cir::GlobalLinkageKind linkage, mlir::ptr::MemorySpaceAttrInterface addrSpace={})
Creates a versioned global variable.
cir::StoreOp createStore(mlir::Location loc, mlir::Value val, Address dst, bool isVolatile=false, mlir::IntegerAttr align={}, cir::SyncScopeKindAttr scope={}, cir::MemOrderAttr order={})
bool getIsFPConstrained() const
Query for the use of constrained floating point math.
CIRGenBuilderTy(mlir::MLIRContext &mlirContext, const CIRGenTypeCache &tc)
cir::IsFPClassOp createIsFPClass(mlir::Location loc, mlir::Value src, cir::FPClassTest flags)
cir::RecordType getCompleteRecordType(mlir::ArrayAttr fields, bool packed=false, bool padded=false, llvm::StringRef name="")
mlir::Attribute getString(llvm::StringRef str, mlir::Type eltTy, std::optional< size_t > size, bool ensureNullTerm=true)
Get a cir::ConstArrayAttr for a string literal.
cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal)
void setIsFPConstrained(bool isCon)
Enable/Disable use of constrained floating point math.
void computeGlobalViewIndicesFromFlatOffset(int64_t offset, mlir::Type ty, cir::CIRDataLayout layout, llvm::SmallVectorImpl< int64_t > &indices)
Address createComplexImagPtr(mlir::Location loc, Address addr)
cir::VectorType getExtendedOrTruncatedElementVectorType(cir::VectorType vt, bool isExtended, bool isSigned=false)
cir::DataMemberAttr getNullDataMemberAttr(cir::DataMemberType ty)
cir::ConstantOp getSInt32(int32_t c, mlir::Location loc)
mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy, mlir::Value addr, uint64_t offset)
cir::MemSetOp createMemSet(mlir::Location loc, mlir::Value dst, mlir::Value val, mlir::Value len)
cir::LoadOp createLoad(mlir::Location loc, Address addr, bool isVolatile=false)
cir::LongDoubleType getLongDoubleTy(const llvm::fltSemantics &format) const
cir::ConstArrayAttr getConstArray(mlir::Attribute attrs, cir::ArrayType arrayTy) const
cir::IntType getUIntNTy(int n)
mlir::Value getArrayElement(mlir::Location arrayLocBegin, mlir::Location arrayLocEnd, mlir::Value arrayPtr, mlir::Type eltTy, mlir::Value idx, bool shouldDecay)
Create a cir.ptr_stride operation to get access to an array element.
cir::LoadOp createAlignedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr, clang::CharUnits align=clang::CharUnits::One())
cir::DataMemberAttr getDataMemberAttr(cir::DataMemberType ty, unsigned memberIndex)
CharUnits - This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset?
Definition CharUnits.h:207
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
Definition CharUnits.h:189
static CharUnits One()
One - Construct a CharUnits quantity of one.
Definition CharUnits.h:58
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition CharUnits.h:63
Represents a struct/union/class.
Definition Decl.h:4331
TagKind getTagKind() const
Definition Decl.h:3923
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5993
@ Class
The "class" keyword.
Definition TypeBase.h:6004
@ Union
The "union" keyword.
Definition TypeBase.h:6001
static bool addressSpace()
static bool fpConstraints()
static bool astRecordDeclAttr()
Record with information about how a bitfield should be accessed.
unsigned offset
The offset within a contiguous run of bitfields that are represented as a single "field" within the c...
unsigned volatileStorageSize
The storage size in bits which should be used when accessing this bitfield.
unsigned size
The total size of the bit-field, in bits.
unsigned isSigned
Whether the bit-field is signed.
unsigned volatileOffset
The offset within a contiguous run of bitfields that are represented as a single "field" within the c...
llvm::StringRef name
The name of a bitfield.
This structure provides a set of types that are commonly used during IR emission.