| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void InstARM32::startNextInst(const Cfg *Func) const { | 96 void InstARM32::startNextInst(const Cfg *Func) const { |
| 97 if (auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>()) | 97 if (auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>()) |
| 98 Asm->incEmitTextSize(InstSize); | 98 Asm->incEmitTextSize(InstSize); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void InstARM32::emitUsingTextFixup(const Cfg *Func) const { | 101 void InstARM32::emitUsingTextFixup(const Cfg *Func) const { |
| 102 if (!BuildDefs::dump()) | 102 if (!BuildDefs::dump()) |
| 103 return; | 103 return; |
| 104 GlobalContext *Ctx = Func->getContext(); | 104 GlobalContext *Ctx = Func->getContext(); |
| 105 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | 105 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); |
| 106 if (Ctx->getFlags().getDisableHybridAssembly() && | 106 if (getFlags().getDisableHybridAssembly() && |
| 107 Ctx->getFlags().getSkipUnimplemented()) { | 107 getFlags().getSkipUnimplemented()) { |
| 108 Asm->trap(); | 108 Asm->trap(); |
| 109 Asm->resetNeedsTextFixup(); | 109 Asm->resetNeedsTextFixup(); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 std::string Buffer; | 112 std::string Buffer; |
| 113 llvm::raw_string_ostream StrBuf(Buffer); | 113 llvm::raw_string_ostream StrBuf(Buffer); |
| 114 OstreamLocker L(Ctx); | 114 OstreamLocker L(Ctx); |
| 115 Ostream &OldStr = Ctx->getStrEmit(); | 115 Ostream &OldStr = Ctx->getStrEmit(); |
| 116 Ctx->setStrEmit(StrBuf); | 116 Ctx->setStrEmit(StrBuf); |
| 117 // Start counting instructions here, so that emit() methods don't | 117 // Start counting instructions here, so that emit() methods don't |
| 118 // need to call this for the first instruction. | 118 // need to call this for the first instruction. |
| 119 Asm->resetEmitTextSize(); | 119 Asm->resetEmitTextSize(); |
| 120 Asm->incEmitTextSize(InstSize); | 120 Asm->incEmitTextSize(InstSize); |
| 121 emit(Func); | 121 emit(Func); |
| 122 Ctx->setStrEmit(OldStr); | 122 Ctx->setStrEmit(OldStr); |
| 123 if (Ctx->getFlags().getDisableHybridAssembly()) { | 123 if (getFlags().getDisableHybridAssembly()) { |
| 124 if (Ctx->getFlags().getSkipUnimplemented()) { | 124 if (getFlags().getSkipUnimplemented()) { |
| 125 Asm->trap(); | 125 Asm->trap(); |
| 126 } else { | 126 } else { |
| 127 llvm::errs() << "Can't assemble: " << StrBuf.str() << "\n"; | 127 llvm::errs() << "Can't assemble: " << StrBuf.str() << "\n"; |
| 128 UnimplementedError(Ctx->getFlags()); | 128 UnimplementedError(getFlags()); |
| 129 } | 129 } |
| 130 Asm->resetNeedsTextFixup(); | 130 Asm->resetNeedsTextFixup(); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 Asm->emitTextInst(StrBuf.str(), Asm->getEmitTextSize()); | 133 Asm->emitTextInst(StrBuf.str(), Asm->getEmitTextSize()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void InstARM32::emitIAS(const Cfg *Func) const { emitUsingTextFixup(Func); } | 136 void InstARM32::emitIAS(const Cfg *Func) const { emitUsingTextFixup(Func); } |
| 137 | 137 |
| 138 void InstARM32Pred::emitUnaryopGPR(const char *Opcode, | 138 void InstARM32Pred::emitUnaryopGPR(const char *Opcode, |
| (...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 // A label is not really an instruction. Hence, we need to fix the | 1734 // A label is not really an instruction. Hence, we need to fix the |
| 1735 // emitted text size. | 1735 // emitted text size. |
| 1736 if (auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>()) | 1736 if (auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>()) |
| 1737 Asm->decEmitTextSize(InstSize); | 1737 Asm->decEmitTextSize(InstSize); |
| 1738 Ostream &Str = Func->getContext()->getStrEmit(); | 1738 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1739 Str << getLabelName() << ":"; | 1739 Str << getLabelName() << ":"; |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 void InstARM32Label::emitIAS(const Cfg *Func) const { | 1742 void InstARM32Label::emitIAS(const Cfg *Func) const { |
| 1743 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | 1743 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); |
| 1744 Asm->bindLocalLabel(Func, this, Number); | 1744 Asm->bindLocalLabel(this, Number); |
| 1745 if (OffsetReloc != nullptr) { | 1745 if (OffsetReloc != nullptr) { |
| 1746 Asm->bindRelocOffset(OffsetReloc); | 1746 Asm->bindRelocOffset(OffsetReloc); |
| 1747 } | 1747 } |
| 1748 if (Asm->needsTextFixup()) | 1748 if (Asm->needsTextFixup()) |
| 1749 emitUsingTextFixup(Func); | 1749 emitUsingTextFixup(Func); |
| 1750 } | 1750 } |
| 1751 | 1751 |
| 1752 void InstARM32Label::dump(const Cfg *Func) const { | 1752 void InstARM32Label::dump(const Cfg *Func) const { |
| 1753 if (!BuildDefs::dump()) | 1753 if (!BuildDefs::dump()) |
| 1754 return; | 1754 return; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 return; | 1880 return; |
| 1881 Ostream &Str = Func->getContext()->getStrEmit(); | 1881 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1882 assert(getSrcSize() == 1); | 1882 assert(getSrcSize() == 1); |
| 1883 Str << "\t" << Opcode << getPredicate() << "\t"; | 1883 Str << "\t" << Opcode << getPredicate() << "\t"; |
| 1884 getDest()->emit(Func); | 1884 getDest()->emit(Func); |
| 1885 Str << ", "; | 1885 Str << ", "; |
| 1886 auto *Src0 = llvm::cast<Constant>(getSrc(0)); | 1886 auto *Src0 = llvm::cast<Constant>(getSrc(0)); |
| 1887 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src0)) { | 1887 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src0)) { |
| 1888 Str << "#:lower16:"; | 1888 Str << "#:lower16:"; |
| 1889 CR->emitWithoutPrefix(Func->getTarget()); | 1889 CR->emitWithoutPrefix(Func->getTarget()); |
| 1890 if (Func->getContext()->getFlags().getUseNonsfi()) { | 1890 if (getFlags().getUseNonsfi()) { |
| 1891 Str << " - ."; | 1891 Str << " - ."; |
| 1892 } | 1892 } |
| 1893 } else { | 1893 } else { |
| 1894 Src0->emit(Func); | 1894 Src0->emit(Func); |
| 1895 } | 1895 } |
| 1896 } | 1896 } |
| 1897 | 1897 |
| 1898 template <> void InstARM32Movw::emitIAS(const Cfg *Func) const { | 1898 template <> void InstARM32Movw::emitIAS(const Cfg *Func) const { |
| 1899 assert(getSrcSize() == 1); | 1899 assert(getSrcSize() == 1); |
| 1900 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | 1900 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); |
| 1901 Asm->movw(getDest(), getSrc(0), getPredicate()); | 1901 Asm->movw(getDest(), getSrc(0), getPredicate()); |
| 1902 if (Asm->needsTextFixup()) | 1902 if (Asm->needsTextFixup()) |
| 1903 emitUsingTextFixup(Func); | 1903 emitUsingTextFixup(Func); |
| 1904 } | 1904 } |
| 1905 | 1905 |
| 1906 template <> void InstARM32Movt::emit(const Cfg *Func) const { | 1906 template <> void InstARM32Movt::emit(const Cfg *Func) const { |
| 1907 if (!BuildDefs::dump()) | 1907 if (!BuildDefs::dump()) |
| 1908 return; | 1908 return; |
| 1909 Ostream &Str = Func->getContext()->getStrEmit(); | 1909 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1910 assert(getSrcSize() == 2); | 1910 assert(getSrcSize() == 2); |
| 1911 Variable *Dest = getDest(); | 1911 Variable *Dest = getDest(); |
| 1912 auto *Src1 = llvm::cast<Constant>(getSrc(1)); | 1912 auto *Src1 = llvm::cast<Constant>(getSrc(1)); |
| 1913 Str << "\t" << Opcode << getPredicate() << "\t"; | 1913 Str << "\t" << Opcode << getPredicate() << "\t"; |
| 1914 Dest->emit(Func); | 1914 Dest->emit(Func); |
| 1915 Str << ", "; | 1915 Str << ", "; |
| 1916 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src1)) { | 1916 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src1)) { |
| 1917 Str << "#:upper16:"; | 1917 Str << "#:upper16:"; |
| 1918 CR->emitWithoutPrefix(Func->getTarget()); | 1918 CR->emitWithoutPrefix(Func->getTarget()); |
| 1919 if (Func->getContext()->getFlags().getUseNonsfi()) { | 1919 if (getFlags().getUseNonsfi()) { |
| 1920 Str << " - ."; | 1920 Str << " - ."; |
| 1921 } | 1921 } |
| 1922 } else { | 1922 } else { |
| 1923 Src1->emit(Func); | 1923 Src1->emit(Func); |
| 1924 } | 1924 } |
| 1925 } | 1925 } |
| 1926 | 1926 |
| 1927 template <> void InstARM32Movt::emitIAS(const Cfg *Func) const { | 1927 template <> void InstARM32Movt::emitIAS(const Cfg *Func) const { |
| 1928 assert(getSrcSize() == 2); | 1928 assert(getSrcSize() == 2); |
| 1929 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | 1929 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2787 | 2787 |
| 2788 template class InstARM32FourAddrGPR<InstARM32::Mla>; | 2788 template class InstARM32FourAddrGPR<InstARM32::Mla>; |
| 2789 template class InstARM32FourAddrGPR<InstARM32::Mls>; | 2789 template class InstARM32FourAddrGPR<InstARM32::Mls>; |
| 2790 | 2790 |
| 2791 template class InstARM32CmpLike<InstARM32::Cmn>; | 2791 template class InstARM32CmpLike<InstARM32::Cmn>; |
| 2792 template class InstARM32CmpLike<InstARM32::Cmp>; | 2792 template class InstARM32CmpLike<InstARM32::Cmp>; |
| 2793 template class InstARM32CmpLike<InstARM32::Tst>; | 2793 template class InstARM32CmpLike<InstARM32::Tst>; |
| 2794 | 2794 |
| 2795 } // end of namespace ARM32 | 2795 } // end of namespace ARM32 |
| 2796 } // end of namespace Ice | 2796 } // end of namespace Ice |
| OLD | NEW |