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

Side by Side Diff: src/IceConverter.cpp

Issue 899483002: Subzero: Track protos + globals w/out initializers as undef too (not just helper funcs) (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: rebase Created 5 years, 10 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 | « no previous file | src/IceELFObjectWriter.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/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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 Ice::Cfg::setCurrentCfg(nullptr); 114 Ice::Cfg::setCurrentCfg(nullptr);
115 Converter.translateFcn(std::move(Func)); 115 Converter.translateFcn(std::move(Func));
116 } 116 }
117 117
118 // convertConstant() does not use Func or require it to be a valid 118 // convertConstant() does not use Func or require it to be a valid
119 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing 119 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing
120 // global initializers. 120 // global initializers.
121 Ice::Constant *convertConstant(const Constant *Const) { 121 Ice::Constant *convertConstant(const Constant *Const) {
122 if (const auto GV = dyn_cast<GlobalValue>(Const)) { 122 if (const auto GV = dyn_cast<GlobalValue>(Const)) {
123 Ice::GlobalDeclaration *Decl = getConverter().getGlobalDeclaration(GV); 123 Ice::GlobalDeclaration *Decl = getConverter().getGlobalDeclaration(GV);
124 const Ice::RelocOffsetT Offset = 0; 124 bool IsUndefined = false;
125 return Ctx->getConstantSym(Offset, Decl->getName(), 125 if (const auto *Func = llvm::dyn_cast<Ice::FunctionDeclaration>(Decl))
126 Decl->getSuppressMangling()); 126 IsUndefined = Func->isProto();
127 else if (const auto *Var = llvm::dyn_cast<Ice::VariableDeclaration>(Decl))
128 IsUndefined = !Var->hasInitializer();
129 else
130 report_fatal_error("Unhandled GlobalDeclaration type");
131 if (IsUndefined)
132 return Ctx->getConstantExternSym(Decl->getName());
133 else {
134 const Ice::RelocOffsetT Offset = 0;
135 return Ctx->getConstantSym(Offset, Decl->getName(),
136 Decl->getSuppressMangling());
137 }
127 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) { 138 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) {
128 Ice::Type Ty = convertToIceType(CI->getType()); 139 Ice::Type Ty = convertToIceType(CI->getType());
129 return Ctx->getConstantInt(Ty, CI->getSExtValue()); 140 return Ctx->getConstantInt(Ty, CI->getSExtValue());
130 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) { 141 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) {
131 Ice::Type Type = convertToIceType(CFP->getType()); 142 Ice::Type Type = convertToIceType(CFP->getType());
132 if (Type == Ice::IceType_f32) 143 if (Type == Ice::IceType_f32)
133 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); 144 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat());
134 else if (Type == Ice::IceType_f64) 145 else if (Type == Ice::IceType_f64)
135 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); 146 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble());
136 llvm_unreachable("Unexpected floating point type"); 147 llvm_unreachable("Unexpected floating point type");
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 Ctx->pushTimer(TimerID, StackID); 902 Ctx->pushTimer(TimerID, StackID);
892 } 903 }
893 LLVM2ICEFunctionConverter FunctionConverter(*this); 904 LLVM2ICEFunctionConverter FunctionConverter(*this);
894 FunctionConverter.convertFunction(&I); 905 FunctionConverter.convertFunction(&I);
895 if (TimeThisFunction) 906 if (TimeThisFunction)
896 Ctx->popTimer(TimerID, StackID); 907 Ctx->popTimer(TimerID, StackID);
897 } 908 }
898 } 909 }
899 910
900 } // end of namespace Ice 911 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceELFObjectWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698