Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 const Constant *Value) { | 320 const Constant *Value) { |
| 321 MoveRelocatableFixup *F = | 321 MoveRelocatableFixup *F = |
| 322 new (allocate<MoveRelocatableFixup>()) MoveRelocatableFixup(); | 322 new (allocate<MoveRelocatableFixup>()) MoveRelocatableFixup(); |
| 323 F->set_kind(IsMovW ? llvm::ELF::R_ARM_MOVW_ABS_NC | 323 F->set_kind(IsMovW ? llvm::ELF::R_ARM_MOVW_ABS_NC |
| 324 : llvm::ELF::R_ARM_MOVT_ABS); | 324 : llvm::ELF::R_ARM_MOVT_ABS); |
| 325 F->set_value(Value); | 325 F->set_value(Value); |
| 326 Buffer.installFixup(F); | 326 Buffer.installFixup(F); |
| 327 return F; | 327 return F; |
| 328 } | 328 } |
| 329 | 329 |
| 330 size_t BlRelocatableFixup::emit(GlobalContext *Ctx, | |
| 331 const Assembler &Asm) const { | |
| 332 if (!BuildDefs::dump()) | |
| 333 return InstARM32::InstSize; | |
| 334 Ostream &Str = Ctx->getStrEmit(); | |
| 335 IValueT Inst = Asm.load<IValueT>(position()); | |
| 336 Str << "\tbl\t" << symbol(Ctx) << "\t@ .word " | |
|
Jim Stichnoth
2015/11/22 03:27:03
At least on the x86 emit() side, we try to separat
Karl
2015/11/30 16:54:35
Done.
| |
| 337 << llvm::format_hex_no_prefix(Inst, 8) << "\n"; | |
| 338 return InstARM32::InstSize; | |
| 339 } | |
| 340 | |
| 341 BlRelocatableFixup * | |
| 342 AssemblerARM32::createBlFixup(const ConstantRelocatable *Target) { | |
| 343 BlRelocatableFixup *F = | |
| 344 new (allocate<BlRelocatableFixup>()) BlRelocatableFixup(); | |
| 345 F->set_kind(llvm::ELF::R_ARM_CALL); | |
| 346 F->set_value(Target); | |
| 347 Buffer.installFixup(F); | |
| 348 return F; | |
| 349 } | |
| 350 | |
| 330 void AssemblerARM32::bindCfgNodeLabel(const CfgNode *Node) { | 351 void AssemblerARM32::bindCfgNodeLabel(const CfgNode *Node) { |
| 331 GlobalContext *Ctx = Node->getCfg()->getContext(); | 352 GlobalContext *Ctx = Node->getCfg()->getContext(); |
| 332 if (BuildDefs::dump() && !Ctx->getFlags().getDisableHybridAssembly()) { | 353 if (BuildDefs::dump() && !Ctx->getFlags().getDisableHybridAssembly()) { |
| 333 // Generate label name so that branches can find it. | 354 // Generate label name so that branches can find it. |
| 334 constexpr SizeT InstSize = 0; | 355 constexpr SizeT InstSize = 0; |
| 335 emitTextInst(Node->getAsmName() + ":", InstSize); | 356 emitTextInst(Node->getAsmName() + ":", InstSize); |
| 336 } | 357 } |
| 337 SizeT NodeNumber = Node->getIndex(); | 358 SizeT NodeNumber = Node->getIndex(); |
| 338 assert(!getPreliminary()); | 359 assert(!getPreliminary()); |
| 339 Label *L = getOrCreateCfgNodeLabel(NodeNumber); | 360 Label *L = getOrCreateCfgNodeLabel(NodeNumber); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 // | 700 // |
| 680 // BIC (immediate) - ARM section A8.8.21, encoding A1: | 701 // BIC (immediate) - ARM section A8.8.21, encoding A1: |
| 681 // bic{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 702 // bic{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 682 // | 703 // |
| 683 // cccc0011110snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rn, nnnn=Rn, | 704 // cccc0011110snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rn, nnnn=Rn, |
| 684 // s=SetFlags, and iiiiiiiiiiii=Src1Value defining RotatedImm8. | 705 // s=SetFlags, and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 685 IValueT Opcode = B3 | B2 | B1; // i.e. 1110 | 706 IValueT Opcode = B3 | B2 | B1; // i.e. 1110 |
| 686 emitType01(Opcode, OpRd, OpRn, OpSrc1, SetFlags, Cond); | 707 emitType01(Opcode, OpRd, OpRn, OpSrc1, SetFlags, Cond); |
| 687 } | 708 } |
| 688 | 709 |
| 710 void AssemblerARM32::bl(const ConstantRelocatable *Target) { | |
| 711 // BL (immediate) - ARM section A8.8.25, encoding A1: | |
| 712 // bl<c> <label> | |
| 713 // | |
| 714 // cccc1011iiiiiiiiiiiiiiiiiiiiiiii where cccc=Cond (not currently allowed) | |
| 715 // and iiiiiiiiiiiiiiiiiiiiiiii is the (encoded) Target to branch to. | |
| 716 emitFixup(createBlFixup(Target)); | |
| 717 constexpr CondARM32::Cond Cond = CondARM32::AL; | |
| 718 constexpr IValueT Immed = 0; | |
| 719 constexpr bool Link = true; | |
| 720 emitType05(Cond, Immed, Link); | |
| 721 } | |
| 722 | |
| 723 void AssemblerARM32::blx(const Operand *Target) { | |
| 724 IValueT Rm; | |
| 725 if (decodeOperand(Target, Rm) != DecodedAsRegister) | |
| 726 return setNeedsTextFixup(); | |
| 727 // BLX (register) - ARM section A8.8.26, encoding A1: | |
| 728 // blx<c> <Rm> | |
| 729 // | |
| 730 // cccc000100101111111111110011mmmm where cccc=Cond (not currently allowed) | |
| 731 // and mmmm=Rm. | |
| 732 if (Rm == RegARM32::Encoded_Reg_pc) | |
| 733 // Unpredictable. | |
| 734 return setNeedsTextFixup(); | |
| 735 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | |
| 736 constexpr CondARM32::Cond Cond = CondARM32::AL; | |
| 737 int32_t Encoding = (static_cast<int32_t>(Cond) << kConditionShift) | B24 | | |
|
Jim Stichnoth
2015/11/22 03:27:03
IValueT instead of int32_t, right?
Karl
2015/11/30 16:54:35
Replaced with encodeCondition(Cond).
| |
| 738 B21 | (0xfff << 8) | B5 | B4 | (Rm << kRmShift); | |
| 739 emitInst(Encoding); | |
| 740 } | |
| 741 | |
| 689 void AssemblerARM32::bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond) { | 742 void AssemblerARM32::bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond) { |
| 690 // BX - ARM section A8.8.27, encoding A1: | 743 // BX - ARM section A8.8.27, encoding A1: |
| 691 // bx<c> <Rm> | 744 // bx<c> <Rm> |
| 692 // | 745 // |
| 693 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. | 746 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. |
| 694 if (!(isGPRRegisterDefined(Rm) && isConditionDefined(Cond))) | 747 if (!(isGPRRegisterDefined(Rm) && isConditionDefined(Cond))) |
| 695 return setNeedsTextFixup(); | 748 return setNeedsTextFixup(); |
| 696 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 749 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 697 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B24 | | 750 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B24 | |
| 698 B21 | (0xfff << 8) | B4 | | 751 B21 | (0xfff << 8) | B4 | |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1242 // rr defined (RotationValue) rotate. | 1295 // rr defined (RotationValue) rotate. |
| 1243 constexpr IValueT Opcode = B26 | B25 | B23 | B22 | B21 | B20; | 1296 constexpr IValueT Opcode = B26 | B25 | B23 | B22 | B21 | B20; |
| 1244 emitUxt(Cond, Opcode, Rd, Rn, Rm, Rotation); | 1297 emitUxt(Cond, Opcode, Rd, Rn, Rm, Rotation); |
| 1245 return; | 1298 return; |
| 1246 } | 1299 } |
| 1247 } | 1300 } |
| 1248 } | 1301 } |
| 1249 | 1302 |
| 1250 } // end of namespace ARM32 | 1303 } // end of namespace ARM32 |
| 1251 } // end of namespace Ice | 1304 } // end of namespace Ice |
| OLD | NEW |