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

Side by Side Diff: src/IceInstMIPS32.cpp

Issue 1716483003: Subzero: implement 64 bit multiply in mips32 (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: changes suggested by stichnot Created 4 years, 10 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/IceInstMIPS32.h ('k') | src/IceInstMIPS32.def » ('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/IceInstMips32.cpp - Mips32 instruction implementation --===// 1 //===- subzero/src/IceInstMips32.cpp - Mips32 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 /// \file 10 /// \file
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return "TBD"; 49 return "TBD";
50 } 50 }
51 51
52 template <> const char *InstMIPS32Addiu::Opcode = "addiu"; 52 template <> const char *InstMIPS32Addiu::Opcode = "addiu";
53 template <> const char *InstMIPS32Lui::Opcode = "lui"; 53 template <> const char *InstMIPS32Lui::Opcode = "lui";
54 template <> const char *InstMIPS32La::Opcode = "la"; 54 template <> const char *InstMIPS32La::Opcode = "la";
55 // Three-addr ops 55 // Three-addr ops
56 template <> const char *InstMIPS32Add::Opcode = "add"; 56 template <> const char *InstMIPS32Add::Opcode = "add";
57 template <> const char *InstMIPS32Addu::Opcode = "addu"; 57 template <> const char *InstMIPS32Addu::Opcode = "addu";
58 template <> const char *InstMIPS32And::Opcode = "and"; 58 template <> const char *InstMIPS32And::Opcode = "and";
59 template <> const char *InstMIPS32Mfhi::Opcode = "mfhi";
60 template <> const char *InstMIPS32Mflo::Opcode = "mflo";
61 template <> const char *InstMIPS32Mthi::Opcode = "mthi";
62 template <> const char *InstMIPS32Mtlo::Opcode = "mtlo";
59 template <> const char *InstMIPS32Mul::Opcode = "mul"; 63 template <> const char *InstMIPS32Mul::Opcode = "mul";
64 template <> const char *InstMIPS32Mult::Opcode = "mult";
65 template <> const char *InstMIPS32Multu::Opcode = "multu";
60 template <> const char *InstMIPS32Or::Opcode = "or"; 66 template <> const char *InstMIPS32Or::Opcode = "or";
61 template <> const char *InstMIPS32Ori::Opcode = "ori"; 67 template <> const char *InstMIPS32Ori::Opcode = "ori";
62 template <> const char *InstMIPS32Sltu::Opcode = "sltu"; 68 template <> const char *InstMIPS32Sltu::Opcode = "sltu";
63 template <> const char *InstMIPS32Sub::Opcode = "sub"; 69 template <> const char *InstMIPS32Sub::Opcode = "sub";
64 template <> const char *InstMIPS32Subu::Opcode = "subu"; 70 template <> const char *InstMIPS32Subu::Opcode = "subu";
65 template <> const char *InstMIPS32Xor::Opcode = "xor"; 71 template <> const char *InstMIPS32Xor::Opcode = "xor";
66 72
73 template <> void InstMIPS32Mflo::emit(const Cfg *Func) const {
74 if (!BuildDefs::dump())
75 return;
76 emitUnaryopGPRFLoHi(Opcode, this, Func);
77 }
78
79 template <> void InstMIPS32Mfhi::emit(const Cfg *Func) const {
80 if (!BuildDefs::dump())
81 return;
82 emitUnaryopGPRFLoHi(Opcode, this, Func);
83 }
84
85 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const {
86 if (!BuildDefs::dump())
87 return;
88 emitUnaryopGPRTLoHi(Opcode, this, Func);
89 }
90
91 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const {
92 if (!BuildDefs::dump())
93 return;
94 emitUnaryopGPRTLoHi(Opcode, this, Func);
95 }
96
97 template <> void InstMIPS32Mult::emit(const Cfg *Func) const {
98 if (!BuildDefs::dump())
99 return;
100 emitThreeAddrLoHi(Opcode, this, Func);
101 }
102
103 template <> void InstMIPS32Multu::emit(const Cfg *Func) const {
104 if (!BuildDefs::dump())
105 return;
106 emitThreeAddrLoHi(Opcode, this, Func);
107 }
108
67 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) 109 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget)
68 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { 110 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) {
69 HasSideEffects = true; 111 HasSideEffects = true;
70 addSource(CallTarget); 112 addSource(CallTarget);
71 } 113 }
72 114
73 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) 115 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src)
74 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { 116 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) {
75 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); 117 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest);
76 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src); 118 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void InstMIPS32::emitUnaryopGPR(const char *Opcode, const InstMIPS32 *Inst, 160 void InstMIPS32::emitUnaryopGPR(const char *Opcode, const InstMIPS32 *Inst,
119 const Cfg *Func) { 161 const Cfg *Func) {
120 if (!BuildDefs::dump()) 162 if (!BuildDefs::dump())
121 return; 163 return;
122 Ostream &Str = Func->getContext()->getStrEmit(); 164 Ostream &Str = Func->getContext()->getStrEmit();
123 Str << "\t" << Opcode << "\t"; 165 Str << "\t" << Opcode << "\t";
124 Inst->getDest()->emit(Func); 166 Inst->getDest()->emit(Func);
125 Str << ", "; 167 Str << ", ";
126 Inst->getSrc(0)->emit(Func); 168 Inst->getSrc(0)->emit(Func);
127 } 169 }
170 void InstMIPS32::emitUnaryopGPRFLoHi(const char *Opcode, const InstMIPS32 *Inst,
171 const Cfg *Func) {
172 if (!BuildDefs::dump())
173 return;
174 Ostream &Str = Func->getContext()->getStrEmit();
175 Str << "\t" << Opcode << "\t";
176 Inst->getDest()->emit(Func);
177 }
178
179 void InstMIPS32::emitUnaryopGPRTLoHi(const char *Opcode, const InstMIPS32 *Inst,
180 const Cfg *Func) {
181 if (!BuildDefs::dump())
182 return;
183 Ostream &Str = Func->getContext()->getStrEmit();
184 Str << "\t" << Opcode << "\t";
185 Inst->getSrc(0)->emit(Func);
186 }
128 187
129 void InstMIPS32::emitThreeAddr(const char *Opcode, const InstMIPS32 *Inst, 188 void InstMIPS32::emitThreeAddr(const char *Opcode, const InstMIPS32 *Inst,
130 const Cfg *Func) { 189 const Cfg *Func) {
131 if (!BuildDefs::dump()) 190 if (!BuildDefs::dump())
132 return; 191 return;
133 Ostream &Str = Func->getContext()->getStrEmit(); 192 Ostream &Str = Func->getContext()->getStrEmit();
134 assert(Inst->getSrcSize() == 2); 193 assert(Inst->getSrcSize() == 2);
135 Str << "\t" << Opcode << "\t"; 194 Str << "\t" << Opcode << "\t";
136 Inst->getDest()->emit(Func); 195 Inst->getDest()->emit(Func);
137 Str << ", "; 196 Str << ", ";
138 Inst->getSrc(0)->emit(Func); 197 Inst->getSrc(0)->emit(Func);
139 Str << ", "; 198 Str << ", ";
140 Inst->getSrc(1)->emit(Func); 199 Inst->getSrc(1)->emit(Func);
141 } 200 }
142 201
202 void InstMIPS32::emitThreeAddrLoHi(const char *Opcode, const InstMIPS32 *Inst,
203 const Cfg *Func) {
204 if (!BuildDefs::dump())
205 return;
206 Ostream &Str = Func->getContext()->getStrEmit();
207 assert(Inst->getSrcSize() == 2);
208 Str << "\t" << Opcode << "\t";
209 Inst->getSrc(0)->emit(Func);
210 Str << ", ";
211 Inst->getSrc(1)->emit(Func);
212 }
213
143 void InstMIPS32Ret::emit(const Cfg *Func) const { 214 void InstMIPS32Ret::emit(const Cfg *Func) const {
144 if (!BuildDefs::dump()) 215 if (!BuildDefs::dump())
145 return; 216 return;
146 assert(getSrcSize() > 0); 217 assert(getSrcSize() > 0);
147 auto *RA = llvm::cast<Variable>(getSrc(0)); 218 auto *RA = llvm::cast<Variable>(getSrc(0));
148 assert(RA->hasReg()); 219 assert(RA->hasReg());
149 assert(RA->getRegNum() == RegMIPS32::Reg_RA); 220 assert(RA->getRegNum() == RegMIPS32::Reg_RA);
150 Ostream &Str = Func->getContext()->getStrEmit(); 221 Ostream &Str = Func->getContext()->getStrEmit();
151 Str << "\t" 222 Str << "\t"
152 "jr" 223 "jr"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 392 }
322 393
323 Str << "\t"; 394 Str << "\t";
324 getDest()->emit(Func); 395 getDest()->emit(Func);
325 Str << ", "; 396 Str << ", ";
326 getSrc(0)->emit(Func); 397 getSrc(0)->emit(Func);
327 } 398 }
328 399
329 } // end of namespace MIPS32 400 } // end of namespace MIPS32
330 } // end of namespace Ice 401 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstMIPS32.h ('k') | src/IceInstMIPS32.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698