| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 // convertConstant() does not use Func or require it to be a valid | 97 // convertConstant() does not use Func or require it to be a valid |
| 98 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing | 98 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing |
| 99 // global initializers. | 99 // global initializers. |
| 100 Ice::Constant *convertConstant(const Constant *Const) { | 100 Ice::Constant *convertConstant(const Constant *Const) { |
| 101 if (const GlobalValue *GV = dyn_cast<GlobalValue>(Const)) { | 101 if (const GlobalValue *GV = dyn_cast<GlobalValue>(Const)) { |
| 102 return Ctx->getConstantSym(convertToIceType(GV->getType()), 0, | 102 return Ctx->getConstantSym(convertToIceType(GV->getType()), 0, |
| 103 GV->getName()); | 103 GV->getName()); |
| 104 } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(Const)) { | 104 } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(Const)) { |
| 105 return Ctx->getConstantInt(convertToIceType(CI->getType()), | 105 Ice::Type Ty = convertToIceType(CI->getType()); |
| 106 CI->getSExtValue()); | 106 if (Ty == Ice::IceType_i64) { |
| 107 return Ctx->getConstantInt64(Ty, CI->getSExtValue()); |
| 108 } else { |
| 109 return Ctx->getConstantInt32(Ty, CI->getSExtValue()); |
| 110 } |
| 107 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) { | 111 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) { |
| 108 Ice::Type Type = convertToIceType(CFP->getType()); | 112 Ice::Type Type = convertToIceType(CFP->getType()); |
| 109 if (Type == Ice::IceType_f32) | 113 if (Type == Ice::IceType_f32) |
| 110 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); | 114 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); |
| 111 else if (Type == Ice::IceType_f64) | 115 else if (Type == Ice::IceType_f64) |
| 112 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); | 116 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); |
| 113 llvm_unreachable("Unexpected floating point type"); | 117 llvm_unreachable("Unexpected floating point type"); |
| 114 return NULL; | 118 return NULL; |
| 115 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) { | 119 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) { |
| 116 return Ctx->getConstantUndef(convertToIceType(CU->getType())); | 120 return Ctx->getConstantUndef(convertToIceType(CU->getType())); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() | 674 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() |
| 671 << " sec\n"; | 675 << " sec\n"; |
| 672 } | 676 } |
| 673 translateFcn(Fcn); | 677 translateFcn(Fcn); |
| 674 } | 678 } |
| 675 | 679 |
| 676 emitConstants(); | 680 emitConstants(); |
| 677 } | 681 } |
| 678 | 682 |
| 679 } // end of namespace Ice | 683 } // end of namespace Ice |
| OLD | NEW |