OLD | NEW |
1 //===- subzero/src/IceAssemblerARM32.h - Assembler for ARM32 ----*- C++ -*-===// | 1 //===- subzero/src/IceAssemblerARM32.h - 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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 namespace Ice { | 38 namespace Ice { |
39 namespace ARM32 { | 39 namespace ARM32 { |
40 | 40 |
41 /// Encoding of an ARM 32-bit instruction. | 41 /// Encoding of an ARM 32-bit instruction. |
42 using IValueT = uint32_t; | 42 using IValueT = uint32_t; |
43 | 43 |
44 /// An Offset value (+/-) used in an ARM 32-bit instruction. | 44 /// An Offset value (+/-) used in an ARM 32-bit instruction. |
45 using IOffsetT = int32_t; | 45 using IOffsetT = int32_t; |
46 | 46 |
| 47 /// Handles encoding of bottom/top 16 bits of an address using movw/movt. |
| 48 class MoveRelocatableFixup : public AssemblerFixup { |
| 49 MoveRelocatableFixup &operator=(const MoveRelocatableFixup &) = delete; |
| 50 MoveRelocatableFixup(const MoveRelocatableFixup &) = default; |
| 51 |
| 52 public: |
| 53 MoveRelocatableFixup() = default; |
| 54 size_t emit(GlobalContext *Ctx, const Assembler &Asm) const override; |
| 55 }; |
| 56 |
47 class AssemblerARM32 : public Assembler { | 57 class AssemblerARM32 : public Assembler { |
48 AssemblerARM32(const AssemblerARM32 &) = delete; | 58 AssemblerARM32(const AssemblerARM32 &) = delete; |
49 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete; | 59 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete; |
50 | 60 |
51 public: | 61 public: |
52 explicit AssemblerARM32(bool use_far_branches = false) | 62 explicit AssemblerARM32(bool use_far_branches = false) |
53 : Assembler(Asm_ARM32) { | 63 : Assembler(Asm_ARM32) { |
54 // TODO(kschimpf): Add mode if needed when branches are handled. | 64 // TODO(kschimpf): Add mode if needed when branches are handled. |
55 (void)use_far_branches; | 65 (void)use_far_branches; |
56 } | 66 } |
57 ~AssemblerARM32() override { | 67 ~AssemblerARM32() override { |
58 if (BuildDefs::asserts()) { | 68 if (BuildDefs::asserts()) { |
59 for (const Label *Label : CfgNodeLabels) { | 69 for (const Label *Label : CfgNodeLabels) { |
60 Label->finalCheck(); | 70 Label->finalCheck(); |
61 } | 71 } |
62 for (const Label *Label : LocalLabels) { | 72 for (const Label *Label : LocalLabels) { |
63 Label->finalCheck(); | 73 Label->finalCheck(); |
64 } | 74 } |
65 } | 75 } |
66 } | 76 } |
67 | 77 |
| 78 MoveRelocatableFixup *createMoveFixup(bool IsMovW, const Constant *Value); |
| 79 |
68 void alignFunction() override { | 80 void alignFunction() override { |
69 const SizeT Align = 1 << getBundleAlignLog2Bytes(); | 81 const SizeT Align = 1 << getBundleAlignLog2Bytes(); |
70 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); | 82 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); |
71 constexpr IValueT UndefinedInst = 0xe7fedef0; // udf #60896 | 83 constexpr IValueT UndefinedInst = 0xe7fedef0; // udf #60896 |
72 constexpr SizeT InstSize = sizeof(IValueT); | 84 constexpr SizeT InstSize = sizeof(IValueT); |
73 assert(BytesNeeded % InstSize == 0); | 85 assert(BytesNeeded % InstSize == 0); |
74 while (BytesNeeded > 0) { | 86 while (BytesNeeded > 0) { |
75 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 87 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
76 emitInst(UndefinedInst); | 88 emitInst(UndefinedInst); |
77 BytesNeeded -= InstSize; | 89 BytesNeeded -= InstSize; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 bool SetFlags, CondARM32::Cond Cond); | 142 bool SetFlags, CondARM32::Cond Cond); |
131 | 143 |
132 void b(Label *L, CondARM32::Cond Cond); | 144 void b(Label *L, CondARM32::Cond Cond); |
133 | 145 |
134 void bkpt(uint16_t Imm16); | 146 void bkpt(uint16_t Imm16); |
135 | 147 |
136 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); | 148 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); |
137 | 149 |
138 void mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); | 150 void mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); |
139 | 151 |
| 152 void movw(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); |
| 153 |
| 154 void movt(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); |
| 155 |
140 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL); | 156 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL); |
141 | 157 |
142 void sbc(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 158 void sbc(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
143 bool SetFlags, CondARM32::Cond Cond); | 159 bool SetFlags, CondARM32::Cond Cond); |
144 | 160 |
145 void str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); | 161 void str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); |
146 | 162 |
147 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 163 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
148 bool SetFlags, CondARM32::Cond Cond); | 164 bool SetFlags, CondARM32::Cond Cond); |
149 | 165 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 IValueT encodeBranchOffset(IOffsetT Offset, IValueT Inst); | 202 IValueT encodeBranchOffset(IOffsetT Offset, IValueT Inst); |
187 | 203 |
188 // Returns the offset encoded in the branch instruction Inst. | 204 // Returns the offset encoded in the branch instruction Inst. |
189 static IOffsetT decodeBranchOffset(IValueT Inst); | 205 static IOffsetT decodeBranchOffset(IValueT Inst); |
190 }; | 206 }; |
191 | 207 |
192 } // end of namespace ARM32 | 208 } // end of namespace ARM32 |
193 } // end of namespace Ice | 209 } // end of namespace Ice |
194 | 210 |
195 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H | 211 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H |
OLD | NEW |