Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: src/IceTypeConverter.cpp

Issue 624663002: Introduce model of global initializers in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTypeConverter.h ('k') | src/PNaClTranslator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTypeConverter.cpp - Convert ICE/LLVM Types ----------===// 1 //===- subzero/src/IceTypeConverter.cpp - Convert ICE/LLVM Types ----------===//
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 how to convert LLVM types to ICE types, and ICE types 10 // This file implements how to convert LLVM types to ICE types, and ICE types
11 // to LLVM types. 11 // to LLVM types.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "llvm/Support/raw_ostream.h" 15 #include "llvm/Support/raw_ostream.h"
16 16
17 #include "IceTypeConverter.h" 17 #include "IceTypeConverter.h"
18 18
19 namespace Ice { 19 namespace Ice {
20 20
21 TypeConverter::TypeConverter(llvm::LLVMContext &Context) { 21 TypeConverter::TypeConverter(llvm::LLVMContext &Context) {
22 AddLLVMType(IceType_void, llvm::Type::getVoidTy(Context)); 22 addLLVMType(IceType_void, llvm::Type::getVoidTy(Context));
23 AddLLVMType(IceType_i1, llvm::IntegerType::get(Context, 1)); 23 addLLVMType(IceType_i1, llvm::IntegerType::get(Context, 1));
24 AddLLVMType(IceType_i8, llvm::IntegerType::get(Context, 8)); 24 addLLVMType(IceType_i8, llvm::IntegerType::get(Context, 8));
25 AddLLVMType(IceType_i16, llvm::IntegerType::get(Context, 16)); 25 addLLVMType(IceType_i16, llvm::IntegerType::get(Context, 16));
26 AddLLVMType(IceType_i32, llvm::IntegerType::get(Context, 32)); 26 addLLVMType(IceType_i32, llvm::IntegerType::get(Context, 32));
27 AddLLVMType(IceType_i64, llvm::IntegerType::get(Context, 64)); 27 addLLVMType(IceType_i64, llvm::IntegerType::get(Context, 64));
28 AddLLVMType(IceType_f32, llvm::Type::getFloatTy(Context)); 28 addLLVMType(IceType_f32, llvm::Type::getFloatTy(Context));
29 AddLLVMType(IceType_f64, llvm::Type::getDoubleTy(Context)); 29 addLLVMType(IceType_f64, llvm::Type::getDoubleTy(Context));
30 AddLLVMType(IceType_v4i1, llvm::VectorType::get(LLVMTypes[IceType_i1], 4)); 30 addLLVMType(IceType_v4i1, llvm::VectorType::get(LLVMTypes[IceType_i1], 4));
31 AddLLVMType(IceType_v8i1, llvm::VectorType::get(LLVMTypes[IceType_i1], 8)); 31 addLLVMType(IceType_v8i1, llvm::VectorType::get(LLVMTypes[IceType_i1], 8));
32 AddLLVMType(IceType_v16i1, llvm::VectorType::get(LLVMTypes[IceType_i1], 16)); 32 addLLVMType(IceType_v16i1, llvm::VectorType::get(LLVMTypes[IceType_i1], 16));
33 AddLLVMType(IceType_v16i8, llvm::VectorType::get(LLVMTypes[IceType_i8], 16)); 33 addLLVMType(IceType_v16i8, llvm::VectorType::get(LLVMTypes[IceType_i8], 16));
34 AddLLVMType(IceType_v8i16, llvm::VectorType::get(LLVMTypes[IceType_i16], 8)); 34 addLLVMType(IceType_v8i16, llvm::VectorType::get(LLVMTypes[IceType_i16], 8));
35 AddLLVMType(IceType_v4i32, llvm::VectorType::get(LLVMTypes[IceType_i32], 4)); 35 addLLVMType(IceType_v4i32, llvm::VectorType::get(LLVMTypes[IceType_i32], 4));
36 AddLLVMType(IceType_v4f32, llvm::VectorType::get(LLVMTypes[IceType_f32], 4)); 36 addLLVMType(IceType_v4f32, llvm::VectorType::get(LLVMTypes[IceType_f32], 4));
37 assert(LLVMTypes.size() == static_cast<size_t>(IceType_NUM)); 37 assert(LLVMTypes.size() == static_cast<size_t>(IceType_NUM));
38 } 38 }
39 39
40 void TypeConverter::AddLLVMType(Type Ty, llvm::Type *LLVMTy) { 40 void TypeConverter::addLLVMType(Type Ty, llvm::Type *LLVMTy) {
41 assert(static_cast<size_t>(Ty) == LLVMTypes.size()); 41 assert(static_cast<size_t>(Ty) == LLVMTypes.size());
42 LLVMTypes.push_back(LLVMTy); 42 LLVMTypes.push_back(LLVMTy);
43 LLVM2IceMap[LLVMTy] = Ty; 43 LLVM2IceMap[LLVMTy] = Ty;
44 } 44 }
45 45
46 Type TypeConverter::convertToIceTypeOther(llvm::Type *LLVMTy) const { 46 Type TypeConverter::convertToIceTypeOther(llvm::Type *LLVMTy) const {
47 switch (LLVMTy->getTypeID()) { 47 switch (LLVMTy->getTypeID()) {
48 case llvm::Type::PointerTyID: 48 case llvm::Type::PointerTyID:
49 case llvm::Type::FunctionTyID: 49 case llvm::Type::FunctionTyID:
50 return getIcePointerType(); 50 return getIcePointerType();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (Size == 4) 100 if (Size == 4)
101 return convertToLLVMType(IceType_v4f32); 101 return convertToLLVMType(IceType_v4f32);
102 break; 102 break;
103 default: 103 default:
104 break; 104 break;
105 } 105 }
106 return NULL; 106 return NULL;
107 } 107 }
108 108
109 } // end of Ice namespace. 109 } // end of Ice namespace.
OLDNEW
« no previous file with comments | « src/IceTypeConverter.h ('k') | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698