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

Side by Side Diff: src/IceAssemblerARM32.cpp

Issue 1397933002: Start incorporating the ARM integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nit and add URL. 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
(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 // TODO(kschimpf) Decide if we have near jumps.
56 label->bindTo(bound);
57 }
58
59 void ARM32::AssemblerARM32::bkpt(uint16_t imm16) {
60 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
61 emitInt32(BkptEncoding(imm16));
62 }
63
64 void ARM32::AssemblerARM32::bx(RegARM32::GPRRegister rm, CondARM32::Cond cond) {
65 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond.
66 assert(rm != RegARM32::Encoded_Not_GPR);
67 assert(cond != CondARM32::kNone);
68 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
69 int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | B24 |
70 B21 | (0xfff << 8) | B4 |
71 (static_cast<int32_t>(rm) << kRmShift);
72 emitInt32(encoding);
73 }
74
75 } // 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