33
33
#include < cctype>
34
34
#include < cstring>
35
35
#include < unordered_map>
36
+ #include < iostream>
36
37
37
38
using namespace llvm ;
38
39
namespace id = itanium_demangle;
@@ -385,12 +386,7 @@ static const ESIMDIntrinDesc &getIntrinDesc(StringRef SrcSpelling) {
385
386
386
387
if (It == Table.end ()) {
387
388
Twine Msg (" unknown ESIMD intrinsic: " + SrcSpelling);
388
-
389
- llvm::errs () << Msg << " \n " ;
390
- // TODO warning message for now, to enable compiling tests with intrinsics
391
- // that are not implemented yet
392
- // llvm::report_fatal_error(Msg, false/*no crash diag*/);
393
- return InvalidDesc;
389
+ llvm::report_fatal_error (Msg, false /* no crash diag*/ );
394
390
}
395
391
return It->second ;
396
392
}
@@ -454,8 +450,8 @@ static const T *castNodeImpl(const id::Node *N, id::Node::Kind K) {
454
450
455
451
static APInt parseTemplateArg (id::FunctionEncoding *FE, unsigned int N,
456
452
Type *&Ty, LLVMContext &Ctx) {
457
- auto *Nm = castNode (FE->getName (), NameWithTemplateArgs);
458
- auto *ArgsN = castNode (Nm->TemplateArgs , TemplateArgs);
453
+ const auto *Nm = castNode (FE->getName (), NameWithTemplateArgs);
454
+ const auto *ArgsN = castNode (Nm->TemplateArgs , TemplateArgs);
459
455
id::NodeArray Args = ArgsN->getParams ();
460
456
assert (N < Args.size () && " too few template arguments" );
461
457
id::StringView Val;
@@ -652,7 +648,7 @@ static void translatePackMask(CallInst &CI) {
652
648
IRBuilder<> Builder (&CI);
653
649
llvm::Value *Trunc = Builder.CreateTrunc (
654
650
CI.getArgOperand (0 ),
655
- llvm::VectorType ::get (llvm::Type::getInt1Ty (Context), N));
651
+ llvm::FixedVectorType ::get (llvm::Type::getInt1Ty (Context), N));
656
652
llvm::Type *Ty = llvm::Type::getIntNTy (Context, N);
657
653
658
654
llvm::Value *BitCast = Builder.CreateBitCast (Trunc, Ty);
@@ -699,11 +695,11 @@ static void translateUnPackMask(CallInst &CI) {
699
695
}
700
696
assert (Arg0->getType ()->getPrimitiveSizeInBits () == N);
701
697
Arg0 = Builder.CreateBitCast (
702
- Arg0, llvm::VectorType ::get (llvm::Type::getInt1Ty (Context), N));
698
+ Arg0, llvm::FixedVectorType ::get (llvm::Type::getInt1Ty (Context), N));
703
699
704
700
// get N x i16
705
701
llvm::Value *TransCI = Builder.CreateZExt (
706
- Arg0, llvm::VectorType ::get (llvm::Type::getInt16Ty (Context), N));
702
+ Arg0, llvm::FixedVectorType ::get (llvm::Type::getInt16Ty (Context), N));
707
703
TransCI->takeName (&CI);
708
704
cast<llvm::Instruction>(TransCI)->setDebugLoc (CI.getDebugLoc ());
709
705
CI.replaceAllUsesWith (TransCI);
@@ -782,7 +778,7 @@ static Instruction *generateVectorGenXForSpirv(CallInst &CI, StringRef Suff,
782
778
LLVMContext &Ctx = CI.getModule ()->getContext ();
783
779
Type *I32Ty = Type::getInt32Ty (Ctx);
784
780
Function *NewFDecl = GenXIntrinsic::getGenXDeclaration (
785
- CI.getModule (), ID, {VectorType ::get (I32Ty, 3 )});
781
+ CI.getModule (), ID, {FixedVectorType ::get (I32Ty, 3 )});
786
782
Instruction *IntrI =
787
783
IntrinsicInst::Create (NewFDecl, {}, CI.getName () + " .esimd" , &CI);
788
784
int ExtractIndex = getIndexForSuffix (Suff);
@@ -825,8 +821,7 @@ translateSpirvIntrinsic(CallInst *CI, StringRef SpirvIntrName,
825
821
auto translateSpirvIntr = [&SpirvIntrName, &ESIMDToErases,
826
822
CI](StringRef SpvIName, auto TranslateFunc) {
827
823
if (SpirvIntrName.consume_front (SpvIName)) {
828
- Value *TranslatedV =
829
- TranslateFunc (*CI, SpirvIntrName.front ()));
824
+ Value *TranslatedV = TranslateFunc (*CI, SpirvIntrName);
830
825
CI->replaceAllUsesWith (TranslatedV);
831
826
ESIMDToErases.push_back (CI);
832
827
}
@@ -1025,8 +1020,7 @@ static void translateESIMDIntrinsicCall(CallInst &CI) {
1025
1020
using Demangler = id::ManglingParser<SimpleAllocator>;
1026
1021
Function *F = CI.getCalledFunction ();
1027
1022
StringRef MnglName = F->getName ();
1028
- const char *MnglNameCStr = MnglName.data ();
1029
- Demangler Parser (MnglName.begin (), MnglName.end ()));
1023
+ Demangler Parser (MnglName.begin (), MnglName.end ());
1030
1024
id::Node *AST = Parser.parse ();
1031
1025
1032
1026
if (!AST || !Parser.ForwardTemplateRefs .empty ()) {
@@ -1219,7 +1213,7 @@ PreservedAnalyses SYCLLowerESIMDPass::run(Function &F,
1219
1213
IRBuilder<> Builder (&I);
1220
1214
llvm::Value *Src = CastOp->getOperand (0 );
1221
1215
auto TmpTy =
1222
- llvm::VectorType ::get (llvm::Type::getInt32Ty (DstTy->getContext ()),
1216
+ llvm::FixedVectorType ::get (llvm::Type::getInt32Ty (DstTy->getContext ()),
1223
1217
cast<VectorType>(DstTy)->getNumElements ());
1224
1218
Src = Builder.CreateFPToSI (Src, TmpTy);
1225
1219
@@ -1241,22 +1235,22 @@ PreservedAnalyses SYCLLowerESIMDPass::run(Function &F,
1241
1235
if (!Name.consume_front (ESIMD_INTRIN_PREF0))
1242
1236
continue ;
1243
1237
// now skip the digits
1244
- StringRef Name1 = Name1 .drop_while ([](char C) { return std::isdigit (C); });
1238
+ Name = Name .drop_while ([](char C) { return std::isdigit (C); });
1245
1239
1246
1240
// process ESIMD builtins that go through special handling instead of
1247
1241
// the translation procedure
1248
- if (Name1 .startswith (" cl4sycl5intel3gpu8slm_init " )) {
1242
+ if (Name .startswith (" N2cl4sycl5intel3gpu8slm_init " )) {
1249
1243
// tag the kernel with meta-data SLMSize, and remove this builtin
1250
1244
translateSLMInit (*CI);
1251
1245
ESIMDToErases.push_back (CI);
1252
1246
continue ;
1253
1247
}
1254
- if (Name1 .startswith (" __esimd_pack_mask" )) {
1248
+ if (Name .startswith (" __esimd_pack_mask" )) {
1255
1249
translatePackMask (*CI);
1256
1250
ESIMDToErases.push_back (CI);
1257
1251
continue ;
1258
1252
}
1259
- if (Name1 .startswith (" __esimd_unpack_mask" )) {
1253
+ if (Name .startswith (" __esimd_unpack_mask" )) {
1260
1254
translateUnPackMask (*CI);
1261
1255
ESIMDToErases.push_back (CI);
1262
1256
continue ;
@@ -1265,32 +1259,32 @@ PreservedAnalyses SYCLLowerESIMDPass::run(Function &F,
1265
1259
// those globals marked as genx_volatile, We can translate
1266
1260
// them directly into generic load/store inst. In this way
1267
1261
// those insts can be optimized by llvm ASAP.
1268
- if (Name1 .startswith (" __esimd_vload" )) {
1262
+ if (Name .startswith (" __esimd_vload" )) {
1269
1263
if (translateVLoad (*CI, GVTS)) {
1270
1264
ESIMDToErases.push_back (CI);
1271
1265
continue ;
1272
1266
}
1273
1267
}
1274
- if (Name1 .startswith (" __esimd_vstore" )) {
1268
+ if (Name .startswith (" __esimd_vstore" )) {
1275
1269
if (translateVStore (*CI, GVTS)) {
1276
1270
ESIMDToErases.push_back (CI);
1277
1271
continue ;
1278
1272
}
1279
1273
}
1280
1274
1281
- if (Name1 .startswith (" __esimd_get_value" )) {
1275
+ if (Name .startswith (" __esimd_get_value" )) {
1282
1276
translateGetValue (*CI);
1283
1277
ESIMDToErases.push_back (CI);
1284
1278
continue ;
1285
1279
}
1286
1280
1287
- if (Name1 .consume_front (SPIRV_INTRIN_PREF)) {
1288
- translateSpirvIntrinsic (CI, Name1 , ESIMDToErases);
1281
+ if (Name .consume_front (SPIRV_INTRIN_PREF)) {
1282
+ translateSpirvIntrinsic (CI, Name , ESIMDToErases);
1289
1283
// For now: if no match, just let it go untranslated.
1290
1284
continue ;
1291
1285
}
1292
1286
1293
- if (Name1 .empty () || !Name1 .startswith (ESIMD_INTRIN_PREF1))
1287
+ if (Name .empty () || !Name .startswith (ESIMD_INTRIN_PREF1))
1294
1288
continue ;
1295
1289
// this is ESIMD intrinsic - record for later translation
1296
1290
ESIMDIntrCalls.push_back (CI);
0 commit comments