OLD | NEW |
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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 | 790 |
791 void InstARM32Call::emit(const Cfg *Func) const { | 791 void InstARM32Call::emit(const Cfg *Func) const { |
792 if (!BuildDefs::dump()) | 792 if (!BuildDefs::dump()) |
793 return; | 793 return; |
794 Ostream &Str = Func->getContext()->getStrEmit(); | 794 Ostream &Str = Func->getContext()->getStrEmit(); |
795 assert(getSrcSize() == 1); | 795 assert(getSrcSize() == 1); |
796 if (llvm::isa<ConstantInteger32>(getCallTarget())) { | 796 if (llvm::isa<ConstantInteger32>(getCallTarget())) { |
797 // This shouldn't happen (typically have to copy the full 32-bits to a | 797 // This shouldn't happen (typically have to copy the full 32-bits to a |
798 // register and do an indirect jump). | 798 // register and do an indirect jump). |
799 llvm::report_fatal_error("ARM32Call to ConstantInteger32"); | 799 llvm::report_fatal_error("ARM32Call to ConstantInteger32"); |
800 } else if (const auto CallTarget = | 800 } else if (const auto *CallTarget = |
801 llvm::dyn_cast<ConstantRelocatable>(getCallTarget())) { | 801 llvm::dyn_cast<ConstantRelocatable>(getCallTarget())) { |
802 // Calls only have 24-bits, but the linker should insert veneers to extend | 802 // Calls only have 24-bits, but the linker should insert veneers to extend |
803 // the range if needed. | 803 // the range if needed. |
804 Str << "\t" | 804 Str << "\t" |
805 << "bl" | 805 << "bl" |
806 << "\t"; | 806 << "\t"; |
807 CallTarget->emitWithoutPrefix(Func->getTarget()); | 807 CallTarget->emitWithoutPrefix(Func->getTarget()); |
808 } else { | 808 } else { |
809 Str << "\t" | 809 Str << "\t" |
810 << "blx" | 810 << "blx" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 getDest()->emit(Func); | 882 getDest()->emit(Func); |
883 Str << ", "; | 883 Str << ", "; |
884 getSrc(0)->emit(Func); | 884 getSrc(0)->emit(Func); |
885 } | 885 } |
886 | 886 |
887 template <InstARM32::InstKindARM32 K> | 887 template <InstARM32::InstKindARM32 K> |
888 void InstARM32TwoAddrGPR<K>::emitIAS(const Cfg *Func) const { | 888 void InstARM32TwoAddrGPR<K>::emitIAS(const Cfg *Func) const { |
889 emitUsingTextFixup(Func); | 889 emitUsingTextFixup(Func); |
890 } | 890 } |
891 | 891 |
| 892 template <InstARM32::InstKindARM32 K, bool Nws> |
| 893 void InstARM32UnaryopGPR<K, Nws>::emitIAS(const Cfg *Func) const { |
| 894 emitUsingTextFixup(Func); |
| 895 } |
| 896 |
892 template <> void InstARM32Movw::emit(const Cfg *Func) const { | 897 template <> void InstARM32Movw::emit(const Cfg *Func) const { |
893 if (!BuildDefs::dump()) | 898 if (!BuildDefs::dump()) |
894 return; | 899 return; |
895 Ostream &Str = Func->getContext()->getStrEmit(); | 900 Ostream &Str = Func->getContext()->getStrEmit(); |
896 assert(getSrcSize() == 1); | 901 assert(getSrcSize() == 1); |
897 Str << "\t" << Opcode << getPredicate() << "\t"; | 902 Str << "\t" << Opcode << getPredicate() << "\t"; |
898 getDest()->emit(Func); | 903 getDest()->emit(Func); |
899 Str << ", "; | 904 Str << ", "; |
900 Constant *Src0 = llvm::cast<Constant>(getSrc(0)); | 905 Constant *Src0 = llvm::cast<Constant>(getSrc(0)); |
901 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src0)) { | 906 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src0)) { |
902 Str << "#:lower16:"; | 907 Str << "#:lower16:"; |
903 CR->emitWithoutPrefix(Func->getTarget()); | 908 CR->emitWithoutPrefix(Func->getTarget()); |
904 } else { | 909 } else { |
905 Src0->emit(Func); | 910 Src0->emit(Func); |
906 } | 911 } |
907 } | 912 } |
908 | 913 |
| 914 template <> void InstARM32Movw::emitIAS(const Cfg *Func) const { |
| 915 assert(getSrcSize() == 1); |
| 916 ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); |
| 917 Asm->movw(getDest(), getSrc(0), getPredicate()); |
| 918 if (Asm->needsTextFixup()) |
| 919 emitUsingTextFixup(Func); |
| 920 } |
| 921 |
909 template <> void InstARM32Movt::emit(const Cfg *Func) const { | 922 template <> void InstARM32Movt::emit(const Cfg *Func) const { |
910 if (!BuildDefs::dump()) | 923 if (!BuildDefs::dump()) |
911 return; | 924 return; |
912 Ostream &Str = Func->getContext()->getStrEmit(); | 925 Ostream &Str = Func->getContext()->getStrEmit(); |
913 assert(getSrcSize() == 2); | 926 assert(getSrcSize() == 2); |
914 Variable *Dest = getDest(); | 927 Variable *Dest = getDest(); |
915 Constant *Src1 = llvm::cast<Constant>(getSrc(1)); | 928 Constant *Src1 = llvm::cast<Constant>(getSrc(1)); |
916 Str << "\t" << Opcode << getPredicate() << "\t"; | 929 Str << "\t" << Opcode << getPredicate() << "\t"; |
917 Dest->emit(Func); | 930 Dest->emit(Func); |
918 Str << ", "; | 931 Str << ", "; |
919 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src1)) { | 932 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src1)) { |
920 Str << "#:upper16:"; | 933 Str << "#:upper16:"; |
921 CR->emitWithoutPrefix(Func->getTarget()); | 934 CR->emitWithoutPrefix(Func->getTarget()); |
922 } else { | 935 } else { |
923 Src1->emit(Func); | 936 Src1->emit(Func); |
924 } | 937 } |
925 } | 938 } |
926 | 939 |
| 940 template <> void InstARM32Movt::emitIAS(const Cfg *Func) const { |
| 941 assert(getSrcSize() == 2); |
| 942 ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); |
| 943 Asm->movt(getDest(), getSrc(1), getPredicate()); |
| 944 if (Asm->needsTextFixup()) |
| 945 emitUsingTextFixup(Func); |
| 946 } |
| 947 |
927 void InstARM32Pop::emit(const Cfg *Func) const { | 948 void InstARM32Pop::emit(const Cfg *Func) const { |
928 // TODO(jpp): Improve FP register save/restore. | 949 // TODO(jpp): Improve FP register save/restore. |
929 if (!BuildDefs::dump()) | 950 if (!BuildDefs::dump()) |
930 return; | 951 return; |
931 SizeT IntegerCount = 0; | 952 SizeT IntegerCount = 0; |
932 for (const Operand *Op : Dests) { | 953 for (const Operand *Op : Dests) { |
933 if (isScalarIntegerType(Op->getType())) { | 954 if (isScalarIntegerType(Op->getType())) { |
934 ++IntegerCount; | 955 ++IntegerCount; |
935 } | 956 } |
936 } | 957 } |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 template class InstARM32ThreeAddrGPR<InstARM32::Sub>; | 1476 template class InstARM32ThreeAddrGPR<InstARM32::Sub>; |
1456 template class InstARM32ThreeAddrGPR<InstARM32::Udiv>; | 1477 template class InstARM32ThreeAddrGPR<InstARM32::Udiv>; |
1457 | 1478 |
1458 template class InstARM32ThreeAddrFP<InstARM32::Vadd>; | 1479 template class InstARM32ThreeAddrFP<InstARM32::Vadd>; |
1459 template class InstARM32ThreeAddrFP<InstARM32::Vdiv>; | 1480 template class InstARM32ThreeAddrFP<InstARM32::Vdiv>; |
1460 template class InstARM32ThreeAddrFP<InstARM32::Vmul>; | 1481 template class InstARM32ThreeAddrFP<InstARM32::Vmul>; |
1461 template class InstARM32ThreeAddrFP<InstARM32::Vsub>; | 1482 template class InstARM32ThreeAddrFP<InstARM32::Vsub>; |
1462 | 1483 |
1463 template class InstARM32TwoAddrGPR<InstARM32::Movt>; | 1484 template class InstARM32TwoAddrGPR<InstARM32::Movt>; |
1464 | 1485 |
| 1486 template class InstARM32UnaryopGPR<InstARM32::Movw, false>; |
| 1487 template class InstARM32UnaryopGPR<InstARM32::Clz, false>; |
| 1488 template class InstARM32UnaryopGPR<InstARM32::Mvn, false>; |
| 1489 template class InstARM32UnaryopGPR<InstARM32::Rbit, false>; |
| 1490 template class InstARM32UnaryopGPR<InstARM32::Rev, false>; |
| 1491 template class InstARM32UnaryopGPR<InstARM32::Sxt, true>; |
| 1492 template class InstARM32UnaryopGPR<InstARM32::Uxt, true>; |
| 1493 template class InstARM32UnaryopFP<InstARM32::Vsqrt>; |
| 1494 |
1465 } // end of namespace Ice | 1495 } // end of namespace Ice |
OLD | NEW |