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

Side by Side Diff: src/IceInstX8632.cpp

Issue 443203003: Subzero: Use scalar arithmetic when no vector instruction exists. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Minor fixes: whitespace, formatting, variable names, etc. Created 6 years, 4 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
OLDNEW
1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===//
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 InstX8632 and OperandX8632 classes, 10 // This file implements the InstX8632 and OperandX8632 classes,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 InstX8632Label *Label, InstX8632::BrCond Condition) 129 InstX8632Label *Label, InstX8632::BrCond Condition)
130 : InstX8632(Func, InstX8632::Br, 0, NULL), Condition(Condition), 130 : InstX8632(Func, InstX8632::Br, 0, NULL), Condition(Condition),
131 TargetTrue(TargetTrue), TargetFalse(TargetFalse), Label(Label) {} 131 TargetTrue(TargetTrue), TargetFalse(TargetFalse), Label(Label) {}
132 132
133 InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget) 133 InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget)
134 : InstX8632(Func, InstX8632::Call, 1, Dest) { 134 : InstX8632(Func, InstX8632::Call, 1, Dest) {
135 HasSideEffects = true; 135 HasSideEffects = true;
136 addSource(CallTarget); 136 addSource(CallTarget);
137 } 137 }
138 138
139 InstX8632Cdq::InstX8632Cdq(Cfg *Func, Variable *Dest, Operand *Source) 139 InstX8632Cbwdq::InstX8632Cbwdq(Cfg *Func, Variable *Dest, Operand *Source)
140 : InstX8632(Func, InstX8632::Cdq, 1, Dest) { 140 : InstX8632(Func, InstX8632::Cbwdq, 1, Dest) {
141 assert(Dest->getRegNum() == TargetX8632::Reg_edx);
142 assert(llvm::isa<Variable>(Source));
143 assert(llvm::dyn_cast<Variable>(Source)->getRegNum() == TargetX8632::Reg_eax);
144 addSource(Source); 141 addSource(Source);
145 } 142 }
146 143
147 InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, 144 InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source,
148 InstX8632::BrCond Condition) 145 InstX8632::BrCond Condition)
149 : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) { 146 : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) {
150 // The final result is either the original Dest, or Source, so mark 147 // The final result is either the original Dest, or Source, so mark
151 // both as sources. 148 // both as sources.
152 addSource(Dest); 149 addSource(Dest);
153 addSource(Source); 150 addSource(Source);
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 Str << "\n"; 711 Str << "\n";
715 } 712 }
716 713
717 void InstX8632Shrd::dump(const Cfg *Func) const { 714 void InstX8632Shrd::dump(const Cfg *Func) const {
718 Ostream &Str = Func->getContext()->getStrDump(); 715 Ostream &Str = Func->getContext()->getStrDump();
719 dumpDest(Func); 716 dumpDest(Func);
720 Str << " = shrd." << getDest()->getType() << " "; 717 Str << " = shrd." << getDest()->getType() << " ";
721 dumpSources(Func); 718 dumpSources(Func);
722 } 719 }
723 720
724 void InstX8632Cdq::emit(const Cfg *Func) const { 721 void InstX8632Cbwdq::emit(const Cfg *Func) const {
725 Ostream &Str = Func->getContext()->getStrEmit(); 722 Ostream &Str = Func->getContext()->getStrEmit();
726 assert(getSrcSize() == 1); 723 assert(getSrcSize() == 1);
727 Str << "\tcdq\n"; 724 Variable *Dest = getDest();
725 (void)Dest;
726 Operand *Src0 = getSrc(0);
727 assert(llvm::isa<Variable>(Dest));
Jim Stichnoth 2014/08/07 19:58:10 This is redundant, since Dest is types as a Variab
wala 2014/08/07 20:30:35 Woops, done.
728 assert(llvm::isa<Variable>(Src0));
729 assert(llvm::cast<Variable>(Src0)->getRegNum() == TargetX8632::Reg_eax);
730 switch (Src0->getType()) {
731 default:
732 llvm_unreachable("unexpected source type!");
733 break;
734 case IceType_i8:
735 assert(llvm::cast<Variable>(Dest)->getRegNum() == TargetX8632::Reg_eax);
Jim Stichnoth 2014/08/07 19:58:10 Don't need to cast Dest to Variable, here and belo
wala 2014/08/07 20:30:35 Done.
736 Str << "\tcbw\n";
737 break;
738 case IceType_i16:
739 assert(llvm::cast<Variable>(Dest)->getRegNum() == TargetX8632::Reg_edx);
740 Str << "\tcwd\n";
741 break;
742 case IceType_i32:
743 assert(llvm::cast<Variable>(Dest)->getRegNum() == TargetX8632::Reg_edx);
744 Str << "\tcdq\n";
745 break;
746 }
728 } 747 }
729 748
730 void InstX8632Cdq::dump(const Cfg *Func) const { 749 void InstX8632Cbwdq::dump(const Cfg *Func) const {
731 Ostream &Str = Func->getContext()->getStrDump(); 750 Ostream &Str = Func->getContext()->getStrDump();
732 dumpDest(Func); 751 dumpDest(Func);
733 Str << " = cdq." << getSrc(0)->getType() << " "; 752 Str << " = cbw/cwd/cdq." << getSrc(0)->getType() << " ";
734 dumpSources(Func); 753 dumpSources(Func);
735 } 754 }
736 755
737 void InstX8632Cmov::emit(const Cfg *Func) const { 756 void InstX8632Cmov::emit(const Cfg *Func) const {
738 Ostream &Str = Func->getContext()->getStrEmit(); 757 Ostream &Str = Func->getContext()->getStrEmit();
739 Str << "\t"; 758 Str << "\t";
740 assert(Condition != Br_None); 759 assert(Condition != Br_None);
741 assert(getDest()->hasReg()); 760 assert(getDest()->hasReg());
742 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "\t"; 761 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "\t";
743 getDest()->emit(Func); 762 getDest()->emit(Func);
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 default: 1486 default:
1468 Str << "???"; 1487 Str << "???";
1469 break; 1488 break;
1470 } 1489 }
1471 Str << "("; 1490 Str << "(";
1472 Var->dump(Func); 1491 Var->dump(Func);
1473 Str << ")"; 1492 Str << ")";
1474 } 1493 }
1475 1494
1476 } // end of namespace Ice 1495 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698