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

Side by Side Diff: src/IceConverter.cpp

Issue 539743002: Subzero: Render constants in dump() to be more like LLVM. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: 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 | « no previous file | src/IceInst.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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 return Ctx->getConstantInt(convertToIceType(CI->getType()),
106 CI->getZExtValue()); 106 CI->getSExtValue());
107 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) { 107 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) {
108 Ice::Type Type = convertToIceType(CFP->getType()); 108 Ice::Type Type = convertToIceType(CFP->getType());
109 if (Type == Ice::IceType_f32) 109 if (Type == Ice::IceType_f32)
110 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); 110 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat());
111 else if (Type == Ice::IceType_f64) 111 else if (Type == Ice::IceType_f64)
112 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); 112 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble());
113 llvm_unreachable("Unexpected floating point type"); 113 llvm_unreachable("Unexpected floating point type");
114 return NULL; 114 return NULL;
115 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) { 115 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) {
116 return Ctx->getConstantUndef(convertToIceType(CU->getType())); 116 return Ctx->getConstantUndef(convertToIceType(CU->getType()));
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 490
491 Ice::Inst *convertSwitchInstruction(const SwitchInst *Inst) { 491 Ice::Inst *convertSwitchInstruction(const SwitchInst *Inst) {
492 Ice::Operand *Source = convertValue(Inst->getCondition()); 492 Ice::Operand *Source = convertValue(Inst->getCondition());
493 Ice::CfgNode *LabelDefault = mapBasicBlockToNode(Inst->getDefaultDest()); 493 Ice::CfgNode *LabelDefault = mapBasicBlockToNode(Inst->getDefaultDest());
494 unsigned NumCases = Inst->getNumCases(); 494 unsigned NumCases = Inst->getNumCases();
495 Ice::InstSwitch *Switch = 495 Ice::InstSwitch *Switch =
496 Ice::InstSwitch::create(Func, NumCases, Source, LabelDefault); 496 Ice::InstSwitch::create(Func, NumCases, Source, LabelDefault);
497 unsigned CurrentCase = 0; 497 unsigned CurrentCase = 0;
498 for (SwitchInst::ConstCaseIt I = Inst->case_begin(), E = Inst->case_end(); 498 for (SwitchInst::ConstCaseIt I = Inst->case_begin(), E = Inst->case_end();
499 I != E; ++I, ++CurrentCase) { 499 I != E; ++I, ++CurrentCase) {
500 uint64_t CaseValue = I.getCaseValue()->getZExtValue(); 500 uint64_t CaseValue = I.getCaseValue()->getSExtValue();
501 Ice::CfgNode *CaseSuccessor = mapBasicBlockToNode(I.getCaseSuccessor()); 501 Ice::CfgNode *CaseSuccessor = mapBasicBlockToNode(I.getCaseSuccessor());
502 Switch->addBranch(CurrentCase, CaseValue, CaseSuccessor); 502 Switch->addBranch(CurrentCase, CaseValue, CaseSuccessor);
503 } 503 }
504 return Switch; 504 return Switch;
505 } 505 }
506 506
507 Ice::Inst *convertCallInstruction(const CallInst *Inst) { 507 Ice::Inst *convertCallInstruction(const CallInst *Inst) {
508 Ice::Variable *Dest = mapValueToIceVar(Inst); 508 Ice::Variable *Dest = mapValueToIceVar(Inst);
509 Ice::Operand *CallTarget = convertValue(Inst->getCalledValue()); 509 Ice::Operand *CallTarget = convertValue(Inst->getCalledValue());
510 unsigned NumArgs = Inst->getNumArgOperands(); 510 unsigned NumArgs = Inst->getNumArgOperands();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() 669 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec()
670 << " sec\n"; 670 << " sec\n";
671 } 671 }
672 translateFcn(Fcn); 672 translateFcn(Fcn);
673 } 673 }
674 674
675 emitConstants(); 675 emitConstants();
676 } 676 }
677 677
678 } // end of namespace Ice 678 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceInst.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698