r370716 - [ARM NEON] Avoid duplicated decarations
Diogo N. Sampaio via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 02:16:44 PDT 2019
Author: dnsampaio
Date: Tue Sep 3 02:16:44 2019
New Revision: 370716
URL: http://llvm.org/viewvc/llvm-project?rev=370716&view=rev
Log:
[ARM NEON] Avoid duplicated decarations
Summary:
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 11k lines out of 73k).
Reviewers: t.p.northover, ostannard, labrinea
Reviewed By: ostannard
Subscribers: kristof.beyls, cfe-commits, olista01
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66588
Modified:
cfe/trunk/utils/TableGen/NeonEmitter.cpp
Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=370716&r1=370715&r2=370716&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Tue Sep 3 02:16:44 2019
@@ -332,6 +332,17 @@ class Intrinsic {
NeonEmitter &Emitter;
std::stringstream OS;
+ bool isBigEndianSafe() const {
+ if (BigEndianSafe)
+ return true;
+
+ for (const auto &T : 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 &Emitter,
@@ -1293,7 +1304,7 @@ void Intrinsic::emitReverseVariable(Vari
}
void Intrinsic::emitArgumentReversal() {
- if (BigEndianSafe)
+ if (isBigEndianSafe())
return;
// Reverse all vector arguments.
@@ -1314,7 +1325,7 @@ void Intrinsic::emitArgumentReversal() {
}
void Intrinsic::emitReturnReversal() {
- if (BigEndianSafe)
+ if (isBigEndianSafe())
return;
if (!getReturnType().isVector() || getReturnType().isVoid() ||
getReturnType().getNumElements() == 1)
@@ -1578,7 +1589,10 @@ std::pair<Type, std::string> Intrinsic::
Intr.Dependencies.insert(&Callee);
// 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 @@ Intrinsic::DagEmitter::emitDagArg(Init *
}
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";
More information about the cfe-commits
mailing list