diff mbox

[nvptx,1/3] Add generic v2 vector mode support

Message ID 2942f8f0-b883-b62e-9498-361863fa7348@mentor.com
State New
Headers show

Commit Message

Tom de Vries June 6, 2017, 1:02 p.m. UTC
Hi,

this patch adds generic v2 vector mode support for nvptx.

Tested in nvptx mainkernel mode and x86_64 accelerator mode.

OK for trunk?

Thanks,
- Tom

Comments

Jeff Law June 23, 2017, 5:16 p.m. UTC | #1
On 06/06/2017 07:02 AM, Tom de Vries wrote:
> Hi,
> 
> this patch adds generic v2 vector mode support for nvptx.
> 
> Tested in nvptx mainkernel mode and x86_64 accelerator mode.
> 
> OK for trunk?
> 
> Thanks,
> - Tom
> 
> 0001-Add-generic-v2-vector-mode-support.patch
> 
> 
> Add generic v2 vector mode support
> 
> 2017-06-06  Tom de Vries  <tom@codesourcery.com>
> 
> 	* config/nvptx/nvptx.c (nvptx_print_operand): Handle v2 vector mode.
OK.
jeff
diff mbox

Patch

Add generic v2 vector mode support

2017-06-06  Tom de Vries  <tom@codesourcery.com>

	* config/nvptx/nvptx.c (nvptx_print_operand): Handle v2 vector mode.

---
 gcc/config/nvptx/nvptx.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 2eb5570..beaad2c 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -2403,9 +2403,15 @@  nvptx_print_operand (FILE *file, rtx x, int code)
     case 'u':
       if (x_code == SUBREG)
 	{
-	  mode = GET_MODE (SUBREG_REG (x));
-	  if (split_mode_p (mode))
-	    mode = maybe_split_mode (mode);
+	  machine_mode inner_mode = GET_MODE (SUBREG_REG (x));
+	  if (VECTOR_MODE_P (inner_mode)
+	      && (GET_MODE_SIZE (mode)
+		  <= GET_MODE_SIZE (GET_MODE_INNER (inner_mode))))
+	    mode = GET_MODE_INNER (inner_mode);
+	  else if (split_mode_p (inner_mode))
+	    mode = maybe_split_mode (inner_mode);
+	  else
+	    mode = inner_mode;
 	}
       fprintf (file, "%s", nvptx_ptx_type_from_mode (mode, code == 't'));
       break;
@@ -2506,7 +2512,14 @@  nvptx_print_operand (FILE *file, rtx x, int code)
 	    machine_mode inner_mode = GET_MODE (inner_x);
 	    machine_mode split = maybe_split_mode (inner_mode);
 
-	    if (split_mode_p (inner_mode)
+	    if (VECTOR_MODE_P (inner_mode)
+		&& (GET_MODE_SIZE (mode)
+		    <= GET_MODE_SIZE (GET_MODE_INNER (inner_mode))))
+	      {
+		output_reg (file, REGNO (inner_x), VOIDmode);
+		fprintf (file, ".%s", SUBREG_BYTE (x) == 0 ? "x" : "y");
+	      }
+	    else if (split_mode_p (inner_mode)
 		&& (GET_MODE_SIZE (inner_mode) == GET_MODE_SIZE (mode)))
 	      output_reg (file, REGNO (inner_x), split);
 	    else
@@ -2548,6 +2561,22 @@  nvptx_print_operand (FILE *file, rtx x, int code)
 	    fprintf (file, "0d%08lx%08lx", vals[1], vals[0]);
 	  break;
 
+	case CONST_VECTOR:
+	  {
+	    unsigned n = CONST_VECTOR_NUNITS (x);
+	    fprintf (file, "{ ");
+	    for (unsigned i = 0; i < n; ++i)
+	      {
+		if (i != 0)
+		  fprintf (file, ", ");
+
+		rtx elem = CONST_VECTOR_ELT (x, i);
+		output_addr_const (file, elem);
+	      }
+	    fprintf (file, " }");
+	  }
+	  break;
+
 	default:
 	  output_addr_const (file, x);
 	}