Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 108 |
| 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 bool IsUndefined = false; |
| 119 return Ctx->getConstantSym(Offset, Decl->getName(), | 119 if (const auto *Func = llvm::dyn_cast<Ice::FunctionDeclaration>(Decl)) |
| 120 Decl->getSuppressMangling()); | 120 IsUndefined = Func->isProto(); |
| 121 else if (const auto *Var = llvm::dyn_cast<Ice::VariableDeclaration>(Decl)) | |
| 122 IsUndefined = !Var->hasInitializer(); | |
| 123 else | |
| 124 llvm_unreachable("Unhandled GlobalDeclaration type"); | |
|
Jim Stichnoth
2015/02/02 21:57:26
report_fatal_error
jvoung (off chromium)
2015/02/03 01:53:38
Done.
| |
| 125 if (IsUndefined) | |
| 126 return Ctx->getConstantExternSym(Decl->getName()); | |
| 127 else { | |
| 128 const Ice::RelocOffsetT Offset = 0; | |
| 129 return Ctx->getConstantSym(Offset, Decl->getName(), | |
| 130 Decl->getSuppressMangling()); | |
| 131 } | |
| 121 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) { | 132 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) { |
| 122 Ice::Type Ty = convertToIceType(CI->getType()); | 133 Ice::Type Ty = convertToIceType(CI->getType()); |
| 123 return Ctx->getConstantInt(Ty, CI->getSExtValue()); | 134 return Ctx->getConstantInt(Ty, CI->getSExtValue()); |
| 124 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) { | 135 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) { |
| 125 Ice::Type Type = convertToIceType(CFP->getType()); | 136 Ice::Type Type = convertToIceType(CFP->getType()); |
| 126 if (Type == Ice::IceType_f32) | 137 if (Type == Ice::IceType_f32) |
| 127 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); | 138 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); |
| 128 else if (Type == Ice::IceType_f64) | 139 else if (Type == Ice::IceType_f64) |
| 129 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); | 140 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); |
| 130 llvm_unreachable("Unexpected floating point type"); | 141 llvm_unreachable("Unexpected floating point type"); |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 LLVM2ICEFunctionConverter FunctionConverter(*this); | 896 LLVM2ICEFunctionConverter FunctionConverter(*this); |
| 886 | 897 |
| 887 Cfg *Fcn = FunctionConverter.convertFunction(&I); | 898 Cfg *Fcn = FunctionConverter.convertFunction(&I); |
| 888 translateFcn(Fcn); | 899 translateFcn(Fcn); |
| 889 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) | 900 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) |
| 890 Ctx->popTimer(TimerID, StackID); | 901 Ctx->popTimer(TimerID, StackID); |
| 891 } | 902 } |
| 892 } | 903 } |
| 893 | 904 |
| 894 } // end of namespace Ice | 905 } // end of namespace Ice |
| OLD | NEW |