• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------- FunctionDescriptor.h ------------------------===//
2 //
3 //                              SPIR Tools
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===---------------------------------------------------------------------===//
9 /*
10  * Contributed by: Intel Corporation.
11  */
12 
13 #ifndef __FUNCTION_DESCRIPTOR_H__
14 #define __FUNCTION_DESCRIPTOR_H__
15 
16 #include "ParameterType.h"
17 #include "Refcount.h"
18 #include <string>
19 #include <vector>
20 
21 namespace SPIR {
22 typedef std::vector<RefCount<ParamType> > TypeVector;
23 
24 struct FunctionDescriptor {
25   /// @brief Returns a human readable string representation of the function's
26   ///        prototype.
27   /// @returns std::string representing the function's prototype.
28   std::string toString() const;
29 
30   /// The name of the function (stripped).
31   std::string name;
32   /// Parameter list of the function.
33   TypeVector parameters;
34 
35   bool operator == (const FunctionDescriptor&) const;
36 
37   /// @brief Enables function descriptors to serve as keys in stl maps.
38   bool operator < (const FunctionDescriptor&) const;
39   bool isNull() const;
40 
41   /// @brief Create a singular value, that represents a 'null' FunctionDescriptor.
42   static FunctionDescriptor null();
43 
44   static std::string nullString();
45 };
46 
47 template <typename T>
48 std::ostream& operator<< (T& o, const SPIR::FunctionDescriptor& fd) {
49   o << fd.toString();
50   return o;
51 }
52 } // End SPIR namespace
53 
54 #endif //__FUNCTION_DESCRIPTOR_H__
55