OLD | NEW |
---|---|
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 const char *InstMIPS32::getWidthString(Type Ty) { | 47 const char *InstMIPS32::getWidthString(Type Ty) { |
48 (void)Ty; | 48 (void)Ty; |
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 *InstMIPS32And::Opcode = "and"; | 58 template <> const char *InstMIPS32And::Opcode = "and"; |
58 template <> const char *InstMIPS32Mul::Opcode = "mul"; | 59 template <> const char *InstMIPS32Mul::Opcode = "mul"; |
59 template <> const char *InstMIPS32Or::Opcode = "or"; | 60 template <> const char *InstMIPS32Or::Opcode = "or"; |
60 template <> const char *InstMIPS32Ori::Opcode = "ori"; | 61 template <> const char *InstMIPS32Ori::Opcode = "ori"; |
62 template <> const char *InstMIPS32Sltu::Opcode = "sltu"; | |
61 template <> const char *InstMIPS32Sub::Opcode = "sub"; | 63 template <> const char *InstMIPS32Sub::Opcode = "sub"; |
64 template <> const char *InstMIPS32Subu::Opcode = "subu"; | |
62 template <> const char *InstMIPS32Xor::Opcode = "xor"; | 65 template <> const char *InstMIPS32Xor::Opcode = "xor"; |
63 | 66 |
67 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) | |
68 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { | |
69 HasSideEffects = true; | |
70 addSource(CallTarget); | |
71 } | |
72 | |
64 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) | 73 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) |
65 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { | 74 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { |
66 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); | 75 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); |
67 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src); | 76 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src); |
68 | 77 |
69 assert(Dest64 == nullptr || Src64 == nullptr); | 78 assert(Dest64 == nullptr || Src64 == nullptr); |
70 | 79 |
71 if (Dest64 != nullptr) { | 80 if (Dest64 != nullptr) { |
72 // this-> is needed below because there is a parameter named Dest. | 81 // this-> is needed below because there is a parameter named Dest. |
73 this->Dest = Dest64->getLo(); | 82 this->Dest = Dest64->getLo(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 auto *RA = llvm::cast<Variable>(getSrc(0)); | 147 auto *RA = llvm::cast<Variable>(getSrc(0)); |
139 assert(RA->hasReg()); | 148 assert(RA->hasReg()); |
140 assert(RA->getRegNum() == RegMIPS32::Reg_RA); | 149 assert(RA->getRegNum() == RegMIPS32::Reg_RA); |
141 Ostream &Str = Func->getContext()->getStrEmit(); | 150 Ostream &Str = Func->getContext()->getStrEmit(); |
142 Str << "\t" | 151 Str << "\t" |
143 "jr" | 152 "jr" |
144 "\t"; | 153 "\t"; |
145 RA->emit(Func); | 154 RA->emit(Func); |
146 } | 155 } |
147 | 156 |
157 void InstMIPS32Call::emit(const Cfg *Func) const { | |
158 if (!BuildDefs::dump()) | |
159 return; | |
160 Ostream &Str = Func->getContext()->getStrEmit(); | |
161 assert(getSrcSize() == 1); | |
162 if (llvm::isa<ConstantInteger32>(getCallTarget())) { | |
163 // This shouldn't happen (typically have to copy the full 32-bits to a | |
164 // register and do an indirect jump). | |
165 llvm::report_fatal_error("ARM32Call to ConstantInteger32"); | |
John
2016/02/01 04:29:32
MIPS32Call
rkotlerimgtec
2016/02/01 21:11:08
Done.
| |
166 } else if (const auto *CallTarget = | |
167 llvm::dyn_cast<ConstantRelocatable>(getCallTarget())) { | |
168 // Calls only have 24-bits, but the linker should insert veneers to extend | |
169 // the range if needed. | |
170 Str << "\t" | |
171 "jal" | |
172 "\t"; | |
173 CallTarget->emitWithoutPrefix(Func->getTarget()); | |
174 } else { | |
175 Str << "\t" | |
176 "jal" | |
177 "\t"; | |
178 getCallTarget()->emit(Func); | |
179 } | |
180 } | |
181 | |
182 void InstMIPS32Call::emitIAS(const Cfg *Func) const { | |
183 (void)Func; | |
184 llvm_unreachable("Not yet implemented"); | |
185 } | |
186 | |
187 void InstMIPS32Call::dump(const Cfg *Func) const { | |
188 if (!BuildDefs::dump()) | |
189 return; | |
190 Ostream &Str = Func->getContext()->getStrDump(); | |
191 if (getDest()) { | |
192 dumpDest(Func); | |
193 Str << " = "; | |
194 } | |
195 Str << "call "; | |
196 getCallTarget()->dump(Func); | |
197 } | |
198 | |
148 void InstMIPS32Ret::emitIAS(const Cfg *Func) const { | 199 void InstMIPS32Ret::emitIAS(const Cfg *Func) const { |
149 (void)Func; | 200 (void)Func; |
150 llvm_unreachable("Not yet implemented"); | 201 llvm_unreachable("Not yet implemented"); |
151 } | 202 } |
152 | 203 |
153 void InstMIPS32Ret::dump(const Cfg *Func) const { | 204 void InstMIPS32Ret::dump(const Cfg *Func) const { |
154 if (!BuildDefs::dump()) | 205 if (!BuildDefs::dump()) |
155 return; | 206 return; |
156 Ostream &Str = Func->getContext()->getStrDump(); | 207 Ostream &Str = Func->getContext()->getStrDump(); |
157 Type Ty = (getSrcSize() == 1 ? IceType_void : getSrc(0)->getType()); | 208 Type Ty = (getSrcSize() == 1 ? IceType_void : getSrc(0)->getType()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 321 } |
271 | 322 |
272 Str << "\t"; | 323 Str << "\t"; |
273 getDest()->emit(Func); | 324 getDest()->emit(Func); |
274 Str << ", "; | 325 Str << ", "; |
275 getSrc(0)->emit(Func); | 326 getSrc(0)->emit(Func); |
276 } | 327 } |
277 | 328 |
278 } // end of namespace MIPS32 | 329 } // end of namespace MIPS32 |
279 } // end of namespace Ice | 330 } // end of namespace Ice |
OLD | NEW |