[aarch64-port-dev ] Fix out-of-range operand in tableswitch
Andrew Haley
aph at redhat.com
Tue Jul 23 08:41:39 PDT 2013
This is a better fix: override subsw.
Andrew.
# HG changeset patch
# User aph
# Date 1374593234 -3600
# Node ID 8720a675c697186c2226f4752dd00d5e132cd667
# Parent 53c82d8e3b681b4450287ad96335fff2f4990c07
Fix subsw for arbitrary integer operands.
diff -r 53c82d8e3b68 -r 8720a675c697 src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
--- a/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Mon Jul 22 15:16:58 2013 +0100
+++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Tue Jul 23 16:27:14 2013 +0100
@@ -143,6 +143,17 @@
virtual void notify(int type);
+ // Overrides
+
+ void subsw(Register Rd, Register Rn, Register Rm,
+ enum shift_kind kind, unsigned shift = 0) {
+ Assembler::subsw(Rd, Rn, Rm, kind, shift);
+ }
+
+ void subsw(Register Rd, Register Rn, Register Rm) {
+ Assembler::subsw(Rd, Rn, Rm);
+ }
+
// aliases defined in AARCH64 spec
@@ -1219,9 +1230,9 @@
Register scratch);
// SUBSW with an arbitrary integer operand
- void adjsw(Register Rd, Register Rn, jint imm) {
- if (operand_valid_for_add_sub_immediate(imm)) {
- subsw(Rd, Rn, imm);
+ virtual void subsw(Register Rd, Register Rn, unsigned imm) {
+ if (operand_valid_for_add_sub_immediate((int)imm)) {
+ Assembler::subsw(Rd, Rn, imm);
} else {
assert_different_registers(Rd, Rn);
movw(Rd, imm);
@@ -1232,8 +1243,8 @@
void tableswitch(Register index, jint lowbound, jint highbound,
Label &jumptable, Label &jumptable_end) {
adr(rscratch1, jumptable);
- adjsw(rscratch2, index, lowbound);
- adjsw(zr, rscratch2, highbound - lowbound);
+ subsw(rscratch2, index, lowbound);
+ subsw(zr, rscratch2, highbound - lowbound);
br(Assembler::HS, jumptable_end);
add(rscratch1, rscratch1, rscratch2, ext::sxtw, 2);
br(rscratch1);
More information about the aarch64-port-dev
mailing list