OLD | NEW |
1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// | 1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// |
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 implements the LLVM to ICE converter. | 10 // This file implements the LLVM to ICE converter. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return Ice::IceType_i32; | 158 return Ice::IceType_i32; |
159 case 64: | 159 case 64: |
160 return Ice::IceType_i64; | 160 return Ice::IceType_i64; |
161 default: | 161 default: |
162 report_fatal_error(std::string("Invalid PNaCl int type: ") + | 162 report_fatal_error(std::string("Invalid PNaCl int type: ") + |
163 LLVMObjectAsString(IntTy)); | 163 LLVMObjectAsString(IntTy)); |
164 return Ice::IceType_void; | 164 return Ice::IceType_void; |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
| 168 Ice::Type convertVectorType(const VectorType *VecTy) const { |
| 169 unsigned NumElements = VecTy->getNumElements(); |
| 170 const Type *ElementType = VecTy->getElementType(); |
| 171 |
| 172 if (ElementType->isFloatTy()) { |
| 173 if (NumElements == 4) |
| 174 return Ice::IceType_v4f32; |
| 175 } else if (ElementType->isIntegerTy()) { |
| 176 switch (cast<IntegerType>(ElementType)->getBitWidth()) { |
| 177 case 1: |
| 178 if (NumElements == 4) |
| 179 return Ice::IceType_v4i1; |
| 180 if (NumElements == 8) |
| 181 return Ice::IceType_v8i1; |
| 182 if (NumElements == 16) |
| 183 return Ice::IceType_v16i1; |
| 184 break; |
| 185 case 8: |
| 186 if (NumElements == 16) |
| 187 return Ice::IceType_v16i8; |
| 188 break; |
| 189 case 16: |
| 190 if (NumElements == 8) |
| 191 return Ice::IceType_v8i16; |
| 192 break; |
| 193 case 32: |
| 194 if (NumElements == 4) |
| 195 return Ice::IceType_v4i32; |
| 196 break; |
| 197 } |
| 198 } |
| 199 |
| 200 report_fatal_error(std::string("Unhandled vector type: ") + |
| 201 LLVMObjectAsString(VecTy)); |
| 202 return Ice::IceType_void; |
| 203 } |
| 204 |
168 Ice::Type convertType(const Type *Ty) const { | 205 Ice::Type convertType(const Type *Ty) const { |
169 switch (Ty->getTypeID()) { | 206 switch (Ty->getTypeID()) { |
170 case Type::VoidTyID: | 207 case Type::VoidTyID: |
171 return Ice::IceType_void; | 208 return Ice::IceType_void; |
172 case Type::IntegerTyID: | 209 case Type::IntegerTyID: |
173 return convertIntegerType(cast<IntegerType>(Ty)); | 210 return convertIntegerType(cast<IntegerType>(Ty)); |
174 case Type::FloatTyID: | 211 case Type::FloatTyID: |
175 return Ice::IceType_f32; | 212 return Ice::IceType_f32; |
176 case Type::DoubleTyID: | 213 case Type::DoubleTyID: |
177 return Ice::IceType_f64; | 214 return Ice::IceType_f64; |
178 case Type::PointerTyID: | 215 case Type::PointerTyID: |
179 return SubzeroPointerType; | 216 return SubzeroPointerType; |
180 case Type::FunctionTyID: | 217 case Type::FunctionTyID: |
181 return SubzeroPointerType; | 218 return SubzeroPointerType; |
| 219 case Type::VectorTyID: |
| 220 return convertVectorType(cast<VectorType>(Ty)); |
182 default: | 221 default: |
183 report_fatal_error(std::string("Invalid PNaCl type: ") + | 222 report_fatal_error(std::string("Invalid PNaCl type: ") + |
184 LLVMObjectAsString(Ty)); | 223 LLVMObjectAsString(Ty)); |
185 } | 224 } |
186 | 225 |
187 llvm_unreachable("convertType"); | 226 llvm_unreachable("convertType"); |
188 return Ice::IceType_void; | 227 return Ice::IceType_void; |
189 } | 228 } |
190 | 229 |
191 // Given an LLVM instruction and an operand number, produce the | 230 // Given an LLVM instruction and an operand number, produce the |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 << " sec\n"; | 709 << " sec\n"; |
671 } | 710 } |
672 } | 711 } |
673 } | 712 } |
674 | 713 |
675 if (!DisableTranslation && Func) | 714 if (!DisableTranslation && Func) |
676 Func->getTarget()->emitConstants(); | 715 Func->getTarget()->emitConstants(); |
677 | 716 |
678 return ExitStatus; | 717 return ExitStatus; |
679 } | 718 } |
OLD | NEW |