Skip to content

Commit

Permalink
Merge from 'sycl' to 'sycl-web'
Browse files Browse the repository at this point in the history
  • Loading branch information
iclsrc committed Jun 5, 2020
2 parents 02dd118 + 8fe2846 commit 72dc69e
Show file tree
Hide file tree
Showing 115 changed files with 12,077 additions and 358 deletions.
10 changes: 9 additions & 1 deletion clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,12 @@ class Qualifiers {
// Otherwise in OpenCLC v2.0 s6.5.5: every address space except
// for __constant can be used as __generic.
(A == LangAS::opencl_generic && B != LangAS::opencl_constant) ||
// We also define global_device and global_host address spaces,
// to distinguish global pointers allocated on host from pointers
// allocated on device, which are a subset of __global.
// FIXME: add a reference to spec when ready
(A == LangAS::opencl_global && (B == LangAS::opencl_global_device ||
B == LangAS::opencl_global_host)) ||
// Consider pointer size address spaces to be equivalent to default.
((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
(isPtrSizeAddressSpace(B) || B == LangAS::Default));
Expand All @@ -493,7 +499,9 @@ class Qualifiers {
(!hasAddressSpace() &&
(other.getAddressSpace() == LangAS::opencl_private ||
other.getAddressSpace() == LangAS::opencl_local ||
other.getAddressSpace() == LangAS::opencl_global));
other.getAddressSpace() == LangAS::opencl_global ||
other.getAddressSpace() == LangAS::opencl_global_device ||
other.getAddressSpace() == LangAS::opencl_global_host));
}

/// Determines if these qualifiers compatibly include another set.
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/AddressSpaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ enum class LangAS : unsigned {
opencl_constant,
opencl_private,
opencl_generic,
opencl_global_device,
opencl_global_host,

// CUDA specific address spaces.
cuda_device,
Expand Down
15 changes: 15 additions & 0 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def CUDA : LangOpt<"CUDA">;
def SYCLIsDevice : LangOpt<"SYCLIsDevice">;
def SYCL : LangOpt<"SYCLIsDevice">;
def SYCLIsHost : LangOpt<"SYCLIsHost">;
def SYCLExplicitSIMD : LangOpt<"SYCLExplicitSIMD">;
def HIP : LangOpt<"HIP">;
def COnly : LangOpt<"", "!LangOpts.CPlusPlus">;
def CPlusPlus : LangOpt<"CPlusPlus">;
Expand Down Expand Up @@ -1124,6 +1125,7 @@ def SYCLDevice : InheritableAttr {
let Subjects = SubjectList<[Function]>;
let LangOpts = [SYCLIsDevice];
let Documentation = [SYCLDeviceDocs];
let PragmaAttributeSupport = 0;
}

def SYCLKernel : InheritableAttr {
Expand Down Expand Up @@ -1159,6 +1161,7 @@ def SYCLDeviceIndirectlyCallable : InheritableAttr {
let Subjects = SubjectList<[Function]>;
let LangOpts = [SYCLIsDevice];
let Documentation = [SYCLDeviceIndirectlyCallableDocs];
let PragmaAttributeSupport = 0;
}

def SYCLIntelKernelArgsRestrict : InheritableAttr {
Expand All @@ -1167,6 +1170,7 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr {
let LangOpts = [ SYCLIsDevice, SYCLIsHost ];
let Documentation = [ SYCLIntelKernelArgsRestrictDocs ];
let SimpleHandler = 1;
let PragmaAttributeSupport = 0;
}

def SYCLIntelNumSimdWorkItems : InheritableAttr {
Expand Down Expand Up @@ -1265,6 +1269,7 @@ def IntelReqdSubGroupSize: InheritableAttr {
let Subjects = SubjectList<[Function, CXXMethod], ErrorDiag>;
let Documentation = [IntelReqdSubGroupSizeDocs];
let LangOpts = [OpenCL, SYCLIsDevice, SYCLIsHost];
let PragmaAttributeSupport = 0;
}

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

def OpenCLGlobalDeviceAddressSpace : TypeAttr {
let Spellings = [Clang<"opencl_global_device">];
let Documentation = [OpenCLGlobalAddressSpacesDocs];
}

def OpenCLGlobalHostAddressSpace : TypeAttr {
let Spellings = [Clang<"opencl_global_host">];
let Documentation = [OpenCLGlobalAddressSpacesDocs];
}

def OpenCLLocalAddressSpace : TypeAttr {
let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">];
let Documentation = [OpenCLAddressSpaceLocalDocs];
Expand Down
11 changes: 11 additions & 0 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,17 @@ scope) variables and static local variable as well.
}];
}

def OpenCLGlobalAddressSpacesDocs : Documentation {
let Category = DocOpenCLAddressSpaces;
let Heading = "[[clang::opencl_global_device]], [[clang::opencl_global_host]]";
let Content = [{
The (global_device) and (global_host) address space attributes specify that an
object is allocated in global memory on the device/host. It helps distinguishing
USM pointers that access device memory and accessors that access global memory
from those that access host memory.
}];
}

def OpenCLAddressSpaceLocalDocs : Documentation {
let Category = DocOpenCLAddressSpaces;
let Heading = "__local, local, [[clang::opencl_local]]";
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ LANGOPT(SYCLStdLayoutKernelParams, 1, 0, "Enable standard layout requirement for
LANGOPT(SYCLUnnamedLambda , 1, 0, "Allow unnamed lambda SYCL kernels")
LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used")
LANGOPT(DeclareSPIRVBuiltins, 1, 0, "Declare SPIR-V builtin functions")
LANGOPT(SYCLExplicitSIMD , 1, 0, "SYCL compilation with explicit SIMD extension")

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

Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,10 @@ def fno_sycl : Flag<["-"], "fno-sycl">, Group<sycl_Group>, Flags<[CoreOption]>,
HelpText<"Disable SYCL kernels compilation for device">;
def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>, Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 1.2.1, sycl-1.2.1">;
def fsycl_esimd : Flag<["-"], "fsycl-explicit-simd">, Group<sycl_Group>, Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
HelpText<"Enable SYCL explicit SIMD extension">;
def fno_sycl_esimd : Flag<["-"], "fno-sycl-explicit-simd">, Group<sycl_Group>,
HelpText<"Disable SYCL explicit SIMD extension">, Flags<[NoArgumentUnused, CoreOption]>;

include "CC1Options.td"

Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Sema/ParsedAttr.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ class ParsedAttr final
return LangAS::opencl_constant;
case ParsedAttr::AT_OpenCLGlobalAddressSpace:
return LangAS::opencl_global;
case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
return LangAS::opencl_global_device;
case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
return LangAS::opencl_global_host;
case ParsedAttr::AT_OpenCLLocalAddressSpace:
return LangAS::opencl_local;
case ParsedAttr::AT_OpenCLPrivateAddressSpace:
Expand Down
30 changes: 17 additions & 13 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,18 +919,20 @@ static const LangASMap *getAddressSpaceMap(const TargetInfo &T,
// The fake address space map must have a distinct entry for each
// language-specific address space.
static const unsigned FakeAddrSpaceMap[] = {
0, // Default
1, // opencl_global
3, // opencl_local
2, // opencl_constant
0, // opencl_private
4, // opencl_generic
5, // cuda_device
6, // cuda_constant
7, // cuda_shared
8, // ptr32_sptr
9, // ptr32_uptr
10 // ptr64
0, // Default
1, // opencl_global
3, // opencl_local
2, // opencl_constant
0, // opencl_private
4, // opencl_generic
11, // opencl_global_device
12, // opencl_global_host
5, // cuda_device
6, // cuda_constant
7, // cuda_shared
8, // ptr32_sptr
9, // ptr32_uptr
10 // ptr64
};
return &FakeAddrSpaceMap;
} else {
Expand Down Expand Up @@ -2067,7 +2069,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
Align = Target->getDoubleAlign();
break;
case BuiltinType::LongDouble:
if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
if (((getLangOpts().SYCL && getLangOpts().SYCLIsDevice) ||
(getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)) &&
AuxTarget != nullptr &&
(Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
Width = AuxTarget->getLongDoubleWidth();
Expand Down
41 changes: 32 additions & 9 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2387,16 +2387,39 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals, const DependentAddressSp
switch (AS) {
default: llvm_unreachable("Not a language specific address space");
// <OpenCL-addrspace> ::= "CL" [ "global" | "local" | "constant" |
// "private"| "generic" ]
case LangAS::opencl_global: ASString = "CLglobal"; break;
case LangAS::opencl_local: ASString = "CLlocal"; break;
case LangAS::opencl_constant: ASString = "CLconstant"; break;
case LangAS::opencl_private: ASString = "CLprivate"; break;
case LangAS::opencl_generic: ASString = "CLgeneric"; break;
// "private"| "generic" | "global_device" |
// "global_host" ]
case LangAS::opencl_global:
ASString = "CLglobal";
break;
case LangAS::opencl_global_device:
ASString = "CLDevice";
break;
case LangAS::opencl_global_host:
ASString = "CLHost";
break;
case LangAS::opencl_local:
ASString = "CLlocal";
break;
case LangAS::opencl_constant:
ASString = "CLconstant";
break;
case LangAS::opencl_private:
ASString = "CLprivate";
break;
case LangAS::opencl_generic:
ASString = "CLgeneric";
break;
// <CUDA-addrspace> ::= "CU" [ "device" | "constant" | "shared" ]
case LangAS::cuda_device: ASString = "CUdevice"; break;
case LangAS::cuda_constant: ASString = "CUconstant"; break;
case LangAS::cuda_shared: ASString = "CUshared"; break;
case LangAS::cuda_device:
ASString = "CUdevice";
break;
case LangAS::cuda_constant:
ASString = "CUconstant";
break;
case LangAS::cuda_shared:
ASString = "CUshared";
break;
// <ptrsize-addrspace> ::= [ "ptr32_sptr" | "ptr32_uptr" | "ptr64" ]
case LangAS::ptr32_sptr:
ASString = "ptr32_sptr";
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,12 @@ void MicrosoftCXXNameMangler::mangleAddressSpaceType(QualType T,
case LangAS::opencl_global:
Extra.mangleSourceName("_ASCLglobal");
break;
case LangAS::opencl_global_device:
Extra.mangleSourceName("_ASCLDevice");
break;
case LangAS::opencl_global_host:
Extra.mangleSourceName("_ASCLHost");
break;
case LangAS::opencl_local:
Extra.mangleSourceName("_ASCLlocal");
break;
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/AST/TypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,8 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,

case attr::OpenCLPrivateAddressSpace:
case attr::OpenCLGlobalAddressSpace:
case attr::OpenCLGlobalDeviceAddressSpace:
case attr::OpenCLGlobalHostAddressSpace:
case attr::OpenCLLocalAddressSpace:
case attr::OpenCLConstantAddressSpace:
case attr::OpenCLGenericAddressSpace:
Expand Down Expand Up @@ -1880,6 +1882,10 @@ std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
return "__constant";
case LangAS::opencl_generic:
return "__generic";
case LangAS::opencl_global_device:
return "__global_device";
case LangAS::opencl_global_host:
return "__global_host";
case LangAS::cuda_device:
return "__device__";
case LangAS::cuda_constant:
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Basic/Targets/AMDGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
Constant, // opencl_constant
Private, // opencl_private
Generic, // opencl_generic
Global, // opencl_global_device
Global, // opencl_global_host
Global, // cuda_device
Constant, // cuda_constant
Local, // cuda_shared
Expand All @@ -60,6 +62,8 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
Constant, // opencl_constant
Private, // opencl_private
Generic, // opencl_generic
Global, // opencl_global_device
Global, // opencl_global_host
Global, // cuda_device
Constant, // cuda_constant
Local, // cuda_shared
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Basic/Targets/NVPTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ static const unsigned NVPTXAddrSpaceMap[] = {
0, // opencl_private
// FIXME: generic has to be added to the target
0, // opencl_generic
1, // opencl_global_device
1, // opencl_global_host
1, // cuda_device
4, // cuda_constant
3, // cuda_shared
Expand Down
56 changes: 28 additions & 28 deletions clang/lib/Basic/Targets/SPIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,37 @@ namespace clang {
namespace targets {

static const unsigned SPIRAddrSpaceMap[] = {
0, // Default
1, // opencl_global
3, // opencl_local
2, // opencl_constant
0, // opencl_private
4, // opencl_generic
0, // cuda_device
0, // cuda_constant
0, // cuda_shared
0, // ptr32_sptr
0, // ptr32_uptr
0 // ptr64
0, // Default
1, // opencl_global
3, // opencl_local
2, // opencl_constant
0, // opencl_private
4, // opencl_generic
11, // opencl_global_device
12, // opencl_global_host
0, // cuda_device
0, // cuda_constant
0, // cuda_shared
0, // ptr32_sptr
0, // ptr32_uptr
0 // ptr64
};

static const unsigned SYCLAddrSpaceMap[] = {
4, // Default
1, // opencl_global
3, // opencl_local
2, // opencl_constant
0, // opencl_private
4, // opencl_generic
0, // cuda_device
0, // cuda_constant
0, // cuda_shared
0, // ptr32_sptr
0, // ptr32_uptr
0 // ptr64
4, // Default
1, // opencl_global
3, // opencl_local
2, // opencl_constant
0, // opencl_private
4, // opencl_generic
11, // opencl_global_device
12, // opencl_global_host
0, // cuda_device
0, // cuda_constant
0, // cuda_shared
0, // ptr32_sptr
0, // ptr32_uptr
0 // ptr64
};

class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
Expand Down Expand Up @@ -209,8 +213,6 @@ class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32SPIRTargetInfo
MicrosoftX86_32SPIRTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsX86_32SPIRTargetInfo(Triple, Opts) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
assert(DataLayout->getPointerSizeInBits() == 32);
}

Expand Down Expand Up @@ -261,8 +263,6 @@ class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64_SPIR64TargetInfo
MicrosoftX86_64_SPIR64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsX86_64_SPIR64TargetInfo(Triple, Opts) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
assert(DataLayout->getPointerSizeInBits() == 64);
}

Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Basic/Targets/TCE.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ static const unsigned TCEOpenCLAddrSpaceMap[] = {
4, // opencl_local
5, // opencl_constant
0, // opencl_private
1, // opencl_global_device
1, // opencl_global_host
// FIXME: generic has to be added to the target
0, // opencl_generic
0, // cuda_device
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Basic/Targets/X86.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ static const unsigned X86AddrSpaceMap[] = {
0, // opencl_constant
0, // opencl_private
0, // opencl_generic
0, // opencl_global_device
0, // opencl_global_host
0, // cuda_device
0, // cuda_constant
0, // cuda_shared
Expand Down
Loading

0 comments on commit 72dc69e

Please sign in to comment.