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

Side by Side Diff: src/IceInstX8632.cpp

Issue 353553004: Add support for vector types and vector constants. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: 1) Fix alignment in type table. 2) Add VECT128_BYTES constant. 3) add _movp() function. Created 6 years, 5 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 : InstX8632(Func, InstX8632::Store, 2, NULL) { 175 : InstX8632(Func, InstX8632::Store, 2, NULL) {
176 addSource(Value); 176 addSource(Value);
177 addSource(Mem); 177 addSource(Mem);
178 } 178 }
179 179
180 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source) 180 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source)
181 : InstX8632(Func, InstX8632::Mov, 1, Dest) { 181 : InstX8632(Func, InstX8632::Mov, 1, Dest) {
182 addSource(Source); 182 addSource(Source);
183 } 183 }
184 184
185 InstX8632Movp::InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source)
186 : InstX8632(Func, InstX8632::Movp, 1, Dest) {
187 addSource(Source);
188 }
189
185 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem) 190 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem)
186 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) { 191 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) {
187 addSource(Value); 192 addSource(Value);
188 addSource(Mem); 193 addSource(Mem);
189 } 194 }
190 195
191 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source) 196 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source)
192 : InstX8632(Func, InstX8632::Movq, 1, Dest) { 197 : InstX8632(Func, InstX8632::Movq, 1, Dest) {
193 addSource(Source); 198 addSource(Source);
194 } 199 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // clear the upper 32 bits of rax. We need to recognize and 235 // clear the upper 32 bits of rax. We need to recognize and
231 // preserve these. 236 // preserve these.
232 return true; 237 return true;
233 } 238 }
234 if (!getDest()->hasReg() && !Src->hasReg() && 239 if (!getDest()->hasReg() && !Src->hasReg() &&
235 Dest->getStackOffset() == Src->getStackOffset()) 240 Dest->getStackOffset() == Src->getStackOffset())
236 return true; 241 return true;
237 return false; 242 return false;
238 } 243 }
239 244
245 bool InstX8632Movp::isRedundantAssign() const {
jvoung (off chromium) 2014/06/26 23:33:46 At some point, we should just have a base implemen
wala 2014/06/27 21:09:19 I'll add a TODO...
246 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0));
247 if (Src == NULL)
248 return false;
249 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) {
250 return true;
251 }
252 if (!getDest()->hasReg() && !Src->hasReg() &&
253 Dest->getStackOffset() == Src->getStackOffset())
254 return true;
255 return false;
256 }
257
240 bool InstX8632Movq::isRedundantAssign() const { 258 bool InstX8632Movq::isRedundantAssign() const {
241 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); 259 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0));
242 if (Src == NULL) 260 if (Src == NULL)
243 return false; 261 return false;
244 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { 262 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) {
245 return true; 263 return true;
246 } 264 }
247 if (!getDest()->hasReg() && !Src->hasReg() && 265 if (!getDest()->hasReg() && !Src->hasReg() &&
248 Dest->getStackOffset() == Src->getStackOffset()) 266 Dest->getStackOffset() == Src->getStackOffset())
249 return true; 267 return true;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 691 }
674 692
675 void InstX8632Mov::dump(const Cfg *Func) const { 693 void InstX8632Mov::dump(const Cfg *Func) const {
676 Ostream &Str = Func->getContext()->getStrDump(); 694 Ostream &Str = Func->getContext()->getStrDump();
677 Str << "mov." << getDest()->getType() << " "; 695 Str << "mov." << getDest()->getType() << " ";
678 dumpDest(Func); 696 dumpDest(Func);
679 Str << ", "; 697 Str << ", ";
680 dumpSources(Func); 698 dumpSources(Func);
681 } 699 }
682 700
701 void InstX8632Movp::emit(const Cfg *Func) const {
702 // TODO(wala): movups works with all vector operands, but there exist
Jim Stichnoth 2014/06/27 18:30:16 maybe TODO(wala,stichnot) just in case
703 // other instructions (movaps, movdqa, movdqu) that may perform
704 // better, depending on the data type and alignment of the operands.
705 Ostream &Str = Func->getContext()->getStrEmit();
706 assert(getSrcSize() == 1);
707 Str << "\tmovups\t";
708 getDest()->emit(Func);
709 Str << ", ";
710 getSrc(0)->emit(Func);
711 Str << "\n";
712 }
713
683 void InstX8632Movq::emit(const Cfg *Func) const { 714 void InstX8632Movq::emit(const Cfg *Func) const {
684 Ostream &Str = Func->getContext()->getStrEmit(); 715 Ostream &Str = Func->getContext()->getStrEmit();
685 assert(getSrcSize() == 1); 716 assert(getSrcSize() == 1);
686 assert(getDest()->getType() == IceType_i64 || 717 assert(getDest()->getType() == IceType_i64 ||
687 getDest()->getType() == IceType_f64); 718 getDest()->getType() == IceType_f64);
688 Str << "\tmovq\t"; 719 Str << "\tmovq\t";
689 getDest()->emit(Func); 720 getDest()->emit(Func);
690 Str << ", "; 721 Str << ", ";
691 getSrc(0)->emit(Func); 722 getSrc(0)->emit(Func);
692 Str << "\n"; 723 Str << "\n";
693 } 724 }
694 725
726 void InstX8632Movp::dump(const Cfg *Func) const {
727 Ostream &Str = Func->getContext()->getStrDump();
728 Str << "movups." << getDest()->getType() << " ";
729 dumpDest(Func);
730 Str << ", ";
731 dumpSources(Func);
732 }
733
695 void InstX8632Movq::dump(const Cfg *Func) const { 734 void InstX8632Movq::dump(const Cfg *Func) const {
696 Ostream &Str = Func->getContext()->getStrDump(); 735 Ostream &Str = Func->getContext()->getStrDump();
697 Str << "movq." << getDest()->getType() << " "; 736 Str << "movq." << getDest()->getType() << " ";
698 dumpDest(Func); 737 dumpDest(Func);
699 Str << ", "; 738 Str << ", ";
700 dumpSources(Func); 739 dumpSources(Func);
701 } 740 }
702 741
703 void InstX8632Movsx::emit(const Cfg *Func) const { 742 void InstX8632Movsx::emit(const Cfg *Func) const {
704 Ostream &Str = Func->getContext()->getStrEmit(); 743 Ostream &Str = Func->getContext()->getStrEmit();
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 default: 1050 default:
1012 Str << "???"; 1051 Str << "???";
1013 break; 1052 break;
1014 } 1053 }
1015 Str << "("; 1054 Str << "(";
1016 Var->dump(Func); 1055 Var->dump(Func);
1017 Str << ")"; 1056 Str << ")";
1018 } 1057 }
1019 1058
1020 } // end of namespace Ice 1059 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698