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

Side by Side Diff: src/IceAssemblerARM32.h

Issue 1424863005: Handle MOV (immediate) and MOVT to load ARM global addresses. (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 26 matching lines...) Expand all
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() = delete; 58 AssemblerARM32() = delete;
49 AssemblerARM32(const AssemblerARM32 &) = delete; 59 AssemblerARM32(const AssemblerARM32 &) = delete;
50 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete; 60 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete;
51 61
52 public: 62 public:
53 explicit AssemblerARM32(GlobalContext *Ctx, bool use_far_branches = false) 63 explicit AssemblerARM32(GlobalContext *Ctx, bool use_far_branches = false)
54 : Assembler(Asm_ARM32, Ctx) { 64 : Assembler(Asm_ARM32, Ctx) {
55 // TODO(kschimpf): Add mode if needed when branches are handled. 65 // TODO(kschimpf): Add mode if needed when branches are handled.
56 (void)use_far_branches; 66 (void)use_far_branches;
57 } 67 }
58 ~AssemblerARM32() override { 68 ~AssemblerARM32() override {
59 if (BuildDefs::asserts()) { 69 if (BuildDefs::asserts()) {
60 for (const Label *Label : CfgNodeLabels) { 70 for (const Label *Label : CfgNodeLabels) {
61 Label->finalCheck(); 71 Label->finalCheck();
62 } 72 }
63 for (const Label *Label : LocalLabels) { 73 for (const Label *Label : LocalLabels) {
64 Label->finalCheck(); 74 Label->finalCheck();
65 } 75 }
66 } 76 }
67 } 77 }
68 78
79 MoveRelocatableFixup *createMoveFixup(bool IsMovW, const Constant *Value);
80
69 void alignFunction() override { 81 void alignFunction() override {
70 const SizeT Align = 1 << getBundleAlignLog2Bytes(); 82 const SizeT Align = 1 << getBundleAlignLog2Bytes();
71 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); 83 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align);
72 constexpr IValueT UndefinedInst = 0xe7fedef0; // udf #60896 84 constexpr IValueT UndefinedInst = 0xe7fedef0; // udf #60896
73 constexpr SizeT InstSize = sizeof(IValueT); 85 constexpr SizeT InstSize = sizeof(IValueT);
74 assert(BytesNeeded % InstSize == 0); 86 assert(BytesNeeded % InstSize == 0);
75 while (BytesNeeded > 0) { 87 while (BytesNeeded > 0) {
76 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 88 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
77 emitInst(UndefinedInst); 89 emitInst(UndefinedInst);
78 BytesNeeded -= InstSize; 90 BytesNeeded -= InstSize;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bool SetFlags, CondARM32::Cond Cond); 143 bool SetFlags, CondARM32::Cond Cond);
132 144
133 void b(Label *L, CondARM32::Cond Cond); 145 void b(Label *L, CondARM32::Cond Cond);
134 146
135 void bkpt(uint16_t Imm16); 147 void bkpt(uint16_t Imm16);
136 148
137 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); 149 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond);
138 150
139 void mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); 151 void mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond);
140 152
153 void movw(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond);
154
155 void movt(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond);
156
141 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL); 157 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL);
142 158
143 void str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); 159 void str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond);
144 160
145 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, 161 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1,
146 bool SetFlags, CondARM32::Cond Cond); 162 bool SetFlags, CondARM32::Cond Cond);
147 163
148 static bool classof(const Assembler *Asm) { 164 static bool classof(const Assembler *Asm) {
149 return Asm->getKind() == Asm_ARM32; 165 return Asm->getKind() == Asm_ARM32;
150 } 166 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 IValueT encodeBranchOffset(IOffsetT Offset, IValueT Inst); 200 IValueT encodeBranchOffset(IOffsetT Offset, IValueT Inst);
185 201
186 // Returns the offset encoded in the branch instruction Inst. 202 // Returns the offset encoded in the branch instruction Inst.
187 static IOffsetT decodeBranchOffset(IValueT Inst); 203 static IOffsetT decodeBranchOffset(IValueT Inst);
188 }; 204 };
189 205
190 } // end of namespace ARM32 206 } // end of namespace ARM32
191 } // end of namespace Ice 207 } // end of namespace Ice
192 208
193 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H 209 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698