Skip to content

Commit de49c1d

Browse files
Added test case for xn
1 parent df3c1ee commit de49c1d

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

clang/lib/DPCT/RulesAsm/AsmMigration.cpp

Lines changed: 24 additions & 12 deletions
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/test/dpct/asm/ldmatrix.cu

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,21 @@ int main () {
9797
return 0;
9898
}
9999

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

0 commit comments

Comments
 (0)