OLD | NEW |
(Empty) | |
| 1 //===- subzero/src/IceIntrinsics.h - List of Ice Intrinsics -----*- C++ -*-===// |
| 2 // |
| 3 // The Subzero Code Generator |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // This file declares the kinds of intrinsics supported by PNaCl. |
| 11 // |
| 12 //===----------------------------------------------------------------------===// |
| 13 |
| 14 #ifndef SUBZERO_SRC_ICEINTRINSICS_H |
| 15 #define SUBZERO_SRC_ICEINTRINSICS_H |
| 16 |
| 17 #include "IceDefs.h" |
| 18 |
| 19 namespace Ice { |
| 20 |
| 21 static const size_t kMaxIntrinsicParameters = 6; |
| 22 |
| 23 class Intrinsics { |
| 24 public: |
| 25 Intrinsics(); |
| 26 ~Intrinsics(); |
| 27 |
| 28 // Some intrinsics allow overloading by type. This enum collapses all |
| 29 // overloads into a single ID, but the type can still be recovered by the |
| 30 // type of the intrinsic function call's return value and parameters. |
| 31 enum IntrinsicID { |
| 32 UnknownIntrinsic = 0, |
| 33 // Arbitrary (alphabetical) order. |
| 34 AtomicCmpxchg, |
| 35 AtomicFence, |
| 36 AtomicFenceAll, |
| 37 AtomicIsLockFree, |
| 38 AtomicLoad, |
| 39 AtomicRMW, |
| 40 AtomicStore, |
| 41 Bswap, |
| 42 Ctlz, |
| 43 Ctpop, |
| 44 Cttz, |
| 45 Longjmp, |
| 46 Memcpy, |
| 47 Memmove, |
| 48 Memset, |
| 49 NaClReadTP, |
| 50 Setjmp, |
| 51 Sqrt, |
| 52 Stacksave, |
| 53 Stackrestore, |
| 54 Trap |
| 55 }; |
| 56 |
| 57 // Basic attributes related to each intrinsic, that are relevant to |
| 58 // code generation. We will want to have more attributes (e.g., Setjmp |
| 59 // returns twice and which affects stack coloring) once the lowering |
| 60 // cares about such attributes. Perhaps the attributes representation |
| 61 // can be shared with general function calls, though most functions |
| 62 // will be opaque. |
| 63 struct IntrinsicInfo { |
| 64 IntrinsicID ID : 31; |
| 65 bool HasSideEffects : 1; |
| 66 }; |
| 67 |
| 68 // The complete set of information about an intrinsic. |
| 69 struct FullIntrinsicInfo { |
| 70 struct IntrinsicInfo Info; // Information that CodeGen would care about. |
| 71 |
| 72 // Sanity check during parsing. |
| 73 Type Signature[kMaxIntrinsicParameters]; |
| 74 uint8_t NumTypes; |
| 75 }; |
| 76 |
| 77 // Find the information about a given intrinsic, based on function name. |
| 78 // The function name is expected to have the common "llvm." prefix |
| 79 // stripped. If found, returns a reference to a FullIntrinsicInfo entry |
| 80 // (valid for the lifetime of the map). Otherwise returns null. |
| 81 const FullIntrinsicInfo *find(const IceString &Name) const; |
| 82 |
| 83 private: |
| 84 // TODO(jvoung): May want to switch to something like LLVM's StringMap. |
| 85 typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap; |
| 86 IntrinsicMap map; |
| 87 |
| 88 Intrinsics(const Intrinsics &) LLVM_DELETED_FUNCTION; |
| 89 Intrinsics &operator=(const Intrinsics &) LLVM_DELETED_FUNCTION; |
| 90 }; |
| 91 |
| 92 } // end of namespace Ice |
| 93 |
| 94 #endif // SUBZERO_SRC_ICEINTRINSICS_H |
OLD | NEW |