Skip to content

Commit 909a832

Browse files
Added test case for xn
1 parent b8a936f commit 909a832

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

clang/lib/DPCT/RulesAsm/AsmMigration.cpp

+24-12
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,23 @@ class SYCLGen : public SYCLGenBase {
13121312
if (Inst->getNumInputOperands() != 1)
13131313
return SYCLGenError();
13141314

1315+
const InlineAsmVectorExpr *VE;
1316+
if (VE = dyn_cast<InlineAsmVectorExpr>(Inst->getOutputOperand())) {
1317+
auto numOutputOperands = VE->getNumElements();
1318+
if (Inst->hasAttr(InstAttr::x1)) {
1319+
if (numOutputOperands != 1)
1320+
return SYCLGenError();
1321+
} else if (Inst->hasAttr(InstAttr::x2)) {
1322+
if (numOutputOperands != 2)
1323+
return SYCLGenError();
1324+
} else if (Inst->hasAttr(InstAttr::x4)) {
1325+
if (numOutputOperands != 4)
1326+
return SYCLGenError();
1327+
}
1328+
} else {
1329+
return SYCLGenError();
1330+
}
1331+
13151332
llvm::SaveAndRestore<const InlineAsmInstruction *> Store(CurrInst);
13161333
CurrInst = Inst;
13171334
const auto *Src =
@@ -1324,18 +1341,13 @@ class SYCLGen : public SYCLGenBase {
13241341
return SYCLGenError();
13251342
}
13261343
OS() << ", ";
1327-
if (const auto *VE =
1328-
dyn_cast<InlineAsmVectorExpr>(Inst->getOutputOperand())) {
1329-
for (unsigned Inst = 0; Inst != VE->getNumElements(); ++Inst) {
1330-
if (isa<InlineAsmDiscardExpr>(VE->getElement(Inst)))
1331-
continue;
1332-
OS() << "&";
1333-
if (emitStmt(VE->getElement(Inst)))
1334-
return SYCLGenError();
1335-
OS() << ", ";
1336-
}
1337-
} else {
1338-
return SYCLGenError();
1344+
for (unsigned Inst = 0; Inst != VE->getNumElements(); ++Inst) {
1345+
if (isa<InlineAsmDiscardExpr>(VE->getElement(Inst)))
1346+
continue;
1347+
OS() << "&";
1348+
if (emitStmt(VE->getElement(Inst)))
1349+
return SYCLGenError();
1350+
OS() << ", ";
13391351
}
13401352
OS() << DpctGlobalInfo::getItem(GAS);
13411353
if (Inst->hasAttr(InstAttr::trans))

clang/lib/DPCT/RulesAsm/Parser/AsmNodes.h

-2
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ class InlineAsmInstruction : public InlineAsmStmt {
340340
/// therest are input operands.
341341
SmallVector<InlineAsmExpr *, 4> InputOps;
342342

343-
SmallVector<InlineAsmExpr *, 4> OutputOps;
344-
345343
public:
346344
InlineAsmInstruction(InlineAsmIdentifierInfo *Op,
347345
SmallVector<AsmStateSpace, 4> AsmStateSpaces,

clang/test/dpct/asm/ldmatrix.cu

+20-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2
33
// RUN: dpct --format-range=none -out-root %T/ldmatrix %s --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
44
// RUN: FileCheck %s --match-full-lines --input-file %T/ldmatrix/ldmatrix.dp.cpp
5-
// RUN: %if build_lit %{icpx -c -fsycl %T/ldmatrix/ldmatrix.dp.cpp -o %T/ldmatrix/ldmatrix.dp.o %}
5+
// RUN: %if build_lit %{icpx -c -DNO_BUILD_TEST -fsycl %T/ldmatrix/ldmatrix.dp.cpp -o %T/ldmatrix/ldmatrix.dp.o %}
66

77
// clang-format off
88
#include <cuda_runtime.h>
@@ -97,4 +97,23 @@ int main () {
9797
return 0;
9898
}
9999

100+
#ifndef NO_BUILD_TEST
101+
__device__ void test_xn(uint32_t addr, int *r) {
102+
// CHECK: DPCT1053:{{.*}}: Migration of device assembly code is not supported.
103+
asm volatile("ldmatrix.sync.aligned.m8n8.x1.shared.b16 {%0, %1}, [%2];\n"
104+
: "=r"(r[0]), "=r"(r[1])
105+
: "r"(addr));
106+
107+
// CHECK: DPCT1053:{{.*}}: Migration of device assembly code is not supported.
108+
asm volatile("ldmatrix.sync.aligned.m8n8.x2.shared.b16 {%0}, [%0];\n"
109+
:
110+
: "r"(addr));
111+
112+
// CHECK: DPCT1053:{{.*}}: Migration of device assembly code is not supported.
113+
asm volatile("ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%0, %1, %2}, [%3];\n"
114+
: "=r"(r[0]), "=r"(r[1]), "=r"(r[2])
115+
: "r"(addr));
116+
}
117+
#endif // NO_BUILD_TEST
118+
100119
// clang-format on

0 commit comments

Comments
 (0)