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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceAssemblerARM32.h ('k') | src/IceAssemblerMIPS32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceAssemblerARM32.cpp
diff --git a/src/IceAssemblerARM32.cpp b/src/IceAssemblerARM32.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ab22450f04ba482c6e3ffa71b8c4a647c93dbb43
--- /dev/null
+++ b/src/IceAssemblerARM32.cpp
@@ -0,0 +1,75 @@
+//===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===//
+//
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// Modified by the Subzero authors.
+//
+//===----------------------------------------------------------------------===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file implements the Assembler class for ARM32.
+///
+//===----------------------------------------------------------------------===//
+
+#include "IceAssemblerARM32.h"
+
+namespace Ice {
+
+Label *ARM32::AssemblerARM32::getOrCreateLabel(SizeT Number,
+ LabelVector &Labels) {
+ Label *L = nullptr;
+ if (Number == Labels.size()) {
+ L = new (this->allocate<Label>()) Label();
+ Labels.push_back(L);
+ return L;
+ }
+ if (Number > Labels.size()) {
+ Labels.resize(Number + 1);
+ }
+ L = Labels[Number];
+ if (!L) {
+ L = new (this->allocate<Label>()) Label();
+ Labels[Number] = L;
+ }
+ return L;
+}
+
+void ARM32::AssemblerARM32::bind(Label *label) {
+ intptr_t bound = Buffer.size();
+ assert(!label->isBound()); // Labels can only be bound once.
+ while (label->isLinked()) {
+ intptr_t position = label->getLinkPosition();
+ intptr_t next = Buffer.load<int32_t>(position);
+ Buffer.store<int32_t>(position, bound - (position + 4));
+ label->setPosition(next);
+ }
+ // TODO(kschimpf) Decide if we have near jumps.
+ label->bindTo(bound);
+}
+
+void ARM32::AssemblerARM32::bkpt(uint16_t imm16) {
+ AssemblerBuffer::EnsureCapacity ensured(&Buffer);
+ emitInt32(BkptEncoding(imm16));
+}
+
+void ARM32::AssemblerARM32::bx(RegARM32::GPRRegister rm, CondARM32::Cond cond) {
+ // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond.
+ assert(rm != RegARM32::Encoded_Not_GPR);
+ assert(cond != CondARM32::kNone);
+ AssemblerBuffer::EnsureCapacity ensured(&Buffer);
+ int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | B24 |
+ B21 | (0xfff << 8) | B4 |
+ (static_cast<int32_t>(rm) << kRmShift);
+ emitInt32(encoding);
+}
+
+} // end of namespace Ice
« 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