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