Skip to content

Commit

Permalink
8285802: AArch64: Consistently handle offsets in MacroAssembler as 64…
Browse files Browse the repository at this point in the history
…-bit quantities

Reviewed-by: ngasson, adinn
  • Loading branch information
Andrew Haley committed Apr 29, 2022
1 parent 694556e commit df4d5cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Expand Up @@ -2192,35 +2192,35 @@ void MacroAssembler::unimplemented(const char* what) {

// If a constant does not fit in an immediate field, generate some
// number of MOV instructions and then perform the operation.
void MacroAssembler::wrap_add_sub_imm_insn(Register Rd, Register Rn, unsigned imm,
void MacroAssembler::wrap_add_sub_imm_insn(Register Rd, Register Rn, uint64_t imm,
add_sub_imm_insn insn1,
add_sub_reg_insn insn2) {
assert(Rd != zr, "Rd = zr and not setting flags?");
if (operand_valid_for_add_sub_immediate((int)imm)) {
if (operand_valid_for_add_sub_immediate(imm)) {
(this->*insn1)(Rd, Rn, imm);
} else {
if (uabs(imm) < (1 << 24)) {
(this->*insn1)(Rd, Rn, imm & -(1 << 12));
(this->*insn1)(Rd, Rd, imm & ((1 << 12)-1));
} else {
assert_different_registers(Rd, Rn);
mov(Rd, (uint64_t)imm);
mov(Rd, imm);
(this->*insn2)(Rd, Rn, Rd, LSL, 0);
}
}
}

// Separate vsn which sets the flags. Optimisations are more restricted
// because we must set the flags correctly.
void MacroAssembler::wrap_adds_subs_imm_insn(Register Rd, Register Rn, unsigned imm,
void MacroAssembler::wrap_adds_subs_imm_insn(Register Rd, Register Rn, uint64_t imm,
add_sub_imm_insn insn1,
add_sub_reg_insn insn2) {
if (operand_valid_for_add_sub_immediate((int)imm)) {
if (operand_valid_for_add_sub_immediate(imm)) {
(this->*insn1)(Rd, Rn, imm);
} else {
assert_different_registers(Rd, Rn);
assert(Rd != zr, "overflow in immediate operand");
mov(Rd, (uint64_t)imm);
mov(Rd, imm);
(this->*insn2)(Rd, Rn, Rd, LSL, 0);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
Expand Up @@ -212,7 +212,7 @@ class MacroAssembler: public Assembler {

inline void movw(Register Rd, Register Rn) {
if (Rd == sp || Rn == sp) {
addw(Rd, Rn, 0U);
Assembler::addw(Rd, Rn, 0U);
} else {
orrw(Rd, zr, Rn);
}
Expand All @@ -221,7 +221,7 @@ class MacroAssembler: public Assembler {
assert(Rd != r31_sp && Rn != r31_sp, "should be");
if (Rd == Rn) {
} else if (Rd == sp || Rn == sp) {
add(Rd, Rn, 0U);
Assembler::add(Rd, Rn, 0U);
} else {
orr(Rd, zr, Rn);
}
Expand Down Expand Up @@ -1144,16 +1144,16 @@ class MacroAssembler: public Assembler {

// If a constant does not fit in an immediate field, generate some
// number of MOV instructions and then perform the operation
void wrap_add_sub_imm_insn(Register Rd, Register Rn, unsigned imm,
void wrap_add_sub_imm_insn(Register Rd, Register Rn, uint64_t imm,
add_sub_imm_insn insn1,
add_sub_reg_insn insn2);
// Separate vsn which sets the flags
void wrap_adds_subs_imm_insn(Register Rd, Register Rn, unsigned imm,
void wrap_adds_subs_imm_insn(Register Rd, Register Rn, uint64_t imm,
add_sub_imm_insn insn1,
add_sub_reg_insn insn2);

#define WRAP(INSN) \
void INSN(Register Rd, Register Rn, unsigned imm) { \
void INSN(Register Rd, Register Rn, uint64_t imm) { \
wrap_add_sub_imm_insn(Rd, Rn, imm, &Assembler::INSN, &Assembler::INSN); \
} \
\
Expand All @@ -1175,7 +1175,7 @@ class MacroAssembler: public Assembler {

#undef WRAP
#define WRAP(INSN) \
void INSN(Register Rd, Register Rn, unsigned imm) { \
void INSN(Register Rd, Register Rn, uint64_t imm) { \
wrap_adds_subs_imm_insn(Rd, Rn, imm, &Assembler::INSN, &Assembler::INSN); \
} \
\
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Expand Up @@ -6521,7 +6521,7 @@ class StubGenerator: public StubCodeGenerator {
assert(is_even(framesize/2), "sp not 16-byte aligned");

// lr and fp are already in place
__ sub(sp, rfp, ((unsigned)framesize-4) << LogBytesPerInt); // prolog
__ sub(sp, rfp, ((uint64_t)framesize-4) << LogBytesPerInt); // prolog

int frame_complete = __ pc() - start;

Expand Down

1 comment on commit df4d5cf

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.