(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
arm/
lp1243022.c
       1  /* { dg-do compile { target arm_thumb2 } } */
       2  /* { dg-options "-O2 -fdump-rtl-subreg2" } */
       3  
       4  /* { dg-final { scan-rtl-dump "REG_INC" "subreg2" { target { ! arm_neon } } } } */
       5  struct device;
       6  typedef unsigned int __u32;
       7  typedef unsigned long long u64;
       8  typedef __u32 __le32;
       9  typedef u64 dma_addr_t;
      10  typedef unsigned gfp_t;
      11  int dev_warn (const struct device *dev, const char *fmt, ...);
      12  struct usb_bus
      13  {
      14      struct device *controller;
      15  };
      16  struct usb_hcd
      17  {
      18      struct usb_bus self;
      19  };
      20  struct xhci_generic_trb
      21  {
      22      __le32 field[4];
      23  };
      24  union xhci_trb
      25  {
      26      struct xhci_generic_trb generic;
      27  };
      28  struct xhci_segment
      29  {
      30      union xhci_trb *trbs;
      31      dma_addr_t dma;
      32  };
      33  struct xhci_ring
      34  {
      35      struct xhci_segment *first_seg;
      36  };
      37  struct xhci_hcd
      38  {
      39      struct xhci_ring *cmd_ring;
      40      struct xhci_ring *event_ring;
      41  };
      42  struct usb_hcd *xhci_to_hcd (struct xhci_hcd *xhci)
      43  {
      44  }
      45  dma_addr_t xhci_trb_virt_to_dma (struct xhci_segment * seg,
      46  				 union xhci_trb * trb);
      47  struct xhci_segment *trb_in_td (struct xhci_segment *start_seg,
      48  				dma_addr_t suspect_dma);
      49  int
      50  xhci_test_trb_in_td (struct xhci_hcd *xhci, struct xhci_segment *input_seg,
      51  		     union xhci_trb *start_trb, union xhci_trb *end_trb,
      52  		     dma_addr_t input_dma, struct xhci_segment *result_seg,
      53  		     char *test_name, int test_number)
      54  {
      55      unsigned long long start_dma;
      56      unsigned long long end_dma;
      57      struct xhci_segment *seg;
      58      start_dma = xhci_trb_virt_to_dma (input_seg, start_trb);
      59      end_dma = xhci_trb_virt_to_dma (input_seg, end_trb);
      60      {
      61          dev_warn (xhci_to_hcd (xhci)->self.controller,
      62                    "%d\n", test_number);
      63          dev_warn (xhci_to_hcd (xhci)->self.controller,
      64                    "Expected seg %p, got seg %p\n", result_seg, seg);
      65      }
      66  }
      67  int
      68  xhci_check_trb_in_td_math (struct xhci_hcd *xhci, gfp_t mem_flags)
      69  {
      70      struct
      71      {
      72          dma_addr_t input_dma;
      73          struct xhci_segment *result_seg;
      74      }
      75      simple_test_vector[] =
      76          {
      77              {
      78                  0, ((void *) 0)
      79              }
      80              ,
      81              {
      82                  xhci->event_ring->first_seg->dma - 16, ((void *) 0)}
      83              ,
      84              {
      85                  xhci->event_ring->first_seg->dma - 1, ((void *) 0)}
      86              ,
      87              {
      88                  xhci->event_ring->first_seg->dma, xhci->event_ring->first_seg}
      89              ,
      90              {
      91                  xhci->event_ring->first_seg->dma + (64 - 1) * 16,
      92                  xhci->event_ring->first_seg
      93              }
      94              ,
      95              {
      96                  xhci->event_ring->first_seg->dma + (64 - 1) * 16 + 1, ((void *) 0)}
      97              ,
      98              {
      99                  xhci->event_ring->first_seg->dma + (64) * 16, ((void *) 0)}
     100              ,
     101              {
     102                  (dma_addr_t) (~0), ((void *) 0)
     103              }
     104          };
     105      struct
     106      {
     107          struct xhci_segment *input_seg;
     108          union xhci_trb *start_trb;
     109          union xhci_trb *end_trb;
     110          dma_addr_t input_dma;
     111          struct xhci_segment *result_seg;
     112      }
     113      complex_test_vector[] =
     114          {
     115              {
     116                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     117                  xhci->event_ring->first_seg->trbs,.end_trb =
     118                  &xhci->event_ring->first_seg->trbs[64 - 1],.input_dma =
     119                  xhci->cmd_ring->first_seg->dma,.result_seg = ((void *) 0),
     120              }
     121              ,
     122              {
     123                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     124                  xhci->event_ring->first_seg->trbs,.end_trb =
     125                  &xhci->cmd_ring->first_seg->trbs[64 - 1],.input_dma =
     126                  xhci->cmd_ring->first_seg->dma,.result_seg = ((void *) 0),
     127              }
     128              ,
     129              {
     130                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     131                  xhci->cmd_ring->first_seg->trbs,.end_trb =
     132                  &xhci->cmd_ring->first_seg->trbs[64 - 1],.input_dma =
     133                  xhci->cmd_ring->first_seg->dma,.result_seg = ((void *) 0),
     134              }
     135              ,
     136              {
     137                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     138                  &xhci->event_ring->first_seg->trbs[0],.end_trb =
     139                  &xhci->event_ring->first_seg->trbs[3],.input_dma =
     140                  xhci->event_ring->first_seg->dma + 4 * 16,.result_seg = ((void *) 0),
     141              }
     142              ,
     143              {
     144                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     145                  &xhci->event_ring->first_seg->trbs[3],.end_trb =
     146                  &xhci->event_ring->first_seg->trbs[6],.input_dma =
     147                  xhci->event_ring->first_seg->dma + 2 * 16,.result_seg = ((void *) 0),
     148              }
     149              ,
     150              {
     151                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     152                  &xhci->event_ring->first_seg->trbs[64 - 3],.end_trb =
     153                  &xhci->event_ring->first_seg->trbs[1],.input_dma =
     154                  xhci->event_ring->first_seg->dma + 2 * 16,.result_seg = ((void *) 0),
     155              }
     156              ,
     157              {
     158                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     159                  &xhci->event_ring->first_seg->trbs[64 - 3],.end_trb =
     160                  &xhci->event_ring->first_seg->trbs[1],.input_dma =
     161                  xhci->event_ring->first_seg->dma + (64 - 4) * 16,.result_seg =
     162                  ((void *) 0),
     163              }
     164              ,
     165              {
     166                  .input_seg = xhci->event_ring->first_seg,.start_trb =
     167                  &xhci->event_ring->first_seg->trbs[64 - 3],.end_trb =
     168                  &xhci->event_ring->first_seg->trbs[1],.input_dma =
     169                  xhci->cmd_ring->first_seg->dma + 2 * 16,.result_seg = ((void *) 0),
     170              }
     171          };
     172      unsigned int num_tests;
     173      int i, ret;
     174      num_tests =
     175          (sizeof (simple_test_vector) / sizeof ((simple_test_vector)[0]) +
     176           (sizeof (struct
     177               {
     178           }
     179               )));
     180      for (i = 0; i < num_tests; i++)
     181      {
     182          ret =
     183              xhci_test_trb_in_td (xhci, xhci->event_ring->first_seg,
     184                                   xhci->event_ring->first_seg->trbs,
     185                                   &xhci->event_ring->first_seg->trbs[64 - 1],
     186                                   simple_test_vector[i].input_dma,
     187                                   simple_test_vector[i].result_seg, "Simple", i);
     188          if (ret < 0)
     189              return ret;
     190      }
     191      for (i = 0; i < num_tests; i++)
     192      {
     193          ret =
     194              xhci_test_trb_in_td (xhci, complex_test_vector[i].input_seg,
     195                                   complex_test_vector[i].start_trb,
     196                                   complex_test_vector[i].end_trb,
     197                                   complex_test_vector[i].input_dma,
     198                                   complex_test_vector[i].result_seg, "Complex", i);
     199          if (ret < 0)
     200              return ret;
     201      }
     202  }