Chromium Code Reviews| Index: src/IceAssemblerARM32.cpp |
| diff --git a/src/IceAssemblerARM32.cpp b/src/IceAssemblerARM32.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5a3a225575be9f56274998330fd792a62bd71554 |
| --- /dev/null |
| +++ b/src/IceAssemblerARM32.cpp |
| @@ -0,0 +1,83 @@ |
| +//===- 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); |
| + } |
| +#if 0 |
| + // TODO(kschimpf) Decide if we have near jumps. |
|
John
2015/10/09 12:12:23
not #if 0 here (and leaving a comment behind) is b
Karl
2015/10/09 19:08:18
Done.
|
| + while (label->hasNear()) { |
| + intptr_t position = label->getNearPosition(); |
| + intptr_t offset = bound - (position + 1); |
| + assert(Utils::IsInt(8, offset)); |
| + Buffer.store<int8_t>(position, offset); |
| + } |
| +#endif |
| + 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 |