Skip to content

Commit

Permalink
Use an interface function instead of macro
Browse files Browse the repository at this point in the history
  • Loading branch information
fg1417 committed Jul 17, 2024
1 parent ac9f382 commit daf42b4
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/cpu/aarch64/aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,10 @@ OptoRegPair Matcher::vector_return_value(uint ideal_reg) {
return OptoRegPair(0, 0);
}

bool Matcher::use_same_src_and_dest_reg_for_CastX2P(void) {
return true;
}

// Is this branch offset short enough that a short branch can be used?
//
// NOTE: If the platform does not provide any short branch variants, then
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/arm/arm.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,10 @@ OptoRegPair Matcher::vector_return_value(uint ideal_reg) {
return OptoRegPair(0, 0);
}

bool Matcher::use_same_src_and_dest_reg_for_CastX2P(void) {
return false;
}

// Vector width in bytes
int Matcher::vector_width_in_bytes(BasicType bt) {
return MaxVectorSize;
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/ppc/ppc.ad
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,10 @@ OptoRegPair Matcher::vector_return_value(uint ideal_reg) {
return OptoRegPair(0, 0);
}

bool Matcher::use_same_src_and_dest_reg_for_CastX2P(void) {
return false;
}

// Vector width in bytes.
int Matcher::vector_width_in_bytes(BasicType bt) {
if (SuperwordUseVSX) {
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,10 @@ OptoRegPair Matcher::vector_return_value(uint ideal_reg) {
return OptoRegPair(0, 0);
}

bool Matcher::use_same_src_and_dest_reg_for_CastX2P(void) {
return false;
}

// Is this branch offset short enough that a short branch can be used?
//
// NOTE: If the platform does not provide any short branch variants, then
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/s390/s390.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,10 @@ OptoRegPair Matcher::vector_return_value(uint ideal_reg) {
return OptoRegPair(0, 0);
}

bool Matcher::use_same_src_and_dest_reg_for_CastX2P(void) {
return false;
}

//----------SUPERWORD HELPERS----------------------------------------

// Vector width in bytes.
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/x86/x86_32.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,10 @@ OptoRegPair Matcher::vector_return_value(uint ideal_reg) {
return OptoRegPair(0, 0);
}

bool Matcher::use_same_src_and_dest_reg_for_CastX2P(void) {
return false;
}

// Is this branch offset short enough that a short branch can be used?
//
// NOTE: If the platform does not provide any short branch variants, then
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/x86/x86_64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,10 @@ OptoRegPair Matcher::vector_return_value(uint ideal_reg) {
return OptoRegPair(hi, lo);
}

bool Matcher::use_same_src_and_dest_reg_for_CastX2P(void) {
return false;
}

// Is this branch offset short enough that a short branch can be used?
//
// NOTE: If the platform does not provide any short branch variants, then
Expand Down
14 changes: 9 additions & 5 deletions src/hotspot/share/adlc/output_h.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,14 +1688,18 @@ void ArchDesc::declareClasses(FILE *fp) {
// Identify which input register matches the input register.
uint matching_input = instr->two_address(_globalNames);

#if defined(AARCH64)
// Allocate the same register for src and dst, then we can remove
// the instructions in the final assembly.
// Allocate the same src and dest register for CastX2P and CastP2X
// on some target platforms, then we can remove the instructions in
// the final assembly.
if (strcmp("CastX2P", instr->ideal_Opcode(_globalNames)) == 0 ||
strcmp("CastP2X", instr->ideal_Opcode(_globalNames)) == 0) {
matching_input = 1;
assert(matching_input == 0, "");
fprintf(fp," virtual uint two_adr() const {\n");
fprintf(fp," if (Matcher::use_same_src_and_dest_reg_for_CastX2P())\n");
fprintf(fp," return oper_input_base();\n");
fprintf(fp," return 0;\n");
fprintf(fp," }\n");
}
#endif

// Generate the method if it returns != 0 otherwise use MachNode::two_adr()
if( matching_input != 0 ) {
Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/opto/matcher.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -456,6 +456,10 @@ class Matcher : public PhaseTransform {
static bool supports_vector_calling_convention();
static OptoRegPair vector_return_value(uint ideal_reg);

// Is it preferred to use the same src and dest register for CastX2P and
// CastP2X? If true, we can remove the instructions in the final assembly.
static bool use_same_src_and_dest_reg_for_CastX2P();

// Is this branch offset small enough to be addressed by a short branch?
bool is_short_branch_offset(int rule, int br_size, int offset);

Expand Down

0 comments on commit daf42b4

Please sign in to comment.