summaryrefslogtreecommitdiff
path: root/compiler/utils/arm/assembler_thumb2.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2015-05-20 11:25:27 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2015-05-20 11:25:27 +0100
commitd126ba19a2a3352fedbe43ed628ab60ccd401424 (patch)
tree79059b8060b33c3955cda9d5001dbf337e1b1f58 /compiler/utils/arm/assembler_thumb2.cc
parent3e736b12d62ea539b71bd9e6ce953347c0f09a3e (diff)
[Optimizing] Thumb2 assembler: use 16bits branches when we can.
We cannot relocate branches, but we can at least encode branches on 16bits when the target is known. Change-Id: Icb6116ed974fc97e03622ac80d914c2c06f4cba2
Diffstat (limited to 'compiler/utils/arm/assembler_thumb2.cc')
-rw-r--r--compiler/utils/arm/assembler_thumb2.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/utils/arm/assembler_thumb2.cc b/compiler/utils/arm/assembler_thumb2.cc
index e7cf26eee2..75f2b77c96 100644
--- a/compiler/utils/arm/assembler_thumb2.cc
+++ b/compiler/utils/arm/assembler_thumb2.cc
@@ -1638,7 +1638,6 @@ void Thumb2Assembler::EmitBranch(Condition cond, Label* label, bool link, bool x
// branch the size may change if it so happens that other branches change size that change
// the distance to the target and that distance puts this branch over the limit for 16 bits.
if (size == Branch::k16Bit) {
- DCHECK(!force_32bit_branches_);
Emit16(0); // Space for a 16 bit branch.
} else {
Emit32(0); // Space for a 32 bit branch.
@@ -1646,7 +1645,7 @@ void Thumb2Assembler::EmitBranch(Condition cond, Label* label, bool link, bool x
} else {
// Branch is to an unbound label. Emit space for it.
uint16_t branch_id = AddBranch(branch_type, pc, cond); // Unresolved branch.
- if (force_32bit_branches_ || force_32bit_) {
+ if (!CanRelocateBranches() || force_32bit_) {
Emit16(static_cast<uint16_t>(label->position_)); // Emit current label link.
Emit16(0); // another 16 bits.
} else {
@@ -2282,7 +2281,7 @@ void Thumb2Assembler::Bind(Label* label) {
uint32_t branch_location = branch->GetLocation();
uint16_t next = buffer_.Load<uint16_t>(branch_location); // Get next in chain.
if (changed) {
- DCHECK(!force_32bit_branches_);
+ DCHECK(CanRelocateBranches());
MakeHoleForBranch(branch->GetLocation(), 2);
if (branch->IsCompareAndBranch()) {
// A cbz/cbnz instruction has changed size. There is no valid encoding for
@@ -2742,21 +2741,21 @@ void Thumb2Assembler::dmb(DmbOptions flavor) {
void Thumb2Assembler::CompareAndBranchIfZero(Register r, Label* label) {
- if (force_32bit_branches_) {
+ if (CanRelocateBranches()) {
+ cbz(r, label);
+ } else {
cmp(r, ShifterOperand(0));
b(label, EQ);
- } else {
- cbz(r, label);
}
}
void Thumb2Assembler::CompareAndBranchIfNonZero(Register r, Label* label) {
- if (force_32bit_branches_) {
+ if (CanRelocateBranches()) {
+ cbnz(r, label);
+ } else {
cmp(r, ShifterOperand(0));
b(label, NE);
- } else {
- cbnz(r, label);
}
}
} // namespace arm