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