@@ -556,10 +556,15 @@ bool SYCLGenBase::emitVectorType(const InlineAsmVectorType *T) {
556556 return SYCLGenError ();
557557 OS () << " , " ;
558558 switch (T->getKind ()) {
559+ case InlineAsmVectorType::x1:
560+ OS () << 1 ;
561+ break ;
559562 case InlineAsmVectorType::v2:
563+ case InlineAsmVectorType::x2:
560564 OS () << 2 ;
561565 break ;
562566 case InlineAsmVectorType::v4:
567+ case InlineAsmVectorType::x4:
563568 OS () << 4 ;
564569 break ;
565570 case InlineAsmVectorType::v8:
@@ -589,9 +594,9 @@ bool SYCLGenBase::emitVariableDeclaration(const InlineAsmVarDecl *D) {
589594
590595bool SYCLGenBase::emitAddressExpr (const InlineAsmAddressExpr *Dst) {
591596 // Address expression only support ld/st/red & atom instructions.
592- if (!CurrInst ||
593- !CurrInst-> is (asmtok::op_st, asmtok::op_ld , asmtok::op_atom ,
594- asmtok::op_prefetch, asmtok::op_red , asmtok::op_cp )) {
597+ if (!CurrInst || !CurrInst-> is (asmtok::op_st, asmtok::op_ld, asmtok::op_atom,
598+ asmtok::op_prefetch , asmtok::op_red ,
599+ asmtok::op_cp , asmtok::op_ldmatrix )) {
595600 return SYCLGenError ();
596601 }
597602 std::string Type;
@@ -624,6 +629,8 @@ bool SYCLGenBase::emitAddressExpr(const InlineAsmAddressExpr *Dst) {
624629 if (CurrInst->is (asmtok::op_prefetch, asmtok::op_red) ||
625630 CanSuppressCast (Dst->getSymbol ()))
626631 OS () << llvm::formatv (" {0}" , Reg);
632+ else if (CurrInst->is (asmtok::op_ldmatrix))
633+ OS () << llvm::formatv (" (uintptr_t){0}" , Reg);
627634 else
628635 OS () << llvm::formatv (" (({0} *)(uintptr_t){1})" , Type, Reg);
629636 break ;
@@ -1305,6 +1312,64 @@ class SYCLGen : public SYCLGenBase {
13051312 return SYCLGenSuccess ();
13061313 }
13071314
1315+ bool handle_ldmatrix (const InlineAsmInstruction *Inst) override {
1316+ if (Inst->getNumInputOperands () != 1 )
1317+ return SYCLGenError ();
1318+
1319+ const auto *Type = dyn_cast<InlineAsmBuiltinType>(Inst->getType (0 ));
1320+
1321+ if (!Type || Type->getKind () != InlineAsmBuiltinType::b16)
1322+ return SYCLGenError ();
1323+
1324+ const InlineAsmVectorExpr *VE ;
1325+ if (VE = dyn_cast<InlineAsmVectorExpr>(Inst->getOutputOperand ())) {
1326+ auto numOutputOperands = VE ->getNumElements ();
1327+ if (Inst->hasAttr (InstAttr::x1)) {
1328+ if (numOutputOperands != 1 )
1329+ return SYCLGenError ();
1330+ } else if (Inst->hasAttr (InstAttr::x2)) {
1331+ if (numOutputOperands != 2 )
1332+ return SYCLGenError ();
1333+ } else if (Inst->hasAttr (InstAttr::x4)) {
1334+ if (numOutputOperands != 4 )
1335+ return SYCLGenError ();
1336+ }
1337+ } else {
1338+ return SYCLGenError ();
1339+ }
1340+
1341+ llvm::SaveAndRestore<const InlineAsmInstruction *> Store (CurrInst);
1342+ CurrInst = Inst;
1343+ const auto *Src =
1344+ dyn_cast_or_null<InlineAsmAddressExpr>(Inst->getInputOperand (0 ));
1345+ if (!Src)
1346+ return false ;
1347+
1348+ OS () << MapNames::getDpctNamespace () << " experimental::matrix::ldmatrix(" ;
1349+ if (emitStmt (Src)) {
1350+ return SYCLGenError ();
1351+ }
1352+ for (unsigned Inst = 0 ; Inst != VE ->getNumElements (); ++Inst) {
1353+ if (isa<InlineAsmDiscardExpr>(VE ->getElement (Inst)))
1354+ continue ;
1355+ OS () << " , &" ;
1356+ if (emitStmt (VE ->getElement (Inst)))
1357+ return SYCLGenError ();
1358+ }
1359+ if (Inst->hasAttr (InstAttr::trans))
1360+ OS () << " , true" ;
1361+ OS () << " );" ;
1362+ const auto *KernelDecl = getImmediateOuterFuncDecl (GAS );
1363+ if (KernelDecl) {
1364+ auto FuncInfo = DeviceFunctionDecl::LinkRedecls (KernelDecl);
1365+ if (FuncInfo)
1366+ FuncInfo->addSubGroupSizeRequest (32 , GAS ->getBeginLoc (),
1367+ DpctGlobalInfo::getSubGroup (GAS ));
1368+ }
1369+
1370+ return SYCLGenSuccess ();
1371+ }
1372+
13081373 bool handle_prefetch (const InlineAsmInstruction *Inst) override {
13091374 if (!DpctGlobalInfo::useExtPrefetch () || Inst->getNumInputOperands () != 1 )
13101375 return SYCLGenError ();
@@ -2881,6 +2946,7 @@ class SYCLGen : public SYCLGenBase {
28812946 bool handle_ld (const InlineAsmInstruction *Inst) override {
28822947 if (Inst->getNumInputOperands () != 1 )
28832948 return SYCLGenError ();
2949+
28842950 llvm::SaveAndRestore<const InlineAsmInstruction *> Store (CurrInst);
28852951 CurrInst = Inst;
28862952 const auto *Src =
0 commit comments