clang 17.0.0git
CGValue.h
Go to the documentation of this file.
1//===-- CGValue.h - LLVM CodeGen wrappers for llvm::Value* ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// These classes implement wrappers around llvm::Value in order to
10// fully represent the range of values for C L- and R- values.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_CODEGEN_CGVALUE_H
15#define LLVM_CLANG_LIB_CODEGEN_CGVALUE_H
16
18#include "clang/AST/Type.h"
19#include "llvm/IR/Value.h"
20#include "llvm/IR/Type.h"
21#include "Address.h"
22#include "CodeGenTBAA.h"
23
24namespace llvm {
25 class Constant;
26 class MDNode;
27}
28
29namespace clang {
30namespace CodeGen {
31 class AggValueSlot;
32 class CodeGenFunction;
33 struct CGBitFieldInfo;
34
35/// RValue - This trivial value class is used to represent the result of an
36/// expression that is evaluated. It can be one of three things: either a
37/// simple LLVM SSA value, a pair of SSA values for complex numbers, or the
38/// address of an aggregate value in memory.
39class RValue {
40 enum Flavor { Scalar, Complex, Aggregate };
41
42 // The shift to make to an aggregate's alignment to make it look
43 // like a pointer.
44 enum { AggAlignShift = 4 };
45
46 // Stores first value and flavor.
47 llvm::PointerIntPair<llvm::Value *, 2, Flavor> V1;
48 // Stores second value and volatility.
49 llvm::PointerIntPair<llvm::Value *, 1, bool> V2;
50 // Stores element type for aggregate values.
51 llvm::Type *ElementType;
52
53public:
54 bool isScalar() const { return V1.getInt() == Scalar; }
55 bool isComplex() const { return V1.getInt() == Complex; }
56 bool isAggregate() const { return V1.getInt() == Aggregate; }
57
58 bool isVolatileQualified() const { return V2.getInt(); }
59
60 /// getScalarVal() - Return the Value* of this scalar value.
61 llvm::Value *getScalarVal() const {
62 assert(isScalar() && "Not a scalar!");
63 return V1.getPointer();
64 }
65
66 /// getComplexVal - Return the real/imag components of this complex value.
67 ///
68 std::pair<llvm::Value *, llvm::Value *> getComplexVal() const {
69 return std::make_pair(V1.getPointer(), V2.getPointer());
70 }
71
72 /// getAggregateAddr() - Return the Value* of the address of the aggregate.
74 assert(isAggregate() && "Not an aggregate!");
75 auto align = reinterpret_cast<uintptr_t>(V2.getPointer()) >> AggAlignShift;
76 return Address(
77 V1.getPointer(), ElementType, CharUnits::fromQuantity(align));
78 }
79 llvm::Value *getAggregatePointer() const {
80 assert(isAggregate() && "Not an aggregate!");
81 return V1.getPointer();
82 }
83
84 static RValue getIgnored() {
85 // FIXME: should we make this a more explicit state?
86 return get(nullptr);
87 }
88
89 static RValue get(llvm::Value *V) {
90 RValue ER;
91 ER.V1.setPointer(V);
92 ER.V1.setInt(Scalar);
93 ER.V2.setInt(false);
94 return ER;
95 }
96 static RValue getComplex(llvm::Value *V1, llvm::Value *V2) {
97 RValue ER;
98 ER.V1.setPointer(V1);
99 ER.V2.setPointer(V2);
100 ER.V1.setInt(Complex);
101 ER.V2.setInt(false);
102 return ER;
103 }
104 static RValue getComplex(const std::pair<llvm::Value *, llvm::Value *> &C) {
105 return getComplex(C.first, C.second);
106 }
107 // FIXME: Aggregate rvalues need to retain information about whether they are
108 // volatile or not. Remove default to find all places that probably get this
109 // wrong.
110 static RValue getAggregate(Address addr, bool isVolatile = false) {
111 RValue ER;
112 ER.V1.setPointer(addr.getPointer());
113 ER.V1.setInt(Aggregate);
114 ER.ElementType = addr.getElementType();
115
116 auto align = static_cast<uintptr_t>(addr.getAlignment().getQuantity());
117 ER.V2.setPointer(reinterpret_cast<llvm::Value*>(align << AggAlignShift));
118 ER.V2.setInt(isVolatile);
119 return ER;
120 }
121};
122
123/// Does an ARC strong l-value have precise lifetime?
127
128/// The source of the alignment of an l-value; an expression of
129/// confidence in the alignment actually matching the estimate.
130enum class AlignmentSource {
131 /// The l-value was an access to a declared entity or something
132 /// equivalently strong, like the address of an array allocated by a
133 /// language runtime.
134 Decl,
135
136 /// The l-value was considered opaque, so the alignment was
137 /// determined from a type, but that type was an explicitly-aligned
138 /// typedef.
140
141 /// The l-value was considered opaque, so the alignment was
142 /// determined from a type.
143 Type
144};
145
146/// Given that the base address has the given alignment source, what's
147/// our confidence in the alignment of the field?
149 // For now, we don't distinguish fields of opaque pointers from
150 // top-level declarations, but maybe we should.
152}
153
155 AlignmentSource AlignSource;
156
157public:
159 : AlignSource(Source) {}
160 AlignmentSource getAlignmentSource() const { return AlignSource; }
161 void setAlignmentSource(AlignmentSource Source) { AlignSource = Source; }
162
163 void mergeForCast(const LValueBaseInfo &Info) {
165 }
166};
167
168/// LValue - This represents an lvalue references. Because C/C++ allow
169/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a
170/// bitrange.
171class LValue {
172 enum {
173 Simple, // This is a normal l-value, use getAddress().
174 VectorElt, // This is a vector element l-value (V[i]), use getVector*
175 BitField, // This is a bitfield l-value, use getBitfield*.
176 ExtVectorElt, // This is an extended vector subset, use getExtVectorComp
177 GlobalReg, // This is a register l-value, use getGlobalReg()
178 MatrixElt // This is a matrix element, use getVector*
179 } LVType;
180
181 llvm::Value *V;
182 llvm::Type *ElementType;
183
184 union {
185 // Index into a vector subscript: V[i]
186 llvm::Value *VectorIdx;
187
188 // ExtVector element subset: V.xyx
189 llvm::Constant *VectorElts;
190
191 // BitField start bit and size
193 };
194
196
197 // 'const' is unused here
198 Qualifiers Quals;
199
200 // The alignment to use when accessing this lvalue. (For vector elements,
201 // this is the alignment of the whole vector.)
202 unsigned Alignment;
203
204 // objective-c's ivar
205 bool Ivar:1;
206
207 // objective-c's ivar is an array
208 bool ObjIsArray:1;
209
210 // LValue is non-gc'able for any reason, including being a parameter or local
211 // variable.
212 bool NonGC: 1;
213
214 // Lvalue is a global reference of an objective-c object
215 bool GlobalObjCRef : 1;
216
217 // Lvalue is a thread local reference
218 bool ThreadLocalRef : 1;
219
220 // Lvalue has ARC imprecise lifetime. We store this inverted to try
221 // to make the default bitfield pattern all-zeroes.
222 bool ImpreciseLifetime : 1;
223
224 // This flag shows if a nontemporal load/stores should be used when accessing
225 // this lvalue.
226 bool Nontemporal : 1;
227
228 // The pointer is known not to be null.
229 bool IsKnownNonNull : 1;
230
231 LValueBaseInfo BaseInfo;
232 TBAAAccessInfo TBAAInfo;
233
234 Expr *BaseIvarExp;
235
236private:
237 void Initialize(QualType Type, Qualifiers Quals, CharUnits Alignment,
238 LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo) {
239 assert((!Alignment.isZero() || Type->isIncompleteType()) &&
240 "initializing l-value with zero alignment!");
241 if (isGlobalReg())
242 assert(ElementType == nullptr && "Global reg does not store elem type");
243 else
244 assert(llvm::cast<llvm::PointerType>(V->getType())
245 ->isOpaqueOrPointeeTypeMatches(ElementType) &&
246 "Pointer element type mismatch");
247
248 this->Type = Type;
249 this->Quals = Quals;
250 const unsigned MaxAlign = 1U << 31;
251 this->Alignment = Alignment.getQuantity() <= MaxAlign
252 ? Alignment.getQuantity()
253 : MaxAlign;
254 assert(this->Alignment == Alignment.getQuantity() &&
255 "Alignment exceeds allowed max!");
256 this->BaseInfo = BaseInfo;
257 this->TBAAInfo = TBAAInfo;
258
259 // Initialize Objective-C flags.
260 this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false;
261 this->ImpreciseLifetime = false;
262 this->Nontemporal = false;
263 this->ThreadLocalRef = false;
264 this->BaseIvarExp = nullptr;
265 }
266
267public:
268 bool isSimple() const { return LVType == Simple; }
269 bool isVectorElt() const { return LVType == VectorElt; }
270 bool isBitField() const { return LVType == BitField; }
271 bool isExtVectorElt() const { return LVType == ExtVectorElt; }
272 bool isGlobalReg() const { return LVType == GlobalReg; }
273 bool isMatrixElt() const { return LVType == MatrixElt; }
274
275 bool isVolatileQualified() const { return Quals.hasVolatile(); }
276 bool isRestrictQualified() const { return Quals.hasRestrict(); }
277 unsigned getVRQualifiers() const {
278 return Quals.getCVRQualifiers() & ~Qualifiers::Const;
279 }
280
281 QualType getType() const { return Type; }
282
284 return Quals.getObjCLifetime();
285 }
286
287 bool isObjCIvar() const { return Ivar; }
288 void setObjCIvar(bool Value) { Ivar = Value; }
289
290 bool isObjCArray() const { return ObjIsArray; }
291 void setObjCArray(bool Value) { ObjIsArray = Value; }
292
293 bool isNonGC () const { return NonGC; }
294 void setNonGC(bool Value) { NonGC = Value; }
295
296 bool isGlobalObjCRef() const { return GlobalObjCRef; }
297 void setGlobalObjCRef(bool Value) { GlobalObjCRef = Value; }
298
299 bool isThreadLocalRef() const { return ThreadLocalRef; }
300 void setThreadLocalRef(bool Value) { ThreadLocalRef = Value;}
301
303 return ARCPreciseLifetime_t(!ImpreciseLifetime);
304 }
306 ImpreciseLifetime = (value == ARCImpreciseLifetime);
307 }
308 bool isNontemporal() const { return Nontemporal; }
309 void setNontemporal(bool Value) { Nontemporal = Value; }
310
311 bool isObjCWeak() const {
312 return Quals.getObjCGCAttr() == Qualifiers::Weak;
313 }
314 bool isObjCStrong() const {
315 return Quals.getObjCGCAttr() == Qualifiers::Strong;
316 }
317
318 bool isVolatile() const {
319 return Quals.hasVolatile();
320 }
321
322 Expr *getBaseIvarExp() const { return BaseIvarExp; }
323 void setBaseIvarExp(Expr *V) { BaseIvarExp = V; }
324
325 TBAAAccessInfo getTBAAInfo() const { return TBAAInfo; }
326 void setTBAAInfo(TBAAAccessInfo Info) { TBAAInfo = Info; }
327
328 const Qualifiers &getQuals() const { return Quals; }
329 Qualifiers &getQuals() { return Quals; }
330
331 LangAS getAddressSpace() const { return Quals.getAddressSpace(); }
332
333 CharUnits getAlignment() const { return CharUnits::fromQuantity(Alignment); }
334 void setAlignment(CharUnits A) { Alignment = A.getQuantity(); }
335
336 LValueBaseInfo getBaseInfo() const { return BaseInfo; }
337 void setBaseInfo(LValueBaseInfo Info) { BaseInfo = Info; }
338
340 return (KnownNonNull_t)IsKnownNonNull;
341 }
343 IsKnownNonNull = true;
344 return *this;
345 }
346
347 // simple lvalue
348 llvm::Value *getPointer(CodeGenFunction &CGF) const {
349 assert(isSimple());
350 return V;
351 }
353 return Address(getPointer(CGF), ElementType, getAlignment(),
355 }
356 void setAddress(Address address) {
357 assert(isSimple());
358 V = address.getPointer();
359 ElementType = address.getElementType();
360 Alignment = address.getAlignment().getQuantity();
361 IsKnownNonNull = address.isKnownNonNull();
362 }
363
364 // vector elt lvalue
366 return Address(getVectorPointer(), ElementType, getAlignment(),
368 }
369 llvm::Value *getVectorPointer() const {
370 assert(isVectorElt());
371 return V;
372 }
373 llvm::Value *getVectorIdx() const {
374 assert(isVectorElt());
375 return VectorIdx;
376 }
377
379 return Address(getMatrixPointer(), ElementType, getAlignment(),
381 }
382 llvm::Value *getMatrixPointer() const {
383 assert(isMatrixElt());
384 return V;
385 }
386 llvm::Value *getMatrixIdx() const {
387 assert(isMatrixElt());
388 return VectorIdx;
389 }
390
391 // extended vector elements.
393 return Address(getExtVectorPointer(), ElementType, getAlignment(),
395 }
396 llvm::Value *getExtVectorPointer() const {
397 assert(isExtVectorElt());
398 return V;
399 }
400 llvm::Constant *getExtVectorElts() const {
401 assert(isExtVectorElt());
402 return VectorElts;
403 }
404
405 // bitfield lvalue
407 return Address(getBitFieldPointer(), ElementType, getAlignment(),
409 }
410 llvm::Value *getBitFieldPointer() const { assert(isBitField()); return V; }
412 assert(isBitField());
413 return *BitFieldInfo;
414 }
415
416 // global register lvalue
417 llvm::Value *getGlobalReg() const { assert(isGlobalReg()); return V; }
418
419 static LValue MakeAddr(Address address, QualType type, ASTContext &Context,
420 LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo) {
421 Qualifiers qs = type.getQualifiers();
422 qs.setObjCGCAttr(Context.getObjCGCAttrKind(type));
423
424 LValue R;
425 R.LVType = Simple;
426 assert(address.getPointer()->getType()->isPointerTy());
427 R.V = address.getPointer();
428 R.ElementType = address.getElementType();
429 R.IsKnownNonNull = address.isKnownNonNull();
430 R.Initialize(type, qs, address.getAlignment(), BaseInfo, TBAAInfo);
431 return R;
432 }
433
434 static LValue MakeVectorElt(Address vecAddress, llvm::Value *Idx,
435 QualType type, LValueBaseInfo BaseInfo,
436 TBAAAccessInfo TBAAInfo) {
437 LValue R;
438 R.LVType = VectorElt;
439 R.V = vecAddress.getPointer();
440 R.ElementType = vecAddress.getElementType();
441 R.VectorIdx = Idx;
442 R.IsKnownNonNull = vecAddress.isKnownNonNull();
443 R.Initialize(type, type.getQualifiers(), vecAddress.getAlignment(),
444 BaseInfo, TBAAInfo);
445 return R;
446 }
447
448 static LValue MakeExtVectorElt(Address vecAddress, llvm::Constant *Elts,
449 QualType type, LValueBaseInfo BaseInfo,
450 TBAAAccessInfo TBAAInfo) {
451 LValue R;
452 R.LVType = ExtVectorElt;
453 R.V = vecAddress.getPointer();
454 R.ElementType = vecAddress.getElementType();
455 R.VectorElts = Elts;
456 R.IsKnownNonNull = vecAddress.isKnownNonNull();
457 R.Initialize(type, type.getQualifiers(), vecAddress.getAlignment(),
458 BaseInfo, TBAAInfo);
459 return R;
460 }
461
462 /// Create a new object to represent a bit-field access.
463 ///
464 /// \param Addr - The base address of the bit-field sequence this
465 /// bit-field refers to.
466 /// \param Info - The information describing how to perform the bit-field
467 /// access.
468 static LValue MakeBitfield(Address Addr, const CGBitFieldInfo &Info,
469 QualType type, LValueBaseInfo BaseInfo,
470 TBAAAccessInfo TBAAInfo) {
471 LValue R;
472 R.LVType = BitField;
473 R.V = Addr.getPointer();
474 R.ElementType = Addr.getElementType();
475 R.BitFieldInfo = &Info;
476 R.IsKnownNonNull = Addr.isKnownNonNull();
477 R.Initialize(type, type.getQualifiers(), Addr.getAlignment(), BaseInfo,
478 TBAAInfo);
479 return R;
480 }
481
482 static LValue MakeGlobalReg(llvm::Value *V, CharUnits alignment,
483 QualType type) {
484 LValue R;
485 R.LVType = GlobalReg;
486 R.V = V;
487 R.ElementType = nullptr;
488 R.IsKnownNonNull = true;
489 R.Initialize(type, type.getQualifiers(), alignment,
491 return R;
492 }
493
494 static LValue MakeMatrixElt(Address matAddress, llvm::Value *Idx,
495 QualType type, LValueBaseInfo BaseInfo,
496 TBAAAccessInfo TBAAInfo) {
497 LValue R;
498 R.LVType = MatrixElt;
499 R.V = matAddress.getPointer();
500 R.ElementType = matAddress.getElementType();
501 R.VectorIdx = Idx;
502 R.IsKnownNonNull = matAddress.isKnownNonNull();
503 R.Initialize(type, type.getQualifiers(), matAddress.getAlignment(),
504 BaseInfo, TBAAInfo);
505 return R;
506 }
507
510 }
511};
512
513/// An aggregate value slot.
515 /// The address.
516 Address Addr;
517
518 // Qualifiers
519 Qualifiers Quals;
520
521 /// DestructedFlag - This is set to true if some external code is
522 /// responsible for setting up a destructor for the slot. Otherwise
523 /// the code which constructs it should push the appropriate cleanup.
524 bool DestructedFlag : 1;
525
526 /// ObjCGCFlag - This is set to true if writing to the memory in the
527 /// slot might require calling an appropriate Objective-C GC
528 /// barrier. The exact interaction here is unnecessarily mysterious.
529 bool ObjCGCFlag : 1;
530
531 /// ZeroedFlag - This is set to true if the memory in the slot is
532 /// known to be zero before the assignment into it. This means that
533 /// zero fields don't need to be set.
534 bool ZeroedFlag : 1;
535
536 /// AliasedFlag - This is set to true if the slot might be aliased
537 /// and it's not undefined behavior to access it through such an
538 /// alias. Note that it's always undefined behavior to access a C++
539 /// object that's under construction through an alias derived from
540 /// outside the construction process.
541 ///
542 /// This flag controls whether calls that produce the aggregate
543 /// value may be evaluated directly into the slot, or whether they
544 /// must be evaluated into an unaliased temporary and then memcpy'ed
545 /// over. Since it's invalid in general to memcpy a non-POD C++
546 /// object, it's important that this flag never be set when
547 /// evaluating an expression which constructs such an object.
548 bool AliasedFlag : 1;
549
550 /// This is set to true if the tail padding of this slot might overlap
551 /// another object that may have already been initialized (and whose
552 /// value must be preserved by this initialization). If so, we may only
553 /// store up to the dsize of the type. Otherwise we can widen stores to
554 /// the size of the type.
555 bool OverlapFlag : 1;
556
557 /// If is set to true, sanitizer checks are already generated for this address
558 /// or not required. For instance, if this address represents an object
559 /// created in 'new' expression, sanitizer checks for memory is made as a part
560 /// of 'operator new' emission and object constructor should not generate
561 /// them.
562 bool SanitizerCheckedFlag : 1;
563
564 AggValueSlot(Address Addr, Qualifiers Quals, bool DestructedFlag,
565 bool ObjCGCFlag, bool ZeroedFlag, bool AliasedFlag,
566 bool OverlapFlag, bool SanitizerCheckedFlag)
567 : Addr(Addr), Quals(Quals), DestructedFlag(DestructedFlag),
568 ObjCGCFlag(ObjCGCFlag), ZeroedFlag(ZeroedFlag),
569 AliasedFlag(AliasedFlag), OverlapFlag(OverlapFlag),
570 SanitizerCheckedFlag(SanitizerCheckedFlag) {}
571
572public:
579
580 /// ignored - Returns an aggregate value slot indicating that the
581 /// aggregate value is being ignored.
585 }
586
587 /// forAddr - Make a slot for an aggregate value.
588 ///
589 /// \param quals - The qualifiers that dictate how the slot should
590 /// be initialied. Only 'volatile' and the Objective-C lifetime
591 /// qualifiers matter.
592 ///
593 /// \param isDestructed - true if something else is responsible
594 /// for calling destructors on this object
595 /// \param needsGC - true if the slot is potentially located
596 /// somewhere that ObjC GC calls should be emitted for
598 Qualifiers quals,
599 IsDestructed_t isDestructed,
600 NeedsGCBarriers_t needsGC,
601 IsAliased_t isAliased,
605 if (addr.isValid())
606 addr.setKnownNonNull();
607 return AggValueSlot(addr, quals, isDestructed, needsGC, isZeroed, isAliased,
608 mayOverlap, isChecked);
609 }
610
611 static AggValueSlot
612 forLValue(const LValue &LV, CodeGenFunction &CGF, IsDestructed_t isDestructed,
613 NeedsGCBarriers_t needsGC, IsAliased_t isAliased,
616 return forAddr(LV.getAddress(CGF), LV.getQuals(), isDestructed, needsGC,
617 isAliased, mayOverlap, isZeroed, isChecked);
618 }
619
621 return IsDestructed_t(DestructedFlag);
622 }
623 void setExternallyDestructed(bool destructed = true) {
624 DestructedFlag = destructed;
625 }
626
627 Qualifiers getQualifiers() const { return Quals; }
628
629 bool isVolatile() const {
630 return Quals.hasVolatile();
631 }
632
633 void setVolatile(bool flag) {
634 if (flag)
635 Quals.addVolatile();
636 else
637 Quals.removeVolatile();
638 }
639
641 return Quals.getObjCLifetime();
642 }
643
645 return NeedsGCBarriers_t(ObjCGCFlag);
646 }
647
648 llvm::Value *getPointer() const {
649 return Addr.getPointer();
650 }
651
653 return Addr;
654 }
655
656 bool isIgnored() const {
657 return !Addr.isValid();
658 }
659
661 return Addr.getAlignment();
662 }
663
665 return IsAliased_t(AliasedFlag);
666 }
667
669 return Overlap_t(OverlapFlag);
670 }
671
672 bool isSanitizerChecked() const {
673 return SanitizerCheckedFlag;
674 }
675
676 RValue asRValue() const {
677 if (isIgnored()) {
678 return RValue::getIgnored();
679 } else {
681 }
682 }
683
684 void setZeroed(bool V = true) { ZeroedFlag = V; }
686 return IsZeroed_t(ZeroedFlag);
687 }
688
689 /// Get the preferred size to use when storing a value to this slot. This
690 /// is the type size unless that might overlap another object, in which
691 /// case it's the dsize.
695 }
696};
697
698} // end namespace CodeGen
699} // end namespace clang
700
701#endif
Defines the clang::ASTContext interface.
#define V(N, I)
Definition: ASTContext.h:3217
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
bool isZero() const
isZero - Test whether the quantity equals zero.
Definition: CharUnits.h:122
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:185
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition: CharUnits.h:63
An aligned address.
Definition: Address.h:29
static Address invalid()
Definition: Address.h:49
CharUnits getAlignment() const
Return the alignment of this pointer.
Definition: Address.h:81
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Definition: Address.h:65
KnownNonNull_t isKnownNonNull() const
Whether the pointer is known not to be null.
Definition: Address.h:102
Address setKnownNonNull()
Set the non-null bit.
Definition: Address.h:108
llvm::Value * getPointer() const
Definition: Address.h:54
bool isValid() const
Definition: Address.h:50
An aggregate value slot.
Definition: CGValue.h:514
void setVolatile(bool flag)
Definition: CGValue.h:633
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored.
Definition: CGValue.h:582
bool isSanitizerChecked() const
Definition: CGValue.h:672
Address getAddress() const
Definition: CGValue.h:652
CharUnits getPreferredSize(ASTContext &Ctx, QualType Type) const
Get the preferred size to use when storing a value to this slot.
Definition: CGValue.h:692
CharUnits getAlignment() const
Definition: CGValue.h:660
static AggValueSlot forLValue(const LValue &LV, CodeGenFunction &CGF, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
Definition: CGValue.h:612
NeedsGCBarriers_t requiresGCollection() const
Definition: CGValue.h:644
void setExternallyDestructed(bool destructed=true)
Definition: CGValue.h:623
void setZeroed(bool V=true)
Definition: CGValue.h:684
llvm::Value * getPointer() const
Definition: CGValue.h:648
IsZeroed_t isZeroed() const
Definition: CGValue.h:685
Qualifiers getQualifiers() const
Definition: CGValue.h:627
IsAliased_t isPotentiallyAliased() const
Definition: CGValue.h:664
Qualifiers::ObjCLifetime getObjCLifetime() const
Definition: CGValue.h:640
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
Definition: CGValue.h:597
IsDestructed_t isExternallyDestructed() const
Definition: CGValue.h:620
Overlap_t mayOverlap() const
Definition: CGValue.h:668
RValue asRValue() const
Definition: CGValue.h:676
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void setAlignmentSource(AlignmentSource Source)
Definition: CGValue.h:161
void mergeForCast(const LValueBaseInfo &Info)
Definition: CGValue.h:163
AlignmentSource getAlignmentSource() const
Definition: CGValue.h:160
LValueBaseInfo(AlignmentSource Source=AlignmentSource::Type)
Definition: CGValue.h:158
LValue - This represents an lvalue references.
Definition: CGValue.h:171
bool isBitField() const
Definition: CGValue.h:270
bool isMatrixElt() const
Definition: CGValue.h:273
Expr * getBaseIvarExp() const
Definition: CGValue.h:322
llvm::Constant * getExtVectorElts() const
Definition: CGValue.h:400
static LValue MakeGlobalReg(llvm::Value *V, CharUnits alignment, QualType type)
Definition: CGValue.h:482
void setObjCIvar(bool Value)
Definition: CGValue.h:288
bool isObjCArray() const
Definition: CGValue.h:290
static LValue MakeExtVectorElt(Address vecAddress, llvm::Constant *Elts, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition: CGValue.h:448
bool isObjCStrong() const
Definition: CGValue.h:314
bool isRestrictQualified() const
Definition: CGValue.h:276
void setAlignment(CharUnits A)
Definition: CGValue.h:334
llvm::Value * getBitFieldPointer() const
Definition: CGValue.h:410
bool isGlobalObjCRef() const
Definition: CGValue.h:296
bool isVectorElt() const
Definition: CGValue.h:269
void setObjCArray(bool Value)
Definition: CGValue.h:291
bool isSimple() const
Definition: CGValue.h:268
llvm::Value * getMatrixPointer() const
Definition: CGValue.h:382
bool isVolatileQualified() const
Definition: CGValue.h:275
llvm::Constant * VectorElts
Definition: CGValue.h:189
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition: CGValue.h:419
void setTBAAInfo(TBAAAccessInfo Info)
Definition: CGValue.h:326
LangAS getAddressSpace() const
Definition: CGValue.h:331
CharUnits getAlignment() const
Definition: CGValue.h:333
llvm::Value * getMatrixIdx() const
Definition: CGValue.h:386
Address getAddress(CodeGenFunction &CGF) const
Definition: CGValue.h:352
llvm::Value * getGlobalReg() const
Definition: CGValue.h:417
bool isVolatile() const
Definition: CGValue.h:318
const Qualifiers & getQuals() const
Definition: CGValue.h:328
bool isGlobalReg() const
Definition: CGValue.h:272
llvm::Value * getVectorPointer() const
Definition: CGValue.h:369
bool isObjCWeak() const
Definition: CGValue.h:311
unsigned getVRQualifiers() const
Definition: CGValue.h:277
Qualifiers & getQuals()
Definition: CGValue.h:329
void setThreadLocalRef(bool Value)
Definition: CGValue.h:300
const CGBitFieldInfo * BitFieldInfo
Definition: CGValue.h:192
LValue setKnownNonNull()
Definition: CGValue.h:342
bool isNonGC() const
Definition: CGValue.h:293
void setGlobalObjCRef(bool Value)
Definition: CGValue.h:297
bool isExtVectorElt() const
Definition: CGValue.h:271
llvm::Value * getVectorIdx() const
Definition: CGValue.h:373
void setNontemporal(bool Value)
Definition: CGValue.h:309
LValueBaseInfo getBaseInfo() const
Definition: CGValue.h:336
llvm::Value * getPointer(CodeGenFunction &CGF) const
Definition: CGValue.h:348
ARCPreciseLifetime_t isARCPreciseLifetime() const
Definition: CGValue.h:302
void setARCPreciseLifetime(ARCPreciseLifetime_t value)
Definition: CGValue.h:305
QualType getType() const
Definition: CGValue.h:281
llvm::Value * getExtVectorPointer() const
Definition: CGValue.h:396
const CGBitFieldInfo & getBitFieldInfo() const
Definition: CGValue.h:411
bool isThreadLocalRef() const
Definition: CGValue.h:299
KnownNonNull_t isKnownNonNull() const
Definition: CGValue.h:339
TBAAAccessInfo getTBAAInfo() const
Definition: CGValue.h:325
void setNonGC(bool Value)
Definition: CGValue.h:294
void setBaseInfo(LValueBaseInfo Info)
Definition: CGValue.h:337
Address getVectorAddress() const
Definition: CGValue.h:365
bool isNontemporal() const
Definition: CGValue.h:308
static LValue MakeBitfield(Address Addr, const CGBitFieldInfo &Info, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Create a new object to represent a bit-field access.
Definition: CGValue.h:468
bool isObjCIvar() const
Definition: CGValue.h:287
static LValue MakeVectorElt(Address vecAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition: CGValue.h:434
void setAddress(Address address)
Definition: CGValue.h:356
Qualifiers::ObjCLifetime getObjCLifetime() const
Definition: CGValue.h:283
void setBaseIvarExp(Expr *V)
Definition: CGValue.h:323
RValue asAggregateRValue(CodeGenFunction &CGF) const
Definition: CGValue.h:508
Address getExtVectorAddress() const
Definition: CGValue.h:392
llvm::Value * VectorIdx
Definition: CGValue.h:186
static LValue MakeMatrixElt(Address matAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition: CGValue.h:494
Address getMatrixAddress() const
Definition: CGValue.h:378
Address getBitFieldAddress() const
Definition: CGValue.h:406
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
Definition: CGValue.h:39
bool isScalar() const
Definition: CGValue.h:54
static RValue getIgnored()
Definition: CGValue.h:84
static RValue get(llvm::Value *V)
Definition: CGValue.h:89
llvm::Value * getAggregatePointer() const
Definition: CGValue.h:79
static RValue getComplex(const std::pair< llvm::Value *, llvm::Value * > &C)
Definition: CGValue.h:104
static RValue getAggregate(Address addr, bool isVolatile=false)
Definition: CGValue.h:110
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
Definition: CGValue.h:96
bool isAggregate() const
Definition: CGValue.h:56
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
Definition: CGValue.h:73
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
Definition: CGValue.h:61
bool isComplex() const
Definition: CGValue.h:55
bool isVolatileQualified() const
Definition: CGValue.h:58
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
Definition: CGValue.h:68
This represents one expression.
Definition: Expr.h:110
A (possibly-)qualified type.
Definition: Type.h:736
The collection of all-type qualifiers we support.
Definition: Type.h:146
unsigned getCVRQualifiers() const
Definition: Type.h:294
GC getObjCGCAttr() const
Definition: Type.h:325
bool hasRestrict() const
Definition: Type.h:283
bool hasVolatile() const
Definition: Type.h:273
void setObjCGCAttr(GC type)
Definition: Type.h:326
ObjCLifetime getObjCLifetime() const
Definition: Type.h:351
void removeVolatile()
Definition: Type.h:275
LangAS getAddressSpace() const
Definition: Type.h:377
void addVolatile()
Definition: Type.h:276
The base class of the type hierarchy.
Definition: Type.h:1566
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
Definition: Type.cpp:2259
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
Definition: CGValue.h:130
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
Definition: CGValue.h:124
@ ARCPreciseLifetime
Definition: CGValue.h:125
@ ARCImpreciseLifetime
Definition: CGValue.h:125
static AlignmentSource getFieldAlignmentSource(AlignmentSource Source)
Given that the base address has the given alignment source, what's our confidence in the alignment of...
Definition: CGValue.h:148
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
@ C
Languages that the frontend can parse and compile.
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
YAML serialization mapping.
Definition: Dominators.h:30
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Structure with information about how a bitfield should be accessed.