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

Side by Side Diff: src/IceAssemblerARM32.cpp

Issue 1407273006: Generate block labels in the ARM hybrid assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nit. Created 5 years, 2 months 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
« no previous file with comments | « src/IceAssemblerARM32.h ('k') | src/IceAssemblerMIPS32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 //
11 // The Subzero Code Generator 11 // The Subzero Code Generator
12 // 12 //
13 // This file is distributed under the University of Illinois Open Source 13 // This file is distributed under the University of Illinois Open Source
14 // License. See LICENSE.TXT for details. 14 // License. See LICENSE.TXT for details.
15 // 15 //
16 //===----------------------------------------------------------------------===// 16 //===----------------------------------------------------------------------===//
17 /// 17 ///
18 /// \file 18 /// \file
19 /// This file implements the Assembler class for ARM32. 19 /// This file implements the Assembler class for ARM32.
20 /// 20 ///
21 //===----------------------------------------------------------------------===// 21 //===----------------------------------------------------------------------===//
22 22
23 #include "IceAssemblerARM32.h" 23 #include "IceAssemblerARM32.h"
24 #include "IceCfgNode.h"
24 #include "IceUtils.h" 25 #include "IceUtils.h"
25 26
26 namespace { 27 namespace {
27 28
28 using namespace Ice; 29 using namespace Ice;
29 30
30 // The following define individual bits. 31 // The following define individual bits.
31 static constexpr uint32_t B0 = 1; 32 static constexpr uint32_t B0 = 1;
32 static constexpr uint32_t B1 = 1 << 1; 33 static constexpr uint32_t B1 = 1 << 1;
33 static constexpr uint32_t B2 = 1 << 2; 34 static constexpr uint32_t B2 = 1 << 2;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 OperandARM32Mem::Offset); 198 OperandARM32Mem::Offset);
198 return DecodedAsImmRegOffset; 199 return DecodedAsImmRegOffset;
199 } 200 }
200 return CantDecode; 201 return CantDecode;
201 } 202 }
202 203
203 } // end of anonymous namespace 204 } // end of anonymous namespace
204 205
205 namespace Ice { 206 namespace Ice {
206 207
208 void ARM32::AssemblerARM32::bindCfgNodeLabel(const CfgNode *Node) {
209 if (BuildDefs::dump() && !Ctx->getFlags().getDisableHybridAssembly()) {
210 // Generate label name so that branches can find it.
211 constexpr SizeT InstSize = 0;
212 emitTextInst(Node->getAsmName() + ":", InstSize);
213 }
214 SizeT NodeNumber = Node->getIndex();
215 assert(!getPreliminary());
216 Label *L = getOrCreateCfgNodeLabel(NodeNumber);
217 this->bind(L);
218 }
219
207 Label *ARM32::AssemblerARM32::getOrCreateLabel(SizeT Number, 220 Label *ARM32::AssemblerARM32::getOrCreateLabel(SizeT Number,
208 LabelVector &Labels) { 221 LabelVector &Labels) {
209 Label *L = nullptr; 222 Label *L = nullptr;
210 if (Number == Labels.size()) { 223 if (Number == Labels.size()) {
211 L = new (this->allocate<Label>()) Label(); 224 L = new (this->allocate<Label>()) Label();
212 Labels.push_back(L); 225 Labels.push_back(L);
213 return L; 226 return L;
214 } 227 }
215 if (Number > Labels.size()) { 228 if (Number > Labels.size()) {
216 Labels.resize(Number + 1); 229 Labels.resize(Number + 1);
(...skipping 12 matching lines...) Expand all
229 while (label->isLinked()) { 242 while (label->isLinked()) {
230 intptr_t position = label->getLinkPosition(); 243 intptr_t position = label->getLinkPosition();
231 intptr_t next = Buffer.load<int32_t>(position); 244 intptr_t next = Buffer.load<int32_t>(position);
232 Buffer.store<int32_t>(position, bound - (position + 4)); 245 Buffer.store<int32_t>(position, bound - (position + 4));
233 label->setPosition(next); 246 label->setPosition(next);
234 } 247 }
235 // TODO(kschimpf) Decide if we have near jumps. 248 // TODO(kschimpf) Decide if we have near jumps.
236 label->bindTo(bound); 249 label->bindTo(bound);
237 } 250 }
238 251
239 void ARM32::AssemblerARM32::emitTextInst(const std::string &Text) { 252 void ARM32::AssemblerARM32::emitTextInst(const std::string &Text,
240 static constexpr uint32_t Placeholder = 0; 253 SizeT InstSize) {
241 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 254 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
242 AssemblerFixup *F = createTextFixup(Text, sizeof(Placeholder)); 255 AssemblerFixup *F = createTextFixup(Text, InstSize);
243 emitFixup(F); 256 emitFixup(F);
244 emitInst(Placeholder); 257 for (SizeT I = 0; I < InstSize; ++I)
258 Buffer.emit<char>(0);
245 } 259 }
246 260
247 void ARM32::AssemblerARM32::emitType01(CondARM32::Cond Cond, uint32_t Type, 261 void ARM32::AssemblerARM32::emitType01(CondARM32::Cond Cond, uint32_t Type,
248 uint32_t Opcode, bool SetCc, uint32_t Rn, 262 uint32_t Opcode, bool SetCc, uint32_t Rn,
249 uint32_t Rd, uint32_t Imm12) { 263 uint32_t Rd, uint32_t Imm12) {
250 assert(isGPRRegisterDefined(Rd)); 264 assert(isGPRRegisterDefined(Rd));
251 // TODO(kschimpf): Remove void cast when MINIMAL build allows. 265 // TODO(kschimpf): Remove void cast when MINIMAL build allows.
252 (void)isGPRRegisterDefined(Rd); 266 (void)isGPRRegisterDefined(Rd);
253 assert(Cond != CondARM32::kNone); 267 assert(Cond != CondARM32::kNone);
254 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 268 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 if (Rd == RegARM32::Encoded_Reg_pc) 494 if (Rd == RegARM32::Encoded_Reg_pc)
481 // Conditions of rule violated. 495 // Conditions of rule violated.
482 return setNeedsTextFixup(); 496 return setNeedsTextFixup();
483 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value); 497 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value);
484 return; 498 return;
485 } 499 }
486 } 500 }
487 } 501 }
488 502
489 } // end of namespace Ice 503 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceAssemblerARM32.h ('k') | src/IceAssemblerMIPS32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698