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