| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 return Ctx->getConstantInt(Ty, CI->getSExtValue()); |
| 125 return Ctx->getConstantInt64(Ty, CI->getSExtValue()); | |
| 126 } else { | |
| 127 return Ctx->getConstantInt32(Ty, CI->getSExtValue()); | |
| 128 } | |
| 129 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) { | 124 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) { |
| 130 Ice::Type Type = convertToIceType(CFP->getType()); | 125 Ice::Type Type = convertToIceType(CFP->getType()); |
| 131 if (Type == Ice::IceType_f32) | 126 if (Type == Ice::IceType_f32) |
| 132 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); | 127 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); |
| 133 else if (Type == Ice::IceType_f64) | 128 else if (Type == Ice::IceType_f64) |
| 134 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); | 129 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); |
| 135 llvm_unreachable("Unexpected floating point type"); | 130 llvm_unreachable("Unexpected floating point type"); |
| 136 return nullptr; | 131 return nullptr; |
| 137 } else if (const auto CU = dyn_cast<UndefValue>(Const)) { | 132 } else if (const auto CU = dyn_cast<UndefValue>(Const)) { |
| 138 return Ctx->getConstantUndef(convertToIceType(CU->getType())); | 133 return Ctx->getConstantUndef(convertToIceType(CU->getType())); |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 Cfg *Fcn = FunctionConverter.convertFunction(&I); | 892 Cfg *Fcn = FunctionConverter.convertFunction(&I); |
| 898 translateFcn(Fcn); | 893 translateFcn(Fcn); |
| 899 if (Ctx->getFlags().TimeEachFunction) | 894 if (Ctx->getFlags().TimeEachFunction) |
| 900 Ctx->popTimer(TimerID, StackID); | 895 Ctx->popTimer(TimerID, StackID); |
| 901 } | 896 } |
| 902 | 897 |
| 903 emitConstants(); | 898 emitConstants(); |
| 904 } | 899 } |
| 905 | 900 |
| 906 } // end of namespace Ice | 901 } // end of namespace Ice |
| OLD | NEW |