summaryrefslogtreecommitdiff
path: root/compiler/utils/assembler.h
diff options
context:
space:
mode:
author Dave Allison <dallison@google.com> 2014-04-28 13:45:27 -0700
committer Dave Allison <dallison@google.com> 2014-06-05 12:45:20 -0700
commit65fcc2cf3c5cd97b84330c094908f3a6a7a8d4e7 (patch)
treefc0ce77d446477be37f0ec8c86d67df4941cac9b /compiler/utils/assembler.h
parente3b5cb502371aff7e7b7291facfc27b092e7803e (diff)
Thumb2 assembler for JNI compiler and optimizing compiler
This provides a programmatic assembler for the thumb2 instruction set for ARM. The interface is the same as the ARM assembler and the ARM assembler has been moved into Arm32Assembler. The assembler handles most 16 and 32 bit instructions and also allows relocations due to branch expansion. It will also rewrite cbz/cbnz instructions if they go out of range. It also changes the JNI compiler to use the thumb2 assembler as opposed to forcing it to use ARM32. The trampoline compiler still uses ARM due to the way it returns the address of its generated code. A trampoline in thumb2 is the same size as that in ARM anyway (8 bytes). Provides gtest for testing the thumb2 instruction output. This gtest only runs on the host as it uses arm-eabi-objdump to disassemble the generated code. On the target the output is not checked but the assembler will still be run to perform all its checks. Change-Id: Icd9742b6f13541bec5b23097896727392e3a6fb6
Diffstat (limited to 'compiler/utils/assembler.h')
-rw-r--r--compiler/utils/assembler.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/compiler/utils/assembler.h b/compiler/utils/assembler.h
index 19239e1256..f72f5e55ed 100644
--- a/compiler/utils/assembler.h
+++ b/compiler/utils/assembler.h
@@ -38,6 +38,8 @@ class AssemblerFixup;
namespace arm {
class ArmAssembler;
+ class Arm32Assembler;
+ class Thumb2Assembler;
}
namespace arm64 {
class Arm64Assembler;
@@ -87,7 +89,7 @@ class Label {
int LinkPosition() const {
CHECK(IsLinked());
- return position_ - kWordSize;
+ return position_ - kPointerSize;
}
bool IsBound() const { return position_ < 0; }
@@ -114,6 +116,8 @@ class Label {
}
friend class arm::ArmAssembler;
+ friend class arm::Arm32Assembler;
+ friend class arm::Thumb2Assembler;
friend class mips::MipsAssembler;
friend class x86::X86Assembler;
friend class x86_64::X86_64Assembler;
@@ -189,6 +193,15 @@ class AssemblerBuffer {
*reinterpret_cast<T*>(contents_ + position) = value;
}
+ void Move(size_t newposition, size_t oldposition) {
+ CHECK(HasEnsuredCapacity());
+ // Move the contents of the buffer from oldposition to
+ // newposition by nbytes.
+ size_t nbytes = Size() - oldposition;
+ memmove(contents_ + newposition, contents_ + oldposition, nbytes);
+ cursor_ += newposition - oldposition;
+ }
+
// Emit a fixup at the current location.
void EmitFixup(AssemblerFixup* fixup) {
fixup->set_previous(fixup_);