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

Side by Side Diff: src/IceInstARM32.cpp

Issue 1433743002: Add POP instruction to ARM integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix issues in last patch. Created 5 years, 1 month 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/IceInstARM32.h ('k') | tests_lit/assembler/arm32/bic.ll » ('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/IceInstARM32.cpp - ARM32 instruction implementation ----===// 1 //===- subzero/src/IceInstARM32.cpp - ARM32 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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 continue; 1109 continue;
1110 startNextInst(Func); 1110 startNextInst(Func);
1111 Str << "\t" 1111 Str << "\t"
1112 << "vpop" 1112 << "vpop"
1113 << "\t{"; 1113 << "\t{";
1114 Op->emit(Func); 1114 Op->emit(Func);
1115 Str << "}\n"; 1115 Str << "}\n";
1116 } 1116 }
1117 } 1117 }
1118 1118
1119 void InstARM32Pop::emitIAS(const Cfg *Func) const {
1120 SizeT DestReg = 0;
Jim Stichnoth 2015/11/09 23:04:11 remove this
Karl 2015/11/10 16:32:22 Done.
1121 SizeT IntegerCount = 0;
1122 ARM32::IValueT GPRegisters = 0;
1123 SizeT Index = 0;
Jim Stichnoth 2015/11/09 23:04:11 replace this with: Variable *LastDest = nullptr;
Karl 2015/11/10 16:32:21 Done.
1124 for (const Variable *Var : Dests) {
1125 if (!isScalarIntegerType(Var->getType()))
1126 // TODO(kschimpf) Implement vpush.
1127 return emitUsingTextFixup(Func);
1128 assert((Var && Var->hasReg()) && "pop only applies to registers");
1129 int32_t Reg = Var->getRegNum();
1130 assert(Reg != RegARM32::Encoded_Not_GPR);
1131 DestReg = Index;
Jim Stichnoth 2015/11/09 23:04:11 replace this with: LastDest = Var;
Karl 2015/11/10 16:32:22 Done.
1132 GPRegisters |= (1 << Reg);
1133 ++IntegerCount;
1134 ++Index;
Jim Stichnoth 2015/11/09 23:04:11 remove this
Karl 2015/11/10 16:32:22 Done.
1135 }
1136 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
1137 switch (IntegerCount) {
1138 case 0:
1139 return;
1140 case 1: {
1141 if (const Variable *Var = Dests[DestReg]) {
Jim Stichnoth 2015/11/09 23:04:11 use LastDest instead of Dests[DestReg] Also, Last
Karl 2015/11/10 16:32:21 Done.
1142 // Note: Can only apply pop register if single register is not sp.
1143 assert((RegARM32::Encoded_Reg_sp != Var->getRegNum()) &&
1144 "Effects of pop register SP is undefined!");
1145 // TODO(kschimpf) ARM sandbox does not allow the single register form of
1146 // pop, and the popList form expects multiple registers. Convert this
1147 // assert to a conditional check once it has been shown that popList
1148 // works.
1149 assert(!Func->getContext()->getFlags().getUseSandboxing() &&
1150 "pop register not in ARM sandbox!");
1151 Asm->pop(Var, CondARM32::AL);
1152 break;
1153 }
1154 // Intentionally fall to next case.
1155 }
1156 default:
1157 Asm->popList(GPRegisters, CondARM32::AL);
1158 break;
1159 }
1160 if (Asm->needsTextFixup())
1161 emitUsingTextFixup(Func);
1162 }
1163
1119 void InstARM32Pop::dump(const Cfg *Func) const { 1164 void InstARM32Pop::dump(const Cfg *Func) const {
1120 if (!BuildDefs::dump()) 1165 if (!BuildDefs::dump())
1121 return; 1166 return;
1122 Ostream &Str = Func->getContext()->getStrDump(); 1167 Ostream &Str = Func->getContext()->getStrDump();
1123 Str << "pop" 1168 Str << "pop"
1124 << " "; 1169 << " ";
1125 for (SizeT I = 0; I < Dests.size(); ++I) { 1170 for (SizeT I = 0; I < Dests.size(); ++I) {
1126 if (I > 0) 1171 if (I > 0)
1127 Str << ", "; 1172 Str << ", ";
1128 Dests[I]->dump(Func); 1173 Dests[I]->dump(Func);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 PrintComma = true; 1237 PrintComma = true;
1193 } 1238 }
1194 } 1239 }
1195 Str << "}\n"; 1240 Str << "}\n";
1196 } 1241 }
1197 } 1242 }
1198 1243
1199 void InstARM32Push::emitIAS(const Cfg *Func) const { 1244 void InstARM32Push::emitIAS(const Cfg *Func) const {
1200 SizeT SrcReg = 0; 1245 SizeT SrcReg = 0;
1201 SizeT IntegerCount = 0; 1246 SizeT IntegerCount = 0;
1202 ARM32::IValueT GPURegisters = 0; 1247 ARM32::IValueT GPRegisters = 0;
1203 for (SizeT i = 0; i < getSrcSize(); ++i) { 1248 for (SizeT Index = 0; Index < getSrcSize(); ++Index) {
1204 if (!isScalarIntegerType(getSrc(i)->getType())) 1249 if (!isScalarIntegerType(getSrc(Index)->getType()))
1205 // TODO(kschimpf) Implement vpush. 1250 // TODO(kschimpf) Implement vpush.
1206 return emitUsingTextFixup(Func); 1251 return emitUsingTextFixup(Func);
1207 auto *Var = llvm::dyn_cast<Variable>(getSrc(i)); 1252 auto *Var = llvm::dyn_cast<Variable>(getSrc(Index));
1208 assert((Var && Var->hasReg()) && "push only applies to registers"); 1253 assert((Var && Var->hasReg()) && "push only applies to registers");
1209 ARM32::IValueT Reg = Var->getRegNum(); 1254 int32_t Reg = Var->getRegNum();
1210 assert(Reg != static_cast<ARM32::IValueT>(RegARM32::Encoded_Not_GPR)); 1255 assert(Reg != RegARM32::Encoded_Not_GPR);
1211 SrcReg = i; 1256 SrcReg = Index;
1212 GPURegisters |= (1 << Reg); 1257 GPRegisters |= (1 << Reg);
1213 ++IntegerCount; 1258 ++IntegerCount;
1214 } 1259 }
1215 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); 1260 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
1216 switch (IntegerCount) { 1261 switch (IntegerCount) {
1217 case 0: 1262 case 0:
1218 return; 1263 return;
1219 case 1: { 1264 case 1: {
1220 if (auto *Var = llvm::dyn_cast<Variable>(getSrc(SrcReg))) { 1265 if (auto *Var = llvm::dyn_cast<Variable>(getSrc(SrcReg))) {
1221 // Note: Can only apply push register if single register is not sp. 1266 // Note: Can only apply push register if single register is not sp.
1222 assert((RegARM32::Encoded_Reg_sp != Var->getRegNum()) && 1267 assert((RegARM32::Encoded_Reg_sp != Var->getRegNum()) &&
1223 "Effects of push register SP is undefined!"); 1268 "Effects of push register SP is undefined!");
1224 // TODO(kschimpf) ARM sandbox does not allow the single register form of 1269 // TODO(kschimpf) ARM sandbox does not allow the single register form of
1225 // push, and the pushList form expects multiple registers. Convert this 1270 // push, and the pushList form expects multiple registers. Convert this
1226 // assert to a conditional check once it has been shown that pushList 1271 // assert to a conditional check once it has been shown that pushList
1227 // works. 1272 // works.
1228 assert(!Func->getContext()->getFlags().getUseSandboxing() && 1273 assert(!Func->getContext()->getFlags().getUseSandboxing() &&
1229 "push register not in ARM sandbox!"); 1274 "push register not in ARM sandbox!");
1230 Asm->push(Var, CondARM32::AL); 1275 Asm->push(Var, CondARM32::AL);
1231 break; 1276 break;
1232 } 1277 }
1233 // Intentionally fall to next case. 1278 // Intentionally fall to next case.
1234 } 1279 }
1235 default: 1280 default:
1236 // TODO(kschimpf) Implement pushList in assembler. 1281 // TODO(kschimpf) Implement pushList in assembler.
1237 Asm->pushList(GPURegisters, CondARM32::AL); 1282 Asm->pushList(GPRegisters, CondARM32::AL);
1238 break; 1283 break;
1239 } 1284 }
1240 if (Asm->needsTextFixup()) 1285 if (Asm->needsTextFixup())
1241 emitUsingTextFixup(Func); 1286 emitUsingTextFixup(Func);
1242 } 1287 }
1243 1288
1244 void InstARM32Push::dump(const Cfg *Func) const { 1289 void InstARM32Push::dump(const Cfg *Func) const {
1245 if (!BuildDefs::dump()) 1290 if (!BuildDefs::dump())
1246 return; 1291 return;
1247 Ostream &Str = Func->getContext()->getStrDump(); 1292 Ostream &Str = Func->getContext()->getStrDump();
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 template class InstARM32UnaryopGPR<InstARM32::Uxt, true>; 1747 template class InstARM32UnaryopGPR<InstARM32::Uxt, true>;
1703 template class InstARM32UnaryopFP<InstARM32::Vsqrt>; 1748 template class InstARM32UnaryopFP<InstARM32::Vsqrt>;
1704 1749
1705 template class InstARM32FourAddrGPR<InstARM32::Mla>; 1750 template class InstARM32FourAddrGPR<InstARM32::Mla>;
1706 template class InstARM32FourAddrGPR<InstARM32::Mls>; 1751 template class InstARM32FourAddrGPR<InstARM32::Mls>;
1707 1752
1708 template class InstARM32CmpLike<InstARM32::Cmp>; 1753 template class InstARM32CmpLike<InstARM32::Cmp>;
1709 template class InstARM32CmpLike<InstARM32::Tst>; 1754 template class InstARM32CmpLike<InstARM32::Tst>;
1710 1755
1711 } // end of namespace Ice 1756 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstARM32.h ('k') | tests_lit/assembler/arm32/bic.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698