@@ -943,24 +943,27 @@ class SYCLGen : public SYCLGenBase {
943943 return SYCLGenError ();
944944 OS () << " = " ;
945945
946- std::string Op[3 ];
947- for (auto Idx : llvm::seq (0 , 3 )) {
946+ std::string Op[4 ];
947+ for (auto Idx : llvm::seq (0 , 4 )) {
948948 if (tryEmitStmt (Op[Idx], I->getInputOperand (Idx)))
949949 return SYCLGenError ();
950950 }
951951
952- if (!isa<InlineAsmIntegerLiteral>(I->getInputOperand (3 )))
953- return SYCLGenError ();
954- unsigned Imm = dyn_cast<InlineAsmIntegerLiteral>(I->getInputOperand (3 ))
955- ->getValue ()
956- .getZExtValue ();
952+ if (!isa<InlineAsmIntegerLiteral>(I->getInputOperand (3 ))) {
953+ OS () << MapNames::getDpctNamespace () << " ternary_logic_op(" << Op[0 ]
954+ << " , " << Op[1 ] << " , " << Op[2 ] << " , " << Op[3 ] << " )" ;
955+
956+ } else {
957+ unsigned Imm = dyn_cast<InlineAsmIntegerLiteral>(I->getInputOperand (3 ))
958+ ->getValue ()
959+ .getZExtValue ();
957960
958961#define EMPTY nullptr
959962#define EMPTY4 EMPTY, EMPTY, EMPTY, EMPTY
960963#define EMPTY16 EMPTY4, EMPTY4, EMPTY4, EMPTY4
961- constexpr const char *FastMap[256 ] = {
962- /* 0x00*/ " 0" ,
963- // clang-format off
964+ constexpr const char *FastMap[256 ] = {
965+ /* 0x00*/ " 0" ,
966+ // clang-format off
964967 EMPTY16, EMPTY4, EMPTY4, EMPTY,
965968 /* 0x1a*/ " ({0} & {1} | {2}) ^ {0}" ,
966969 EMPTY, EMPTY, EMPTY,
@@ -988,12 +991,12 @@ class SYCLGen : public SYCLGenBase {
988991 EMPTY16, EMPTY, EMPTY, EMPTY,
989992 /* 0xfe*/ " {0} | {1} | {2}" ,
990993 /* 0xff*/ " uint32_t(-1)" };
991- // clang-format on
994+ // clang-format on
992995
993996#undef EMPTY16
994997#undef EMPTY4
995998#undef EMPTY
996- // clang-format off
999+ // clang-format off
9971000 constexpr const char *SlowMap[8 ] = {
9981001 /* 0x01*/ " (~{0} & ~{1} & ~{2})" ,
9991002 /* 0x02*/ " (~{0} & ~{1} & {2})" ,
@@ -1004,20 +1007,21 @@ class SYCLGen : public SYCLGenBase {
10041007 /* 0x40*/ " ({0} & {1} & ~{2})" ,
10051008 /* 0x80*/ " ({0} & {1} & {2})"
10061009 };
1007- // clang-format on
1010+ // clang-format on
10081011
1009- if (FastMap[Imm]) {
1010- OS () << llvm::formatv (FastMap[Imm], Op[0 ], Op[1 ], Op[2 ]);
1011- } else {
1012- SmallVector<std::string, 8 > Templates;
1013- for (auto Bit : llvm::seq (0 , 8 )) {
1014- if (Imm & (1U << Bit)) {
1015- Templates.push_back (
1016- llvm::formatv (SlowMap[Bit], Op[0 ], Op[1 ], Op[2 ]).str ());
1012+ if (FastMap[Imm]) {
1013+ OS () << llvm::formatv (FastMap[Imm], Op[0 ], Op[1 ], Op[2 ]);
1014+ } else {
1015+ SmallVector<std::string, 8 > Templates;
1016+ for (auto Bit : llvm::seq (0 , 8 )) {
1017+ if (Imm & (1U << Bit)) {
1018+ Templates.push_back (
1019+ llvm::formatv (SlowMap[Bit], Op[0 ], Op[1 ], Op[2 ]).str ());
1020+ }
10171021 }
1018- }
10191022
1020- OS () << llvm::join (Templates, " | " );
1023+ OS () << llvm::join (Templates, " | " );
1024+ }
10211025 }
10221026
10231027 endstmt ();
0 commit comments