8248901: Signed immediate support in .../share/assembler.hpp is broken

Reviewed-by: neliasso, kvn, thartmann
This commit is contained in:
Patric Hedlin 2020-07-06 21:29:51 +02:00
parent ba2caf0014
commit 3e0dc68883
2 changed files with 21 additions and 20 deletions

View File

@ -216,7 +216,7 @@ int ConstantTable::calculate_table_base_offset() const {
// flds, fldd: 8-bit offset multiplied by 4: +/- 1024
// ldr, ldrb : 12-bit offset: +/- 4096
if (!Assembler::is_simm10(offset)) {
offset = Assembler::min_simm10();
offset = Assembler::min_simm10;
}
return offset;
}

View File

@ -299,28 +299,29 @@ class AbstractAssembler : public ResourceObj {
void emit_double( jdouble x) { code_section()->emit_double(x); }
void emit_address(address x) { code_section()->emit_address(x); }
// min and max values for signed immediate ranges
static int min_simm(int nbits) { return -(intptr_t(1) << (nbits - 1)) ; }
static int max_simm(int nbits) { return (intptr_t(1) << (nbits - 1)) - 1; }
enum { min_simm10 = -512 };
// Define some:
static int min_simm10() { return min_simm(10); }
static int min_simm13() { return min_simm(13); }
static int min_simm16() { return min_simm(16); }
// Test if x is within signed immediate range for width.
static bool is_simm(int64_t x, uint w) {
precond(1 < w && w < 64);
int64_t limes = INT64_C(1) << (w - 1);
return -limes <= x && x < limes;
}
// Test if x is within signed immediate range for nbits
static bool is_simm(intptr_t x, int nbits) { return min_simm(nbits) <= x && x <= max_simm(nbits); }
static bool is_simm8(int64_t x) { return is_simm(x, 8); }
static bool is_simm9(int64_t x) { return is_simm(x, 9); }
static bool is_simm10(int64_t x) { return is_simm(x, 10); }
static bool is_simm16(int64_t x) { return is_simm(x, 16); }
static bool is_simm32(int64_t x) { return is_simm(x, 32); }
// Define some:
static bool is_simm5( intptr_t x) { return is_simm(x, 5 ); }
static bool is_simm8( intptr_t x) { return is_simm(x, 8 ); }
static bool is_simm10(intptr_t x) { return is_simm(x, 10); }
static bool is_simm11(intptr_t x) { return is_simm(x, 11); }
static bool is_simm12(intptr_t x) { return is_simm(x, 12); }
static bool is_simm13(intptr_t x) { return is_simm(x, 13); }
static bool is_simm16(intptr_t x) { return is_simm(x, 16); }
static bool is_simm26(intptr_t x) { return is_simm(x, 26); }
static bool is_simm32(intptr_t x) { return is_simm(x, 32); }
// Test if x is within unsigned immediate range for width.
static bool is_uimm(uint64_t x, uint w) {
precond(0 < w && w < 64);
uint64_t limes = UINT64_C(1) << w;
return x < limes;
}
static bool is_uimm12(uint64_t x) { return is_uimm(x, 12); }
// Accessors
CodeSection* code_section() const { return _code_section; }