| OLD | NEW |
| 1 //===- subzero/src/IceTypes.h - Primitive ICE types -------------*- C++ -*-===// | 1 //===- subzero/src/IceTypes.h - Primitive ICE types -------------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 /// |
| 10 // This file declares a few properties of the primitive types allowed | 10 /// \file |
| 11 // in Subzero. Every Subzero source file is expected to include | 11 /// This file declares a few properties of the primitive types allowed |
| 12 // IceTypes.h. | 12 /// in Subzero. Every Subzero source file is expected to include |
| 13 // | 13 /// IceTypes.h. |
| 14 /// |
| 14 //===----------------------------------------------------------------------===// | 15 //===----------------------------------------------------------------------===// |
| 15 | 16 |
| 16 #ifndef SUBZERO_SRC_ICETYPES_H | 17 #ifndef SUBZERO_SRC_ICETYPES_H |
| 17 #define SUBZERO_SRC_ICETYPES_H | 18 #define SUBZERO_SRC_ICETYPES_H |
| 18 | 19 |
| 19 #include "IceDefs.h" | 20 #include "IceDefs.h" |
| 20 #include "IceTypes.def" | 21 #include "IceTypes.def" |
| 21 | 22 |
| 22 namespace Ice { | 23 namespace Ice { |
| 23 | 24 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 #undef X | 35 #undef X |
| 35 TargetArch_NUM | 36 TargetArch_NUM |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 const char *targetArchString(TargetArch Arch); | 39 const char *targetArchString(TargetArch Arch); |
| 39 | 40 |
| 40 inline Ostream &operator<<(Ostream &Stream, TargetArch Arch) { | 41 inline Ostream &operator<<(Ostream &Stream, TargetArch Arch) { |
| 41 return Stream << targetArchString(Arch); | 42 return Stream << targetArchString(Arch); |
| 42 } | 43 } |
| 43 | 44 |
| 44 // The list of all target instruction sets. Individual targets will | 45 /// The list of all target instruction sets. Individual targets will |
| 45 // map this to include only what is valid for the target. | 46 /// map this to include only what is valid for the target. |
| 46 enum TargetInstructionSet { | 47 enum TargetInstructionSet { |
| 47 // Represents baseline that can be assumed for a target (usually "Begin"). | 48 // Represents baseline that can be assumed for a target (usually "Begin"). |
| 48 BaseInstructionSet, | 49 BaseInstructionSet, |
| 49 X86InstructionSet_Begin, | 50 X86InstructionSet_Begin, |
| 50 X86InstructionSet_SSE2 = X86InstructionSet_Begin, | 51 X86InstructionSet_SSE2 = X86InstructionSet_Begin, |
| 51 X86InstructionSet_SSE4_1, | 52 X86InstructionSet_SSE4_1, |
| 52 X86InstructionSet_End, | 53 X86InstructionSet_End, |
| 53 ARM32InstructionSet_Begin, | 54 ARM32InstructionSet_Begin, |
| 54 ARM32InstructionSet_Neon = ARM32InstructionSet_Begin, | 55 ARM32InstructionSet_Neon = ARM32InstructionSet_Begin, |
| 55 ARM32InstructionSet_HWDivArm, | 56 ARM32InstructionSet_HWDivArm, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 81 bool isLoadStoreType(Type Ty); | 82 bool isLoadStoreType(Type Ty); |
| 82 | 83 |
| 83 /// Returns type generated by applying the compare instructions (icmp and fcmp) | 84 /// Returns type generated by applying the compare instructions (icmp and fcmp) |
| 84 /// to arguments of the given type. Returns IceType_void if compare is not | 85 /// to arguments of the given type. Returns IceType_void if compare is not |
| 85 /// allowed. | 86 /// allowed. |
| 86 Type getCompareResultType(Type Ty); | 87 Type getCompareResultType(Type Ty); |
| 87 | 88 |
| 88 /// Returns the number of bits in a scalar integer type. | 89 /// Returns the number of bits in a scalar integer type. |
| 89 SizeT getScalarIntBitWidth(Type Ty); | 90 SizeT getScalarIntBitWidth(Type Ty); |
| 90 | 91 |
| 91 // Check if a type is byte sized (slight optimization over typeWidthInBytes). | 92 /// Check if a type is byte sized (slight optimization over typeWidthInBytes). |
| 92 inline bool isByteSizedType(Type Ty) { | 93 inline bool isByteSizedType(Type Ty) { |
| 93 bool result = Ty == IceType_i8 || Ty == IceType_i1; | 94 bool result = Ty == IceType_i8 || Ty == IceType_i1; |
| 94 assert(result == (1 == typeWidthInBytes(Ty))); | 95 assert(result == (1 == typeWidthInBytes(Ty))); |
| 95 return result; | 96 return result; |
| 96 } | 97 } |
| 97 | 98 |
| 98 // Check if Ty is byte sized and specifically i8. Assert that it's not | 99 /// Check if Ty is byte sized and specifically i8. Assert that it's not |
| 99 // byte sized due to being an i1. | 100 /// byte sized due to being an i1. |
| 100 inline bool isByteSizedArithType(Type Ty) { | 101 inline bool isByteSizedArithType(Type Ty) { |
| 101 assert(Ty != IceType_i1); | 102 assert(Ty != IceType_i1); |
| 102 return Ty == IceType_i8; | 103 return Ty == IceType_i8; |
| 103 } | 104 } |
| 104 | 105 |
| 105 // Return true if Ty is i32. This asserts that Ty is either i32 or i64. | 106 /// Return true if Ty is i32. This asserts that Ty is either i32 or i64. |
| 106 inline bool isInt32Asserting32Or64(Type Ty) { | 107 inline bool isInt32Asserting32Or64(Type Ty) { |
| 107 bool result = Ty == IceType_i32; | 108 bool result = Ty == IceType_i32; |
| 108 assert(result || Ty == IceType_i64); | 109 assert(result || Ty == IceType_i64); |
| 109 return result; | 110 return result; |
| 110 } | 111 } |
| 111 | 112 |
| 112 // Return true if Ty is f32. This asserts that Ty is either f32 or f64. | 113 /// Return true if Ty is f32. This asserts that Ty is either f32 or f64. |
| 113 inline bool isFloat32Asserting32Or64(Type Ty) { | 114 inline bool isFloat32Asserting32Or64(Type Ty) { |
| 114 bool result = Ty == IceType_f32; | 115 bool result = Ty == IceType_f32; |
| 115 assert(result || Ty == IceType_f64); | 116 assert(result || Ty == IceType_f64); |
| 116 return result; | 117 return result; |
| 117 } | 118 } |
| 118 | 119 |
| 119 template <typename StreamType> | 120 template <typename StreamType> |
| 120 inline StreamType &operator<<(StreamType &Str, const Type &Ty) { | 121 inline StreamType &operator<<(StreamType &Str, const Type &Ty) { |
| 121 Str << typeString(Ty); | 122 Str << typeString(Ty); |
| 122 return Str; | 123 return Str; |
| 123 } | 124 } |
| 124 | 125 |
| 125 /// Models a type signature for a function. | 126 /// Models a type signature for a function. |
| 126 class FuncSigType { | 127 class FuncSigType { |
| 127 FuncSigType &operator=(const FuncSigType &Ty) = delete; | 128 FuncSigType &operator=(const FuncSigType &Ty) = delete; |
| 128 | 129 |
| 129 public: | 130 public: |
| 130 typedef std::vector<Type> ArgListType; | 131 typedef std::vector<Type> ArgListType; |
| 131 | 132 |
| 132 // Creates a function signature type with the given return type. | 133 /// Creates a function signature type with the given return type. |
| 133 // Parameter types should be added using calls to appendArgType. | 134 /// Parameter types should be added using calls to appendArgType. |
| 134 FuncSigType() = default; | 135 FuncSigType() = default; |
| 135 FuncSigType(const FuncSigType &Ty) = default; | 136 FuncSigType(const FuncSigType &Ty) = default; |
| 136 | 137 |
| 137 void appendArgType(Type ArgType) { ArgList.push_back(ArgType); } | 138 void appendArgType(Type ArgType) { ArgList.push_back(ArgType); } |
| 138 | 139 |
| 139 Type getReturnType() const { return ReturnType; } | 140 Type getReturnType() const { return ReturnType; } |
| 140 void setReturnType(Type NewType) { ReturnType = NewType; } | 141 void setReturnType(Type NewType) { ReturnType = NewType; } |
| 141 SizeT getNumArgs() const { return ArgList.size(); } | 142 SizeT getNumArgs() const { return ArgList.size(); } |
| 142 Type getArgType(SizeT Index) const { | 143 Type getArgType(SizeT Index) const { |
| 143 assert(Index < ArgList.size()); | 144 assert(Index < ArgList.size()); |
| 144 return ArgList[Index]; | 145 return ArgList[Index]; |
| 145 } | 146 } |
| 146 const ArgListType &getArgList() const { return ArgList; } | 147 const ArgListType &getArgList() const { return ArgList; } |
| 147 void dump(Ostream &Stream) const; | 148 void dump(Ostream &Stream) const; |
| 148 | 149 |
| 149 private: | 150 private: |
| 150 // The return type. | 151 /// The return type. |
| 151 Type ReturnType = IceType_void; | 152 Type ReturnType = IceType_void; |
| 152 // The list of parameters. | 153 /// The list of parameters. |
| 153 ArgListType ArgList; | 154 ArgListType ArgList; |
| 154 }; | 155 }; |
| 155 | 156 |
| 156 inline Ostream &operator<<(Ostream &Stream, const FuncSigType &Sig) { | 157 inline Ostream &operator<<(Ostream &Stream, const FuncSigType &Sig) { |
| 157 Sig.dump(Stream); | 158 Sig.dump(Stream); |
| 158 return Stream; | 159 return Stream; |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // end of namespace Ice | 162 } // end of namespace Ice |
| 162 | 163 |
| 163 #endif // SUBZERO_SRC_ICETYPES_H | 164 #endif // SUBZERO_SRC_ICETYPES_H |
| OLD | NEW |