OLD | NEW |
---|---|
(Empty) | |
1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// | |
2 // | |
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 | |
5 // BSD-style license that can be found in the LICENSE file. | |
6 // | |
7 // Modified by the Subzero authors. | |
8 // | |
9 //===----------------------------------------------------------------------===// | |
10 // | |
11 // The Subzero Code Generator | |
12 // | |
13 // This file is distributed under the University of Illinois Open Source | |
14 // License. See LICENSE.TXT for details. | |
15 // | |
16 //===----------------------------------------------------------------------===// | |
17 /// | |
18 /// \file | |
19 /// This file implements the Assembler class for ARM32. | |
20 /// | |
21 //===----------------------------------------------------------------------===// | |
22 | |
23 #include "IceAssemblerARM32.h" | |
24 | |
25 namespace Ice { | |
26 | |
27 Label *ARM32::AssemblerARM32::getOrCreateLabel(SizeT Number, | |
28 LabelVector &Labels) { | |
29 Label *L = nullptr; | |
30 if (Number == Labels.size()) { | |
31 L = new (this->allocate<Label>()) Label(); | |
32 Labels.push_back(L); | |
33 return L; | |
34 } | |
35 if (Number > Labels.size()) { | |
36 Labels.resize(Number + 1); | |
37 } | |
38 L = Labels[Number]; | |
39 if (!L) { | |
40 L = new (this->allocate<Label>()) Label(); | |
41 Labels[Number] = L; | |
42 } | |
43 return L; | |
44 } | |
45 | |
46 void ARM32::AssemblerARM32::bind(Label *label) { | |
47 intptr_t bound = Buffer.size(); | |
48 assert(!label->isBound()); // Labels can only be bound once. | |
49 while (label->isLinked()) { | |
50 intptr_t position = label->getLinkPosition(); | |
51 intptr_t next = Buffer.load<int32_t>(position); | |
52 Buffer.store<int32_t>(position, bound - (position + 4)); | |
53 label->setPosition(next); | |
54 } | |
55 #if 0 | |
56 // TODO(kschimpf) Decide if we have near jumps. | |
John
2015/10/09 12:12:23
not #if 0 here (and leaving a comment behind) is b
Karl
2015/10/09 19:08:18
Done.
| |
57 while (label->hasNear()) { | |
58 intptr_t position = label->getNearPosition(); | |
59 intptr_t offset = bound - (position + 1); | |
60 assert(Utils::IsInt(8, offset)); | |
61 Buffer.store<int8_t>(position, offset); | |
62 } | |
63 #endif | |
64 label->bindTo(bound); | |
65 } | |
66 | |
67 void ARM32::AssemblerARM32::bkpt(uint16_t imm16) { | |
68 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | |
69 emitInt32(BkptEncoding(imm16)); | |
70 } | |
71 | |
72 void ARM32::AssemblerARM32::bx(RegARM32::GPRRegister rm, CondARM32::Cond cond) { | |
73 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. | |
74 assert(rm != RegARM32::Encoded_Not_GPR); | |
75 assert(cond != CondARM32::kNone); | |
76 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | |
77 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | B24 | | |
78 B21 | (0xfff << 8) | B4 | | |
79 (static_cast<int32_t>(rm) << kRmShift); | |
80 emitInt32(encoding); | |
81 } | |
82 | |
83 } // end of namespace Ice | |
OLD | NEW |