| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 Buffer.installFixup(F); | 360 Buffer.installFixup(F); |
| 361 return F; | 361 return F; |
| 362 } | 362 } |
| 363 | 363 |
| 364 size_t BlRelocatableFixup::emit(GlobalContext *Ctx, | 364 size_t BlRelocatableFixup::emit(GlobalContext *Ctx, |
| 365 const Assembler &Asm) const { | 365 const Assembler &Asm) const { |
| 366 if (!BuildDefs::dump()) | 366 if (!BuildDefs::dump()) |
| 367 return InstARM32::InstSize; | 367 return InstARM32::InstSize; |
| 368 Ostream &Str = Ctx->getStrEmit(); | 368 Ostream &Str = Ctx->getStrEmit(); |
| 369 IValueT Inst = Asm.load<IValueT>(position()); | 369 IValueT Inst = Asm.load<IValueT>(position()); |
| 370 Str << "\tbl\t" << symbol(Ctx) << "\t@ .word " | 370 Str << "\t" |
| 371 << "bl\t" << symbol(Ctx) << "\t@ .word " |
| 371 << llvm::format_hex_no_prefix(Inst, 8) << "\n"; | 372 << llvm::format_hex_no_prefix(Inst, 8) << "\n"; |
| 372 return InstARM32::InstSize; | 373 return InstARM32::InstSize; |
| 373 } | 374 } |
| 374 | 375 |
| 375 BlRelocatableFixup * | 376 BlRelocatableFixup * |
| 376 AssemblerARM32::createBlFixup(const ConstantRelocatable *Target) { | 377 AssemblerARM32::createBlFixup(const ConstantRelocatable *BlTarget) { |
| 377 BlRelocatableFixup *F = | 378 BlRelocatableFixup *F = |
| 378 new (allocate<BlRelocatableFixup>()) BlRelocatableFixup(); | 379 new (allocate<BlRelocatableFixup>()) BlRelocatableFixup(); |
| 379 F->set_kind(llvm::ELF::R_ARM_CALL); | 380 F->set_kind(llvm::ELF::R_ARM_CALL); |
| 380 F->set_value(Target); | 381 F->set_value(BlTarget); |
| 381 Buffer.installFixup(F); | 382 Buffer.installFixup(F); |
| 382 return F; | 383 return F; |
| 383 } | 384 } |
| 384 | 385 |
| 385 void AssemblerARM32::bindCfgNodeLabel(const CfgNode *Node) { | 386 void AssemblerARM32::bindCfgNodeLabel(const CfgNode *Node) { |
| 386 GlobalContext *Ctx = Node->getCfg()->getContext(); | 387 GlobalContext *Ctx = Node->getCfg()->getContext(); |
| 387 if (BuildDefs::dump() && !Ctx->getFlags().getDisableHybridAssembly()) { | 388 if (BuildDefs::dump() && !Ctx->getFlags().getDisableHybridAssembly()) { |
| 388 // Generate label name so that branches can find it. | 389 // Generate label name so that branches can find it. |
| 389 constexpr SizeT InstSize = 0; | 390 constexpr SizeT InstSize = 0; |
| 390 emitTextInst(Node->getAsmName() + ":", InstSize); | 391 emitTextInst(Node->getAsmName() + ":", InstSize); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } | 458 } |
| 458 | 459 |
| 459 void AssemblerARM32::emitType01(CondARM32::Cond Cond, IValueT Type, | 460 void AssemblerARM32::emitType01(CondARM32::Cond Cond, IValueT Type, |
| 460 IValueT Opcode, bool SetFlags, IValueT Rn, | 461 IValueT Opcode, bool SetFlags, IValueT Rn, |
| 461 IValueT Rd, IValueT Imm12, | 462 IValueT Rd, IValueT Imm12, |
| 462 EmitChecks RuleChecks) { | 463 EmitChecks RuleChecks) { |
| 463 switch (RuleChecks) { | 464 switch (RuleChecks) { |
| 464 case NoChecks: | 465 case NoChecks: |
| 465 break; | 466 break; |
| 466 case RdIsPcAndSetFlags: | 467 case RdIsPcAndSetFlags: |
| 467 if (((Rd == RegARM32::Encoded_Reg_pc) && SetFlags)) | 468 if ((Rd == RegARM32::Encoded_Reg_pc) && SetFlags) |
| 468 // Conditions of rule violated. | 469 // Conditions of rule violated. |
| 469 return setNeedsTextFixup(); | 470 return setNeedsTextFixup(); |
| 470 break; | 471 break; |
| 471 } | 472 } |
| 472 | 473 |
| 473 if (!isGPRRegisterDefined(Rd) || !isConditionDefined(Cond)) | 474 if (!isGPRRegisterDefined(Rd) || !isConditionDefined(Cond)) |
| 474 return setNeedsTextFixup(); | 475 return setNeedsTextFixup(); |
| 475 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 476 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 476 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | | 477 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | |
| 477 (Type << kTypeShift) | (Opcode << kOpcodeShift) | | 478 (Type << kTypeShift) | (Opcode << kOpcodeShift) | |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 // BLX (register) - ARM section A8.8.26, encoding A1: | 772 // BLX (register) - ARM section A8.8.26, encoding A1: |
| 772 // blx<c> <Rm> | 773 // blx<c> <Rm> |
| 773 // | 774 // |
| 774 // cccc000100101111111111110011mmmm where cccc=Cond (not currently allowed) | 775 // cccc000100101111111111110011mmmm where cccc=Cond (not currently allowed) |
| 775 // and mmmm=Rm. | 776 // and mmmm=Rm. |
| 776 if (Rm == RegARM32::Encoded_Reg_pc) | 777 if (Rm == RegARM32::Encoded_Reg_pc) |
| 777 // Unpredictable. | 778 // Unpredictable. |
| 778 return setNeedsTextFixup(); | 779 return setNeedsTextFixup(); |
| 779 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 780 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 780 constexpr CondARM32::Cond Cond = CondARM32::AL; | 781 constexpr CondARM32::Cond Cond = CondARM32::AL; |
| 781 int32_t Encoding = (static_cast<int32_t>(Cond) << kConditionShift) | B24 | | 782 int32_t Encoding = (encodeCondition(Cond) << kConditionShift) | B24 | B21 | |
| 782 B21 | (0xfff << 8) | B5 | B4 | (Rm << kRmShift); | 783 (0xfff << 8) | B5 | B4 | (Rm << kRmShift); |
| 783 emitInst(Encoding); | 784 emitInst(Encoding); |
| 784 } | 785 } |
| 785 | 786 |
| 786 void AssemblerARM32::bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond) { | 787 void AssemblerARM32::bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond) { |
| 787 // BX - ARM section A8.8.27, encoding A1: | 788 // BX - ARM section A8.8.27, encoding A1: |
| 788 // bx<c> <Rm> | 789 // bx<c> <Rm> |
| 789 // | 790 // |
| 790 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. | 791 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. |
| 791 if (!(isGPRRegisterDefined(Rm) && isConditionDefined(Cond))) | 792 if (!(isGPRRegisterDefined(Rm) && isConditionDefined(Cond))) |
| 792 return setNeedsTextFixup(); | 793 return setNeedsTextFixup(); |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 // rr defined (RotationValue) rotate. | 1407 // rr defined (RotationValue) rotate. |
| 1407 constexpr IValueT Opcode = B26 | B25 | B23 | B22 | B21 | B20; | 1408 constexpr IValueT Opcode = B26 | B25 | B23 | B22 | B21 | B20; |
| 1408 emitUxt(Cond, Opcode, Rd, Rn, Rm, Rotation); | 1409 emitUxt(Cond, Opcode, Rd, Rn, Rm, Rotation); |
| 1409 return; | 1410 return; |
| 1410 } | 1411 } |
| 1411 } | 1412 } |
| 1412 } | 1413 } |
| 1413 | 1414 |
| 1414 } // end of namespace ARM32 | 1415 } // end of namespace ARM32 |
| 1415 } // end of namespace Ice | 1416 } // end of namespace Ice |
| OLD | NEW |