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

Side by Side Diff: src/IceConverter.cpp

Issue 476323004: Start adding an integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: make fixups part of address Created 6 years, 3 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 | « src/IceClFlags.h ('k') | src/IceFixups.h » ('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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « src/IceClFlags.h ('k') | src/IceFixups.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698