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

Side by Side Diff: src/IceInstX8632.cpp

Issue 444443002: Subzero: Align the stack at the point of function calls. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Comments round 2 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source) 230 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source)
228 : InstX8632(Func, InstX8632::Mov, 1, Dest) { 231 : InstX8632(Func, InstX8632::Mov, 1, Dest) {
229 addSource(Source); 232 addSource(Source);
230 } 233 }
231 234
232 InstX8632Movp::InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source) 235 InstX8632Movp::InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source)
233 : InstX8632(Func, InstX8632::Movp, 1, Dest) { 236 : InstX8632(Func, InstX8632::Movp, 1, Dest) {
234 addSource(Source); 237 addSource(Source);
235 } 238 }
236 239
240 InstX8632StoreP::InstX8632StoreP(Cfg *Func, Operand *Value, OperandX8632 *Mem)
241 : InstX8632(Func, InstX8632::StoreP, 2, NULL) {
242 addSource(Value);
243 addSource(Mem);
244 }
245
237 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem) 246 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem)
238 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) { 247 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) {
239 addSource(Value); 248 addSource(Value);
240 addSource(Mem); 249 addSource(Mem);
241 } 250 }
242 251
243 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source) 252 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source)
244 : InstX8632(Func, InstX8632::Movq, 1, Dest) { 253 : InstX8632(Func, InstX8632::Movq, 1, Dest) {
245 addSource(Source); 254 addSource(Source);
246 } 255 }
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 930 }
922 931
923 void InstX8632Store::dump(const Cfg *Func) const { 932 void InstX8632Store::dump(const Cfg *Func) const {
924 Ostream &Str = Func->getContext()->getStrDump(); 933 Ostream &Str = Func->getContext()->getStrDump();
925 Str << "mov." << getSrc(0)->getType() << " "; 934 Str << "mov." << getSrc(0)->getType() << " ";
926 getSrc(1)->dump(Func); 935 getSrc(1)->dump(Func);
927 Str << ", "; 936 Str << ", ";
928 getSrc(0)->dump(Func); 937 getSrc(0)->dump(Func);
929 } 938 }
930 939
940 void InstX8632StoreP::emit(const Cfg *Func) const {
941 Ostream &Str = Func->getContext()->getStrEmit();
942 assert(getSrcSize() == 2);
943 Str << "\tmovups\t";
944 getSrc(1)->emit(Func);
945 Str << ", ";
946 getSrc(0)->emit(Func);
947 Str << "\n";
948 }
949
950 void InstX8632StoreP::dump(const Cfg *Func) const {
951 Ostream &Str = Func->getContext()->getStrDump();
952 Str << "storep." << getSrc(0)->getType() << " ";
953 getSrc(1)->dump(Func);
954 Str << ", ";
955 getSrc(0)->dump(Func);
956 }
957
931 void InstX8632StoreQ::emit(const Cfg *Func) const { 958 void InstX8632StoreQ::emit(const Cfg *Func) const {
932 Ostream &Str = Func->getContext()->getStrEmit(); 959 Ostream &Str = Func->getContext()->getStrEmit();
933 assert(getSrcSize() == 2); 960 assert(getSrcSize() == 2);
934 assert(getSrc(1)->getType() == IceType_i64 || 961 assert(getSrc(1)->getType() == IceType_i64 ||
935 getSrc(1)->getType() == IceType_f64); 962 getSrc(1)->getType() == IceType_f64);
936 Str << "\tmovq\t"; 963 Str << "\tmovq\t";
937 getSrc(1)->emit(Func); 964 getSrc(1)->emit(Func);
938 Str << ", "; 965 Str << ", ";
939 getSrc(0)->emit(Func); 966 getSrc(0)->emit(Func);
940 Str << "\n"; 967 Str << "\n";
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 getDest()->emit(Func); 1251 getDest()->emit(Func);
1225 Str << "\n"; 1252 Str << "\n";
1226 } 1253 }
1227 1254
1228 void InstX8632Pop::dump(const Cfg *Func) const { 1255 void InstX8632Pop::dump(const Cfg *Func) const {
1229 Ostream &Str = Func->getContext()->getStrDump(); 1256 Ostream &Str = Func->getContext()->getStrDump();
1230 dumpDest(Func); 1257 dumpDest(Func);
1231 Str << " = pop." << getDest()->getType() << " "; 1258 Str << " = pop." << getDest()->getType() << " ";
1232 } 1259 }
1233 1260
1261 void InstX8632AdjustStack::emit(const Cfg *Func) const {
1262 Ostream &Str = Func->getContext()->getStrEmit();
1263 Str << "\tsub\tesp, " << Amount << "\n";
1264 Func->getTarget()->updateStackAdjustment(Amount);
1265 }
1266
1267 void InstX8632AdjustStack::dump(const Cfg *Func) const {
1268 Ostream &Str = Func->getContext()->getStrDump();
1269 Str << "esp = sub.i32 esp, " << Amount;
1270 }
1271
1234 void InstX8632Push::emit(const Cfg *Func) const { 1272 void InstX8632Push::emit(const Cfg *Func) const {
1235 Ostream &Str = Func->getContext()->getStrEmit(); 1273 Ostream &Str = Func->getContext()->getStrEmit();
1236 assert(getSrcSize() == 1); 1274 assert(getSrcSize() == 1);
1237 Type Ty = getSrc(0)->getType(); 1275 Type Ty = getSrc(0)->getType();
1238 Variable *Var = llvm::dyn_cast<Variable>(getSrc(0)); 1276 Variable *Var = llvm::dyn_cast<Variable>(getSrc(0));
1239 if ((isVectorType(Ty) || Ty == IceType_f32 || Ty == IceType_f64) && Var && 1277 if ((isVectorType(Ty) || Ty == IceType_f32 || Ty == IceType_f64) && Var &&
1240 Var->hasReg()) { 1278 Var->hasReg()) {
1241 // The xmm registers can't be directly pushed, so we fake it by 1279 // The xmm registers can't be directly pushed, so we fake it by
1242 // decrementing esp and then storing to [esp]. 1280 // decrementing esp and then storing to [esp].
1243 Str << "\tsub\tesp, " << typeWidthInBytes(Ty) << "\n"; 1281 Str << "\tsub\tesp, " << typeWidthInBytes(Ty) << "\n";
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 default: 1505 default:
1468 Str << "???"; 1506 Str << "???";
1469 break; 1507 break;
1470 } 1508 }
1471 Str << "("; 1509 Str << "(";
1472 Var->dump(Func); 1510 Var->dump(Func);
1473 Str << ")"; 1511 Str << ")";
1474 } 1512 }
1475 1513
1476 } // end of namespace Ice 1514 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698