clang 24.0.0git
Mips.cpp
Go to the documentation of this file.
1//===- Mips.cpp -----------------------------------------------------------===//
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#include "ABIInfoImpl.h"
10#include "TargetInfo.h"
11
12using namespace clang;
13using namespace clang::CodeGen;
14
15//===----------------------------------------------------------------------===//
16// MIPS ABI Implementation. This works for both little-endian and
17// big-endian variants.
18//===----------------------------------------------------------------------===//
19
20namespace {
21class MipsABIInfo : public ABIInfo {
22 bool IsO32;
23 const unsigned MinABIStackAlignInBytes, StackAlignInBytes;
24 void CoerceToIntArgs(uint64_t TySize,
25 SmallVectorImpl<llvm::Type *> &ArgList) const;
26 llvm::Type *HandleAggregates(QualType Ty, uint64_t TySize,
27 bool ComplexFitsInFPRs) const;
28 llvm::Type* returnAggregateInRegs(QualType RetTy, uint64_t Size) const;
29 llvm::Type* getPaddingType(uint64_t Align, uint64_t Offset) const;
30
31 /// Whether `_Complex` values with an integer element type are returned the
32 /// way GCC returns them. Clang 23 and earlier returned the real and the
33 /// imaginary part in two separate GPRs, later versions match GCC and pack
34 /// them into one when possible.
35 bool isComplexGnuABI() const {
36 return !getContext().getLangOpts().isCompatibleWith(
37 LangOptions::ClangABI::Ver23);
38 }
39
40 ABIArgInfo classifyComplexReturnType(QualType RetTy, uint64_t Size) const;
41
42public:
43 MipsABIInfo(CodeGenTypes &CGT, bool _IsO32) :
44 ABIInfo(CGT), IsO32(_IsO32), MinABIStackAlignInBytes(IsO32 ? 4 : 8),
45 StackAlignInBytes(IsO32 ? 8 : 16) {}
46
47 ABIArgInfo classifyReturnType(QualType RetTy) const;
48 ABIArgInfo classifyArgumentType(QualType RetTy, uint64_t &Offset,
49 bool IsNamedArg) const;
50 void computeInfo(CGFunctionInfo &FI) const override;
51 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
52 AggValueSlot Slot) const override;
53 ABIArgInfo extendType(QualType Ty, llvm::Type *Padding = nullptr) const;
54};
55
56class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
57 unsigned SizeOfUnwindException;
58public:
59 MIPSTargetCodeGenInfo(CodeGenTypes &CGT, bool IsO32)
60 : TargetCodeGenInfo(std::make_unique<MipsABIInfo>(CGT, IsO32)),
61 SizeOfUnwindException(IsO32 ? 24 : 32) {}
62
63 int getDwarfEHStackPointer(CodeGen::CodeGenModule &CGM) const override {
64 return 29;
65 }
66
67 void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
68 CodeGen::CodeGenModule &CGM) const override {
69 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
70 if (!FD) return;
71 llvm::Function *Fn = cast<llvm::Function>(GV);
72
73 if (FD->hasAttr<MipsLongCallAttr>())
74 Fn->addFnAttr("long-call");
75 else if (FD->hasAttr<MipsShortCallAttr>())
76 Fn->addFnAttr("short-call");
77
78 // Other attributes do not have a meaning for declarations.
79 if (GV->isDeclaration())
80 return;
81
82 if (FD->hasAttr<Mips16Attr>()) {
83 Fn->addFnAttr("mips16");
84 }
85 else if (FD->hasAttr<NoMips16Attr>()) {
86 Fn->addFnAttr("nomips16");
87 }
88
89 if (FD->hasAttr<MicroMipsAttr>())
90 Fn->addFnAttr("micromips");
91 else if (FD->hasAttr<NoMicroMipsAttr>())
92 Fn->addFnAttr("nomicromips");
93
94 const MipsInterruptAttr *Attr = FD->getAttr<MipsInterruptAttr>();
95 if (!Attr)
96 return;
97
98 const char *Kind;
99 switch (Attr->getInterrupt()) {
100 case MipsInterruptAttr::eic: Kind = "eic"; break;
101 case MipsInterruptAttr::sw0: Kind = "sw0"; break;
102 case MipsInterruptAttr::sw1: Kind = "sw1"; break;
103 case MipsInterruptAttr::hw0: Kind = "hw0"; break;
104 case MipsInterruptAttr::hw1: Kind = "hw1"; break;
105 case MipsInterruptAttr::hw2: Kind = "hw2"; break;
106 case MipsInterruptAttr::hw3: Kind = "hw3"; break;
107 case MipsInterruptAttr::hw4: Kind = "hw4"; break;
108 case MipsInterruptAttr::hw5: Kind = "hw5"; break;
109 }
110
111 Fn->addFnAttr("interrupt", Kind);
112
113 }
114
115 bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
116 llvm::Value *Address) const override;
117
118 unsigned getSizeOfUnwindException() const override {
119 return SizeOfUnwindException;
120 }
121};
122
123class WindowsMIPSTargetCodeGenInfo : public MIPSTargetCodeGenInfo {
124public:
125 WindowsMIPSTargetCodeGenInfo(CodeGenTypes &CGT, bool IsO32)
126 : MIPSTargetCodeGenInfo(CGT, IsO32) {}
127
128 void getDependentLibraryOption(llvm::StringRef Lib,
129 llvm::SmallString<24> &Opt) const override {
130 Opt = "/DEFAULTLIB:";
131 Opt += qualifyWindowsLibrary(Lib);
132 }
133
134 void getDetectMismatchOption(llvm::StringRef Name, llvm::StringRef Value,
135 llvm::SmallString<32> &Opt) const override {
136 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
137 }
138};
139}
140
141void MipsABIInfo::CoerceToIntArgs(
142 uint64_t TySize, SmallVectorImpl<llvm::Type *> &ArgList) const {
143 llvm::IntegerType *IntTy =
144 llvm::IntegerType::get(getVMContext(), MinABIStackAlignInBytes * 8);
145
146 // Add (TySize / MinABIStackAlignInBytes) args of IntTy.
147 for (unsigned N = TySize / (MinABIStackAlignInBytes * 8); N; --N)
148 ArgList.push_back(IntTy);
149
150 // If necessary, add one more integer type to ArgList.
151 unsigned R = TySize % (MinABIStackAlignInBytes * 8);
152
153 if (R)
154 ArgList.push_back(llvm::IntegerType::get(getVMContext(), R));
155}
156
157// In N32/64, an aligned double precision floating point field is passed in
158// a register.
159llvm::Type *MipsABIInfo::HandleAggregates(QualType Ty, uint64_t TySize,
160 bool ComplexFitsInFPRs) const {
161 SmallVector<llvm::Type*, 8> ArgList, IntArgList;
162
163 if (IsO32) {
164 CoerceToIntArgs(TySize, ArgList);
165 return llvm::StructType::get(getVMContext(), ArgList);
166 }
167
168 // A `_Complex` value that stays in FPRs is passed as its two parts.
169 // When that does not fit, it is passed like an integer of the same size.
170 if (Ty->isComplexType()) {
171 if (ComplexFitsInFPRs)
172 return CGT.ConvertType(Ty);
173
174 CoerceToIntArgs(TySize, ArgList);
175 return llvm::StructType::get(getVMContext(), ArgList);
176 }
177
178 const RecordType *RT = Ty->getAsCanonical<RecordType>();
179
180 // Unions/vectors are passed in integer registers.
181 if (!RT || !RT->isStructureOrClassType()) {
182 CoerceToIntArgs(TySize, ArgList);
183 return llvm::StructType::get(getVMContext(), ArgList);
184 }
185
186 const RecordDecl *RD = RT->getDecl()->getDefinitionOrSelf();
187 const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
188 assert(!(TySize % 8) && "Size of structure must be multiple of 8.");
189
190 uint64_t LastOffset = 0;
191 unsigned idx = 0;
192 llvm::IntegerType *I64 = llvm::IntegerType::get(getVMContext(), 64);
193
194 // Iterate over fields in the struct/class and check if there are any aligned
195 // double fields.
196 for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
197 i != e; ++i, ++idx) {
198 const QualType Ty = i->getType();
199 const BuiltinType *BT = Ty->getAs<BuiltinType>();
200
201 if (!BT || BT->getKind() != BuiltinType::Double)
202 continue;
203
204 uint64_t Offset = Layout.getFieldOffset(idx);
205 if (Offset % 64) // Ignore doubles that are not aligned.
206 continue;
207
208 // Add ((Offset - LastOffset) / 64) args of type i64.
209 for (unsigned j = (Offset - LastOffset) / 64; j > 0; --j)
210 ArgList.push_back(I64);
211
212 // Add double type.
213 ArgList.push_back(llvm::Type::getDoubleTy(getVMContext()));
214 LastOffset = Offset + 64;
215 }
216
217 CoerceToIntArgs(TySize - LastOffset, IntArgList);
218 ArgList.append(IntArgList.begin(), IntArgList.end());
219
220 return llvm::StructType::get(getVMContext(), ArgList);
221}
222
223llvm::Type *MipsABIInfo::getPaddingType(uint64_t OrigOffset,
224 uint64_t Offset) const {
225 if (OrigOffset + MinABIStackAlignInBytes > Offset)
226 return nullptr;
227
228 return llvm::IntegerType::get(getVMContext(), (Offset - OrigOffset) * 8);
229}
230
231ABIArgInfo MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t &Offset,
232 bool IsNamedArg) const {
234
235 uint64_t OrigOffset = Offset;
236 uint64_t TySize = getContext().getTypeSize(Ty);
237 uint64_t Align = getContext().getTypeAlign(Ty) / 8;
238
239 Align = std::clamp(Align, (uint64_t)MinABIStackAlignInBytes,
240 (uint64_t)StackAlignInBytes);
241 unsigned CurrOffset = llvm::alignTo(Offset, Align);
242 Offset = CurrOffset + llvm::alignTo(TySize, Align * 8) / 8;
243
244 // Only pass _Complex float and _Complex double in FPRs when there are 2 free
245 // slots, and it's not a variadic argument otherwise use GPRs (or the stack).
246 //
247 // _Complex long double never uses GPRs. Its parts are an FPR pair each,
248 // so passing them as they are puts each part in a pair and spills to
249 // the stack the parts that don't fit.
250 bool ComplexFitsInFPRs = IsNamedArg;
251 if (!IsO32 && IsNamedArg && Ty->isComplexType() && isComplexGnuABI() &&
252 TySize < 256) {
253 unsigned NumArgSlots = 8;
254 uint64_t SlotsUsed = CurrOffset / MinABIStackAlignInBytes;
255 if (SlotsUsed + 2 <= NumArgSlots)
256 // Claim 2 slots. Only a `_Complex float` needs this,
257 // a `_Complex double` is already two slots.
258 Offset = CurrOffset + 2 * MinABIStackAlignInBytes;
259 else
260 // Pass like an integer of the same size, packing both parts into GPRs
261 // (or the stack).
262 ComplexFitsInFPRs = false;
263 }
264
265 if (isAggregateTypeForABI(Ty) || Ty->isVectorType()) {
266 // Ignore empty aggregates, but do insert padding for over-aligned
267 // zero-sized types.
268 if (TySize == 0) {
269 if (llvm::Type *Padding = getPaddingType(OrigOffset, CurrOffset))
270 return ABIArgInfo::getExpandWithPadding(/*PaddingInReg=*/false,
271 Padding);
272 return ABIArgInfo::getIgnore();
273 }
274
275 if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) {
276 Offset = OrigOffset + MinABIStackAlignInBytes;
277 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
279 }
280
281 // If we have reached here, aggregates are passed directly by coercing to
282 // another structure type. Padding is inserted if the offset of the
283 // aggregate is unaligned.
284 ABIArgInfo ArgInfo =
285 ABIArgInfo::getDirect(HandleAggregates(Ty, TySize, ComplexFitsInFPRs),
286 0, getPaddingType(OrigOffset, CurrOffset));
287 ArgInfo.setInReg(true);
288 return ArgInfo;
289 }
290
291 // Treat an enum type as its underlying type.
292 if (const auto *ED = Ty->getAsEnumDecl())
293 Ty = ED->getIntegerType();
294
295 // Make sure we pass indirectly things that are too large.
296 if (const auto *EIT = Ty->getAs<BitIntType>())
297 if (EIT->getNumBits() > 128 ||
298 (EIT->getNumBits() > 64 &&
299 !getContext().getTargetInfo().hasInt128Type()))
300 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
301
302 // Scalars never get explicit padding on O32: CC_MipsO32 already does the
303 // alignment itself based on the argument's original alignment.
304 //
305 // For __int128 and other types that are 16-byte aligned this padding ensures
306 // that the value starts in an even-numbered register or stack slot.
307 llvm::Type *Padding =
308 IsO32 ? nullptr : getPaddingType(OrigOffset, CurrOffset);
309
310 // All integral types are promoted to the GPR width.
312 return extendType(Ty, Padding);
313
314 return ABIArgInfo::getDirect(nullptr, 0, Padding);
315}
316
317llvm::Type*
318MipsABIInfo::returnAggregateInRegs(QualType RetTy, uint64_t Size) const {
319 const RecordType *RT = RetTy->getAsCanonical<RecordType>();
320 SmallVector<llvm::Type*, 8> RTList;
321
322 if (RT && RT->isStructureOrClassType()) {
323 const RecordDecl *RD = RT->getDecl()->getDefinitionOrSelf();
324 const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
325 unsigned FieldCnt = Layout.getFieldCount();
326
327 // N32/64 returns struct/classes in floating point registers if the
328 // following conditions are met:
329 // 1. The size of the struct/class is no larger than 128-bit.
330 // 2. The struct/class has one or two fields all of which are floating
331 // point types.
332 // 3. The offset of the first field is zero (this follows what gcc does).
333 //
334 // Any other composite results are returned in integer registers.
335 //
336 if (FieldCnt && (FieldCnt <= 2) && !Layout.getFieldOffset(0)) {
338 for (; b != e; ++b) {
339 const BuiltinType *BT = b->getType()->getAs<BuiltinType>();
340
341 if (!BT || !BT->isFloatingPoint())
342 break;
343
344 RTList.push_back(CGT.ConvertType(b->getType()));
345 }
346
347 if (b == e)
348 return llvm::StructType::get(getVMContext(), RTList,
349 RD->hasAttr<PackedAttr>());
350
351 RTList.clear();
352 }
353 }
354
355 CoerceToIntArgs(Size, RTList);
356 return llvm::StructType::get(getVMContext(), RTList);
357}
358
359ABIArgInfo MipsABIInfo::classifyComplexReturnType(QualType RetTy,
360 uint64_t Size) const {
361 // A `_Complex` value with a floating-point element type is returned in FPRs,
362 // `_Complex long long` is returned in 2 GPRs. For older ABI versions all
363 // `_Complex {integer}` types are returned in 2 GPRs.
364 uint64_t RegisterWidth = MinABIStackAlignInBytes * 8;
365 if (!isComplexGnuABI() || RetTy->isFloatingType() || Size > RegisterWidth)
366 return ABIArgInfo::getDirect();
367
368 // Match GCC for `_Complex int`, `_Complex short` and `_Complex char` by
369 // packing the real and imaginary field into one GPR.
370 return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), Size));
371}
372
373ABIArgInfo MipsABIInfo::classifyReturnType(QualType RetTy) const {
374 uint64_t Size = getContext().getTypeSize(RetTy);
375
376 if (RetTy->isVoidType())
377 return ABIArgInfo::getIgnore();
378
379 // O32 doesn't treat zero-sized structs differently from other structs.
380 // However, N32/N64 ignores zero sized return values.
381 if (!IsO32 && Size == 0)
382 return ABIArgInfo::getIgnore();
383
384 if (isAggregateTypeForABI(RetTy) || RetTy->isVectorType()) {
385 if (Size <= 128) {
386 if (RetTy->isAnyComplexType())
387 return classifyComplexReturnType(RetTy, Size);
388
389 // O32 returns integer vectors in registers and N32/N64 returns all small
390 // aggregates in registers.
391 if (!IsO32 ||
392 (RetTy->isVectorType() && !RetTy->hasFloatingRepresentation())) {
393 ABIArgInfo ArgInfo =
394 ABIArgInfo::getDirect(returnAggregateInRegs(RetTy, Size));
395 ArgInfo.setInReg(true);
396 return ArgInfo;
397 }
398 }
399
400 return getNaturalAlignIndirect(RetTy, getDataLayout().getAllocaAddrSpace());
401 }
402
403 // Treat an enum type as its underlying type.
404 if (const auto *ED = RetTy->getAsEnumDecl())
405 RetTy = ED->getIntegerType();
406
407 // Make sure we pass indirectly things that are too large.
408 if (const auto *EIT = RetTy->getAs<BitIntType>())
409 if (EIT->getNumBits() > 128 ||
410 (EIT->getNumBits() > 64 &&
411 !getContext().getTargetInfo().hasInt128Type()))
412 return getNaturalAlignIndirect(RetTy,
413 getDataLayout().getAllocaAddrSpace());
414
415 if (isPromotableIntegerTypeForABI(RetTy))
416 return ABIArgInfo::getExtend(RetTy);
417
419 RetTy->isSignedIntegerOrEnumerationType()) && Size == 32 && !IsO32)
420 return ABIArgInfo::getSignExtend(RetTy);
421
422 return ABIArgInfo::getDirect();
423}
424
425void MipsABIInfo::computeInfo(CGFunctionInfo &FI) const {
426 ABIArgInfo &RetInfo = FI.getReturnInfo();
427 if (!getCXXABI().classifyReturnType(FI))
428 RetInfo = classifyReturnType(FI.getReturnType());
429
430 // Check if a pointer to an aggregate is passed as a hidden argument.
431 uint64_t Offset = RetInfo.isIndirect() ? MinABIStackAlignInBytes : 0;
432
433 // Zero-sized arguments are not passed, but do end the run of floats.
434 bool SawZeroSizedArg = false;
435
436 for (auto [ArgNo, I] : llvm::enumerate(FI.arguments())) {
437 bool IsNamedArg = ArgNo < FI.getNumRequiredArgs();
438 I.info = classifyArgumentType(I.type, Offset, IsNamedArg);
439
440 // N32 and N64 always pass floating points in float registers.
441 if (!IsO32)
442 continue;
443
444 if (getContext().getTypeSize(I.type) == 0)
445 SawZeroSizedArg = true;
446 else if (SawZeroSizedArg && I.type->isRealFloatingType()) {
447 // A zero-sized type ends the leading run of float arguments that is
448 // passed in FPRs. Any subsequent floats must be passed via GPRs. Cast the
449 // float to an integer now because we drop the zero-sized argument here
450 // and later stages have no way of inferring that it was there.
451 I.info = ABIArgInfo::getDirect(llvm::IntegerType::get(
452 getVMContext(), getContext().getTypeSize(I.type)));
453 }
454 }
455}
456
457RValue MipsABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
458 QualType OrigTy, AggValueSlot Slot) const {
459 QualType Ty = OrigTy;
460
461 // Integer arguments are promoted to 32-bit on O32 and 64-bit on N32/N64.
462 // Pointers are also promoted in the same way but this only matters for N32.
463 unsigned SlotSizeInBits = IsO32 ? 32 : 64;
464 unsigned PtrWidth = getTarget().getPointerWidth(LangAS::Default);
465 bool DidPromote = false;
466 if ((Ty->isIntegerType() &&
467 getContext().getIntWidth(Ty) < SlotSizeInBits) ||
468 (Ty->isPointerType() && PtrWidth < SlotSizeInBits)) {
469 DidPromote = true;
470 Ty = getContext().getIntTypeForBitwidth(SlotSizeInBits,
471 Ty->isSignedIntegerType());
472 }
473
474 auto TyInfo = getContext().getTypeInfoInChars(Ty);
475
476 // The alignment of things in the argument area is never larger than
477 // StackAlignInBytes.
478 TyInfo.Align =
479 std::min(TyInfo.Align, CharUnits::fromQuantity(StackAlignInBytes));
480
481 // MinABIStackAlignInBytes is the size of argument slots on the stack.
482 CharUnits ArgSlotSize = CharUnits::fromQuantity(MinABIStackAlignInBytes);
483
484 RValue Res = emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false, TyInfo,
485 ArgSlotSize, /*AllowHigherAlign*/ true, Slot);
486
487 // If there was a promotion, "unpromote".
488 // TODO: can we just use a pointer into a subset of the original slot?
489 if (DidPromote) {
490 llvm::Type *ValTy = CGF.ConvertType(OrigTy);
491 llvm::Value *Promoted = Res.getScalarVal();
492
493 // Truncate down to the right width.
494 llvm::Type *IntTy = (OrigTy->isIntegerType() ? ValTy : CGF.IntPtrTy);
495 llvm::Value *V = CGF.Builder.CreateTrunc(Promoted, IntTy);
496 if (OrigTy->isPointerType())
497 V = CGF.Builder.CreateIntToPtr(V, ValTy);
498
499 return RValue::get(V);
500 }
501
502 return Res;
503}
504
505ABIArgInfo MipsABIInfo::extendType(QualType Ty, llvm::Type *Padding) const {
506 int TySize = getContext().getTypeSize(Ty);
507
508 // MIPS64 ABI requires unsigned 32 bit integers to be sign extended.
509 if (Ty->isUnsignedIntegerOrEnumerationType() && TySize == 32)
510 return ABIArgInfo::getSignExtend(Ty, /*T=*/nullptr, Padding);
511
512 return ABIArgInfo::getExtend(Ty, /*T=*/nullptr, Padding);
513}
514
515bool
516MIPSTargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
517 llvm::Value *Address) const {
518 // This information comes from gcc's implementation, which seems to
519 // as canonical as it gets.
520
521 // Everything on MIPS is 4 bytes. Double-precision FP registers
522 // are aliased to pairs of single-precision FP registers.
523 llvm::Value *Four8 = llvm::ConstantInt::get(CGF.Int8Ty, 4);
524
525 // 0-31 are the general purpose registers, $0 - $31.
526 // 32-63 are the floating-point registers, $f0 - $f31.
527 // 64 and 65 are the multiply/divide registers, $hi and $lo.
528 // 66 is the (notional, I think) register for signal-handler return.
529 AssignToArrayRange(CGF.Builder, Address, Four8, 0, 65);
530
531 // 67-74 are the floating-point status registers, $fcc0 - $fcc7.
532 // They are one bit wide and ignored here.
533
534 // 80-111 are the coprocessor 0 registers, $c0r0 - $c0r31.
535 // (coprocessor 1 is the FP unit)
536 // 112-143 are the coprocessor 2 registers, $c2r0 - $c2r31.
537 // 144-175 are the coprocessor 3 registers, $c3r0 - $c3r31.
538 // 176-181 are the DSP accumulator registers.
539 AssignToArrayRange(CGF.Builder, Address, Four8, 80, 181);
540 return false;
541}
542
543std::unique_ptr<TargetCodeGenInfo>
545 return std::make_unique<MIPSTargetCodeGenInfo>(CGM.getTypes(), IsOS32);
546}
547
548std::unique_ptr<TargetCodeGenInfo>
550 return std::make_unique<WindowsMIPSTargetCodeGenInfo>(CGM.getTypes(), IsOS32);
551}
#define V(N, I)
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
bool isFloatingPoint() const
Definition TypeBase.h:3317
Kind getKind() const
Definition TypeBase.h:3292
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition CharUnits.h:63
static ABIArgInfo getSignExtend(QualType Ty, llvm::Type *T=nullptr, llvm::Type *Padding=nullptr)
static ABIArgInfo getIgnore()
static ABIArgInfo getExpandWithPadding(bool PaddingInReg, llvm::Type *Padding)
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
static ABIArgInfo getExtend(QualType Ty, llvm::Type *T=nullptr, llvm::Type *Padding=nullptr)
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
Definition ABIInfo.h:49
RecordArgABI
Specify how one should pass an argument of a record type.
Definition CGCXXABI.h:150
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
Definition CGCXXABI.h:158
CanQualType getReturnType() const
MutableArrayRef< ArgInfo > arguments()
llvm::Type * ConvertType(QualType T)
This class organizes the cross-function state that is used while generating LLVM code.
static RValue get(llvm::Value *V)
Definition CGValue.h:99
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
Definition CGValue.h:72
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Definition TargetInfo.h:80
T * getAttr() const
Definition DeclBase.h:581
bool hasAttr() const
Definition DeclBase.h:585
field_iterator field_end() const
Definition Decl.h:4665
specific_decl_iterator< FieldDecl > field_iterator
Definition Decl.h:4659
RecordDecl * getDefinitionOrSelf() const
Definition Decl.h:4647
field_iterator field_begin() const
Definition Decl.cpp:5338
bool isVoidType() const
Definition TypeBase.h:9111
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Definition Type.cpp:2319
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
Definition Type.cpp:2296
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
Definition Type.cpp:761
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
Definition Type.cpp:2387
bool isPointerType() const
Definition TypeBase.h:8739
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition TypeBase.h:9155
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Definition TypeBase.h:9233
bool isAnyComplexType() const
Definition TypeBase.h:8874
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
Definition Type.h:53
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
Definition Type.cpp:2429
bool isVectorType() const
Definition TypeBase.h:8878
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
Definition TypeBase.h:2998
bool isFloatingType() const
Definition Type.cpp:2421
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9338
ABIArgInfo classifyArgumentType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to pass a particular type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Definition CGValue.h:146
CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
bool classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI, const ABIInfo &Info)
std::unique_ptr< TargetCodeGenInfo > createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32)
Definition Mips.cpp:544
RValue emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType ValueTy, bool IsIndirect, TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign, bool AllowHigherAlign, AggValueSlot Slot, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
bool isAggregateTypeForABI(QualType T)
std::unique_ptr< TargetCodeGenInfo > createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32)
Definition Mips.cpp:549
void AssignToArrayRange(CodeGen::CGBuilderTy &Builder, llvm::Value *Array, llvm::Value *Value, unsigned FirstIndex, unsigned LastIndex)
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
Top level wrappers for InstallAPI frontend operations.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)
Definition Address.h:327
unsigned long uint64_t
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64