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

Side by Side Diff: src/IceAssemblerARM32.h

Issue 1452293003: Add BL (immediate) and BLX (register) to ARM 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.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 27 matching lines...) Expand all
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. 47 /// Handles encoding of bottom/top 16 bits of an address using movw/movt.
48 class MoveRelocatableFixup : public AssemblerFixup { 48 class MoveRelocatableFixup final : public AssemblerFixup {
49 MoveRelocatableFixup &operator=(const MoveRelocatableFixup &) = delete; 49 MoveRelocatableFixup &operator=(const MoveRelocatableFixup &) = delete;
50 MoveRelocatableFixup(const MoveRelocatableFixup &) = default; 50 MoveRelocatableFixup(const MoveRelocatableFixup &) = default;
51 51
52 public: 52 public:
53 MoveRelocatableFixup() = default; 53 MoveRelocatableFixup() = default;
54 size_t emit(GlobalContext *Ctx, const Assembler &Asm) const override; 54 size_t emit(GlobalContext *Ctx, const Assembler &Asm) const final;
55 };
56
57 /// Handles encoding of branch and link to global location.
58 class BlRelocatableFixup final : public AssemblerFixup {
59 BlRelocatableFixup(const BlRelocatableFixup &) = delete;
60 BlRelocatableFixup &operator=(const BlRelocatableFixup &) = delete;
61
62 public:
63 BlRelocatableFixup() = default;
64 size_t emit(GlobalContext *Ctx, const Assembler &Asm) const final;
55 }; 65 };
56 66
57 class AssemblerARM32 : public Assembler { 67 class AssemblerARM32 : public Assembler {
58 AssemblerARM32(const AssemblerARM32 &) = delete; 68 AssemblerARM32(const AssemblerARM32 &) = delete;
59 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete; 69 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete;
60 70
61 public: 71 public:
62 // Rotation values. 72 // Rotation values.
63 enum RotationValue { 73 enum RotationValue {
64 kRotateNone, // Omitted 74 kRotateNone, // Omitted
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 Label->finalCheck(); 106 Label->finalCheck();
97 } 107 }
98 for (const Label *Label : LocalLabels) { 108 for (const Label *Label : LocalLabels) {
99 Label->finalCheck(); 109 Label->finalCheck();
100 } 110 }
101 } 111 }
102 } 112 }
103 113
104 MoveRelocatableFixup *createMoveFixup(bool IsMovW, const Constant *Value); 114 MoveRelocatableFixup *createMoveFixup(bool IsMovW, const Constant *Value);
105 115
116 BlRelocatableFixup *createBlFixup(const ConstantRelocatable *Target);
Jim Stichnoth 2015/11/22 03:27:03 I'd be happier if we reserved variable name "Targe
Karl 2015/11/30 16:54:35 Done.
117
106 void alignFunction() override { 118 void alignFunction() override {
107 const SizeT Align = 1 << getBundleAlignLog2Bytes(); 119 const SizeT Align = 1 << getBundleAlignLog2Bytes();
108 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); 120 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align);
109 constexpr IValueT UndefinedInst = 0xe7fedef0; // udf #60896 121 constexpr IValueT UndefinedInst = 0xe7fedef0; // udf #60896
110 constexpr SizeT InstSize = sizeof(IValueT); 122 constexpr SizeT InstSize = sizeof(IValueT);
111 assert(BytesNeeded % InstARM32::InstSize == 0); 123 assert(BytesNeeded % InstARM32::InstSize == 0);
112 while (BytesNeeded > 0) { 124 while (BytesNeeded > 0) {
113 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 125 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
114 emitInst(UndefinedInst); 126 emitInst(UndefinedInst);
115 BytesNeeded -= InstSize; 127 BytesNeeded -= InstSize;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 bool SetFlags, CondARM32::Cond Cond); 191 bool SetFlags, CondARM32::Cond Cond);
180 192
181 void add(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, 193 void add(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1,
182 bool SetFlags, CondARM32::Cond Cond); 194 bool SetFlags, CondARM32::Cond Cond);
183 195
184 void and_(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, 196 void and_(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1,
185 bool SetFlags, CondARM32::Cond Cond); 197 bool SetFlags, CondARM32::Cond Cond);
186 198
187 void b(Label *L, CondARM32::Cond Cond); 199 void b(Label *L, CondARM32::Cond Cond);
188 200
189 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL);
190
191 void bkpt(uint16_t Imm16); 201 void bkpt(uint16_t Imm16);
192 202
193 void cmp(const Operand *OpRn, const Operand *OpSrc1, CondARM32::Cond Cond);
194
195 void bic(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, 203 void bic(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1,
196 bool SetFlags, CondARM32::Cond Cond); 204 bool SetFlags, CondARM32::Cond Cond);
197 205
206 void bl(const ConstantRelocatable *Target);
207
208 void blx(const Operand *Target);
209
210 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL);
211
212 void cmp(const Operand *OpRn, const Operand *OpSrc1, CondARM32::Cond Cond);
213
198 void eor(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, 214 void eor(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1,
199 bool SetFlags, CondARM32::Cond Cond); 215 bool SetFlags, CondARM32::Cond Cond);
200 216
201 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond, 217 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond,
202 const TargetInfo &TInfo); 218 const TargetInfo &TInfo);
203 219
204 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond, 220 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond,
205 const TargetLowering *Lowering) { 221 const TargetLowering *Lowering) {
206 const TargetInfo TInfo(Lowering); 222 const TargetInfo TInfo(Lowering);
207 ldr(OpRt, OpAddress, Cond, TInfo); 223 ldr(OpRt, OpAddress, Cond, TInfo);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // cccc=Cond, xxxxxxx<<21=Opcode, dddd=Rd, s=SetFlags, and 384 // cccc=Cond, xxxxxxx<<21=Opcode, dddd=Rd, s=SetFlags, and
369 // iiiiiiiiiiiiiiii=Imm16. 385 // iiiiiiiiiiiiiiii=Imm16.
370 void emitMovw(IValueT Opcode, IValueT Rd, IValueT Imm16, bool SetFlags, 386 void emitMovw(IValueT Opcode, IValueT Rd, IValueT Imm16, bool SetFlags,
371 CondARM32::Cond Cond); 387 CondARM32::Cond Cond);
372 }; 388 };
373 389
374 } // end of namespace ARM32 390 } // end of namespace ARM32
375 } // end of namespace Ice 391 } // end of namespace Ice
376 392
377 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H 393 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698