Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 class TypeConverter { | 30 class TypeConverter { |
| 31 TypeConverter(const TypeConverter &) = delete; | 31 TypeConverter(const TypeConverter &) = delete; |
| 32 TypeConverter &operator=(const TypeConverter &) = delete; | 32 TypeConverter &operator=(const TypeConverter &) = delete; |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 /// Context is the context to use to build llvm types. | 35 /// Context is the context to use to build llvm types. |
| 36 TypeConverter(llvm::LLVMContext &Context); | 36 TypeConverter(llvm::LLVMContext &Context); |
| 37 | 37 |
| 38 /// Returns the LLVM type for the corresponding ICE type Ty. | 38 /// Returns the LLVM type for the corresponding ICE type Ty. |
| 39 llvm::Type *convertToLLVMType(Type Ty) const { | 39 llvm::Type *convertToLLVMType(Type Ty) const { |
| 40 // Note: We use "at" here in case Ty wasn't registered. | 40 // Note: We use "at" here in case Ty wasn't registered. |
|
jvoung (off chromium)
2014/12/15 19:47:02
You might be able to remove this, since I only see
Karl
2014/12/15 20:27:54
Removed.
| |
| 41 return LLVMTypes.at(Ty); | 41 return LLVMTypes.at(Ty); |
| 42 } | 42 } |
| 43 | 43 |
| 44 /// Converts LLVM type LLVMTy to an ICE type. Returns | 44 /// Converts LLVM type LLVMTy to an ICE type. Returns |
| 45 /// Ice::IceType_NUM if unable to convert. | 45 /// Ice::IceType_NUM if unable to convert. |
| 46 Type convertToIceType(llvm::Type *LLVMTy) const { | 46 Type convertToIceType(llvm::Type *LLVMTy) const { |
| 47 auto Pos = LLVM2IceMap.find(LLVMTy); | 47 auto Pos = LLVM2IceMap.find(LLVMTy); |
| 48 if (Pos == LLVM2IceMap.end()) | 48 if (Pos == LLVM2IceMap.end()) |
| 49 return convertToIceTypeOther(LLVMTy); | 49 return convertToIceTypeOther(LLVMTy); |
| 50 return Pos->second; | 50 return Pos->second; |
| 51 } | 51 } |
| 52 | 52 |
| 53 /// Returns ICE model of pointer type. | |
| 54 Type getIcePointerType() const { return IceType_i32; } | |
| 55 | |
| 56 private: | 53 private: |
| 57 // The list of allowable LLVM types. Indexed by ICE type. | 54 // The list of allowable LLVM types. Indexed by ICE type. |
| 58 std::vector<llvm::Type *> LLVMTypes; | 55 std::vector<llvm::Type *> LLVMTypes; |
| 59 // The inverse mapping of LLVMTypes. | 56 // The inverse mapping of LLVMTypes. |
| 60 std::map<llvm::Type *, Type> LLVM2IceMap; | 57 std::map<llvm::Type *, Type> LLVM2IceMap; |
| 61 | 58 |
| 62 // Add LLVM/ICE pair to internal tables. | 59 // Add LLVM/ICE pair to internal tables. |
| 63 void addLLVMType(Type Ty, llvm::Type *LLVMTy); | 60 void addLLVMType(Type Ty, llvm::Type *LLVMTy); |
| 64 | 61 |
| 65 // Converts types not in LLVM2IceMap. | 62 // Converts types not in LLVM2IceMap. |
| 66 Type convertToIceTypeOther(llvm::Type *LLVMTy) const; | 63 Type convertToIceTypeOther(llvm::Type *LLVMTy) const; |
| 67 }; | 64 }; |
| 68 | 65 |
| 69 } // end of Ice namespace. | 66 } // end of Ice namespace. |
| 70 | 67 |
| 71 #endif // SUBZERO_SRC_ICETYPECONVERTER_H | 68 #endif // SUBZERO_SRC_ICETYPECONVERTER_H |
| OLD | NEW |