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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } TypeX8632Attributes[] = { | 43 } TypeX8632Attributes[] = { |
44 #define X(tag, cvt, sdss, width) \ | 44 #define X(tag, cvt, sdss, width) \ |
45 { cvt, "" sdss, width } \ | 45 { cvt, "" sdss, width } \ |
46 , | 46 , |
47 ICETYPEX8632_TABLE | 47 ICETYPEX8632_TABLE |
48 #undef X | 48 #undef X |
49 }; | 49 }; |
50 const size_t TypeX8632AttributesSize = | 50 const size_t TypeX8632AttributesSize = |
51 llvm::array_lengthof(TypeX8632Attributes); | 51 llvm::array_lengthof(TypeX8632Attributes); |
52 | 52 |
| 53 const char *InstX8632SegmentRegNames[] = { |
| 54 #define X(val, name) \ |
| 55 name, |
| 56 SEG_REGX8632_TABLE |
| 57 #undef X |
| 58 }; |
| 59 const size_t InstX8632SegmentRegNamesSize = |
| 60 llvm::array_lengthof(InstX8632SegmentRegNames); |
| 61 |
53 } // end of anonymous namespace | 62 } // end of anonymous namespace |
54 | 63 |
55 const char *InstX8632::getWidthString(Type Ty) { | 64 const char *InstX8632::getWidthString(Type Ty) { |
56 return TypeX8632Attributes[Ty].WidthString; | 65 return TypeX8632Attributes[Ty].WidthString; |
57 } | 66 } |
58 | 67 |
59 OperandX8632Mem::OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, | 68 OperandX8632Mem::OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, |
60 Constant *Offset, Variable *Index, | 69 Constant *Offset, Variable *Index, |
61 uint32_t Shift) | 70 uint32_t Shift) |
62 : OperandX8632(kMem, Ty), Base(Base), Offset(Offset), Index(Index), | 71 : OperandX8632(kMem, Ty), Base(Base), Offset(Offset), Index(Index), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 addSource(Src0); | 150 addSource(Src0); |
142 addSource(Src1); | 151 addSource(Src1); |
143 } | 152 } |
144 | 153 |
145 InstX8632Ucomiss::InstX8632Ucomiss(Cfg *Func, Operand *Src0, Operand *Src1) | 154 InstX8632Ucomiss::InstX8632Ucomiss(Cfg *Func, Operand *Src0, Operand *Src1) |
146 : InstX8632(Func, InstX8632::Ucomiss, 2, NULL) { | 155 : InstX8632(Func, InstX8632::Ucomiss, 2, NULL) { |
147 addSource(Src0); | 156 addSource(Src0); |
148 addSource(Src1); | 157 addSource(Src1); |
149 } | 158 } |
150 | 159 |
| 160 InstX8632UD2::InstX8632UD2(Cfg *Func) |
| 161 : InstX8632(Func, InstX8632::UD2, 0, NULL) { |
| 162 } |
| 163 |
151 InstX8632Test::InstX8632Test(Cfg *Func, Operand *Src1, Operand *Src2) | 164 InstX8632Test::InstX8632Test(Cfg *Func, Operand *Src1, Operand *Src2) |
152 : InstX8632(Func, InstX8632::Test, 2, NULL) { | 165 : InstX8632(Func, InstX8632::Test, 2, NULL) { |
153 addSource(Src1); | 166 addSource(Src1); |
154 addSource(Src2); | 167 addSource(Src2); |
155 } | 168 } |
156 | 169 |
157 InstX8632Store::InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem) | 170 InstX8632Store::InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem) |
158 : InstX8632(Func, InstX8632::Store, 2, NULL) { | 171 : InstX8632(Func, InstX8632::Store, 2, NULL) { |
159 addSource(Value); | 172 addSource(Value); |
160 addSource(Mem); | 173 addSource(Mem); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 getSrc(1)->emit(Func); | 531 getSrc(1)->emit(Func); |
519 Str << "\n"; | 532 Str << "\n"; |
520 } | 533 } |
521 | 534 |
522 void InstX8632Ucomiss::dump(const Cfg *Func) const { | 535 void InstX8632Ucomiss::dump(const Cfg *Func) const { |
523 Ostream &Str = Func->getContext()->getStrDump(); | 536 Ostream &Str = Func->getContext()->getStrDump(); |
524 Str << "ucomiss." << getSrc(0)->getType() << " "; | 537 Str << "ucomiss." << getSrc(0)->getType() << " "; |
525 dumpSources(Func); | 538 dumpSources(Func); |
526 } | 539 } |
527 | 540 |
| 541 void InstX8632UD2::emit(const Cfg *Func) const { |
| 542 Ostream &Str = Func->getContext()->getStrEmit(); |
| 543 assert(getSrcSize() == 0); |
| 544 Str << "\tud2\n"; |
| 545 } |
| 546 |
| 547 void InstX8632UD2::dump(const Cfg *Func) const { |
| 548 Ostream &Str = Func->getContext()->getStrDump(); |
| 549 Str << "ud2\n"; |
| 550 } |
| 551 |
528 void InstX8632Test::emit(const Cfg *Func) const { | 552 void InstX8632Test::emit(const Cfg *Func) const { |
529 Ostream &Str = Func->getContext()->getStrEmit(); | 553 Ostream &Str = Func->getContext()->getStrEmit(); |
530 assert(getSrcSize() == 2); | 554 assert(getSrcSize() == 2); |
531 Str << "\ttest\t"; | 555 Str << "\ttest\t"; |
532 getSrc(0)->emit(Func); | 556 getSrc(0)->emit(Func); |
533 Str << ", "; | 557 Str << ", "; |
534 getSrc(1)->emit(Func); | 558 getSrc(1)->emit(Func); |
535 Str << "\n"; | 559 Str << "\n"; |
536 } | 560 } |
537 | 561 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 if (!OffsetIsZero) { // Suppress if Offset is known to be 0 | 843 if (!OffsetIsZero) { // Suppress if Offset is known to be 0 |
820 if (Dumped) { | 844 if (Dumped) { |
821 if (!OffsetIsNegative) // Suppress if Offset is known to be negative | 845 if (!OffsetIsNegative) // Suppress if Offset is known to be negative |
822 Str << "+"; | 846 Str << "+"; |
823 } | 847 } |
824 Offset->dump(Func); | 848 Offset->dump(Func); |
825 } | 849 } |
826 Str << "]"; | 850 Str << "]"; |
827 } | 851 } |
828 | 852 |
| 853 void OperandX8632MemOffSeg::emit(const Cfg *Func) const { |
| 854 Ostream &Str = Func->getContext()->getStrEmit(); |
| 855 Str << TypeX8632Attributes[getType()].WidthString << " "; |
| 856 assert(SegmentReg < InstX8632SegmentRegNamesSize); |
| 857 Str << InstX8632SegmentRegNames[SegmentReg] << ":"; |
| 858 int64_t OffVal = 0; |
| 859 if (ConstantInteger *CI = llvm::dyn_cast<ConstantInteger>(Offset)) { |
| 860 OffVal = CI->getValue(); |
| 861 } else { |
| 862 assert (Offset == NULL && "Offset should be NULL or ConstantInteger"); |
| 863 OffVal = 0; |
| 864 } |
| 865 Str << "[" << OffVal << "]"; |
| 866 } |
| 867 |
| 868 void OperandX8632MemOffSeg::dump(const Cfg *Func) const { |
| 869 // Same as emit for now. |
| 870 emit(Func); |
| 871 } |
| 872 |
829 void VariableSplit::emit(const Cfg *Func) const { | 873 void VariableSplit::emit(const Cfg *Func) const { |
830 Ostream &Str = Func->getContext()->getStrEmit(); | 874 Ostream &Str = Func->getContext()->getStrEmit(); |
831 assert(Var->getLocalUseNode() == NULL || | 875 assert(Var->getLocalUseNode() == NULL || |
832 Var->getLocalUseNode() == Func->getCurrentNode()); | 876 Var->getLocalUseNode() == Func->getCurrentNode()); |
833 assert(!Var->hasReg()); | 877 assert(!Var->hasReg()); |
834 // The following is copied/adapted from TargetX8632::emitVariable(). | 878 // The following is copied/adapted from TargetX8632::emitVariable(). |
835 const TargetLowering *Target = Func->getTarget(); | 879 const TargetLowering *Target = Func->getTarget(); |
836 const Type Ty = IceType_i32; | 880 const Type Ty = IceType_i32; |
837 Str << TypeX8632Attributes[Ty].WidthString << " [" | 881 Str << TypeX8632Attributes[Ty].WidthString << " [" |
838 << Target->getRegName(Target->getFrameOrStackReg(), Ty); | 882 << Target->getRegName(Target->getFrameOrStackReg(), Ty); |
(...skipping 20 matching lines...) Expand all Loading... |
859 default: | 903 default: |
860 Str << "???"; | 904 Str << "???"; |
861 break; | 905 break; |
862 } | 906 } |
863 Str << "("; | 907 Str << "("; |
864 Var->dump(Func); | 908 Var->dump(Func); |
865 Str << ")"; | 909 Str << ")"; |
866 } | 910 } |
867 | 911 |
868 } // end of namespace Ice | 912 } // end of namespace Ice |
OLD | NEW |