From e9a06e06064145e0baf723187ab023dd91e914f9 Mon Sep 17 00:00:00 2001 From: Francesco Petrogalli Date: Wed, 30 Oct 2019 19:08:21 +0000 Subject: [VFABI] Read/Write functions for the VFABI attribute. The attribute is stored at the `FunctionIndex` attribute set, with the name "vector-function-abi-variant". The get/set methods of the attribute have assertion to verify that: 1. Each name in the attribute is a valid VFABI mangled name. 2. Each name in the attribute correspond to a function declared in the module. Differential Revision: https://reviews.llvm.org/D69976 --- llvm/lib/Analysis/VFABIDemangling.cpp | 5 +++-- llvm/lib/Analysis/VectorUtils.cpp | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Analysis') diff --git a/llvm/lib/Analysis/VFABIDemangling.cpp b/llvm/lib/Analysis/VFABIDemangling.cpp index 6fd8ae63f5f..152f7ae4667 100644 --- a/llvm/lib/Analysis/VFABIDemangling.cpp +++ b/llvm/lib/Analysis/VFABIDemangling.cpp @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Analysis/VectorUtils.h" using namespace llvm; @@ -34,7 +36,6 @@ ParseRet tryParseISA(StringRef &MangledName, VFISAKind &ISA) { .Case("d", VFISAKind::AVX2) .Case("e", VFISAKind::AVX512) .Default(VFISAKind::Unknown); - MangledName = MangledName.drop_front(1); return ParseRet::OK; @@ -338,7 +339,7 @@ Optional VFABI::tryDemangleForVFABI(StringRef MangledName) { } } while (ParamFound == ParseRet::OK); - // A valid MangledName mus have at least one valid entry in the + // A valid MangledName must have at least one valid entry in the // . if (Parameters.empty()) return None; diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index 600f57ab9d7..90e326687f7 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -1159,3 +1159,22 @@ void InterleaveGroup::addMetadata(Instruction *NewInst) const { propagateMetadata(NewInst, VL); } } + +void VFABI::getVectorVariantNames( + const CallInst &CI, SmallVectorImpl &VariantMappings) { + const StringRef S = + CI.getAttribute(AttributeList::FunctionIndex, VFABI::MappingsAttrName) + .getValueAsString(); + SmallVector ListAttr; + S.split(ListAttr, ","); + + for (auto &S : SetVector(ListAttr.begin(), ListAttr.end())) { +#ifndef NDEBUG + Optional 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); + } +} -- cgit v1.2.3