Skip to content

Commit b524502

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 7fa4ab4 + 6c41afe commit b524502

File tree

20 files changed

+584
-30
lines changed

20 files changed

+584
-30
lines changed

.github/workflows/gh_pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
repository: intel/llvm-docs
1818
path: docs
1919
- name: Install deps
20-
run: sudo apt-get install -y doxygen graphviz ssh
20+
run: sudo apt-get install -y doxygen graphviz ssh ninja-build
2121
- name: Build Docs
2222
run: |
2323
mkdir -p $GITHUB_WORKSPACE/build

clang/include/clang/Basic/Attr.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,15 @@ def SYCLFPGAPipe : TypeAttr {
18231823
let Documentation = [SYCLFPGAPipeDocs];
18241824
}
18251825

1826+
def SYCLIntelPipeIO : Attr {
1827+
let Spellings = [GNU<"io_pipe_id">];
1828+
let Args = [ExprArgument<"ID">];
1829+
let LangOpts = [SYCLIsDevice, SYCLIsHost];
1830+
let Subjects = SubjectList<[Var]>;
1831+
let Documentation = [SYCLIntelPipeIOAttrDocs];
1832+
let PragmaAttributeSupport = 0;
1833+
}
1834+
18261835
// Variadic integral arguments.
18271836
def IntelFPGABankBits : Attr {
18281837
let Spellings = [CXX11<"intelfpga", "bank_bits">];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,20 @@ write only. Expected to be used only in SYCL headers.
20332033
}];
20342034
}
20352035

2036+
def SYCLIntelPipeIOAttrDocs : Documentation {
2037+
let Category = DocCatVariable;
2038+
let Heading = "IO pipe ID";
2039+
let Content = [{
2040+
Add I/O attribute to SYCL pipe declaration to declare a special I/O pipe to
2041+
interface with input or output features of an FPGA. These features might include
2042+
network interfaces, PCIe, cameras, or other data capture or processing devices
2043+
or protocols.
2044+
2045+
The io_pipe_id(id) attribute specifies the I/O feature of an accelerator board
2046+
with which a pipe interfaces. The id argument is the name of the I/O interface.
2047+
}];
2048+
}
2049+
20362050
def SYCLIntelFPGAIVDepAttrDocs : Documentation {
20372051
let Category = DocCatVariable;
20382052
let Heading = "ivdep";

clang/include/clang/Sema/Sema.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9710,6 +9710,10 @@ class Sema final {
97109710
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI,
97119711
Expr *Min, Expr *Max);
97129712

9713+
/// addSYCLIntelPipeIOAttr - Adds a pipe I/O attribute to a particular
9714+
/// declaration.
9715+
void addSYCLIntelPipeIOAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ID);
9716+
97139717
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
97149718

97159719
//===--------------------------------------------------------------------===//

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,32 @@ bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor) {
34703470
return true;
34713471
}
34723472

3473+
static void maybeEmitPipeStorageMetadata(const VarDecl *D,
3474+
llvm::GlobalVariable *GV,
3475+
CodeGenModule &CGM) {
3476+
// TODO: Applicable only on pipe storages. Currently they are defined
3477+
// as structures inside of SYCL headers. Add a check for pipe_storage_t
3478+
// when it ready.
3479+
QualType PipeTy = D->getType();
3480+
if (!PipeTy->isStructureType())
3481+
return;
3482+
3483+
if (auto *IOAttr = D->getAttr<SYCLIntelPipeIOAttr>()) {
3484+
llvm::APSInt ID(32);
3485+
llvm::LLVMContext &Context = CGM.getLLVMContext();
3486+
bool IsValid =
3487+
IOAttr->getID()->isIntegerConstantExpr(ID, D->getASTContext());
3488+
assert(IsValid && "Not an integer constant expression");
3489+
(void)IsValid;
3490+
3491+
llvm::Metadata *AttrMDArgs[] = {
3492+
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
3493+
llvm::Type::getInt32Ty(Context), ID.getSExtValue()))};
3494+
GV->setMetadata(IOAttr->getSpelling(),
3495+
llvm::MDNode::get(Context, AttrMDArgs));
3496+
}
3497+
}
3498+
34733499
/// GetOrCreateLLVMGlobal - If the specified mangled name is not in the module,
34743500
/// create and return an llvm GlobalVariable with the specified type. If there
34753501
/// is something in the module with the specified name, return it potentially
@@ -3659,6 +3685,10 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
36593685
: (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
36603686
assert(getContext().getTargetAddressSpace(ExpectedAS) ==
36613687
Ty->getPointerAddressSpace());
3688+
3689+
if (LangOpts.SYCLIsDevice)
3690+
maybeEmitPipeStorageMetadata(D, GV, *this);
3691+
36623692
if (AddrSpace != ExpectedAS)
36633693
return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace,
36643694
ExpectedAS, Ty);
@@ -4310,6 +4340,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
43104340
if (CGDebugInfo *DI = getModuleDebugInfo())
43114341
if (getCodeGenOpts().hasReducedDebugInfo())
43124342
DI->EmitGlobalVariable(GV, D);
4343+
4344+
if (LangOpts.SYCLIsDevice)
4345+
maybeEmitPipeStorageMetadata(D, GV, *this);
43134346
}
43144347

43154348
void CodeGenModule::EmitExternalVarDeclaration(const VarDecl *D) {

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5516,6 +5516,47 @@ static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D,
55165516
PatchableFunctionEntryAttr(S.Context, AL, Count, Offset));
55175517
}
55185518

5519+
void Sema::addSYCLIntelPipeIOAttr(Decl *D, const AttributeCommonInfo &Attr,
5520+
Expr *E) {
5521+
VarDecl *VD = cast<VarDecl>(D);
5522+
QualType Ty = VD->getType();
5523+
// TODO: Applicable only on pipe storages. Currently they are defined
5524+
// as structures inside of SYCL headers. Add a check for pipe_storage_t
5525+
// when it is ready.
5526+
if (!Ty->isStructureType()) {
5527+
Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
5528+
<< Attr.getAttrName() << "SYCL pipe storage declaration";
5529+
return;
5530+
}
5531+
5532+
if (!E->isInstantiationDependent()) {
5533+
llvm::APSInt ArgVal(32);
5534+
if (!E->isIntegerConstantExpr(ArgVal, getASTContext())) {
5535+
Diag(E->getExprLoc(), diag::err_attribute_argument_type)
5536+
<< Attr.getAttrName() << AANT_ArgumentIntegerConstant
5537+
<< E->getSourceRange();
5538+
return;
5539+
}
5540+
int32_t ArgInt = ArgVal.getSExtValue();
5541+
if (ArgInt < 0) {
5542+
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
5543+
<< Attr.getAttrName() << /*non-negative*/ 1;
5544+
return;
5545+
}
5546+
}
5547+
5548+
D->addAttr(::new (Context) SYCLIntelPipeIOAttr(Context, Attr, E));
5549+
}
5550+
5551+
static void handleSYCLIntelPipeIOAttr(Sema &S, Decl *D,
5552+
const ParsedAttr &Attr) {
5553+
if (D->isInvalidDecl())
5554+
return;
5555+
5556+
Expr *E = Attr.getArgAsExpr(0);
5557+
S.addSYCLIntelPipeIOAttr(D, Attr, E);
5558+
}
5559+
55195560
static bool ArmMveAliasValid(unsigned BuiltinID, StringRef AliasName) {
55205561
if (AliasName.startswith("__arm_"))
55215562
AliasName = AliasName.substr(6);
@@ -8040,6 +8081,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
80408081
case ParsedAttr::AT_IntelFPGABankBits:
80418082
handleIntelFPGABankBitsAttr(S, D, AL);
80428083
break;
8084+
case ParsedAttr::AT_SYCLIntelPipeIO:
8085+
handleSYCLIntelPipeIOAttr(S, D, AL);
8086+
break;
80438087

80448088
case ParsedAttr::AT_AnyX86NoCallerSavedRegisters:
80458089
handleSimpleAttribute<AnyX86NoCallerSavedRegistersAttr>(S, D, AL);

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,17 @@ static void instantiateIntelFPGABankBitsAttr(
553553
S.AddIntelFPGABankBitsAttr(New, *Attr, Args.data(), Args.size());
554554
}
555555

556+
static void instantiateSYCLIntelPipeIOAttr(
557+
Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
558+
const SYCLIntelPipeIOAttr *Attr, Decl *New) {
559+
// The ID expression is a constant expression.
560+
EnterExpressionEvaluationContext Unevaluated(
561+
S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
562+
ExprResult Result = S.SubstExpr(Attr->getID(), TemplateArgs);
563+
if (!Result.isInvalid())
564+
S.addSYCLIntelPipeIOAttr(New, *Attr, Result.getAs<Expr>());
565+
}
566+
556567
void Sema::InstantiateAttrsForDecl(
557568
const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Tmpl,
558569
Decl *New, LateInstantiatedAttrVec *LateAttrs,
@@ -686,6 +697,10 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
686697
instantiateIntelFPGABankBitsAttr(*this, TemplateArgs, IntelFPGABankBits,
687698
New);
688699
}
700+
if (const auto *SYCLIntelPipeIO = dyn_cast<SYCLIntelPipeIOAttr>(TmplAttr)) {
701+
instantiateSYCLIntelPipeIOAttr(*this, TemplateArgs, SYCLIntelPipeIO, New);
702+
continue;
703+
}
689704

690705
// Existing DLL attribute on the instantiation takes precedence.
691706
if (TmplAttr->getKind() == attr::DLLExport ||

clang/test/CodeGenSYCL/fpga_pipes.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@ RPipeTy RPipeCreator();
1111
template <typename PipeTy>
1212
void foo(PipeTy Pipe) {}
1313

14+
struct PipeStorageTy {
15+
int Size;
16+
};
17+
18+
// CHECK: @{{.*}}Storage = {{.*}} !io_pipe_id ![[ID0:[0-9]+]]
19+
constexpr PipeStorageTy
20+
Storage __attribute__((io_pipe_id(1))) = {1};
21+
22+
// CHECK: @{{.*}}TempStorage{{.*}} = {{.*}} !io_pipe_id ![[ID1:[0-9]+]]
23+
template <int N>
24+
constexpr PipeStorageTy
25+
TempStorage __attribute__((io_pipe_id(N))) = {2};
26+
27+
void boo(PipeStorageTy PipeStorage);
28+
29+
template <int ID>
30+
struct ethernet_pipe {
31+
static constexpr int id = ID;
32+
};
33+
34+
// CHECK: @{{.*}}PipeStorage{{.*}} = {{.*}} !io_pipe_id ![[ID2:[0-9]+]]
35+
template <typename name>
36+
class pipe {
37+
public:
38+
static void read() {
39+
boo(PipeStorage);
40+
}
41+
42+
private:
43+
static constexpr PipeStorageTy
44+
PipeStorage __attribute__((io_pipe_id(name::id))) = {3};
45+
};
46+
1447
template <typename name, typename Func>
1548
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
1649
kernelFunc();
@@ -24,7 +57,12 @@ int main() {
2457
RPipeTy rpipe = RPipeCreator();
2558
foo<WPipeTy>(wpipe);
2659
foo<RPipeTy>(rpipe);
60+
boo(Storage);
61+
boo(TempStorage<2>);
62+
pipe<ethernet_pipe<42>>::read();
2763
});
2864
return 0;
2965
}
30-
66+
// CHECK: ![[ID0]] = !{i32 1}
67+
// CHECK: ![[ID1]] = !{i32 2}
68+
// CHECK: ![[ID2]] = !{i32 42}

clang/test/SemaSYCL/fpga_pipes.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,35 @@ using type4 = __attribute__((pipe(0))) const int;
1414

1515
// expected-error@+1{{'pipe' attribute takes one argument}}
1616
using type5 = __attribute__((pipe)) const int;
17+
18+
struct pipe_storage {};
19+
20+
// no error expected
21+
const pipe_storage Storage1 __attribute__((io_pipe_id(1)));
22+
23+
// expected-error@+1{{'io_pipe_id' attribute requires a non-negative integral compile time constant expression}}
24+
const pipe_storage Storage2 __attribute__((io_pipe_id(-11)));
25+
26+
// expected-error@+1{{'io_pipe_id' attribute requires an integer constant}}
27+
const pipe_storage Storage3 __attribute__((io_pipe_id("abc")));
28+
29+
// expected-error@+1{{'io_pipe_id' attribute only applies to SYCL pipe storage declaration}}
30+
int Storage4 __attribute__((io_pipe_id(5)));
31+
32+
// expected-error@+2{{'io_pipe_id' attribute requires a non-negative integral compile time constant expression}}
33+
template <int N>
34+
pipe_storage Storage5 __attribute__((io_pipe_id(N)));
35+
36+
template <typename name, typename Func>
37+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
38+
kernelFunc();
39+
}
40+
41+
void foo(pipe_storage PS) {}
42+
43+
int main() {
44+
// no error expected
45+
foo(Storage5<2>);
46+
// expected-note@+1{{in instantiation of variable template specialization 'Storage5' requested here}}
47+
foo(Storage5<-1>);
48+
}

sycl/doc/doxygen.cfg.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ SHORT_NAMES = NO
187187
# description.)
188188
# The default value is: NO.
189189

190-
JAVADOC_AUTOBRIEF = NO
190+
JAVADOC_AUTOBRIEF = YES
191191

192192
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
193193
# line (until the first dot) of a Qt-style comment as the brief description. If
194194
# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
195195
# requiring an explicit \brief command for a brief description.)
196196
# The default value is: NO.
197197

198-
QT_AUTOBRIEF = NO
198+
QT_AUTOBRIEF = YES
199199

200200
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
201201
# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
@@ -2061,15 +2061,15 @@ ENABLE_PREPROCESSING = YES
20612061
# The default value is: NO.
20622062
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
20632063

2064-
MACRO_EXPANSION = NO
2064+
MACRO_EXPANSION = YES
20652065

20662066
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
20672067
# the macro expansion is limited to the macros specified with the PREDEFINED and
20682068
# EXPAND_AS_DEFINED tags.
20692069
# The default value is: NO.
20702070
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
20712071

2072-
EXPAND_ONLY_PREDEF = NO
2072+
EXPAND_ONLY_PREDEF = YES
20732073

20742074
# If the SEARCH_INCLUDES tag is set to YES, the include files in the
20752075
# INCLUDE_PATH will be searched if a #include is found.
@@ -2101,7 +2101,7 @@ INCLUDE_FILE_PATTERNS =
21012101
# recursively expanded use the := operator instead of the = operator.
21022102
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
21032103

2104-
PREDEFINED =
2104+
PREDEFINED = "__SYCL_INLINE_NAMESPACE(X)=namespace X"
21052105

21062106
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
21072107
# tag can be used to specify a list of macro names that should be expanded. The
@@ -2390,7 +2390,7 @@ DOT_IMAGE_FORMAT = @DOT_IMAGE_FORMAT@
23902390
# The default value is: NO.
23912391
# This tag requires that the tag HAVE_DOT is set to YES.
23922392

2393-
INTERACTIVE_SVG = NO
2393+
INTERACTIVE_SVG = YES
23942394

23952395
# The DOT_PATH tag can be used to specify the path where the dot tool can be
23962396
# found. If left blank, it is assumed the dot tool can be found in the path.

0 commit comments

Comments
 (0)