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

Side by Side Diff: src/IceConverter.cpp

Issue 737513008: Subzero: Simplify the constant pools. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More cleanup Created 6 years, 1 month 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 | « no previous file | src/IceGlobalContext.h » ('j') | src/IceGlobalContext.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return Func; 109 return Func;
110 } 110 }
111 111
112 // convertConstant() does not use Func or require it to be a valid 112 // convertConstant() does not use Func or require it to be a valid
113 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing 113 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing
114 // global initializers. 114 // global initializers.
115 Ice::Constant *convertConstant(const Constant *Const) { 115 Ice::Constant *convertConstant(const Constant *Const) {
116 if (const auto GV = dyn_cast<GlobalValue>(Const)) { 116 if (const auto GV = dyn_cast<GlobalValue>(Const)) {
117 Ice::GlobalDeclaration *Decl = getConverter().getGlobalDeclaration(GV); 117 Ice::GlobalDeclaration *Decl = getConverter().getGlobalDeclaration(GV);
118 const Ice::RelocOffsetT Offset = 0; 118 const Ice::RelocOffsetT Offset = 0;
119 return Ctx->getConstantSym(TypeConverter.getIcePointerType(), 119 return Ctx->getConstantSym(Offset, Decl->getName(),
120 Offset, Decl->getName(),
121 Decl->getSuppressMangling()); 120 Decl->getSuppressMangling());
122 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) { 121 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) {
123 Ice::Type Ty = convertToIceType(CI->getType()); 122 Ice::Type Ty = convertToIceType(CI->getType());
124 if (Ty == Ice::IceType_i64) { 123 switch (Ty) {
Karl 2014/11/19 18:45:28 Why not move this switch into IceGlobalcontext.{h,
Jim Stichnoth 2014/11/20 00:08:57 Done.
125 return Ctx->getConstantInt64(Ty, CI->getSExtValue()); 124 default:
126 } else { 125 llvm_unreachable("Unhandled constant integer type");
127 return Ctx->getConstantInt32(Ty, CI->getSExtValue()); 126 return nullptr;
127 case Ice::IceType_i1:
128 return Ctx->getConstantInt1(CI->getSExtValue());
129 case Ice::IceType_i8:
130 return Ctx->getConstantInt8(CI->getSExtValue());
131 case Ice::IceType_i16:
132 return Ctx->getConstantInt16(CI->getSExtValue());
133 case Ice::IceType_i32:
134 return Ctx->getConstantInt32(CI->getSExtValue());
135 case Ice::IceType_i64:
136 return Ctx->getConstantInt64(CI->getSExtValue());
128 } 137 }
129 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) { 138 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) {
130 Ice::Type Type = convertToIceType(CFP->getType()); 139 Ice::Type Type = convertToIceType(CFP->getType());
131 if (Type == Ice::IceType_f32) 140 if (Type == Ice::IceType_f32)
132 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); 141 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat());
133 else if (Type == Ice::IceType_f64) 142 else if (Type == Ice::IceType_f64)
134 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); 143 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble());
135 llvm_unreachable("Unexpected floating point type"); 144 llvm_unreachable("Unexpected floating point type");
136 return nullptr; 145 return nullptr;
137 } else if (const auto CU = dyn_cast<UndefValue>(Const)) { 146 } else if (const auto CU = dyn_cast<UndefValue>(Const)) {
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 Cfg *Fcn = FunctionConverter.convertFunction(&I); 906 Cfg *Fcn = FunctionConverter.convertFunction(&I);
898 translateFcn(Fcn); 907 translateFcn(Fcn);
899 if (Ctx->getFlags().TimeEachFunction) 908 if (Ctx->getFlags().TimeEachFunction)
900 Ctx->popTimer(TimerID, StackID); 909 Ctx->popTimer(TimerID, StackID);
901 } 910 }
902 911
903 emitConstants(); 912 emitConstants();
904 } 913 }
905 914
906 } // end of namespace Ice 915 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceGlobalContext.h » ('j') | src/IceGlobalContext.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698