[PATCH] D66588: [ARM NEON] Avoid duplicated decarations
This revision was automatically updated to reflect the committed changes. Closed by commit rL370716: [ARM NEON] Avoid duplicated decarations (authored by dnsampaio, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D66588?vs=218412=218414#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66588/new/ https://reviews.llvm.org/D66588 Files: cfe/trunk/utils/TableGen/NeonEmitter.cpp Index: cfe/trunk/utils/TableGen/NeonEmitter.cpp === --- cfe/trunk/utils/TableGen/NeonEmitter.cpp +++ cfe/trunk/utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1578,7 +1589,10 @@ Intr.Dependencies.insert(); // Now create the call itself. - std::string S = CallPrefix.str() + Callee.getMangledName(true) + "("; + std::string S = ""; + if (!Callee.isBigEndianSafe()) +S += CallPrefix.str(); + S += Callee.getMangledName(true) + "("; for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) { if (I != 0) S += ", "; @@ -1889,6 +1903,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and little endian + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; Index: cfe/trunk/utils/TableGen/NeonEmitter.cpp === --- cfe/trunk/utils/TableGen/NeonEmitter.cpp +++ cfe/trunk/utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1578,7 +1589,10 @@ Intr.Dependencies.insert(); // Now create the call itself. - std::string S = CallPrefix.str() + Callee.getMangledName(true) + "("; + std::string S = ""; + if (!Callee.isBigEndianSafe()) +S += CallPrefix.str(); + S += Callee.getMangledName(true) + "("; for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) { if (I != 0) S += ", "; @@ -1889,6 +1903,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and little endian + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D66588: [ARM NEON] Avoid duplicated decarations
dnsampaio updated this revision to Diff 218412. dnsampaio added a comment. - Fix comment Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66588/new/ https://reviews.llvm.org/D66588 Files: clang/utils/TableGen/NeonEmitter.cpp Index: clang/utils/TableGen/NeonEmitter.cpp === --- clang/utils/TableGen/NeonEmitter.cpp +++ clang/utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1578,7 +1589,10 @@ Intr.Dependencies.insert(); // Now create the call itself. - std::string S = CallPrefix.str() + Callee.getMangledName(true) + "("; + std::string S = ""; + if (!Callee.isBigEndianSafe()) +S += CallPrefix.str(); + S += Callee.getMangledName(true) + "("; for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) { if (I != 0) S += ", "; @@ -1889,6 +1903,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and little endian + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; Index: clang/utils/TableGen/NeonEmitter.cpp === --- clang/utils/TableGen/NeonEmitter.cpp +++ clang/utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1578,7 +1589,10 @@ Intr.Dependencies.insert(); // Now create the call itself. - std::string S = CallPrefix.str() + Callee.getMangledName(true) + "("; + std::string S = ""; + if (!Callee.isBigEndianSafe()) +S += CallPrefix.str(); + S += Callee.getMangledName(true) + "("; for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) { if (I != 0) S += ", "; @@ -1889,6 +1903,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and little endian + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D66588: [ARM NEON] Avoid duplicated decarations
ostannard added a comment. LGTM with one small nit. Comment at: clang/utils/TableGen/NeonEmitter.cpp:1906 std::string Intrinsic::generate() { + // Avoid duplicated code for big and small endians + if (isBigEndianSafe()) { s/small endians/little endian/ Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66588/new/ https://reviews.llvm.org/D66588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D66588: [ARM NEON] Avoid duplicated decarations
dnsampaio updated this revision to Diff 217594. dnsampaio added a comment. Fix / Update / Rebase - Avoid appending __noswap_ to intrinsics that are BigEndianSafe - Moved to monorepo Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66588/new/ https://reviews.llvm.org/D66588 Files: clang/utils/TableGen/NeonEmitter.cpp Index: clang/utils/TableGen/NeonEmitter.cpp === --- clang/utils/TableGen/NeonEmitter.cpp +++ clang/utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1578,7 +1589,10 @@ Intr.Dependencies.insert(); // Now create the call itself. - std::string S = CallPrefix.str() + Callee.getMangledName(true) + "("; + std::string S = ""; + if (!Callee.isBigEndianSafe()) +S += CallPrefix.str(); + S += Callee.getMangledName(true) + "("; for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) { if (I != 0) S += ", "; @@ -1889,6 +1903,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and small endians + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; Index: clang/utils/TableGen/NeonEmitter.cpp === --- clang/utils/TableGen/NeonEmitter.cpp +++ clang/utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1578,7 +1589,10 @@ Intr.Dependencies.insert(); // Now create the call itself. - std::string S = CallPrefix.str() + Callee.getMangledName(true) + "("; + std::string S = ""; + if (!Callee.isBigEndianSafe()) +S += CallPrefix.str(); + S += Callee.getMangledName(true) + "("; for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) { if (I != 0) S += ", "; @@ -1889,6 +1903,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and small endians + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D66588: [ARM NEON] Avoid duplicated decarations
dnsampaio planned changes to this revision. dnsampaio added a comment. Breaks the header. Needs to avoid generating calls to functions with predicated __noswap when it is BigEndianSafe. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66588/new/ https://reviews.llvm.org/D66588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D66588: [ARM NEON] Avoid duplicated decarations
dnsampaio updated this revision to Diff 216801. dnsampaio added a comment. - Consider BigEndianSafe intrinsics that all inputs and outputs are scalar or single element vectors Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66588/new/ https://reviews.llvm.org/D66588 Files: utils/TableGen/NeonEmitter.cpp Index: utils/TableGen/NeonEmitter.cpp === --- utils/TableGen/NeonEmitter.cpp +++ utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1889,6 +1900,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and small endians + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; Index: utils/TableGen/NeonEmitter.cpp === --- utils/TableGen/NeonEmitter.cpp +++ utils/TableGen/NeonEmitter.cpp @@ -332,6 +332,17 @@ NeonEmitter std::stringstream OS; + bool isBigEndianSafe() const { +if (BigEndianSafe) + return true; + +for (const auto : Types){ + if (T.isVector() && T.getNumElements() > 1) +return false; +} +return true; + } + public: Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS, TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter , @@ -1293,7 +1304,7 @@ } void Intrinsic::emitArgumentReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; // Reverse all vector arguments. @@ -1314,7 +1325,7 @@ } void Intrinsic::emitReturnReversal() { - if (BigEndianSafe) + if (isBigEndianSafe()) return; if (!getReturnType().isVector() || getReturnType().isVoid() || getReturnType().getNumElements() == 1) @@ -1889,6 +1900,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and small endians + if (isBigEndianSafe()) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D66588: [ARM NEON] Avoid duplicated decarations
dnsampaio created this revision. dnsampaio added reviewers: t.p.northover, ostannard. Herald added subscribers: cfe-commits, kristof.beyls, javed.absar. Herald added a project: clang. The declaration of arm neon intrinsics that are "big endian safe" print the same code for big and small endian targets. This patch avoids duplicates by checking if an intrinsic is safe to have a single definition. (decreases header 6030 lines out of 73k). Repository: rC Clang https://reviews.llvm.org/D66588 Files: utils/TableGen/NeonEmitter.cpp Index: utils/TableGen/NeonEmitter.cpp === --- utils/TableGen/NeonEmitter.cpp +++ utils/TableGen/NeonEmitter.cpp @@ -1889,6 +1889,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and small endians + if (BigEndianSafe) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; Index: utils/TableGen/NeonEmitter.cpp === --- utils/TableGen/NeonEmitter.cpp +++ utils/TableGen/NeonEmitter.cpp @@ -1889,6 +1889,11 @@ } std::string Intrinsic::generate() { + // Avoid duplicated code for big and small endians + if (BigEndianSafe) { +generateImpl(false, "", ""); +return OS.str(); + } // Little endian intrinsics are simple and don't require any argument // swapping. OS << "#ifdef __LITTLE_ENDIAN__\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits