clang: lib/CIR/CodeGen/CIRGenValue.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef CLANG_LIB_CIR_CIRGENVALUE_H
15#define CLANG_LIB_CIR_CIRGENVALUE_H
16
18
21
23#include "mlir/IR/Value.h"
24
26
28
29
30
31
32
34 enum Flavor { Scalar, Complex, Aggregate };
35
36 union {
38
39
41 };
42
43 unsigned isVolatile : 1;
44 unsigned flavor : 2;
45
46public:
48
49 bool isScalar() const { return flavor == Scalar; }
50 bool isComplex() const { return flavor == Complex; }
51 bool isAggregate() const { return flavor == Aggregate; }
53
55
56
58 assert(isScalar() && "Not a scalar!");
60 }
61
62
64 assert(isComplex() && "Not a complex!");
66 }
67
68
73
77
79
80 return get(nullptr);
81 }
82
86 er.flavor = Scalar;
87 er.isVolatile = false;
88 return er;
89 }
90
94 er.flavor = Complex;
95 er.isVolatile = false;
96 return er;
97 }
98
99
100
101
102
103
104
108 er.flavor = Aggregate;
109 er.isVolatile = isVolatile;
110 return er;
111 }
112};
113
114
115
117
118
119
121
122
123
124
126
127
128
130};
131
132
133
139
142
143public:
145 : alignSource(source) {}
148
152};
153
155 enum {
156 Simple,
157 VectorElt,
158 BitField,
159 ExtVectorElt,
160 GlobalReg,
161 MatrixElt
162 } lvType;
165
166
167
168 unsigned alignment;
169 mlir::Value v;
170 mlir::Value vectorIdx;
171 mlir::Attribute vectorElts;
172 mlir::Type elementType;
175
178 assert((!alignment.isZero() || type->isIncompleteType()) &&
179 "initializing l-value with zero alignment!");
180 this->type = type;
181 this->quals = quals;
182 const unsigned maxAlign = 1U << 31;
183 this->alignment = alignment.getQuantity() <= maxAlign
184 ? alignment.getQuantity()
185 : maxAlign;
186 assert(this->alignment == alignment.getQuantity() &&
187 "Alignment exceeds allowed max!");
188 this->baseInfo = baseInfo;
189 }
190
191public:
192 bool isSimple() const { return lvType == Simple; }
193 bool isVectorElt() const { return lvType == VectorElt; }
194 bool isBitField() const { return lvType == BitField; }
196 bool isGlobalReg() const { return lvType == GlobalReg; }
197 bool isVolatile() const { return quals.hasVolatile(); }
198
200
204
206
208
213
217
225
228
231
234
235
237
239 r.lvType = Simple;
243 return r;
244 }
245
249
254
257 return vectorIdx;
258 }
259
260
265
270
273 return mlir::castmlir::ArrayAttr(vectorElts);
274 }
275
279 r.lvType = VectorElt;
282 r.vectorIdx = index;
284 return r;
285 }
286
291 r.lvType = ExtVectorElt;
294 r.vectorElts = elts;
295 r.initialize(type, type.getQualifiers(), vecAddress.getAlignment(),
296 baseInfo);
297 return r;
298 }
299
300
304
309
312 return *bitFieldInfo;
313 }
314
315
316
317
318
319
320
324 r.lvType = BitField;
327 r.bitFieldInfo = &info;
328 r.initialize(type, type.getQualifiers(), addr.getAlignment(), baseInfo);
329 return r;
330 }
331};
332
333
335
338
339
340
341
342 [[maybe_unused]]
343 LLVM_PREFERRED_TYPE(bool) unsigned destructedFlag : 1;
344
345
346
347 LLVM_PREFERRED_TYPE(bool)
348 unsigned zeroedFlag : 1;
349
350
351
352
353
354
355
356
357
358
359
360
361 [[maybe_unused]]
362 LLVM_PREFERRED_TYPE(bool) unsigned aliasedFlag : 1;
363
364
365
366
367
368
369 [[maybe_unused]]
370 LLVM_PREFERRED_TYPE(bool) unsigned overlapFlag : 1;
371
372public:
377
378
379
384
386 bool zeroedFlag, bool aliasedFlag, bool overlapFlag)
387 : addr(addr), quals(quals), destructedFlag(destructedFlag),
388 zeroedFlag(zeroedFlag), aliasedFlag(aliasedFlag),
389 overlapFlag(overlapFlag) {}
390
398
405
410 destructedFlag = destructed;
411 }
412
414
415 bool isVolatile() const { return quals.hasVolatile(); }
416
418 if (flag)
419 quals.addVolatile();
420 else
421 quals.removeVolatile();
422 }
423
425
426 bool isIgnored() const { return !addr.isValid(); }
427
428 mlir::Value getPointer() const { return addr.getPointer(); }
429
431
433
435
442};
443
444}
445
446#endif
C Language Family Type Representation.
mlir::Value getPointer() const
mlir::Type getElementType() const
clang::CharUnits getAlignment() const
IsZeroed_t
Definition CIRGenValue.h:374
@ IsZeroed
Definition CIRGenValue.h:374
@ IsNotZeroed
Definition CIRGenValue.h:374
IsZeroed_t isZeroed() const
Definition CIRGenValue.h:432
bool isIgnored() const
Definition CIRGenValue.h:426
Overlap_t mayOverlap() const
Definition CIRGenValue.h:430
IsDestructed_t
This is set to true if the slot might be aliased and it's not undefined behavior to access it through...
Definition CIRGenValue.h:373
@ IsDestructed
Definition CIRGenValue.h:373
@ IsNotDestructed
Definition CIRGenValue.h:373
static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Definition CIRGenValue.h:391
IsDestructed_t isExternallyDestructed() const
Definition CIRGenValue.h:406
AggValueSlot(Address addr, clang::Qualifiers quals, bool destructedFlag, bool zeroedFlag, bool aliasedFlag, bool overlapFlag)
Definition CIRGenValue.h:385
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Definition CIRGenValue.h:399
Address getAddress() const
Definition CIRGenValue.h:424
void setExternallyDestructed(bool destructed=true)
Definition CIRGenValue.h:409
IsAliased_t
Definition CIRGenValue.h:375
@ IsNotAliased
Definition CIRGenValue.h:375
@ IsAliased
Definition CIRGenValue.h:375
RValue asRValue() const
Definition CIRGenValue.h:436
static AggValueSlot ignored()
Returns an aggregate value slot indicating that the aggregate value is being ignored.
Definition CIRGenValue.h:380
IsAliased_t isPotentiallyAliased() const
Definition CIRGenValue.h:434
bool isVolatile() const
Definition CIRGenValue.h:415
mlir::Value getPointer() const
Definition CIRGenValue.h:428
clang::Qualifiers getQualifiers() const
Definition CIRGenValue.h:413
Overlap_t
Definition CIRGenValue.h:376
@ MayOverlap
Definition CIRGenValue.h:376
@ DoesNotOverlap
Definition CIRGenValue.h:376
void setVolatile(bool flag)
Definition CIRGenValue.h:417
Definition CIRGenValue.h:140
AlignmentSource getAlignmentSource() const
Definition CIRGenValue.h:146
void mergeForCast(const LValueBaseInfo &info)
Definition CIRGenValue.h:149
LValueBaseInfo(AlignmentSource source=AlignmentSource::Type)
Definition CIRGenValue.h:144
void setAlignmentSource(AlignmentSource source)
Definition CIRGenValue.h:147
Definition CIRGenValue.h:154
bool isExtVectorElt() const
Definition CIRGenValue.h:195
mlir::Value getBitFieldPointer() const
Definition CIRGenValue.h:305
mlir::Value getVectorPointer() const
Definition CIRGenValue.h:250
const clang::Qualifiers & getQuals() const
Definition CIRGenValue.h:226
mlir::Value getExtVectorPointer() const
Definition CIRGenValue.h:266
static LValue makeExtVectorElt(Address vecAddress, mlir::ArrayAttr elts, clang::QualType type, LValueBaseInfo baseInfo)
Definition CIRGenValue.h:287
mlir::Value getVectorIdx() const
Definition CIRGenValue.h:255
bool isVectorElt() const
Definition CIRGenValue.h:193
Address getAddress() const
Definition CIRGenValue.h:214
static LValue makeAddr(Address address, clang::QualType t, LValueBaseInfo baseInfo)
Definition CIRGenValue.h:232
mlir::ArrayAttr getExtVectorElts() const
Definition CIRGenValue.h:271
static LValue makeVectorElt(Address vecAddress, mlir::Value index, clang::QualType t, LValueBaseInfo baseInfo)
Definition CIRGenValue.h:276
unsigned getVRQualifiers() const
Definition CIRGenValue.h:201
clang::QualType getType() const
Definition CIRGenValue.h:205
static LValue makeBitfield(Address addr, const CIRGenBitFieldInfo &info, clang::QualType type, LValueBaseInfo baseInfo)
Create a new object to represent a bit-field access.
Definition CIRGenValue.h:321
mlir::Value getPointer() const
Definition CIRGenValue.h:207
clang::Qualifiers & getQuals()
Definition CIRGenValue.h:227
bool isVolatileQualified() const
Definition CIRGenValue.h:199
bool isBitField() const
Definition CIRGenValue.h:194
void setAlignment(clang::CharUnits a)
Definition CIRGenValue.h:212
Address getVectorAddress() const
Definition CIRGenValue.h:246
clang::CharUnits getAlignment() const
Definition CIRGenValue.h:209
LValueBaseInfo getBaseInfo() const
Definition CIRGenValue.h:229
void setBaseInfo(LValueBaseInfo info)
Definition CIRGenValue.h:230
bool isVolatile() const
Definition CIRGenValue.h:197
bool isGlobalReg() const
Definition CIRGenValue.h:196
const CIRGenBitFieldInfo & getBitFieldInfo() const
Definition CIRGenValue.h:310
Address getBitFieldAddress() const
Definition CIRGenValue.h:301
Address getExtVectorAddress() const
Definition CIRGenValue.h:261
void setAddress(Address address)
Definition CIRGenValue.h:218
bool isSimple() const
Definition CIRGenValue.h:192
This trivial value class is used to represent the result of an expression that is evaluated.
Definition CIRGenValue.h:33
Address getAggregateAddress() const
Return the value of the address of the aggregate.
Definition CIRGenValue.h:69
bool isAggregate() const
Definition CIRGenValue.h:51
mlir::Value value
Definition CIRGenValue.h:37
static RValue get(mlir::Value v)
Definition CIRGenValue.h:83
static RValue getAggregate(Address addr, bool isVolatile=false)
Convert an Address to an RValue.
Definition CIRGenValue.h:105
mlir::Value getAggregatePointer(QualType pointeeType) const
Definition CIRGenValue.h:74
static RValue getComplex(mlir::Value v)
Definition CIRGenValue.h:91
bool isComplex() const
Definition CIRGenValue.h:50
RValue()
Definition CIRGenValue.h:47
bool isVolatileQualified() const
Definition CIRGenValue.h:54
mlir::Value getValue() const
Return the value of this scalar value.
Definition CIRGenValue.h:57
bool isScalar() const
Definition CIRGenValue.h:49
bool isIgnored() const
Definition CIRGenValue.h:52
Address aggregateAddr
Definition CIRGenValue.h:40
mlir::Value getComplexValue() const
Return the value of this complex value.
Definition CIRGenValue.h:63
static RValue getIgnored()
Definition CIRGenValue.h:78
CharUnits - This is an opaque type for sizes expressed in character units.
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.
A (possibly-)qualified type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this 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 CIRGenValue.h:116
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
Definition CIRGenValue.h:125
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CIRGenValue.h:129
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Definition CIRGenValue.h:120
static AlignmentSource getFieldAlignmentSource(AlignmentSource source)
Given that the base address has the given alignment source, what's our confidence in the alignment of...
Definition CIRGenValue.h:134
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',...
static bool aggValueSlot()
static bool addressIsKnownNonNull()
Record with information about how a bitfield should be accessed.