clang: lib/CodeGen/CGValue.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_LIB_CODEGEN_CGVALUE_H
15#define LLVM_CLANG_LIB_CODEGEN_CGVALUE_H
16
23#include "llvm/IR/Type.h"
24#include "llvm/IR/Value.h"
25
26namespace llvm {
27 class Constant;
28 class MDNode;
29}
30
37
38
39
40
41
44
45 enum FlavorEnum { Scalar, Complex, Aggregate };
46
47 union {
48
49 struct {
52 } Vals;
53
54
56 };
57
58 unsigned IsVolatile : 1;
59 unsigned Flavor : 2;
60
61public:
63
64 bool isScalar() const { return Flavor == Scalar; }
65 bool isComplex() const { return Flavor == Complex; }
66 bool isAggregate() const { return Flavor == Aggregate; }
68
70
71
73 assert(isScalar() && "Not a scalar!");
74 return Vals.first;
75 }
76
77
78
79 std::pair<llvm::Value *, llvm::Value *> getComplexVal() const {
80 return std::make_pair(Vals.first, Vals.second);
81 }
82
83
88
93
95
96 return get(nullptr);
97 }
98
102 ER.Flavor = Scalar;
103 ER.IsVolatile = false;
104 return ER;
105 }
111 ER.Vals = {V1, V2};
112 ER.Flavor = Complex;
113 ER.IsVolatile = false;
114 return ER;
115 }
119
120
121
122
123
124
125
129 ER.Flavor = Aggregate;
130 ER.IsVolatile = isVolatile;
131 return ER;
132 }
133};
134
135
139
140
141
143
144
145
147
148
149
150
152
153
154
156};
157
158
159
161
162
164}
165
168
169public:
171 : AlignSource(Source) {}
174
178};
179
180
181
182
184 enum {
185 Simple,
186 VectorElt,
187 BitField,
188 ExtVectorElt,
189 GlobalReg,
190 MatrixElt
191 } LVType;
192
193 union {
196 };
197
198 union {
199
201
202
204
205
207 };
208
210
211
213
214
215 bool Ivar:1;
216
217
218 bool ObjIsArray:1;
219
220
221
222 bool NonGC: 1;
223
224
225 bool GlobalObjCRef : 1;
226
227
228 bool ThreadLocalRef : 1;
229
230
231
232 bool ImpreciseLifetime : 1;
233
234
235
236 bool Nontemporal : 1;
237
240
241 Expr *BaseIvarExp;
242
243private:
246 this->Type = Type;
247 this->Quals = Quals;
248 const unsigned MaxAlign = 1U << 31;
251 "initializing l-value with zero alignment!");
252 if (Alignment.getQuantity() > MaxAlign) {
253 assert(false && "Alignment exceeds allowed max!");
255 }
256 this->Addr = Addr;
257 this->BaseInfo = BaseInfo;
258 this->TBAAInfo = TBAAInfo;
259
260
261 this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false;
262 this->ImpreciseLifetime = false;
263 this->Nontemporal = false;
264 this->ThreadLocalRef = false;
265 this->BaseIvarExp = nullptr;
266 }
267
268 void initializeSimpleLValue(Address Addr, QualType Type,
269 LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo,
271 Qualifiers QS = Type.getQualifiers();
272 QS.setObjCGCAttr(Context.getObjCGCAttrKind(Type));
273 LVType = Simple;
274 Initialize(Type, QS, Addr, BaseInfo, TBAAInfo);
276 }
277
278public:
279 bool isSimple() const { return LVType == Simple; }
280 bool isVectorElt() const { return LVType == VectorElt; }
281 bool isBitField() const { return LVType == BitField; }
283 bool isGlobalReg() const { return LVType == GlobalReg; }
284 bool isMatrixElt() const { return LVType == MatrixElt; }
285
289 return Quals.getCVRQualifiers() & ~Qualifiers::Const;
290 }
291
293
295 return Quals.getObjCLifetime();
296 }
297
300
303
304 bool isNonGC () const { return NonGC; }
306
309
312
321
328
330 return Quals.hasVolatile();
331 }
332
335
338
341
343
346
349
352 Addr.setKnownNonNull();
353 return *this;
354 }
355
356
361
363
365
367 return Addr.getPointerAuthInfo();
368 }
369
370
377 return Addr.emitRawPointer(CGF);
378 }
381 return Addr.getBasePointer();
382 }
387
394 return Addr.getBasePointer();
395 }
400
401
408 return Addr.emitRawPointer(CGF);
409 }
414
415
422 return Addr.emitRawPointer(CGF);
423 }
424
429
430
432
436 R.LVType = Simple;
437 R.initializeSimpleLValue(Addr, type, BaseInfo, TBAAInfo, Context);
439 assert(Addr.getType()->isPointerTy());
440 return R;
441 }
442
447 R.LVType = VectorElt;
449 R.Initialize(type, type.getQualifiers(), vecAddress, BaseInfo, TBAAInfo);
450 return R;
451 }
452
457 R.LVType = ExtVectorElt;
459 R.Initialize(type, type.getQualifiers(), Addr, BaseInfo, TBAAInfo);
460 return R;
461 }
462
463
464
465
466
467
468
473 R.LVType = BitField;
475 R.Initialize(type, type.getQualifiers(), Addr, BaseInfo, TBAAInfo);
476 return R;
477 }
478
482 R.LVType = GlobalReg;
486 return R;
487 }
488
493 R.LVType = MatrixElt;
495 R.Initialize(type, type.getQualifiers(), matAddress, BaseInfo, TBAAInfo);
496 return R;
497 }
498
502};
503
504
505class AggValueSlot {
506
508
509
511
512
513
514
515 bool DestructedFlag : 1;
516
517
518
519
520 bool ObjCGCFlag : 1;
521
522
523
524
525 bool ZeroedFlag : 1;
526
527
528
529
530
531
532
533
534
535
536
537
538
539 bool AliasedFlag : 1;
540
541
542
543
544
545
546 bool OverlapFlag : 1;
547
548
549
550
551
552
553 bool SanitizerCheckedFlag : 1;
554
555 AggValueSlot(Address Addr, Qualifiers Quals, bool DestructedFlag,
556 bool ObjCGCFlag, bool ZeroedFlag, bool AliasedFlag,
557 bool OverlapFlag, bool SanitizerCheckedFlag)
558 : Addr(Addr), Quals(Quals), DestructedFlag(DestructedFlag),
559 ObjCGCFlag(ObjCGCFlag), ZeroedFlag(ZeroedFlag),
560 AliasedFlag(AliasedFlag), OverlapFlag(OverlapFlag),
561 SanitizerCheckedFlag(SanitizerCheckedFlag) {}
562
563public:
570
571
572
577
578
579
580
581
582
583
584
585
586
587
598 return AggValueSlot(addr, quals, isDestructed, needsGC, isZeroed, isAliased,
600 }
601
610
615 DestructedFlag = destructed;
616 }
617
619
621 return Quals.hasVolatile();
622 }
623
625 if (flag)
626 Quals.addVolatile();
627 else
628 Quals.removeVolatile();
629 }
630
632 return Quals.getObjCLifetime();
633 }
634
638
640
642 return Addr.isValid() ? Addr.emitRawPointer(CGF) : nullptr;
643 }
644
648
649 bool isIgnored() const { return !Addr.isValid(); }
650
652 return Addr.getAlignment();
653 }
654
658
662
664 return SanitizerCheckedFlag;
665 }
666
674
679
680
681
682
687};
688
689}
690}
691
692#endif
Defines the clang::ASTContext interface.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Value * getBasePointer() const
Address setKnownNonNull()
An aggregate value slot.
Definition CGValue.h:505
void setVolatile(bool flag)
Definition CGValue.h:624
Overlap_t
Definition CGValue.h:567
@ DoesNotOverlap
Definition CGValue.h:567
@ MayOverlap
Definition CGValue.h:567
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored.
Definition CGValue.h:573
bool isSanitizerChecked() const
Definition CGValue.h:663
Address getAddress() const
Definition CGValue.h:645
CharUnits getPreferredSize(ASTContext &Ctx, QualType Type) const
Get the preferred size to use when storing a value to this slot.
Definition CGValue.h:683
CharUnits getAlignment() const
Definition CGValue.h:651
IsZeroed_t
Definition CGValue.h:566
@ IsZeroed
Definition CGValue.h:566
@ IsNotZeroed
Definition CGValue.h:566
NeedsGCBarriers_t requiresGCollection() const
Definition CGValue.h:635
void setExternallyDestructed(bool destructed=true)
Definition CGValue.h:614
void setZeroed(bool V=true)
Definition CGValue.h:675
IsAliased_t
Definition CGValue.h:564
@ IsAliased
Definition CGValue.h:564
@ IsNotAliased
Definition CGValue.h:564
llvm::Value * getPointer(QualType PointeeTy, CodeGenFunction &CGF) const
IsZeroed_t isZeroed() const
Definition CGValue.h:676
bool isIgnored() const
Definition CGValue.h:649
IsDestructed_t
Definition CGValue.h:565
@ IsNotDestructed
Definition CGValue.h:565
@ IsDestructed
Definition CGValue.h:565
Qualifiers getQualifiers() const
Definition CGValue.h:618
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
Definition CGValue.h:603
IsAliased_t isPotentiallyAliased() const
Definition CGValue.h:655
IsSanitizerChecked_t
Definition CGValue.h:569
@ IsSanitizerChecked
Definition CGValue.h:569
@ IsNotSanitizerChecked
Definition CGValue.h:569
Qualifiers::ObjCLifetime getObjCLifetime() const
Definition CGValue.h:631
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:588
NeedsGCBarriers_t
Definition CGValue.h:568
@ NeedsGCBarriers
Definition CGValue.h:568
@ DoesNotNeedGCBarriers
Definition CGValue.h:568
IsDestructed_t isExternallyDestructed() const
Definition CGValue.h:611
Overlap_t mayOverlap() const
Definition CGValue.h:659
RValue asRValue() const
Definition CGValue.h:667
bool isVolatile() const
Definition CGValue.h:620
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Definition CGValue.h:641
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void setAlignmentSource(AlignmentSource Source)
Definition CGValue.h:173
void mergeForCast(const LValueBaseInfo &Info)
Definition CGValue.h:175
AlignmentSource getAlignmentSource() const
Definition CGValue.h:172
LValueBaseInfo(AlignmentSource Source=AlignmentSource::Type)
Definition CGValue.h:170
LValue - This represents an lvalue references.
Definition CGValue.h:183
llvm::Value * getRawExtVectorPointer(CodeGenFunction &CGF) const
Definition CGValue.h:406
bool isBitField() const
Definition CGValue.h:281
bool isMatrixElt() const
Definition CGValue.h:284
Expr * getBaseIvarExp() const
Definition CGValue.h:333
llvm::Value * emitResignedPointer(QualType PointeeTy, CodeGenFunction &CGF) const
llvm::Constant * getExtVectorElts() const
Definition CGValue.h:410
static LValue MakeGlobalReg(llvm::Value *V, CharUnits alignment, QualType type)
Definition CGValue.h:479
void setObjCIvar(bool Value)
Definition CGValue.h:299
bool isObjCArray() const
Definition CGValue.h:301
bool isObjCStrong() const
Definition CGValue.h:325
bool isRestrictQualified() const
Definition CGValue.h:287
void setAlignment(CharUnits A)
Definition CGValue.h:345
Address Addr
Definition CGValue.h:194
bool isGlobalObjCRef() const
Definition CGValue.h:307
bool isVectorElt() const
Definition CGValue.h:280
void setObjCArray(bool Value)
Definition CGValue.h:302
bool isSimple() const
Definition CGValue.h:279
llvm::Value * getMatrixPointer() const
Definition CGValue.h:392
bool isVolatileQualified() const
Definition CGValue.h:286
llvm::Constant * VectorElts
Definition CGValue.h:203
llvm::Value * getRawBitFieldPointer(CodeGenFunction &CGF) const
Definition CGValue.h:420
RValue asAggregateRValue() const
Definition CGValue.h:499
void setTBAAInfo(TBAAAccessInfo Info)
Definition CGValue.h:337
LangAS getAddressSpace() const
Definition CGValue.h:342
CharUnits getAlignment() const
Definition CGValue.h:344
llvm::Value * getPointer(CodeGenFunction &CGF) const
llvm::Value * getMatrixIdx() const
Definition CGValue.h:396
llvm::Value * getGlobalReg() const
Definition CGValue.h:431
static LValue MakeAddr(Address Addr, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition CGValue.h:433
bool isVolatile() const
Definition CGValue.h:329
const Qualifiers & getQuals() const
Definition CGValue.h:339
bool isGlobalReg() const
Definition CGValue.h:283
static LValue MakeExtVectorElt(Address Addr, llvm::Constant *Elts, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition CGValue.h:453
llvm::Value * getVectorPointer() const
Definition CGValue.h:379
bool isObjCWeak() const
Definition CGValue.h:322
Address getAddress() const
Definition CGValue.h:362
unsigned getVRQualifiers() const
Definition CGValue.h:288
Qualifiers & getQuals()
Definition CGValue.h:340
void setThreadLocalRef(bool Value)
Definition CGValue.h:311
const CGBitFieldInfo * BitFieldInfo
Definition CGValue.h:206
LValue setKnownNonNull()
Definition CGValue.h:351
bool isNonGC() const
Definition CGValue.h:304
void setGlobalObjCRef(bool Value)
Definition CGValue.h:308
llvm::Value * getRawVectorPointer(CodeGenFunction &CGF) const
Definition CGValue.h:375
bool isExtVectorElt() const
Definition CGValue.h:282
llvm::Value * getVectorIdx() const
Definition CGValue.h:383
void setNontemporal(bool Value)
Definition CGValue.h:320
LValueBaseInfo getBaseInfo() const
Definition CGValue.h:347
ARCPreciseLifetime_t isARCPreciseLifetime() const
Definition CGValue.h:313
void setARCPreciseLifetime(ARCPreciseLifetime_t value)
Definition CGValue.h:316
QualType getType() const
Definition CGValue.h:292
const CGBitFieldInfo & getBitFieldInfo() const
Definition CGValue.h:425
CGPointerAuthInfo getPointerAuthInfo() const
Definition CGValue.h:366
bool isThreadLocalRef() const
Definition CGValue.h:310
KnownNonNull_t isKnownNonNull() const
Definition CGValue.h:350
TBAAAccessInfo getTBAAInfo() const
Definition CGValue.h:336
void setNonGC(bool Value)
Definition CGValue.h:305
llvm::Value * V
Definition CGValue.h:195
void setBaseInfo(LValueBaseInfo Info)
Definition CGValue.h:348
Address getVectorAddress() const
Definition CGValue.h:371
bool isNontemporal() const
Definition CGValue.h:319
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:469
bool isObjCIvar() const
Definition CGValue.h:298
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
static LValue MakeVectorElt(Address vecAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition CGValue.h:443
void setAddress(Address address)
Definition CGValue.h:364
Qualifiers::ObjCLifetime getObjCLifetime() const
Definition CGValue.h:294
void setBaseIvarExp(Expr *V)
Definition CGValue.h:334
Address getExtVectorAddress() const
Definition CGValue.h:402
llvm::Value * VectorIdx
Definition CGValue.h:200
static LValue MakeMatrixElt(Address matAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Definition CGValue.h:489
Address getMatrixAddress() const
Definition CGValue.h:388
Address getBitFieldAddress() const
Definition CGValue.h:416
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
Definition CGValue.h:42
llvm::Value * getAggregatePointer(QualType PointeeType, CodeGenFunction &CGF) const
Definition CGValue.h:89
bool isScalar() const
Definition CGValue.h:64
static RValue getIgnored()
Definition CGValue.h:94
Address AggregateAddr
Definition CGValue.h:55
static RValue get(llvm::Value *V)
Definition CGValue.h:99
static RValue get(Address Addr, CodeGenFunction &CGF)
Definition CGValue.h:106
static RValue getComplex(const std::pair< llvm::Value *, llvm::Value * > &C)
Definition CGValue.h:116
static RValue getAggregate(Address addr, bool isVolatile=false)
Convert an Address to an RValue.
Definition CGValue.h:126
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
Definition CGValue.h:109
struct clang::CodeGen::RValue::@377313303130300032223230221113302037235375040355::@177233336262150053115237272127353314357374062335 Vals
bool isAggregate() const
Definition CGValue.h:66
bool isIgnored() const
Definition CGValue.h:67
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
Definition CGValue.h:84
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
Definition CGValue.h:72
llvm::Value * second
Definition CGValue.h:51
bool isComplex() const
Definition CGValue.h:65
bool isVolatileQualified() const
Definition CGValue.h:69
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
Definition CGValue.h:79
llvm::Value * first
Definition CGValue.h:50
RValue()
Definition CGValue.h:62
This represents one expression.
A (possibly-)qualified type.
The collection of all-type qualifiers we support.
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
Definition CGValue.h:142
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
Definition CGValue.h:151
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CGValue.h:155
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Definition CGValue.h:146
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
Definition CGValue.h:136
@ ARCPreciseLifetime
Definition CGValue.h:137
@ ARCImpreciseLifetime
Definition CGValue.h:137
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:160
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
LangAS
Defines the address space values used by the address space qualifier of QualType.
Diagnostic wrappers for TextAPI types for error reporting.
Structure with information about how a bitfield should be accessed.
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function.