@@ -95,11 +95,9 @@ class DefaultABIInfo : public ABIInfo {
95
95
// ===----------------------------------------------------------------------===//
96
96
97
97
namespace {
98
+ using ABIKind = cir::AArch64ABIKind;
98
99
99
100
class AArch64ABIInfo : public ABIInfo {
100
- public:
101
- enum ABIKind { AAPCS = 0 , DarwinPCS, Win64 };
102
-
103
101
private:
104
102
ABIKind Kind;
105
103
@@ -113,7 +111,7 @@ class AArch64ABIInfo : public ABIInfo {
113
111
114
112
private:
115
113
ABIKind getABIKind () const { return Kind; }
116
- bool isDarwinPCS () const { return Kind == DarwinPCS; }
114
+ bool isDarwinPCS () const { return Kind == ABIKind:: DarwinPCS; }
117
115
118
116
cir::ABIArgInfo classifyReturnType (QualType RetTy, bool IsVariadic) const ;
119
117
cir::ABIArgInfo classifyArgumentType (QualType RetTy, bool IsVariadic,
@@ -143,12 +141,18 @@ class AArch64ABIInfo : public ABIInfo {
143
141
144
142
class AArch64TargetCIRGenInfo : public TargetCIRGenInfo {
145
143
public:
146
- AArch64TargetCIRGenInfo (CIRGenTypes &CGT, AArch64ABIInfo:: ABIKind Kind)
144
+ AArch64TargetCIRGenInfo (CIRGenTypes &CGT, ABIKind Kind)
147
145
: TargetCIRGenInfo(std::make_unique<AArch64ABIInfo>(CGT, Kind)) {}
148
146
};
149
147
150
148
} // namespace
151
149
150
+ std::unique_ptr<TargetCIRGenInfo>
151
+ clang::CIRGen::createAArch64TargetCIRGenInfo (CIRGenTypes &CGT,
152
+ cir::AArch64ABIKind Kind) {
153
+ return std::make_unique<AArch64TargetCIRGenInfo>(CGT, Kind);
154
+ }
155
+
152
156
// ===----------------------------------------------------------------------===//
153
157
// X86 ABI Implementation
154
158
// ===----------------------------------------------------------------------===//
@@ -230,6 +234,12 @@ class X86_64TargetCIRGenInfo : public TargetCIRGenInfo {
230
234
};
231
235
} // namespace
232
236
237
+ std::unique_ptr<TargetCIRGenInfo>
238
+ clang::CIRGen::createX86_64TargetCIRGenInfo (CIRGenTypes &CGT,
239
+ X86AVXABILevel AVXLevel) {
240
+ return std::make_unique<X86_64TargetCIRGenInfo>(CGT, AVXLevel);
241
+ }
242
+
233
243
// ===----------------------------------------------------------------------===//
234
244
// Base ABI and target codegen info implementation common between SPIR and
235
245
// SPIR-V.
@@ -309,6 +319,11 @@ class SPIRVTargetCIRGenInfo : public CommonSPIRTargetCIRGenInfo {
309
319
310
320
} // namespace
311
321
322
+ std::unique_ptr<TargetCIRGenInfo>
323
+ clang::CIRGen::createSPIRVTargetCIRGenInfo (CIRGenTypes &CGT) {
324
+ return std::make_unique<SPIRVTargetCIRGenInfo>(CGT);
325
+ }
326
+
312
327
// ===----------------------------------------------------------------------===//
313
328
// NVPTX ABI Implementation
314
329
// ===----------------------------------------------------------------------===//
@@ -333,6 +348,11 @@ class NVPTXTargetCIRGenInfo : public TargetCIRGenInfo {
333
348
334
349
} // namespace
335
350
351
+ std::unique_ptr<TargetCIRGenInfo>
352
+ clang::CIRGen::createNVPTXTargetCIRGenInfo (CIRGenTypes &CGT) {
353
+ return std::make_unique<NVPTXTargetCIRGenInfo>(CGT);
354
+ }
355
+
336
356
// ===----------------------------------------------------------------------===//
337
357
// AMDGPU ABI Implementation
338
358
// ===----------------------------------------------------------------------===//
@@ -361,6 +381,11 @@ class AMDGPUTargetCIRGenInfo : public TargetCIRGenInfo {
361
381
362
382
} // namespace
363
383
384
+ std::unique_ptr<TargetCIRGenInfo>
385
+ clang::CIRGen::createAMDGPUTargetCIRGenInfo (CIRGenTypes &CGT) {
386
+ return std::make_unique<AMDGPUTargetCIRGenInfo>(CGT);
387
+ }
388
+
364
389
// TODO(cir): remove the attribute once this gets used.
365
390
LLVM_ATTRIBUTE_UNUSED
366
391
static bool classifyReturnType (const CIRGenCXXABI &CXXABI,
@@ -702,57 +727,3 @@ mlir::Value TargetCIRGenInfo::performAddrSpaceCast(
702
727
// Try to preserve the source's name to make IR more readable.
703
728
return CGF.getBuilder ().createAddrSpaceCast (Src, DestTy);
704
729
}
705
-
706
- const TargetCIRGenInfo &CIRGenModule::getTargetCIRGenInfo () {
707
- if (TheTargetCIRGenInfo)
708
- return *TheTargetCIRGenInfo;
709
-
710
- // Helper to set the unique_ptr while still keeping the return value.
711
- auto SetCIRGenInfo = [&](TargetCIRGenInfo *P) -> const TargetCIRGenInfo & {
712
- this ->TheTargetCIRGenInfo .reset (P);
713
- return *P;
714
- };
715
-
716
- const llvm::Triple &Triple = getTarget ().getTriple ();
717
-
718
- switch (Triple.getArch ()) {
719
- default :
720
- assert (false && " Target not yet supported!" );
721
-
722
- case llvm::Triple::aarch64_be:
723
- case llvm::Triple::aarch64: {
724
- AArch64ABIInfo::ABIKind Kind = AArch64ABIInfo::AAPCS;
725
- assert (getTarget ().getABI () == " aapcs" ||
726
- getTarget ().getABI () == " darwinpcs" &&
727
- " Only Darwin supported for aarch64" );
728
- Kind = AArch64ABIInfo::DarwinPCS;
729
- return SetCIRGenInfo (new AArch64TargetCIRGenInfo (genTypes, Kind));
730
- }
731
-
732
- case llvm::Triple::x86_64: {
733
- StringRef ABI = getTarget ().getABI ();
734
- X86AVXABILevel AVXLevel = (ABI == " avx512" ? X86AVXABILevel::AVX512
735
- : ABI == " avx" ? X86AVXABILevel::AVX
736
- : X86AVXABILevel::None);
737
-
738
- switch (Triple.getOS ()) {
739
- default :
740
- assert (false && " OSType NYI" );
741
- case llvm::Triple::Linux:
742
- return SetCIRGenInfo (new X86_64TargetCIRGenInfo (genTypes, AVXLevel));
743
- }
744
- }
745
-
746
- case llvm::Triple::spirv64: {
747
- return SetCIRGenInfo (new SPIRVTargetCIRGenInfo (genTypes));
748
- }
749
-
750
- case llvm::Triple::nvptx64: {
751
- return SetCIRGenInfo (new NVPTXTargetCIRGenInfo (genTypes));
752
- }
753
-
754
- case llvm::Triple::amdgcn: {
755
- return SetCIRGenInfo (new AMDGPUTargetCIRGenInfo (genTypes));
756
- }
757
- }
758
- }
0 commit comments