Skip to content

Commit fc7a1c3

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (intel#13)
2 parents 061ef02 + f9cbf2a commit fc7a1c3

29 files changed

+389
-56
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,13 @@ def IntelFPGASimpleDualPort : Attr {
17351735
let Documentation = [IntelFPGASimpleDualPortAttrDocs];
17361736
}
17371737

1738+
def SYCLFPGAPipe : TypeAttr {
1739+
let Spellings = [GNU<"pipe">];
1740+
let Args = [StringArgument<"Mode">];
1741+
let LangOpts = [SYCLIsDevice];
1742+
let Documentation = [SYCLFPGAPipeDocs];
1743+
}
1744+
17381745
def Naked : InheritableAttr {
17391746
let Spellings = [GCC<"naked">, Declspec<"naked">];
17401747
let Subjects = SubjectList<[Function]>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,16 @@ function, and no effect otherwise.
18851885
}];
18861886
}
18871887

1888+
def SYCLFPGAPipeDocs : Documentation {
1889+
let Category = DocCatStmt;
1890+
let Heading = "pipe (read_only, write_only)";
1891+
let Content = [{
1892+
This attribute applies to a type to indicate that it is a pipe type.
1893+
It requires a string argument that specifies if the pipe is read only or
1894+
write only. Expected to be used only in SYCL headers.
1895+
}];
1896+
}
1897+
18881898
def SYCLIntelFPGAIVDepAttrDocs : Documentation {
18891899
let Category = DocCatVariable;
18901900
let Heading = "ivdep";

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def err_sycl_loop_attr_duplication : Error<
137137
"duplicate %select{unroll|Intel FPGA}0 loop attribute '%1'">;
138138
def err_loop_unroll_compatibility : Error<
139139
"incompatible loop unroll instructions: '%0' and '%1'">;
140+
def err_pipe_attribute_arg_not_allowed : Error<
141+
"'%0' mode for pipe attribute is not supported. Allowed modes: 'read_only', 'write_only'">;
140142

141143
// C99 variable-length arrays
142144
def ext_vla : Extension<"variable length arrays are a C99 feature">,

clang/include/clang/Basic/TokenKinds.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ KEYWORD(vec_step , KEYOPENCLC | KEYALTIVEC | KEYZVECTOR)
578578
KEYWORD(__builtin_omp_required_simd_align, KEYALL)
579579

580580
KEYWORD(pipe , KEYOPENCLC | KEYOPENCLCXX)
581-
KEYWORD(__pipe , KEYSYCL)
582581

583582
// Borland Extensions.
584583
KEYWORD(__pascal , KEYALL)

clang/lib/AST/TypePrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,10 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
15091509
// AttributedType nodes for them.
15101510
break;
15111511

1512+
case attr::SYCLFPGAPipe:
1513+
OS << "pipe";
1514+
break;
1515+
15121516
case attr::LifetimeBound:
15131517
case attr::TypeNonNull:
15141518
case attr::TypeNullable:

clang/lib/Driver/Driver.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,6 +3299,11 @@ class OffloadingActionBuilder final {
32993299
if (auto *IA = dyn_cast<InputAction>(HostAction)) {
33003300
SYCLDeviceActions.clear();
33013301

3302+
// Options that are considered LinkerInput are not valid input actions
3303+
// to the device tool chain.
3304+
if (IA->getInputArg().getOption().hasFlag(options::LinkerInput))
3305+
return ABRT_Inactive;
3306+
33023307
std::string InputName = IA->getInputArg().getAsString(Args);
33033308
// Objects should already be consumed with -foffload-static-lib
33043309
if (Args.hasArg(options::OPT_foffload_static_lib_EQ) &&
@@ -3319,6 +3324,11 @@ class OffloadingActionBuilder final {
33193324
if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction)) {
33203325
SYCLDeviceActions.clear();
33213326
if (auto *IA = dyn_cast<InputAction>(UA->getInputs().back())) {
3327+
// Options that are considered LinkerInput are not valid input actions
3328+
// to the device tool chain.
3329+
if (IA->getInputArg().getOption().hasFlag(options::LinkerInput))
3330+
return ABRT_Inactive;
3331+
33223332
std::string FileName = IA->getInputArg().getAsString(Args);
33233333
// Check if the type of the file is the same as the action. Do not
33243334
// unbundle it if it is not. Do not unbundle .so files, for example,
@@ -3772,6 +3782,7 @@ class OffloadingActionBuilder final {
37723782
// the input is not a bundle.
37733783
if (CanUseBundler && isa<InputAction>(HostAction) &&
37743784
InputArg->getOption().getKind() == llvm::opt::Option::InputClass &&
3785+
!InputArg->getOption().hasFlag(options::LinkerInput) &&
37753786
!types::isSrcFile(HostAction->getType())) {
37763787
std::string InputName = InputArg->getAsString(Args);
37773788
// Do not create an unbundling action for an object when we know a fat

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5649,12 +5649,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
56495649
// Host-side SYCL compilation receives the integration header file as
56505650
// Inputs[1]. Include the header with -include
56515651
if (!IsSYCLOffloadDevice && SYCLDeviceInput) {
5652+
SmallString<128> RealPath;
5653+
// Fixup the header path name in case there are discrepancies in the
5654+
// string used for the temporary directory environment variable and
5655+
// actual path expectations.
5656+
llvm::sys::fs::real_path(SYCLDeviceInput->getFilename(), RealPath);
56525657
CmdArgs.push_back("-include");
5653-
CmdArgs.push_back(SYCLDeviceInput->getFilename());
5658+
CmdArgs.push_back(Args.MakeArgString(RealPath));
56545659
// When creating dependency information, filter out the generated
56555660
// header file.
56565661
CmdArgs.push_back("-dependency-filter");
5657-
CmdArgs.push_back(SYCLDeviceInput->getFilename());
5662+
CmdArgs.push_back(Args.MakeArgString(RealPath));
56585663
// Let the FE know we are doing a SYCL offload compilation, but we are
56595664
// doing the host pass.
56605665
CmdArgs.push_back("-fsycl-is-host");

clang/lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,11 +3830,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
38303830
}
38313831
isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);
38323832
break;
3833-
case tok::kw___pipe:
3834-
if (getLangOpts().SYCLIsDevice)
3835-
// __pipe keyword is defined only for SYCL kernel language
3836-
isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);
3837-
break;
38383833
#define GENERIC_IMAGE_TYPE(ImgType, Id) \
38393834
case tok::kw_##ImgType##_t: \
38403835
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, \
@@ -4967,9 +4962,8 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
49674962
default: return false;
49684963

49694964
case tok::kw_pipe:
4970-
case tok::kw___pipe:
49714965
return (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) ||
4972-
getLangOpts().OpenCLCPlusPlus || getLangOpts().SYCLIsDevice;
4966+
getLangOpts().OpenCLCPlusPlus;
49734967

49744968
case tok::identifier: // foo::bar
49754969
// Unfortunate hack to support "Class.factoryMethod" notation.
@@ -5463,9 +5457,8 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang,
54635457
if (Kind == tok::star || Kind == tok::caret)
54645458
return true;
54655459

5466-
if ((Kind == tok::kw_pipe || Kind == tok::kw___pipe) &&
5467-
((Lang.OpenCL && Lang.OpenCLVersion >= 200) || Lang.OpenCLCPlusPlus ||
5468-
Lang.SYCLIsDevice))
5460+
if ((Kind == tok::kw_pipe) &&
5461+
((Lang.OpenCL && Lang.OpenCLVersion >= 200) || Lang.OpenCLCPlusPlus))
54695462
return true;
54705463

54715464
if (!Lang.CPlusPlus)

clang/lib/Parse/ParseTentative.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,6 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
14671467
case tok::kw___read_write:
14681468
// OpenCL pipe
14691469
case tok::kw_pipe:
1470-
// SYCL pipe
1471-
case tok::kw___pipe:
14721470

14731471
// GNU
14741472
case tok::kw_restrict:

clang/lib/Sema/SemaType.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6103,6 +6103,66 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type,
61036103
}
61046104
}
61056105

6106+
static void HandleSYCLFPGAPipeAttribute(QualType &Type, const ParsedAttr &Attr,
6107+
TypeProcessingState &State) {
6108+
Sema &S = State.getSema();
6109+
ASTContext &Ctx = S.Context;
6110+
6111+
// Check the attribute arguments.
6112+
if (Attr.getNumArgs() != 1) {
6113+
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
6114+
<< Attr << 1;
6115+
Attr.setInvalid();
6116+
return;
6117+
}
6118+
6119+
if (!Attr.isArgExpr(0)) {
6120+
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
6121+
<< Attr << AANT_ArgumentString;
6122+
Attr.setInvalid();
6123+
return;
6124+
}
6125+
6126+
StringRef Str;
6127+
if (auto *SL = dyn_cast<StringLiteral>(Attr.getArgAsExpr(0))) {
6128+
Str = SL->getString();
6129+
} else {
6130+
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
6131+
<< Attr << AANT_ArgumentString;
6132+
Attr.setInvalid();
6133+
return;
6134+
}
6135+
6136+
bool isReadOnlyPipe;
6137+
if (Str == "write_only")
6138+
isReadOnlyPipe = false;
6139+
else if (Str == "read_only")
6140+
isReadOnlyPipe = true;
6141+
else {
6142+
S.Diag(Attr.getLoc(), diag::err_pipe_attribute_arg_not_allowed) << Str;
6143+
Attr.setInvalid();
6144+
return;
6145+
}
6146+
6147+
auto *PipeAttr = ::new (Ctx) SYCLFPGAPipeAttr(Ctx, Attr, Str);
6148+
6149+
// Apply pipe qualifiers just to the equivalent type, as the expression is not
6150+
// value dependent (not templated).
6151+
QualType EquivType = isReadOnlyPipe
6152+
? S.BuildReadPipeType(Type, Attr.getLoc())
6153+
: S.BuildWritePipeType(Type, Attr.getLoc());
6154+
if (EquivType.isNull()) {
6155+
Attr.setInvalid();
6156+
return;
6157+
}
6158+
6159+
QualType T = State.getAttributedType(PipeAttr, Type, EquivType);
6160+
if (!T.isNull())
6161+
Type = T;
6162+
else
6163+
Attr.setInvalid();
6164+
}
6165+
61066166
/// handleObjCOwnershipTypeAttr - Process an objc_ownership
61076167
/// attribute on the specified type.
61086168
///
@@ -7670,6 +7730,10 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type,
76707730
HandleOpenCLAccessAttr(type, attr, state.getSema());
76717731
attr.setUsedAsTypeAttr();
76727732
break;
7733+
case ParsedAttr::AT_SYCLFPGAPipe:
7734+
HandleSYCLFPGAPipeAttribute(type, attr, state);
7735+
attr.setUsedAsTypeAttr();
7736+
break;
76737737
case ParsedAttr::AT_LifetimeBound:
76747738
if (TAL == TAL_DeclChunk)
76757739
HandleLifetimeBoundAttr(state, type, attr);

0 commit comments

Comments
 (0)