Skip to content

Commit 72dc69e

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 02dd118 + 8fe2846 commit 72dc69e

File tree

115 files changed

+12077
-358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+12077
-358
lines changed

clang/include/clang/AST/Type.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,12 @@ class Qualifiers {
480480
// Otherwise in OpenCLC v2.0 s6.5.5: every address space except
481481
// for __constant can be used as __generic.
482482
(A == LangAS::opencl_generic && B != LangAS::opencl_constant) ||
483+
// We also define global_device and global_host address spaces,
484+
// to distinguish global pointers allocated on host from pointers
485+
// allocated on device, which are a subset of __global.
486+
// FIXME: add a reference to spec when ready
487+
(A == LangAS::opencl_global && (B == LangAS::opencl_global_device ||
488+
B == LangAS::opencl_global_host)) ||
483489
// Consider pointer size address spaces to be equivalent to default.
484490
((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
485491
(isPtrSizeAddressSpace(B) || B == LangAS::Default));
@@ -493,7 +499,9 @@ class Qualifiers {
493499
(!hasAddressSpace() &&
494500
(other.getAddressSpace() == LangAS::opencl_private ||
495501
other.getAddressSpace() == LangAS::opencl_local ||
496-
other.getAddressSpace() == LangAS::opencl_global));
502+
other.getAddressSpace() == LangAS::opencl_global ||
503+
other.getAddressSpace() == LangAS::opencl_global_device ||
504+
other.getAddressSpace() == LangAS::opencl_global_host));
497505
}
498506

499507
/// Determines if these qualifiers compatibly include another set.

clang/include/clang/Basic/AddressSpaces.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ enum class LangAS : unsigned {
3636
opencl_constant,
3737
opencl_private,
3838
opencl_generic,
39+
opencl_global_device,
40+
opencl_global_host,
3941

4042
// CUDA specific address spaces.
4143
cuda_device,

clang/include/clang/Basic/Attr.td

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ def CUDA : LangOpt<"CUDA">;
326326
def SYCLIsDevice : LangOpt<"SYCLIsDevice">;
327327
def SYCL : LangOpt<"SYCLIsDevice">;
328328
def SYCLIsHost : LangOpt<"SYCLIsHost">;
329+
def SYCLExplicitSIMD : LangOpt<"SYCLExplicitSIMD">;
329330
def HIP : LangOpt<"HIP">;
330331
def COnly : LangOpt<"", "!LangOpts.CPlusPlus">;
331332
def CPlusPlus : LangOpt<"CPlusPlus">;
@@ -1124,6 +1125,7 @@ def SYCLDevice : InheritableAttr {
11241125
let Subjects = SubjectList<[Function]>;
11251126
let LangOpts = [SYCLIsDevice];
11261127
let Documentation = [SYCLDeviceDocs];
1128+
let PragmaAttributeSupport = 0;
11271129
}
11281130

11291131
def SYCLKernel : InheritableAttr {
@@ -1159,6 +1161,7 @@ def SYCLDeviceIndirectlyCallable : InheritableAttr {
11591161
let Subjects = SubjectList<[Function]>;
11601162
let LangOpts = [SYCLIsDevice];
11611163
let Documentation = [SYCLDeviceIndirectlyCallableDocs];
1164+
let PragmaAttributeSupport = 0;
11621165
}
11631166

11641167
def SYCLIntelKernelArgsRestrict : InheritableAttr {
@@ -1167,6 +1170,7 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr {
11671170
let LangOpts = [ SYCLIsDevice, SYCLIsHost ];
11681171
let Documentation = [ SYCLIntelKernelArgsRestrictDocs ];
11691172
let SimpleHandler = 1;
1173+
let PragmaAttributeSupport = 0;
11701174
}
11711175

11721176
def SYCLIntelNumSimdWorkItems : InheritableAttr {
@@ -1265,6 +1269,7 @@ def IntelReqdSubGroupSize: InheritableAttr {
12651269
let Subjects = SubjectList<[Function, CXXMethod], ErrorDiag>;
12661270
let Documentation = [IntelReqdSubGroupSizeDocs];
12671271
let LangOpts = [OpenCL, SYCLIsDevice, SYCLIsHost];
1272+
let PragmaAttributeSupport = 0;
12681273
}
12691274

12701275
// This attribute is both a type attribute, and a declaration attribute (for
@@ -1293,6 +1298,16 @@ def OpenCLGlobalAddressSpace : TypeAttr {
12931298
let Documentation = [OpenCLAddressSpaceGlobalDocs];
12941299
}
12951300

1301+
def OpenCLGlobalDeviceAddressSpace : TypeAttr {
1302+
let Spellings = [Clang<"opencl_global_device">];
1303+
let Documentation = [OpenCLGlobalAddressSpacesDocs];
1304+
}
1305+
1306+
def OpenCLGlobalHostAddressSpace : TypeAttr {
1307+
let Spellings = [Clang<"opencl_global_host">];
1308+
let Documentation = [OpenCLGlobalAddressSpacesDocs];
1309+
}
1310+
12961311
def OpenCLLocalAddressSpace : TypeAttr {
12971312
let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">];
12981313
let Documentation = [OpenCLAddressSpaceLocalDocs];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,6 +3561,17 @@ scope) variables and static local variable as well.
35613561
}];
35623562
}
35633563

3564+
def OpenCLGlobalAddressSpacesDocs : Documentation {
3565+
let Category = DocOpenCLAddressSpaces;
3566+
let Heading = "[[clang::opencl_global_device]], [[clang::opencl_global_host]]";
3567+
let Content = [{
3568+
The (global_device) and (global_host) address space attributes specify that an
3569+
object is allocated in global memory on the device/host. It helps distinguishing
3570+
USM pointers that access device memory and accessors that access global memory
3571+
from those that access host memory.
3572+
}];
3573+
}
3574+
35643575
def OpenCLAddressSpaceLocalDocs : Documentation {
35653576
let Category = DocOpenCLAddressSpaces;
35663577
let Heading = "__local, local, [[clang::opencl_local]]";

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ LANGOPT(SYCLStdLayoutKernelParams, 1, 0, "Enable standard layout requirement for
248248
LANGOPT(SYCLUnnamedLambda , 1, 0, "Allow unnamed lambda SYCL kernels")
249249
LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used")
250250
LANGOPT(DeclareSPIRVBuiltins, 1, 0, "Declare SPIR-V builtin functions")
251+
LANGOPT(SYCLExplicitSIMD , 1, 0, "SYCL compilation with explicit SIMD extension")
251252

252253
LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
253254

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,6 +3576,10 @@ def fno_sycl : Flag<["-"], "fno-sycl">, Group<sycl_Group>, Flags<[CoreOption]>,
35763576
HelpText<"Disable SYCL kernels compilation for device">;
35773577
def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>, Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
35783578
HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 1.2.1, sycl-1.2.1">;
3579+
def fsycl_esimd : Flag<["-"], "fsycl-explicit-simd">, Group<sycl_Group>, Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
3580+
HelpText<"Enable SYCL explicit SIMD extension">;
3581+
def fno_sycl_esimd : Flag<["-"], "fno-sycl-explicit-simd">, Group<sycl_Group>,
3582+
HelpText<"Disable SYCL explicit SIMD extension">, Flags<[NoArgumentUnused, CoreOption]>;
35793583

35803584
include "CC1Options.td"
35813585

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ class ParsedAttr final
606606
return LangAS::opencl_constant;
607607
case ParsedAttr::AT_OpenCLGlobalAddressSpace:
608608
return LangAS::opencl_global;
609+
case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
610+
return LangAS::opencl_global_device;
611+
case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
612+
return LangAS::opencl_global_host;
609613
case ParsedAttr::AT_OpenCLLocalAddressSpace:
610614
return LangAS::opencl_local;
611615
case ParsedAttr::AT_OpenCLPrivateAddressSpace:

clang/lib/AST/ASTContext.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -919,18 +919,20 @@ static const LangASMap *getAddressSpaceMap(const TargetInfo &T,
919919
// The fake address space map must have a distinct entry for each
920920
// language-specific address space.
921921
static const unsigned FakeAddrSpaceMap[] = {
922-
0, // Default
923-
1, // opencl_global
924-
3, // opencl_local
925-
2, // opencl_constant
926-
0, // opencl_private
927-
4, // opencl_generic
928-
5, // cuda_device
929-
6, // cuda_constant
930-
7, // cuda_shared
931-
8, // ptr32_sptr
932-
9, // ptr32_uptr
933-
10 // ptr64
922+
0, // Default
923+
1, // opencl_global
924+
3, // opencl_local
925+
2, // opencl_constant
926+
0, // opencl_private
927+
4, // opencl_generic
928+
11, // opencl_global_device
929+
12, // opencl_global_host
930+
5, // cuda_device
931+
6, // cuda_constant
932+
7, // cuda_shared
933+
8, // ptr32_sptr
934+
9, // ptr32_uptr
935+
10 // ptr64
934936
};
935937
return &FakeAddrSpaceMap;
936938
} else {
@@ -2067,7 +2069,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
20672069
Align = Target->getDoubleAlign();
20682070
break;
20692071
case BuiltinType::LongDouble:
2070-
if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
2072+
if (((getLangOpts().SYCL && getLangOpts().SYCLIsDevice) ||
2073+
(getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)) &&
2074+
AuxTarget != nullptr &&
20712075
(Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
20722076
Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
20732077
Width = AuxTarget->getLongDoubleWidth();

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,16 +2387,39 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals, const DependentAddressSp
23872387
switch (AS) {
23882388
default: llvm_unreachable("Not a language specific address space");
23892389
// <OpenCL-addrspace> ::= "CL" [ "global" | "local" | "constant" |
2390-
// "private"| "generic" ]
2391-
case LangAS::opencl_global: ASString = "CLglobal"; break;
2392-
case LangAS::opencl_local: ASString = "CLlocal"; break;
2393-
case LangAS::opencl_constant: ASString = "CLconstant"; break;
2394-
case LangAS::opencl_private: ASString = "CLprivate"; break;
2395-
case LangAS::opencl_generic: ASString = "CLgeneric"; break;
2390+
// "private"| "generic" | "global_device" |
2391+
// "global_host" ]
2392+
case LangAS::opencl_global:
2393+
ASString = "CLglobal";
2394+
break;
2395+
case LangAS::opencl_global_device:
2396+
ASString = "CLDevice";
2397+
break;
2398+
case LangAS::opencl_global_host:
2399+
ASString = "CLHost";
2400+
break;
2401+
case LangAS::opencl_local:
2402+
ASString = "CLlocal";
2403+
break;
2404+
case LangAS::opencl_constant:
2405+
ASString = "CLconstant";
2406+
break;
2407+
case LangAS::opencl_private:
2408+
ASString = "CLprivate";
2409+
break;
2410+
case LangAS::opencl_generic:
2411+
ASString = "CLgeneric";
2412+
break;
23962413
// <CUDA-addrspace> ::= "CU" [ "device" | "constant" | "shared" ]
2397-
case LangAS::cuda_device: ASString = "CUdevice"; break;
2398-
case LangAS::cuda_constant: ASString = "CUconstant"; break;
2399-
case LangAS::cuda_shared: ASString = "CUshared"; break;
2414+
case LangAS::cuda_device:
2415+
ASString = "CUdevice";
2416+
break;
2417+
case LangAS::cuda_constant:
2418+
ASString = "CUconstant";
2419+
break;
2420+
case LangAS::cuda_shared:
2421+
ASString = "CUshared";
2422+
break;
24002423
// <ptrsize-addrspace> ::= [ "ptr32_sptr" | "ptr32_uptr" | "ptr64" ]
24012424
case LangAS::ptr32_sptr:
24022425
ASString = "ptr32_sptr";

clang/lib/AST/MicrosoftMangle.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,12 @@ void MicrosoftCXXNameMangler::mangleAddressSpaceType(QualType T,
18231823
case LangAS::opencl_global:
18241824
Extra.mangleSourceName("_ASCLglobal");
18251825
break;
1826+
case LangAS::opencl_global_device:
1827+
Extra.mangleSourceName("_ASCLDevice");
1828+
break;
1829+
case LangAS::opencl_global_host:
1830+
Extra.mangleSourceName("_ASCLHost");
1831+
break;
18261832
case LangAS::opencl_local:
18271833
Extra.mangleSourceName("_ASCLlocal");
18281834
break;

clang/lib/AST/TypePrinter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,8 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
15771577

15781578
case attr::OpenCLPrivateAddressSpace:
15791579
case attr::OpenCLGlobalAddressSpace:
1580+
case attr::OpenCLGlobalDeviceAddressSpace:
1581+
case attr::OpenCLGlobalHostAddressSpace:
15801582
case attr::OpenCLLocalAddressSpace:
15811583
case attr::OpenCLConstantAddressSpace:
15821584
case attr::OpenCLGenericAddressSpace:
@@ -1880,6 +1882,10 @@ std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
18801882
return "__constant";
18811883
case LangAS::opencl_generic:
18821884
return "__generic";
1885+
case LangAS::opencl_global_device:
1886+
return "__global_device";
1887+
case LangAS::opencl_global_host:
1888+
return "__global_host";
18831889
case LangAS::cuda_device:
18841890
return "__device__";
18851891
case LangAS::cuda_constant:

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
4545
Constant, // opencl_constant
4646
Private, // opencl_private
4747
Generic, // opencl_generic
48+
Global, // opencl_global_device
49+
Global, // opencl_global_host
4850
Global, // cuda_device
4951
Constant, // cuda_constant
5052
Local, // cuda_shared
@@ -60,6 +62,8 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
6062
Constant, // opencl_constant
6163
Private, // opencl_private
6264
Generic, // opencl_generic
65+
Global, // opencl_global_device
66+
Global, // opencl_global_host
6367
Global, // cuda_device
6468
Constant, // cuda_constant
6569
Local, // cuda_shared

clang/lib/Basic/Targets/NVPTX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ static const unsigned NVPTXAddrSpaceMap[] = {
3030
0, // opencl_private
3131
// FIXME: generic has to be added to the target
3232
0, // opencl_generic
33+
1, // opencl_global_device
34+
1, // opencl_global_host
3335
1, // cuda_device
3436
4, // cuda_constant
3537
3, // cuda_shared

clang/lib/Basic/Targets/SPIR.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,37 @@ namespace clang {
2424
namespace targets {
2525

2626
static const unsigned SPIRAddrSpaceMap[] = {
27-
0, // Default
28-
1, // opencl_global
29-
3, // opencl_local
30-
2, // opencl_constant
31-
0, // opencl_private
32-
4, // opencl_generic
33-
0, // cuda_device
34-
0, // cuda_constant
35-
0, // cuda_shared
36-
0, // ptr32_sptr
37-
0, // ptr32_uptr
38-
0 // ptr64
27+
0, // Default
28+
1, // opencl_global
29+
3, // opencl_local
30+
2, // opencl_constant
31+
0, // opencl_private
32+
4, // opencl_generic
33+
11, // opencl_global_device
34+
12, // opencl_global_host
35+
0, // cuda_device
36+
0, // cuda_constant
37+
0, // cuda_shared
38+
0, // ptr32_sptr
39+
0, // ptr32_uptr
40+
0 // ptr64
3941
};
4042

4143
static const unsigned SYCLAddrSpaceMap[] = {
42-
4, // Default
43-
1, // opencl_global
44-
3, // opencl_local
45-
2, // opencl_constant
46-
0, // opencl_private
47-
4, // opencl_generic
48-
0, // cuda_device
49-
0, // cuda_constant
50-
0, // cuda_shared
51-
0, // ptr32_sptr
52-
0, // ptr32_uptr
53-
0 // ptr64
44+
4, // Default
45+
1, // opencl_global
46+
3, // opencl_local
47+
2, // opencl_constant
48+
0, // opencl_private
49+
4, // opencl_generic
50+
11, // opencl_global_device
51+
12, // opencl_global_host
52+
0, // cuda_device
53+
0, // cuda_constant
54+
0, // cuda_shared
55+
0, // ptr32_sptr
56+
0, // ptr32_uptr
57+
0 // ptr64
5458
};
5559

5660
class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
@@ -209,8 +213,6 @@ class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32SPIRTargetInfo
209213
MicrosoftX86_32SPIRTargetInfo(const llvm::Triple &Triple,
210214
const TargetOptions &Opts)
211215
: WindowsX86_32SPIRTargetInfo(Triple, Opts) {
212-
LongDoubleWidth = LongDoubleAlign = 64;
213-
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
214216
assert(DataLayout->getPointerSizeInBits() == 32);
215217
}
216218

@@ -261,8 +263,6 @@ class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64_SPIR64TargetInfo
261263
MicrosoftX86_64_SPIR64TargetInfo(const llvm::Triple &Triple,
262264
const TargetOptions &Opts)
263265
: WindowsX86_64_SPIR64TargetInfo(Triple, Opts) {
264-
LongDoubleWidth = LongDoubleAlign = 64;
265-
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
266266
assert(DataLayout->getPointerSizeInBits() == 64);
267267
}
268268

clang/lib/Basic/Targets/TCE.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ static const unsigned TCEOpenCLAddrSpaceMap[] = {
3535
4, // opencl_local
3636
5, // opencl_constant
3737
0, // opencl_private
38+
1, // opencl_global_device
39+
1, // opencl_global_host
3840
// FIXME: generic has to be added to the target
3941
0, // opencl_generic
4042
0, // cuda_device

clang/lib/Basic/Targets/X86.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ static const unsigned X86AddrSpaceMap[] = {
2929
0, // opencl_constant
3030
0, // opencl_private
3131
0, // opencl_generic
32+
0, // opencl_global_device
33+
0, // opencl_global_host
3234
0, // cuda_device
3335
0, // cuda_constant
3436
0, // cuda_shared

0 commit comments

Comments
 (0)