Skip to content

Commit d51b7b8

Browse files
Added test case for xn
1 parent b1655e2 commit d51b7b8

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
@@ -1316,6 +1316,23 @@ class SYCLGen : public SYCLGenBase {
13161316
if (Inst->getNumInputOperands() != 1)
13171317
return SYCLGenError();
13181318

1319+
const InlineAsmVectorExpr *VE;
1320+
if (VE = dyn_cast<InlineAsmVectorExpr>(Inst->getOutputOperand())) {
1321+
auto numOutputOperands = VE->getNumElements();
1322+
if (Inst->hasAttr(InstAttr::x1)) {
1323+
if (numOutputOperands != 1)
1324+
return SYCLGenError();
1325+
} else if (Inst->hasAttr(InstAttr::x2)) {
1326+
if (numOutputOperands != 2)
1327+
return SYCLGenError();
1328+
} else if (Inst->hasAttr(InstAttr::x4)) {
1329+
if (numOutputOperands != 4)
1330+
return SYCLGenError();
1331+
}
1332+
} else {
1333+
return SYCLGenError();
1334+
}
1335+
13191336
llvm::SaveAndRestore<const InlineAsmInstruction *> Store(CurrInst);
13201337
CurrInst = Inst;
13211338
const auto *Src =
@@ -1328,18 +1345,13 @@ class SYCLGen : public SYCLGenBase {
13281345
return SYCLGenError();
13291346
}
13301347
OS() << ", ";
1331-
if (const auto *VE =
1332-
dyn_cast<InlineAsmVectorExpr>(Inst->getOutputOperand())) {
1333-
for (unsigned Inst = 0; Inst != VE->getNumElements(); ++Inst) {
1334-
if (isa<InlineAsmDiscardExpr>(VE->getElement(Inst)))
1335-
continue;
1336-
OS() << "&";
1337-
if (emitStmt(VE->getElement(Inst)))
1338-
return SYCLGenError();
1339-
OS() << ", ";
1340-
}
1341-
} else {
1342-
return SYCLGenError();
1348+
for (unsigned Inst = 0; Inst != VE->getNumElements(); ++Inst) {
1349+
if (isa<InlineAsmDiscardExpr>(VE->getElement(Inst)))
1350+
continue;
1351+
OS() << "&";
1352+
if (emitStmt(VE->getElement(Inst)))
1353+
return SYCLGenError();
1354+
OS() << ", ";
13431355
}
13441356
OS() << DpctGlobalInfo::getItem(GAS);
13451357
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)