1 //===-- Lower/Mangler.h -- name mangling ------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/ 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef FORTRAN_LOWER_MANGLER_H 14 #define FORTRAN_LOWER_MANGLER_H 15 16 #include "mlir/IR/BuiltinTypes.h" 17 #include "llvm/ADT/StringRef.h" 18 #include <string> 19 20 namespace fir { 21 struct NameUniquer; 22 23 /// Returns a name suitable to define mlir functions for Fortran intrinsic 24 /// Procedure. These names are guaranteed to not conflict with user defined 25 /// procedures. This is needed to implement Fortran generic intrinsics as 26 /// several mlir functions specialized for the argument types. 27 /// The result is guaranteed to be distinct for different mlir::FunctionType 28 /// arguments. The mangling pattern is: 29 /// fir.<generic name>.<result type>.<arg type>... 30 /// e.g ACOS(COMPLEX(4)) is mangled as fir.acos.z4.z4 31 std::string mangleIntrinsicProcedure(llvm::StringRef genericName, 32 mlir::FunctionType); 33 } // namespace fir 34 35 namespace Fortran { 36 namespace common { 37 template <typename> 38 class Reference; 39 } 40 41 namespace semantics { 42 class Symbol; 43 } 44 45 namespace lower { 46 namespace mangle { 47 48 /// Convert a front-end Symbol to an internal name 49 std::string mangleName(fir::NameUniquer &uniquer, const semantics::Symbol &); 50 51 std::string demangleName(llvm::StringRef name); 52 53 } // namespace mangle 54 } // namespace lower 55 } // namespace Fortran 56 57 #endif // FORTRAN_LOWER_MANGLER_H 58