summaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/VectorUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r--llvm/lib/Analysis/VectorUtils.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 600f57ab9d716..c45ab941a1428 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -24,6 +24,7 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Value.h"
+#include "llvm/Support/CommandLine.h"
#define DEBUG_TYPE "vectorutils"
@@ -1159,3 +1160,69 @@ void InterleaveGroup<Instruction>::addMetadata(Instruction *NewInst) const {
propagateMetadata(NewInst, VL);
}
}
+
+void VFABI::getVectorVariantNames(
+ const CallInst &CI, SmallVectorImpl<std::string> &VariantMappings) {
+ const StringRef S =
+ CI.getAttribute(AttributeList::FunctionIndex, VFABI::MappingsAttrName)
+ .getValueAsString();
+ if (S.empty())
+ return;
+
+ SmallVector<StringRef, 8> ListAttr;
+ S.split(ListAttr, ",");
+
+ for (auto &S : SetVector<StringRef>(ListAttr.begin(), ListAttr.end())) {
+#ifndef NDEBUG
+ Optional<VFInfo> Info = VFABI::tryDemangleForVFABI(S);
+ assert(Info.hasValue() && "Invalid name for a VFABI variant.");
+ assert(CI.getModule()->getFunction(Info.getValue().VectorName) &&
+ "Vector function is missing.");
+#endif
+ VariantMappings.push_back(S);
+ }
+}
+
+bool VFShape::hasValidParameterList() const {
+ for (unsigned Pos = 0, NumParams = Parameters.size(); Pos < NumParams;
+ ++Pos) {
+ assert(Parameters[Pos].ParamPos == Pos && "Broken parameter list.");
+
+ switch (Parameters[Pos].ParamKind) {
+ default: // Nothing to check.
+ break;
+ case VFParamKind::OMP_Linear:
+ case VFParamKind::OMP_LinearRef:
+ case VFParamKind::OMP_LinearVal:
+ case VFParamKind::OMP_LinearUVal:
+ // Compile time linear steps must be non-zero.
+ if (Parameters[Pos].LinearStepOrPos == 0)
+ return false;
+ break;
+ case VFParamKind::OMP_LinearPos:
+ case VFParamKind::OMP_LinearRefPos:
+ case VFParamKind::OMP_LinearValPos:
+ case VFParamKind::OMP_LinearUValPos:
+ // The runtime linear step must be referring to some other
+ // parameters in the signature.
+ if (Parameters[Pos].LinearStepOrPos >= int(NumParams))
+ return false;
+ // The linear step parameter must be marked as uniform.
+ if (Parameters[Parameters[Pos].LinearStepOrPos].ParamKind !=
+ VFParamKind::OMP_Uniform)
+ return false;
+ // The linear step parameter can't point at itself.
+ if (Parameters[Pos].LinearStepOrPos == int(Pos))
+ return false;
+ break;
+ case VFParamKind::GlobalPredicate:
+ // The global predicate must be the unique. Can be placed anywhere in the
+ // signature.
+ for (unsigned NextPos = Pos + 1; NextPos < NumParams; ++NextPos)
+ if (Parameters[NextPos].ParamKind == VFParamKind::GlobalPredicate)
+ return false;
+ break;
+ }
+ }
+ return true;
+}