llvm/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp

//===-- AMDGPULibFunc.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//  This file contains utility functions to work with Itanium mangled names
//
//===----------------------------------------------------------------------===//

#include "AMDGPULibFunc.h"
#include "AMDGPU.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ModRef.h"
#include "llvm/Support/raw_ostream.h"

usingnamespacellvm;

static cl::opt<bool> EnableOCLManglingMismatchWA(
    "amdgpu-enable-ocl-mangling-mismatch-workaround", cl::init(true),
    cl::ReallyHidden,
    cl::desc("Enable the workaround for OCL name mangling mismatch."));

namespace {

enum EManglingParam {};

struct ManglingRule {};

// Information about library functions with unmangled names.
class UnmangledFuncInfo {};

unsigned ManglingRule::getNumArgs() const {}

// This table describes function formal argument type rules. The order of rules
// corresponds to the EFuncId enum at AMDGPULibFunc.h
//
// "<func name>", { <leads> }, { <param rules> }
// where:
//  <leads> - list of integers that are one-based indexes of formal argument
//    used to mangle a function name. Other argument types are derived from types
//    of these 'leads'. The order of integers in this list correspond to the
//    order in which these arguments are mangled in the EDG mangling scheme. The
//    same order should be preserved for arguments in the AMDGPULibFunc structure
//    when it is used for mangling. For example:
//    { "vstorea_half", {3,1}, {E_ANY,EX_SIZET,E_ANY}},
//    will be mangled in EDG scheme as  vstorea_half_<3dparam>_<1stparam>
//    When mangling from code use:
//    AMDGPULibFunc insc;
//    insc.param[0] = ... // describe 3rd parameter
//    insc.param[1] = ... // describe 1rd parameter
//
// <param rules> - list of rules used to derive all of the function formal
//    argument types. EX_ prefixed are simple types, other derived from the
//    latest 'lead' argument type in the order of encoding from first to last.
//    E_ANY - use prev lead type, E_CONSTPTR_ANY - make const pointer out of
//    prev lead type, etc. see ParamIterator::getNextParam() for details.

static constexpr ManglingRule manglingRules[] =;

// Library functions with unmangled name.
const UnmangledFuncInfo UnmangledFuncInfo::Table[] =;

const unsigned UnmangledFuncInfo::TableSize =;

static AMDGPULibFunc::Param getRetType(AMDGPULibFunc::EFuncId id,
                                       const AMDGPULibFunc::Param (&Leads)[2]) {}

class ParamIterator {};

AMDGPULibFunc::Param ParamIterator::getNextParam() {}

inline static void drop_front(StringRef& str, size_t n = 1) {}

static bool eatTerm(StringRef& mangledName, const char c) {}

template <size_t N>
static bool eatTerm(StringRef& mangledName, const char (&str)[N]) {}

static int eatNumber(StringRef& s) {}

static StringRef eatLengthPrefixedName(StringRef& mangledName) {}

} // end anonymous namespace

AMDGPUMangledLibFunc::AMDGPUMangledLibFunc() {}

AMDGPUUnmangledLibFunc::AMDGPUUnmangledLibFunc() {}

AMDGPUMangledLibFunc::AMDGPUMangledLibFunc(
    EFuncId id, const AMDGPUMangledLibFunc &copyFrom) {}

AMDGPUMangledLibFunc::AMDGPUMangledLibFunc(EFuncId id, FunctionType *FT,
                                           bool SignedInts) {}

///////////////////////////////////////////////////////////////////////////////
// Demangling

static int parseVecSize(StringRef& mangledName) {}

static AMDGPULibFunc::ENamePrefix parseNamePrefix(StringRef& mangledName) {}

StringMap<int> ManglingRule::buildManglingRulesMap() {}

bool AMDGPUMangledLibFunc::parseUnmangledName(StringRef FullName) {}

///////////////////////////////////////////////////////////////////////////////
// Itanium Demangling

namespace {
struct ItaniumParamParser {};
} // namespace

bool ItaniumParamParser::parseItaniumParam(StringRef& param,
                                           AMDGPULibFunc::Param &res) {}

bool AMDGPUMangledLibFunc::parseFuncName(StringRef &mangledName) {}

bool AMDGPUUnmangledLibFunc::parseFuncName(StringRef &Name) {}

bool AMDGPULibFunc::parse(StringRef FuncName, AMDGPULibFunc &F) {}

StringRef AMDGPUMangledLibFunc::getUnmangledName(StringRef mangledName) {}

///////////////////////////////////////////////////////////////////////////////
// Mangling

template <typename Stream>
void AMDGPUMangledLibFunc::writeName(Stream &OS) const {}

std::string AMDGPUMangledLibFunc::mangle() const {}

///////////////////////////////////////////////////////////////////////////////
// Itanium Mangling

static const char *getItaniumTypeName(AMDGPULibFunc::EType T) {}

namespace {
// Itanium mangling ABI says:
// "5.1.8. Compression
// ... Each non-terminal in the grammar for which <substitution> appears on the
// right-hand side is both a source of future substitutions and a candidate
// for being substituted. There are two exceptions that appear to be
// substitution candidates from the grammar, but are explicitly excluded:
// 1. <builtin-type> other than vendor extended types ..."

// For the purpose of functions the following productions make sense for the
// substitution:
//  <type> ::= <builtin-type>
//    ::= <class-enum-type>
//    ::= <array-type>
//    ::=<CV-qualifiers> <type>
//    ::= P <type>                # pointer-to
//    ::= <substitution>
//
// Note that while types like images, samplers and events are by the ABI encoded
// using <class-enum-type> production rule they're not used for substitution
// because clang consider them as builtin types.
//
// DvNN_ type is GCC extension for vectors and is a subject for the
// substitution.

class ItaniumMangler {};
} // namespace

std::string AMDGPUMangledLibFunc::mangleNameItanium() const {}

///////////////////////////////////////////////////////////////////////////////
// Misc

AMDGPULibFuncBase::Param AMDGPULibFuncBase::Param::getFromTy(Type *Ty,
                                                             bool Signed) {}

static Type* getIntrinsicParamType(
  LLVMContext& C,
  const AMDGPULibFunc::Param& P,
  bool useAddrSpace) {}

FunctionType *AMDGPUMangledLibFunc::getFunctionType(Module &M) const {}

unsigned AMDGPUMangledLibFunc::getNumArgs() const {}

unsigned AMDGPUUnmangledLibFunc::getNumArgs() const {}

std::string AMDGPUMangledLibFunc::getName() const {}

bool AMDGPULibFunc::isCompatibleSignature(const FunctionType *FuncTy) const {}

Function *AMDGPULibFunc::getFunction(Module *M, const AMDGPULibFunc &fInfo) {}

FunctionCallee AMDGPULibFunc::getOrInsertFunction(Module *M,
                                                  const AMDGPULibFunc &fInfo) {}

StringMap<unsigned> UnmangledFuncInfo::buildNameMap() {}

bool UnmangledFuncInfo::lookup(StringRef Name, ID &Id) {}

AMDGPULibFunc::AMDGPULibFunc(const AMDGPULibFunc &F) {}

AMDGPULibFunc &AMDGPULibFunc::operator=(const AMDGPULibFunc &F) {}

AMDGPULibFunc::AMDGPULibFunc(EFuncId Id, const AMDGPULibFunc &CopyFrom) {}

AMDGPULibFunc::AMDGPULibFunc(EFuncId Id, FunctionType *FT, bool SignedInts) {}

AMDGPULibFunc::AMDGPULibFunc(StringRef Name, FunctionType *FT) {}

void AMDGPULibFunc::initMangled() {}

AMDGPULibFunc::Param *AMDGPULibFunc::getLeads() {}

const AMDGPULibFunc::Param *AMDGPULibFunc::getLeads() const {}