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

Side by Side Diff: src/IceAssemblerARM32.cpp

Issue 1440693002: Handle another form of MOVW in ARM integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 5 years, 1 month 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
OLDNEW
1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===//
2 // 2 //
3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
4 // for details. All rights reserved. Use of this source code is governed by a 4 // for details. All rights reserved. Use of this source code is governed by a
5 // BSD-style license that can be found in the LICENSE file. 5 // BSD-style license that can be found in the LICENSE file.
6 // 6 //
7 // Modified by the Subzero authors. 7 // Modified by the Subzero authors.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 // 10 //
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 // assembler. 747 // assembler.
748 IValueT Rd; 748 IValueT Rd;
749 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) 749 if (decodeOperand(OpRd, Rd) != DecodedAsRegister)
750 return setNeedsTextFixup(); 750 return setNeedsTextFixup();
751 constexpr bool SetFlags = false; 751 constexpr bool SetFlags = false;
752 constexpr IValueT Rn = 0; 752 constexpr IValueT Rn = 0;
753 constexpr IValueT Mov = B3 | B2 | B0; // 1101. 753 constexpr IValueT Mov = B3 | B2 | B0; // 1101.
754 emitType01(Mov, Rd, Rn, OpSrc, SetFlags, Cond); 754 emitType01(Mov, Rd, Rn, OpSrc, SetFlags, Cond);
755 } 755 }
756 756
757 void AssemblerARM32::emitMovw(IValueT Opcode, IValueT Rd, IValueT Imm16,
758 bool SetFlags, CondARM32::Cond Cond) {
759 if (!isConditionDefined(Cond) || !Utils::IsAbsoluteUint(16, Imm16))
760 return setNeedsTextFixup();
761 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
762 const IValueT Encoding = encodeCondition(Cond) << kConditionShift | Opcode |
763 (encodeBool(SetFlags) << kSShift) |
764 ((Imm16 >> 12) << 16) | Rd << kRdShift |
765 (Imm16 & 0xfff);
766 emitInst(Encoding);
767 }
768
757 void AssemblerARM32::movw(const Operand *OpRd, const Operand *OpSrc, 769 void AssemblerARM32::movw(const Operand *OpRd, const Operand *OpSrc,
758 CondARM32::Cond Cond) { 770 CondARM32::Cond Cond) {
759 IValueT Rd; 771 IValueT Rd;
760 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) 772 if (decodeOperand(OpRd, Rd) != DecodedAsRegister)
761 return setNeedsTextFixup(); 773 return setNeedsTextFixup();
762 auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc); 774 if (const auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc)) {
763 if (Src == nullptr) 775 // MOVW (immediate) - ARM section A8.8.102, encoding A2:
776 // movw<c> <Rd>, #<imm16>
777 //
778 // cccc00110000iiiiddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, and
779 // iiiiiiiiiiiiiiii=imm16.
780 if (!isConditionDefined(Cond))
781 // Conditions of rule violated.
782 return setNeedsTextFixup();
783 // Use 0 for the lower 16 bits of the relocatable, and add a fixup to
784 // install the correct bits.
785 constexpr bool IsMovW = true;
786 emitFixup(createMoveFixup(IsMovW, Src));
787 constexpr IValueT Imm16 = 0;
788 constexpr bool SetFlags = false;
789 emitMovw(B25 | B24, Rd, Imm16, SetFlags, Cond);
790 return;
791 }
792 IValueT ConstVal;
793 if (decodeOperand(OpSrc, ConstVal) != DecodedAsConstI32)
764 return setNeedsTextFixup(); 794 return setNeedsTextFixup();
765 // MOVW (immediate) - ARM section A8.8.102, encoding A2: 795 // TODO(kschimpf): Determine if we want to handle rotated immediate 8 values
766 // movw<c> <Rd>, #<imm16> 796 // to handle cases where the constant is greater tham 16 bits (encoding A1
Jim Stichnoth 2015/11/11 21:46:39 than
Karl 2015/11/11 22:48:19 Done.
797 // below). For now, handle using encoding A2.
798 constexpr bool SetFlags = 0;
799 emitMovw(B25 | B24, Rd, ConstVal, SetFlags, Cond);
800 return;
801
802 // MOVW (immediate) - ARM section A8.8.102, encoding A1:
803 // movw<c> <Rd>, #<RotatedImm8>
767 // 804 //
768 // cccc00110000iiiiddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, and 805 // cccc0011101s0000ddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, s=SetFlags=0,
769 // iiiiiiiiiiiiiiii=imm16. 806 // and iiiiiiiiiiii is a shift-rotated value defining RotatedImm8.
770 if (!isConditionDefined(Cond))
771 // Conditions of rule violated.
772 return setNeedsTextFixup();
773 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
774 // Use 0 for the lower 16 bits of the relocatable, and add a fixup to
775 // install the correct bits.
776 constexpr bool IsMovW = true;
777 emitFixup(createMoveFixup(IsMovW, Src));
778 constexpr IValueT Imm16 = 0;
779 const IValueT Encoding = encodeCondition(Cond) << kConditionShift | B25 |
780 B24 | ((Imm16 >> 12) << 16) | Rd << kRdShift |
781 (Imm16 & 0xfff);
782 emitInst(Encoding);
783 } 807 }
784 808
785 void AssemblerARM32::movt(const Operand *OpRd, const Operand *OpSrc, 809 void AssemblerARM32::movt(const Operand *OpRd, const Operand *OpSrc,
786 CondARM32::Cond Cond) { 810 CondARM32::Cond Cond) {
787 IValueT Rd; 811 IValueT Rd;
788 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) 812 if (decodeOperand(OpRd, Rd) != DecodedAsRegister)
789 return setNeedsTextFixup(); 813 return setNeedsTextFixup();
790 auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc); 814 auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc);
791 if (Src == nullptr) 815 if (Src == nullptr)
792 return setNeedsTextFixup(); 816 return setNeedsTextFixup();
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 if (RdHi == RegARM32::Encoded_Reg_pc || RdLo == RegARM32::Encoded_Reg_pc || 1121 if (RdHi == RegARM32::Encoded_Reg_pc || RdLo == RegARM32::Encoded_Reg_pc ||
1098 Rn == RegARM32::Encoded_Reg_pc || Rm == RegARM32::Encoded_Reg_pc || 1122 Rn == RegARM32::Encoded_Reg_pc || Rm == RegARM32::Encoded_Reg_pc ||
1099 RdHi == RdLo) 1123 RdHi == RdLo)
1100 llvm::report_fatal_error("Umull instruction unpredictable on pc"); 1124 llvm::report_fatal_error("Umull instruction unpredictable on pc");
1101 constexpr bool SetFlags = false; 1125 constexpr bool SetFlags = false;
1102 emitMulOp(Cond, B23, RdLo, RdHi, Rn, Rm, SetFlags); 1126 emitMulOp(Cond, B23, RdLo, RdHi, Rn, Rm, SetFlags);
1103 } 1127 }
1104 1128
1105 } // end of namespace ARM32 1129 } // end of namespace ARM32
1106 } // end of namespace Ice 1130 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceAssemblerARM32.h ('k') | src/IceTLS.h » ('j') | tests_lit/assembler/arm32/mov-const.ll » ('J')

Powered by Google App Engine
This is Rietveld 408576698