OLD | NEW |
1 //===- subzero/src/IceTypeConverter.h - Convert ICE/LLVM Types --*- C++ -*-===// | 1 //===- subzero/src/IceTypeConverter.h - Convert ICE/LLVM 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 defines how to convert LLVM types to ICE types, and ICE types | 10 // This file defines how to convert LLVM types to ICE types, and ICE types |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "IceTypes.h" | 21 #include "IceTypes.h" |
22 | 22 |
23 namespace llvm { | 23 namespace llvm { |
24 class LLVMContext; | 24 class LLVMContext; |
25 } // end of llvm namespace. | 25 } // end of llvm namespace. |
26 | 26 |
27 namespace Ice { | 27 namespace Ice { |
28 | 28 |
29 /// Converts LLVM types to ICE types, and ICE types to LLVM types. | 29 /// Converts LLVM types to ICE types, and ICE types to LLVM types. |
30 class TypeConverter { | 30 class TypeConverter { |
| 31 TypeConverter() = delete; |
31 TypeConverter(const TypeConverter &) = delete; | 32 TypeConverter(const TypeConverter &) = delete; |
32 TypeConverter &operator=(const TypeConverter &) = delete; | 33 TypeConverter &operator=(const TypeConverter &) = delete; |
33 | 34 |
34 public: | 35 public: |
35 /// Context is the context to use to build llvm types. | 36 /// Context is the context to use to build llvm types. |
36 TypeConverter(llvm::LLVMContext &Context); | 37 explicit TypeConverter(llvm::LLVMContext &Context); |
37 | 38 |
38 /// Converts LLVM type LLVMTy to an ICE type. Returns | 39 /// Converts LLVM type LLVMTy to an ICE type. Returns |
39 /// Ice::IceType_NUM if unable to convert. | 40 /// Ice::IceType_NUM if unable to convert. |
40 Type convertToIceType(llvm::Type *LLVMTy) const { | 41 Type convertToIceType(llvm::Type *LLVMTy) const { |
41 auto Pos = LLVM2IceMap.find(LLVMTy); | 42 auto Pos = LLVM2IceMap.find(LLVMTy); |
42 if (Pos == LLVM2IceMap.end()) | 43 if (Pos == LLVM2IceMap.end()) |
43 return convertToIceTypeOther(LLVMTy); | 44 return convertToIceTypeOther(LLVMTy); |
44 return Pos->second; | 45 return Pos->second; |
45 } | 46 } |
46 | 47 |
47 private: | 48 private: |
48 // The mapping from LLVM types to corresopnding Ice types. | 49 // The mapping from LLVM types to corresopnding Ice types. |
49 std::map<llvm::Type *, Type> LLVM2IceMap; | 50 std::map<llvm::Type *, Type> LLVM2IceMap; |
50 | 51 |
51 // Add LLVM/ICE pair to internal tables. | 52 // Add LLVM/ICE pair to internal tables. |
52 void addLLVMType(Type Ty, llvm::Type *LLVMTy); | 53 void addLLVMType(Type Ty, llvm::Type *LLVMTy); |
53 | 54 |
54 // Converts types not in LLVM2IceMap. | 55 // Converts types not in LLVM2IceMap. |
55 Type convertToIceTypeOther(llvm::Type *LLVMTy) const; | 56 Type convertToIceTypeOther(llvm::Type *LLVMTy) const; |
56 }; | 57 }; |
57 | 58 |
58 } // end of Ice namespace. | 59 } // end of Ice namespace. |
59 | 60 |
60 #endif // SUBZERO_SRC_ICETYPECONVERTER_H | 61 #endif // SUBZERO_SRC_ICETYPECONVERTER_H |
OLD | NEW |