| 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 /// \file | 10 /// \file |
| 11 /// This file declares a few properties of the primitive types allowed | 11 /// This file declares a few properties of the primitive types allowed in |
| 12 /// in Subzero. Every Subzero source file is expected to include | 12 /// Subzero. Every Subzero source file is expected to include IceTypes.h. |
| 13 /// IceTypes.h. | |
| 14 /// | 13 /// |
| 15 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 16 | 15 |
| 17 #ifndef SUBZERO_SRC_ICETYPES_H | 16 #ifndef SUBZERO_SRC_ICETYPES_H |
| 18 #define SUBZERO_SRC_ICETYPES_H | 17 #define SUBZERO_SRC_ICETYPES_H |
| 19 | 18 |
| 20 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 21 #include "IceTypes.def" | 20 #include "IceTypes.def" |
| 22 | 21 |
| 23 namespace Ice { | 22 namespace Ice { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 #undef X | 34 #undef X |
| 36 TargetArch_NUM | 35 TargetArch_NUM |
| 37 }; | 36 }; |
| 38 | 37 |
| 39 const char *targetArchString(TargetArch Arch); | 38 const char *targetArchString(TargetArch Arch); |
| 40 | 39 |
| 41 inline Ostream &operator<<(Ostream &Stream, TargetArch Arch) { | 40 inline Ostream &operator<<(Ostream &Stream, TargetArch Arch) { |
| 42 return Stream << targetArchString(Arch); | 41 return Stream << targetArchString(Arch); |
| 43 } | 42 } |
| 44 | 43 |
| 45 /// The list of all target instruction sets. Individual targets will | 44 /// The list of all target instruction sets. Individual targets will map this to |
| 46 /// map this to include only what is valid for the target. | 45 /// include only what is valid for the target. |
| 47 enum TargetInstructionSet { | 46 enum TargetInstructionSet { |
| 48 // Represents baseline that can be assumed for a target (usually "Begin"). | 47 // Represents baseline that can be assumed for a target (usually "Begin"). |
| 49 BaseInstructionSet, | 48 BaseInstructionSet, |
| 50 X86InstructionSet_Begin, | 49 X86InstructionSet_Begin, |
| 51 X86InstructionSet_SSE2 = X86InstructionSet_Begin, | 50 X86InstructionSet_SSE2 = X86InstructionSet_Begin, |
| 52 X86InstructionSet_SSE4_1, | 51 X86InstructionSet_SSE4_1, |
| 53 X86InstructionSet_End, | 52 X86InstructionSet_End, |
| 54 ARM32InstructionSet_Begin, | 53 ARM32InstructionSet_Begin, |
| 55 ARM32InstructionSet_Neon = ARM32InstructionSet_Begin, | 54 ARM32InstructionSet_Neon = ARM32InstructionSet_Begin, |
| 56 ARM32InstructionSet_HWDivArm, | 55 ARM32InstructionSet_HWDivArm, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 /// Returns the number of bits in a scalar integer type. | 89 /// Returns the number of bits in a scalar integer type. |
| 91 SizeT getScalarIntBitWidth(Type Ty); | 90 SizeT getScalarIntBitWidth(Type Ty); |
| 92 | 91 |
| 93 /// Check if a type is byte sized (slight optimization over typeWidthInBytes). | 92 /// Check if a type is byte sized (slight optimization over typeWidthInBytes). |
| 94 inline bool isByteSizedType(Type Ty) { | 93 inline bool isByteSizedType(Type Ty) { |
| 95 bool result = Ty == IceType_i8 || Ty == IceType_i1; | 94 bool result = Ty == IceType_i8 || Ty == IceType_i1; |
| 96 assert(result == (1 == typeWidthInBytes(Ty))); | 95 assert(result == (1 == typeWidthInBytes(Ty))); |
| 97 return result; | 96 return result; |
| 98 } | 97 } |
| 99 | 98 |
| 100 /// 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 byte |
| 101 /// byte sized due to being an i1. | 100 /// sized due to being an i1. |
| 102 inline bool isByteSizedArithType(Type Ty) { | 101 inline bool isByteSizedArithType(Type Ty) { |
| 103 assert(Ty != IceType_i1); | 102 assert(Ty != IceType_i1); |
| 104 return Ty == IceType_i8; | 103 return Ty == IceType_i8; |
| 105 } | 104 } |
| 106 | 105 |
| 107 /// 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. |
| 108 inline bool isInt32Asserting32Or64(Type Ty) { | 107 inline bool isInt32Asserting32Or64(Type Ty) { |
| 109 bool result = Ty == IceType_i32; | 108 bool result = Ty == IceType_i32; |
| 110 assert(result || Ty == IceType_i64); | 109 assert(result || Ty == IceType_i64); |
| 111 return result; | 110 return result; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 124 return Str; | 123 return Str; |
| 125 } | 124 } |
| 126 | 125 |
| 127 /// Models a type signature for a function. | 126 /// Models a type signature for a function. |
| 128 class FuncSigType { | 127 class FuncSigType { |
| 129 FuncSigType &operator=(const FuncSigType &Ty) = delete; | 128 FuncSigType &operator=(const FuncSigType &Ty) = delete; |
| 130 | 129 |
| 131 public: | 130 public: |
| 132 using ArgListType = std::vector<Type>; | 131 using ArgListType = std::vector<Type>; |
| 133 | 132 |
| 134 /// Creates a function signature type with the given return type. | 133 /// Creates a function signature type with the given return type. Parameter |
| 135 /// Parameter types should be added using calls to appendArgType. | 134 /// types should be added using calls to appendArgType. |
| 136 FuncSigType() = default; | 135 FuncSigType() = default; |
| 137 FuncSigType(const FuncSigType &Ty) = default; | 136 FuncSigType(const FuncSigType &Ty) = default; |
| 138 | 137 |
| 139 void appendArgType(Type ArgType) { ArgList.push_back(ArgType); } | 138 void appendArgType(Type ArgType) { ArgList.push_back(ArgType); } |
| 140 | 139 |
| 141 Type getReturnType() const { return ReturnType; } | 140 Type getReturnType() const { return ReturnType; } |
| 142 void setReturnType(Type NewType) { ReturnType = NewType; } | 141 void setReturnType(Type NewType) { ReturnType = NewType; } |
| 143 SizeT getNumArgs() const { return ArgList.size(); } | 142 SizeT getNumArgs() const { return ArgList.size(); } |
| 144 Type getArgType(SizeT Index) const { | 143 Type getArgType(SizeT Index) const { |
| 145 assert(Index < ArgList.size()); | 144 assert(Index < ArgList.size()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 156 }; | 155 }; |
| 157 | 156 |
| 158 inline Ostream &operator<<(Ostream &Stream, const FuncSigType &Sig) { | 157 inline Ostream &operator<<(Ostream &Stream, const FuncSigType &Sig) { |
| 159 Sig.dump(Stream); | 158 Sig.dump(Stream); |
| 160 return Stream; | 159 return Stream; |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // end of namespace Ice | 162 } // end of namespace Ice |
| 164 | 163 |
| 165 #endif // SUBZERO_SRC_ICETYPES_H | 164 #endif // SUBZERO_SRC_ICETYPES_H |
| OLD | NEW |