OLD | NEW |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 Vars = Func->allocateArrayOf<Variable *>(NumVars); | 85 Vars = Func->allocateArrayOf<Variable *>(NumVars); |
86 SizeT I = 0; | 86 SizeT I = 0; |
87 if (Base) | 87 if (Base) |
88 Vars[I++] = Base; | 88 Vars[I++] = Base; |
89 if (Index) | 89 if (Index) |
90 Vars[I++] = Index; | 90 Vars[I++] = Index; |
91 assert(I == NumVars); | 91 assert(I == NumVars); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
| 95 InstX8632AdjustStack::InstX8632AdjustStack(Cfg *Func, SizeT Amount) |
| 96 : InstX8632(Func, InstX8632::Adjuststack, 0, NULL), Amount(Amount) {} |
| 97 |
95 InstX8632Mul::InstX8632Mul(Cfg *Func, Variable *Dest, Variable *Source1, | 98 InstX8632Mul::InstX8632Mul(Cfg *Func, Variable *Dest, Variable *Source1, |
96 Operand *Source2) | 99 Operand *Source2) |
97 : InstX8632(Func, InstX8632::Mul, 2, Dest) { | 100 : InstX8632(Func, InstX8632::Mul, 2, Dest) { |
98 addSource(Source1); | 101 addSource(Source1); |
99 addSource(Source2); | 102 addSource(Source2); |
100 } | 103 } |
101 | 104 |
102 InstX8632Shld::InstX8632Shld(Cfg *Func, Variable *Dest, Variable *Source1, | 105 InstX8632Shld::InstX8632Shld(Cfg *Func, Variable *Dest, Variable *Source1, |
103 Variable *Source2) | 106 Variable *Source2) |
104 : InstX8632(Func, InstX8632::Shld, 3, Dest) { | 107 : InstX8632(Func, InstX8632::Shld, 3, Dest) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source) | 222 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source) |
220 : InstX8632(Func, InstX8632::Mov, 1, Dest) { | 223 : InstX8632(Func, InstX8632::Mov, 1, Dest) { |
221 addSource(Source); | 224 addSource(Source); |
222 } | 225 } |
223 | 226 |
224 InstX8632Movp::InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source) | 227 InstX8632Movp::InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source) |
225 : InstX8632(Func, InstX8632::Movp, 1, Dest) { | 228 : InstX8632(Func, InstX8632::Movp, 1, Dest) { |
226 addSource(Source); | 229 addSource(Source); |
227 } | 230 } |
228 | 231 |
| 232 InstX8632StoreP::InstX8632StoreP(Cfg *Func, Operand *Value, OperandX8632 *Mem) |
| 233 : InstX8632(Func, InstX8632::StoreP, 2, NULL) { |
| 234 addSource(Value); |
| 235 addSource(Mem); |
| 236 } |
| 237 |
229 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem) | 238 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem) |
230 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) { | 239 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) { |
231 addSource(Value); | 240 addSource(Value); |
232 addSource(Mem); | 241 addSource(Mem); |
233 } | 242 } |
234 | 243 |
235 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source) | 244 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source) |
236 : InstX8632(Func, InstX8632::Movq, 1, Dest) { | 245 : InstX8632(Func, InstX8632::Movq, 1, Dest) { |
237 addSource(Source); | 246 addSource(Source); |
238 } | 247 } |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 } | 935 } |
927 | 936 |
928 void InstX8632Store::dump(const Cfg *Func) const { | 937 void InstX8632Store::dump(const Cfg *Func) const { |
929 Ostream &Str = Func->getContext()->getStrDump(); | 938 Ostream &Str = Func->getContext()->getStrDump(); |
930 Str << "mov." << getSrc(0)->getType() << " "; | 939 Str << "mov." << getSrc(0)->getType() << " "; |
931 getSrc(1)->dump(Func); | 940 getSrc(1)->dump(Func); |
932 Str << ", "; | 941 Str << ", "; |
933 getSrc(0)->dump(Func); | 942 getSrc(0)->dump(Func); |
934 } | 943 } |
935 | 944 |
| 945 void InstX8632StoreP::emit(const Cfg *Func) const { |
| 946 Ostream &Str = Func->getContext()->getStrEmit(); |
| 947 assert(getSrcSize() == 2); |
| 948 Str << "\tmovups\t"; |
| 949 getSrc(1)->emit(Func); |
| 950 Str << ", "; |
| 951 getSrc(0)->emit(Func); |
| 952 Str << "\n"; |
| 953 } |
| 954 |
| 955 void InstX8632StoreP::dump(const Cfg *Func) const { |
| 956 Ostream &Str = Func->getContext()->getStrDump(); |
| 957 Str << "storep." << getSrc(0)->getType() << " "; |
| 958 getSrc(1)->dump(Func); |
| 959 Str << ", "; |
| 960 getSrc(0)->dump(Func); |
| 961 } |
| 962 |
936 void InstX8632StoreQ::emit(const Cfg *Func) const { | 963 void InstX8632StoreQ::emit(const Cfg *Func) const { |
937 Ostream &Str = Func->getContext()->getStrEmit(); | 964 Ostream &Str = Func->getContext()->getStrEmit(); |
938 assert(getSrcSize() == 2); | 965 assert(getSrcSize() == 2); |
939 assert(getSrc(1)->getType() == IceType_i64 || | 966 assert(getSrc(1)->getType() == IceType_i64 || |
940 getSrc(1)->getType() == IceType_f64); | 967 getSrc(1)->getType() == IceType_f64); |
941 Str << "\tmovq\t"; | 968 Str << "\tmovq\t"; |
942 getSrc(1)->emit(Func); | 969 getSrc(1)->emit(Func); |
943 Str << ", "; | 970 Str << ", "; |
944 getSrc(0)->emit(Func); | 971 getSrc(0)->emit(Func); |
945 Str << "\n"; | 972 Str << "\n"; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 getDest()->emit(Func); | 1256 getDest()->emit(Func); |
1230 Str << "\n"; | 1257 Str << "\n"; |
1231 } | 1258 } |
1232 | 1259 |
1233 void InstX8632Pop::dump(const Cfg *Func) const { | 1260 void InstX8632Pop::dump(const Cfg *Func) const { |
1234 Ostream &Str = Func->getContext()->getStrDump(); | 1261 Ostream &Str = Func->getContext()->getStrDump(); |
1235 dumpDest(Func); | 1262 dumpDest(Func); |
1236 Str << " = pop." << getDest()->getType() << " "; | 1263 Str << " = pop." << getDest()->getType() << " "; |
1237 } | 1264 } |
1238 | 1265 |
| 1266 void InstX8632AdjustStack::emit(const Cfg *Func) const { |
| 1267 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1268 Str << "\tsub\tesp, " << Amount << "\n"; |
| 1269 Func->getTarget()->updateStackAdjustment(Amount); |
| 1270 } |
| 1271 |
| 1272 void InstX8632AdjustStack::dump(const Cfg *Func) const { |
| 1273 Ostream &Str = Func->getContext()->getStrDump(); |
| 1274 Str << "esp = sub.i32 esp, " << Amount; |
| 1275 } |
| 1276 |
1239 void InstX8632Push::emit(const Cfg *Func) const { | 1277 void InstX8632Push::emit(const Cfg *Func) const { |
1240 Ostream &Str = Func->getContext()->getStrEmit(); | 1278 Ostream &Str = Func->getContext()->getStrEmit(); |
1241 assert(getSrcSize() == 1); | 1279 assert(getSrcSize() == 1); |
1242 Type Ty = getSrc(0)->getType(); | 1280 Type Ty = getSrc(0)->getType(); |
1243 Variable *Var = llvm::dyn_cast<Variable>(getSrc(0)); | 1281 Variable *Var = llvm::dyn_cast<Variable>(getSrc(0)); |
1244 if ((isVectorType(Ty) || Ty == IceType_f32 || Ty == IceType_f64) && Var && | 1282 if ((isVectorType(Ty) || Ty == IceType_f32 || Ty == IceType_f64) && Var && |
1245 Var->hasReg()) { | 1283 Var->hasReg()) { |
1246 // The xmm registers can't be directly pushed, so we fake it by | 1284 // The xmm registers can't be directly pushed, so we fake it by |
1247 // decrementing esp and then storing to [esp]. | 1285 // decrementing esp and then storing to [esp]. |
1248 Str << "\tsub\tesp, " << typeWidthInBytes(Ty) << "\n"; | 1286 Str << "\tsub\tesp, " << typeWidthInBytes(Ty) << "\n"; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 default: | 1510 default: |
1473 Str << "???"; | 1511 Str << "???"; |
1474 break; | 1512 break; |
1475 } | 1513 } |
1476 Str << "("; | 1514 Str << "("; |
1477 Var->dump(Func); | 1515 Var->dump(Func); |
1478 Str << ")"; | 1516 Str << ")"; |
1479 } | 1517 } |
1480 | 1518 |
1481 } // end of namespace Ice | 1519 } // end of namespace Ice |
OLD | NEW |