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 15 matching lines...) Expand all Loading... |
26 const struct InstX8632BrAttributes_ { | 26 const struct InstX8632BrAttributes_ { |
27 const char *DisplayString; | 27 const char *DisplayString; |
28 const char *EmitString; | 28 const char *EmitString; |
29 } InstX8632BrAttributes[] = { | 29 } InstX8632BrAttributes[] = { |
30 #define X(tag, dump, emit) \ | 30 #define X(tag, dump, emit) \ |
31 { dump, emit } \ | 31 { dump, emit } \ |
32 , | 32 , |
33 ICEINSTX8632BR_TABLE | 33 ICEINSTX8632BR_TABLE |
34 #undef X | 34 #undef X |
35 }; | 35 }; |
36 const size_t InstX8632BrAttributesSize = | |
37 llvm::array_lengthof(InstX8632BrAttributes); | |
38 | 36 |
39 const struct InstX8632CmppsAttributes_ { | 37 const struct InstX8632CmppsAttributes_ { |
40 const char *EmitString; | 38 const char *EmitString; |
41 } InstX8632CmppsAttributes[] = { | 39 } InstX8632CmppsAttributes[] = { |
42 #define X(tag, emit) \ | 40 #define X(tag, emit) \ |
43 { emit } \ | 41 { emit } \ |
44 , | 42 , |
45 ICEINSTX8632CMPPS_TABLE | 43 ICEINSTX8632CMPPS_TABLE |
46 #undef X | 44 #undef X |
47 }; | 45 }; |
48 const size_t InstX8632CmppsAttributesSize = | |
49 llvm::array_lengthof(InstX8632CmppsAttributes); | |
50 | 46 |
51 const struct TypeX8632Attributes_ { | 47 const struct TypeX8632Attributes_ { |
52 const char *CvtString; // i (integer), s (single FP), d (double FP) | 48 const char *CvtString; // i (integer), s (single FP), d (double FP) |
53 const char *SdSsString; // ss, sd, or <blank> | 49 const char *SdSsString; // ss, sd, or <blank> |
54 const char *PackString; // b, w, d, or <blank> | 50 const char *PackString; // b, w, d, or <blank> |
55 const char *WidthString; // {byte,word,dword,qword} ptr | 51 const char *WidthString; // {byte,word,dword,qword} ptr |
56 } TypeX8632Attributes[] = { | 52 } TypeX8632Attributes[] = { |
57 #define X(tag, elementty, cvt, sdss, pack, width) \ | 53 #define X(tag, elementty, cvt, sdss, pack, width) \ |
58 { cvt, "" sdss, pack, width } \ | 54 { cvt, "" sdss, pack, width } \ |
59 , | 55 , |
60 ICETYPEX8632_TABLE | 56 ICETYPEX8632_TABLE |
61 #undef X | 57 #undef X |
62 }; | 58 }; |
63 const size_t TypeX8632AttributesSize = | |
64 llvm::array_lengthof(TypeX8632Attributes); | |
65 | 59 |
66 const char *InstX8632SegmentRegNames[] = { | 60 const char *InstX8632SegmentRegNames[] = { |
67 #define X(val, name) name, | 61 #define X(val, name) name, |
68 SEG_REGX8632_TABLE | 62 SEG_REGX8632_TABLE |
69 #undef X | 63 #undef X |
70 }; | 64 }; |
71 const size_t InstX8632SegmentRegNamesSize = | |
72 llvm::array_lengthof(InstX8632SegmentRegNames); | |
73 | 65 |
74 } // end of anonymous namespace | 66 } // end of anonymous namespace |
75 | 67 |
76 const char *InstX8632::getWidthString(Type Ty) { | 68 const char *InstX8632::getWidthString(Type Ty) { |
77 return TypeX8632Attributes[Ty].WidthString; | 69 return TypeX8632Attributes[Ty].WidthString; |
78 } | 70 } |
79 | 71 |
80 OperandX8632Mem::OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, | 72 OperandX8632Mem::OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, |
81 Constant *Offset, Variable *Index, | 73 Constant *Offset, Variable *Index, |
82 uint16_t Shift, SegmentRegisters SegmentReg) | 74 uint16_t Shift, SegmentRegisters SegmentReg) |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "."; | 751 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "."; |
760 Str << getDest()->getType() << " "; | 752 Str << getDest()->getType() << " "; |
761 dumpDest(Func); | 753 dumpDest(Func); |
762 Str << ", "; | 754 Str << ", "; |
763 dumpSources(Func); | 755 dumpSources(Func); |
764 } | 756 } |
765 | 757 |
766 void InstX8632Cmpps::emit(const Cfg *Func) const { | 758 void InstX8632Cmpps::emit(const Cfg *Func) const { |
767 Ostream &Str = Func->getContext()->getStrEmit(); | 759 Ostream &Str = Func->getContext()->getStrEmit(); |
768 assert(getSrcSize() == 2); | 760 assert(getSrcSize() == 2); |
769 assert(Condition < InstX8632CmppsAttributesSize); | 761 assert(Condition < Cmpps_Invalid); |
770 Str << "\t"; | 762 Str << "\t"; |
771 Str << "cmp" << InstX8632CmppsAttributes[Condition].EmitString << "ps" | 763 Str << "cmp" << InstX8632CmppsAttributes[Condition].EmitString << "ps" |
772 << "\t"; | 764 << "\t"; |
773 getDest()->emit(Func); | 765 getDest()->emit(Func); |
774 Str << ", "; | 766 Str << ", "; |
775 getSrc(1)->emit(Func); | 767 getSrc(1)->emit(Func); |
776 Str << "\n"; | 768 Str << "\n"; |
777 } | 769 } |
778 | 770 |
779 void InstX8632Cmpps::dump(const Cfg *Func) const { | 771 void InstX8632Cmpps::dump(const Cfg *Func) const { |
780 Ostream &Str = Func->getContext()->getStrDump(); | 772 Ostream &Str = Func->getContext()->getStrDump(); |
781 assert(Condition < InstX8632CmppsAttributesSize); | 773 assert(Condition < Cmpps_Invalid); |
782 dumpDest(Func); | 774 dumpDest(Func); |
783 Str << " = cmp" << InstX8632CmppsAttributes[Condition].EmitString << "ps" | 775 Str << " = cmp" << InstX8632CmppsAttributes[Condition].EmitString << "ps" |
784 << "\t"; | 776 << "\t"; |
785 dumpSources(Func); | 777 dumpSources(Func); |
786 } | 778 } |
787 | 779 |
788 void InstX8632Cmpxchg::emit(const Cfg *Func) const { | 780 void InstX8632Cmpxchg::emit(const Cfg *Func) const { |
789 Ostream &Str = Func->getContext()->getStrEmit(); | 781 Ostream &Str = Func->getContext()->getStrEmit(); |
790 assert(getSrcSize() == 3); | 782 assert(getSrcSize() == 3); |
791 if (Locked) { | 783 if (Locked) { |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 | 1345 |
1354 void OperandX8632::dump(const Cfg *Func) const { | 1346 void OperandX8632::dump(const Cfg *Func) const { |
1355 Ostream &Str = Func->getContext()->getStrDump(); | 1347 Ostream &Str = Func->getContext()->getStrDump(); |
1356 Str << "<OperandX8632>"; | 1348 Str << "<OperandX8632>"; |
1357 } | 1349 } |
1358 | 1350 |
1359 void OperandX8632Mem::emit(const Cfg *Func) const { | 1351 void OperandX8632Mem::emit(const Cfg *Func) const { |
1360 Ostream &Str = Func->getContext()->getStrEmit(); | 1352 Ostream &Str = Func->getContext()->getStrEmit(); |
1361 Str << TypeX8632Attributes[getType()].WidthString << " "; | 1353 Str << TypeX8632Attributes[getType()].WidthString << " "; |
1362 if (SegmentReg != DefaultSegment) { | 1354 if (SegmentReg != DefaultSegment) { |
1363 assert(SegmentReg >= 0 && | 1355 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); |
1364 static_cast<size_t>(SegmentReg) < InstX8632SegmentRegNamesSize); | |
1365 Str << InstX8632SegmentRegNames[SegmentReg] << ":"; | 1356 Str << InstX8632SegmentRegNames[SegmentReg] << ":"; |
1366 } | 1357 } |
1367 // TODO: The following is an almost verbatim paste of dump(). | 1358 // TODO: The following is an almost verbatim paste of dump(). |
1368 bool Dumped = false; | 1359 bool Dumped = false; |
1369 Str << "["; | 1360 Str << "["; |
1370 if (Base) { | 1361 if (Base) { |
1371 Base->emit(Func); | 1362 Base->emit(Func); |
1372 Dumped = true; | 1363 Dumped = true; |
1373 } | 1364 } |
1374 if (Index) { | 1365 if (Index) { |
(...skipping 22 matching lines...) Expand all Loading... |
1397 } else { | 1388 } else { |
1398 // There is only the offset. | 1389 // There is only the offset. |
1399 Offset->emit(Func); | 1390 Offset->emit(Func); |
1400 } | 1391 } |
1401 Str << "]"; | 1392 Str << "]"; |
1402 } | 1393 } |
1403 | 1394 |
1404 void OperandX8632Mem::dump(const Cfg *Func) const { | 1395 void OperandX8632Mem::dump(const Cfg *Func) const { |
1405 Ostream &Str = Func->getContext()->getStrDump(); | 1396 Ostream &Str = Func->getContext()->getStrDump(); |
1406 if (SegmentReg != DefaultSegment) { | 1397 if (SegmentReg != DefaultSegment) { |
1407 assert(SegmentReg >= 0 && | 1398 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); |
1408 static_cast<size_t>(SegmentReg) < InstX8632SegmentRegNamesSize); | |
1409 Str << InstX8632SegmentRegNames[SegmentReg] << ":"; | 1399 Str << InstX8632SegmentRegNames[SegmentReg] << ":"; |
1410 } | 1400 } |
1411 bool Dumped = false; | 1401 bool Dumped = false; |
1412 Str << "["; | 1402 Str << "["; |
1413 if (Base) { | 1403 if (Base) { |
1414 Base->dump(Func); | 1404 Base->dump(Func); |
1415 Dumped = true; | 1405 Dumped = true; |
1416 } | 1406 } |
1417 if (Index) { | 1407 if (Index) { |
1418 assert(Base); | 1408 assert(Base); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 default: | 1467 default: |
1478 Str << "???"; | 1468 Str << "???"; |
1479 break; | 1469 break; |
1480 } | 1470 } |
1481 Str << "("; | 1471 Str << "("; |
1482 Var->dump(Func); | 1472 Var->dump(Func); |
1483 Str << ")"; | 1473 Str << ")"; |
1484 } | 1474 } |
1485 | 1475 |
1486 } // end of namespace Ice | 1476 } // end of namespace Ice |
OLD | NEW |