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

Side by Side Diff: src/IceInstARM32.cpp

Issue 1378303003: Subzero. Adds ldrex, strex, and dmb support (ARM32) (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 2 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/IceInstARM32.h ('k') | src/IceTargetLoweringARM32.h » ('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 //===----------------------------------------------------------------------===//
Jim Stichnoth 2015/10/01 21:46:47 Why was this changed?
John 2015/10/01 22:11:45 Done.
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
11 /// This file implements the InstARM32 and OperandARM32 classes, primarily the 11 /// This file implements the InstARM32 and OperandARM32 classes, primarily the
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 addSource(Source); 353 addSource(Source);
354 } 354 }
355 355
356 InstARM32Str::InstARM32Str(Cfg *Func, Variable *Value, OperandARM32Mem *Mem, 356 InstARM32Str::InstARM32Str(Cfg *Func, Variable *Value, OperandARM32Mem *Mem,
357 CondARM32::Cond Predicate) 357 CondARM32::Cond Predicate)
358 : InstARM32Pred(Func, InstARM32::Str, 2, nullptr, Predicate) { 358 : InstARM32Pred(Func, InstARM32::Str, 2, nullptr, Predicate) {
359 addSource(Value); 359 addSource(Value);
360 addSource(Mem); 360 addSource(Mem);
361 } 361 }
362 362
363 InstARM32Strex::InstARM32Strex(Cfg *Func, Variable *Dest, Variable *Value,
364 OperandARM32Mem *Mem, CondARM32::Cond Predicate)
365 : InstARM32Pred(Func, InstARM32::Strex, 2, Dest, Predicate) {
366 addSource(Value);
367 addSource(Mem);
368 }
369
363 InstARM32Trap::InstARM32Trap(Cfg *Func) 370 InstARM32Trap::InstARM32Trap(Cfg *Func)
364 : InstARM32(Func, InstARM32::Trap, 0, nullptr) {} 371 : InstARM32(Func, InstARM32::Trap, 0, nullptr) {}
365 372
366 InstARM32Umull::InstARM32Umull(Cfg *Func, Variable *DestLo, Variable *DestHi, 373 InstARM32Umull::InstARM32Umull(Cfg *Func, Variable *DestLo, Variable *DestHi,
367 Variable *Src0, Variable *Src1, 374 Variable *Src0, Variable *Src1,
368 CondARM32::Cond Predicate) 375 CondARM32::Cond Predicate)
369 : InstARM32Pred(Func, InstARM32::Umull, 2, DestLo, Predicate), 376 : InstARM32Pred(Func, InstARM32::Umull, 2, DestLo, Predicate),
370 // DestHi is expected to have a FakeDef inserted by the lowering code. 377 // DestHi is expected to have a FakeDef inserted by the lowering code.
371 DestHi(DestHi) { 378 DestHi(DestHi) {
372 addSource(Src0); 379 addSource(Src0);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 417 }
411 418
412 InstARM32Vmrs::InstARM32Vmrs(Cfg *Func, CondARM32::Cond Predicate) 419 InstARM32Vmrs::InstARM32Vmrs(Cfg *Func, CondARM32::Cond Predicate)
413 : InstARM32Pred(Func, InstARM32::Vmrs, 0, nullptr, Predicate) {} 420 : InstARM32Pred(Func, InstARM32::Vmrs, 0, nullptr, Predicate) {}
414 421
415 InstARM32Vabs::InstARM32Vabs(Cfg *Func, Variable *Dest, Variable *Src, 422 InstARM32Vabs::InstARM32Vabs(Cfg *Func, Variable *Dest, Variable *Src,
416 CondARM32::Cond Predicate) 423 CondARM32::Cond Predicate)
417 : InstARM32Pred(Func, InstARM32::Vabs, 1, Dest, Predicate) { 424 : InstARM32Pred(Func, InstARM32::Vabs, 1, Dest, Predicate) {
418 addSource(Src); 425 addSource(Src);
419 } 426 }
427
428 InstARM32Dmb::InstARM32Dmb(Cfg *Func)
429 : InstARM32Pred(Func, InstARM32::Dmb, 0, nullptr, CondARM32::AL) {}
430
420 // ======================== Dump routines ======================== // 431 // ======================== Dump routines ======================== //
421 432
422 // Two-addr ops 433 // Two-addr ops
423 template <> const char *InstARM32Movt::Opcode = "movt"; 434 template <> const char *InstARM32Movt::Opcode = "movt";
424 // Unary ops 435 // Unary ops
425 template <> const char *InstARM32Movw::Opcode = "movw"; 436 template <> const char *InstARM32Movw::Opcode = "movw";
426 template <> const char *InstARM32Clz::Opcode = "clz"; 437 template <> const char *InstARM32Clz::Opcode = "clz";
427 template <> const char *InstARM32Mvn::Opcode = "mvn"; 438 template <> const char *InstARM32Mvn::Opcode = "mvn";
428 template <> const char *InstARM32Rbit::Opcode = "rbit"; 439 template <> const char *InstARM32Rbit::Opcode = "rbit";
429 template <> const char *InstARM32Rev::Opcode = "rev"; 440 template <> const char *InstARM32Rev::Opcode = "rev";
430 template <> const char *InstARM32Sxt::Opcode = "sxt"; // still requires b/h 441 template <> const char *InstARM32Sxt::Opcode = "sxt"; // still requires b/h
431 template <> const char *InstARM32Uxt::Opcode = "uxt"; // still requires b/h 442 template <> const char *InstARM32Uxt::Opcode = "uxt"; // still requires b/h
432 // FP 443 // FP
433 template <> const char *InstARM32Vsqrt::Opcode = "vsqrt"; 444 template <> const char *InstARM32Vsqrt::Opcode = "vsqrt";
434 // Mov-like ops 445 // Mov-like ops
435 template <> const char *InstARM32Ldr::Opcode = "ldr"; 446 template <> const char *InstARM32Ldr::Opcode = "ldr";
447 template <> const char *InstARM32Ldrex::Opcode = "ldrex";
436 // Three-addr ops 448 // Three-addr ops
437 template <> const char *InstARM32Adc::Opcode = "adc"; 449 template <> const char *InstARM32Adc::Opcode = "adc";
438 template <> const char *InstARM32Add::Opcode = "add"; 450 template <> const char *InstARM32Add::Opcode = "add";
439 template <> const char *InstARM32And::Opcode = "and"; 451 template <> const char *InstARM32And::Opcode = "and";
440 template <> const char *InstARM32Asr::Opcode = "asr"; 452 template <> const char *InstARM32Asr::Opcode = "asr";
441 template <> const char *InstARM32Bic::Opcode = "bic"; 453 template <> const char *InstARM32Bic::Opcode = "bic";
442 template <> const char *InstARM32Eor::Opcode = "eor"; 454 template <> const char *InstARM32Eor::Opcode = "eor";
443 template <> const char *InstARM32Lsl::Opcode = "lsl"; 455 template <> const char *InstARM32Lsl::Opcode = "lsl";
444 template <> const char *InstARM32Lsr::Opcode = "lsr"; 456 template <> const char *InstARM32Lsr::Opcode = "lsr";
445 template <> const char *InstARM32Mul::Opcode = "mul"; 457 template <> const char *InstARM32Mul::Opcode = "mul";
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 if (!BuildDefs::dump()) 506 if (!BuildDefs::dump())
495 return; 507 return;
496 Ostream &Str = Func->getContext()->getStrEmit(); 508 Ostream &Str = Func->getContext()->getStrEmit();
497 Variable *Dest = getDest(); 509 Variable *Dest = getDest();
498 Variable *SrcLo = llvm::cast<Variable>(getSrc(0)); 510 Variable *SrcLo = llvm::cast<Variable>(getSrc(0));
499 Variable *SrcHi = llvm::cast<Variable>(getSrc(1)); 511 Variable *SrcHi = llvm::cast<Variable>(getSrc(1));
500 512
501 assert(SrcHi->hasReg()); 513 assert(SrcHi->hasReg());
502 assert(SrcLo->hasReg()); 514 assert(SrcLo->hasReg());
503 assert(Dest->hasReg()); 515 assert(Dest->hasReg());
516 assert(getSrcSize() == 2);
504 517
505 Str << "\t" 518 Str << "\t"
506 << "vmov" << getPredicate() << "\t"; 519 << "vmov" << getPredicate() << "\t";
507 Dest->emit(Func); 520 Dest->emit(Func);
508 Str << ", "; 521 Str << ", ";
509 SrcLo->emit(Func); 522 SrcLo->emit(Func);
510 Str << ", "; 523 Str << ", ";
511 SrcHi->emit(Func); 524 SrcHi->emit(Func);
512 } 525 }
513 526
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 Str << ", "; 765 Str << ", ";
753 getSrc(0)->emit(Func); 766 getSrc(0)->emit(Func);
754 } 767 }
755 768
756 template <> void InstARM32Ldr::emitIAS(const Cfg *Func) const { 769 template <> void InstARM32Ldr::emitIAS(const Cfg *Func) const {
757 assert(getSrcSize() == 1); 770 assert(getSrcSize() == 1);
758 (void)Func; 771 (void)Func;
759 llvm_unreachable("Not yet implemented"); 772 llvm_unreachable("Not yet implemented");
760 } 773 }
761 774
775 template <> void InstARM32Ldrex::emit(const Cfg *Func) const {
776 if (!BuildDefs::dump())
777 return;
778 Ostream &Str = Func->getContext()->getStrEmit();
779 assert(getSrcSize() == 1);
780 assert(getDest()->hasReg());
781 Variable *Dest = getDest();
782 Type DestTy = Dest->getType();
783 assert(isScalarIntegerType(DestTy));
784 const char *WidthString = getWidthString(DestTy);
785 Str << "\t" << Opcode << WidthString << getPredicate() << "\t";
786 getDest()->emit(Func);
787 Str << ", ";
788 getSrc(0)->emit(Func);
789 }
790
791 template <> void InstARM32Ldrex::emitIAS(const Cfg *Func) const {
792 assert(getSrcSize() == 1);
793 (void)Func;
794 llvm_unreachable("Not yet implemented");
795 }
796
762 template <> void InstARM32Movw::emit(const Cfg *Func) const { 797 template <> void InstARM32Movw::emit(const Cfg *Func) const {
763 if (!BuildDefs::dump()) 798 if (!BuildDefs::dump())
764 return; 799 return;
765 Ostream &Str = Func->getContext()->getStrEmit(); 800 Ostream &Str = Func->getContext()->getStrEmit();
766 assert(getSrcSize() == 1); 801 assert(getSrcSize() == 1);
767 Str << "\t" << Opcode << getPredicate() << "\t"; 802 Str << "\t" << Opcode << getPredicate() << "\t";
768 getDest()->emit(Func); 803 getDest()->emit(Func);
769 Str << ", "; 804 Str << ", ";
770 Constant *Src0 = llvm::cast<Constant>(getSrc(0)); 805 Constant *Src0 = llvm::cast<Constant>(getSrc(0));
771 if (auto CR = llvm::dyn_cast<ConstantRelocatable>(Src0)) { 806 if (auto CR = llvm::dyn_cast<ConstantRelocatable>(Src0)) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 return; 1010 return;
976 Ostream &Str = Func->getContext()->getStrDump(); 1011 Ostream &Str = Func->getContext()->getStrDump();
977 Type Ty = getSrc(0)->getType(); 1012 Type Ty = getSrc(0)->getType();
978 dumpOpcodePred(Str, "str", Ty); 1013 dumpOpcodePred(Str, "str", Ty);
979 Str << " "; 1014 Str << " ";
980 getSrc(1)->dump(Func); 1015 getSrc(1)->dump(Func);
981 Str << ", "; 1016 Str << ", ";
982 getSrc(0)->dump(Func); 1017 getSrc(0)->dump(Func);
983 } 1018 }
984 1019
1020 void InstARM32Strex::emit(const Cfg *Func) const {
1021 if (!BuildDefs::dump())
1022 return;
1023 assert(getSrcSize() == 2);
1024 Type Ty = getSrc(0)->getType();
1025 assert(isScalarIntegerType(Ty));
1026 Variable *Dest = getDest();
1027 Ostream &Str = Func->getContext()->getStrEmit();
1028 static constexpr char Opcode[] = "strex";
1029 const char *WidthString = getWidthString(Ty);
1030 Str << "\t" << Opcode << WidthString << getPredicate() << "\t";
1031 Dest->emit(Func);
1032 Str << ", ";
1033 emitSources(Func);
1034 }
1035
1036 void InstARM32Strex::emitIAS(const Cfg *Func) const {
1037 assert(getSrcSize() == 2);
1038 (void)Func;
1039 llvm_unreachable("Not yet implemented");
1040 }
1041
1042 void InstARM32Strex::dump(const Cfg *Func) const {
1043 if (!BuildDefs::dump())
1044 return;
1045 Ostream &Str = Func->getContext()->getStrDump();
1046 Variable *Dest = getDest();
1047 Dest->dump(Func);
1048 Str << " = ";
1049 Type Ty = getSrc(0)->getType();
1050 dumpOpcodePred(Str, "strex", Ty);
1051 Str << " ";
1052 getSrc(1)->dump(Func);
1053 Str << ", ";
1054 getSrc(0)->dump(Func);
1055 }
1056
985 void InstARM32Trap::emit(const Cfg *Func) const { 1057 void InstARM32Trap::emit(const Cfg *Func) const {
986 if (!BuildDefs::dump()) 1058 if (!BuildDefs::dump())
987 return; 1059 return;
988 Ostream &Str = Func->getContext()->getStrEmit(); 1060 Ostream &Str = Func->getContext()->getStrEmit();
989 assert(getSrcSize() == 0); 1061 assert(getSrcSize() == 0);
990 // There isn't a mnemonic for the special NaCl Trap encoding, so dump 1062 // There isn't a mnemonic for the special NaCl Trap encoding, so dump
991 // the raw bytes. 1063 // the raw bytes.
992 Str << "\t.long 0x"; 1064 Str << "\t.long 0x";
993 ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); 1065 ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
994 for (uint8_t I : Asm->getNonExecBundlePadding()) { 1066 for (uint8_t I : Asm->getNonExecBundlePadding()) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 } 1245 }
1174 1246
1175 void InstARM32Vabs::dump(const Cfg *Func) const { 1247 void InstARM32Vabs::dump(const Cfg *Func) const {
1176 if (!BuildDefs::dump()) 1248 if (!BuildDefs::dump())
1177 return; 1249 return;
1178 Ostream &Str = Func->getContext()->getStrDump(); 1250 Ostream &Str = Func->getContext()->getStrDump();
1179 dumpDest(Func); 1251 dumpDest(Func);
1180 Str << " = vabs" << getPredicate() << getVecWidthString(getSrc(0)->getType()); 1252 Str << " = vabs" << getPredicate() << getVecWidthString(getSrc(0)->getType());
1181 } 1253 }
1182 1254
1255 void InstARM32Dmb::emit(const Cfg *Func) const {
1256 if (!BuildDefs::dump())
1257 return;
1258 Ostream &Str = Func->getContext()->getStrEmit();
1259 assert(getSrcSize() == 0);
1260 Str << "\t"
1261 "dmb"
1262 "\t"
1263 "sy";
1264 }
1265
1266 void InstARM32Dmb::emitIAS(const Cfg *Func) const {
1267 assert(getSrcSize() == 1);
1268 (void)Func;
1269 llvm_unreachable("Not yet implemented");
1270 }
1271
1272 void InstARM32Dmb::dump(const Cfg *Func) const {
1273 if (!BuildDefs::dump())
1274 return;
1275 Func->getContext()->getStrDump() << "dmb\tsy";
1276 }
1277
1183 void OperandARM32Mem::emit(const Cfg *Func) const { 1278 void OperandARM32Mem::emit(const Cfg *Func) const {
1184 if (!BuildDefs::dump()) 1279 if (!BuildDefs::dump())
1185 return; 1280 return;
1186 Ostream &Str = Func->getContext()->getStrEmit(); 1281 Ostream &Str = Func->getContext()->getStrEmit();
1187 Str << "["; 1282 Str << "[";
1188 getBase()->emit(Func); 1283 getBase()->emit(Func);
1189 switch (getAddrMode()) { 1284 switch (getAddrMode()) {
1190 case PostIndex: 1285 case PostIndex:
1191 case NegPostIndex: 1286 case NegPostIndex:
1192 Str << "]"; 1287 Str << "]";
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 if (getShiftOp() != kNoShift) { 1388 if (getShiftOp() != kNoShift) {
1294 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " "; 1389 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " ";
1295 if (Func) 1390 if (Func)
1296 getShiftAmt()->dump(Func); 1391 getShiftAmt()->dump(Func);
1297 else 1392 else
1298 getShiftAmt()->dump(Str); 1393 getShiftAmt()->dump(Str);
1299 } 1394 }
1300 } 1395 }
1301 1396
1302 } // end of namespace Ice 1397 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstARM32.h ('k') | src/IceTargetLoweringARM32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698