summaryrefslogtreecommitdiff
path: root/lib/SPIRV/Mangler/FunctionDescriptor.h
blob: 9e71f41377fae96ea9c4e194059ee00ecd1cc378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//===----------------------- FunctionDescriptor.h ------------------------===//
//
//                              SPIR Tools
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===---------------------------------------------------------------------===//
/*
 * Contributed by: Intel Corporation.
 */

#ifndef __FUNCTION_DESCRIPTOR_H__
#define __FUNCTION_DESCRIPTOR_H__

#include "ParameterType.h"
#include "Refcount.h"
#include <string>
#include <vector>

namespace SPIR {
typedef std::vector<RefCount<ParamType>> TypeVector;

struct FunctionDescriptor {
  /// @brief Returns a human readable string representation of the function's
  ///        prototype.
  /// @returns std::string representing the function's prototype.
  std::string toString() const;

  /// The name of the function (stripped).
  std::string name;
  /// Parameter list of the function.
  TypeVector parameters;

  bool operator==(const FunctionDescriptor &) const;

  /// @brief Enables function descriptors to serve as keys in stl maps.
  bool operator<(const FunctionDescriptor &) const;
  bool isNull() const;

  /// @brief Create a singular value, that represents a 'null'
  /// FunctionDescriptor.
  static FunctionDescriptor null();

  static std::string nullString();
};

template <typename T>
std::ostream &operator<<(T &o, const SPIR::FunctionDescriptor &fd) {
  o << fd.toString();
  return o;
}
} // namespace SPIR

#endif //__FUNCTION_DESCRIPTOR_H__