Source file src/cmd/internal/obj/loong64/list.go

     1  // Copyright 2022 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package loong64
     6  
     7  import (
     8  	"cmd/internal/obj"
     9  	"fmt"
    10  )
    11  
    12  func init() {
    13  	obj.RegisterRegister(obj.RBaseLOONG64, REG_LAST, RegName)
    14  	obj.RegisterOpcode(obj.ABaseLoong64, Anames)
    15  }
    16  
    17  func arrange(valid int16) string {
    18  	var regPrefix string
    19  	var arngName string
    20  
    21  	// bits 0-4 indicates register: Vn or Xn
    22  	// bits 5-9 indicates arrangement: <T>
    23  	// bits 10 indicates SMID type: 0: LSX, 1: LASX
    24  	simdType := (valid >> EXT_SIMDTYPE_SHIFT) & EXT_SIMDTYPE_MASK
    25  	simdReg := (valid >> EXT_REG_SHIFT) & EXT_REG_MASK
    26  	arngType := (valid >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK
    27  
    28  	switch simdType {
    29  	case LSX:
    30  		regPrefix = "V"
    31  	case LASX:
    32  		regPrefix = "X"
    33  	default:
    34  		regPrefix = "#"
    35  	}
    36  
    37  	switch arngType {
    38  	case ARNG_32B:
    39  		arngName = "B32"
    40  	case ARNG_16H:
    41  		arngName = "H16"
    42  	case ARNG_8W:
    43  		arngName = "W8"
    44  	case ARNG_4V:
    45  		arngName = "V4"
    46  	case ARNG_2Q:
    47  		arngName = "Q2"
    48  	case ARNG_16B:
    49  		arngName = "B16"
    50  	case ARNG_8H:
    51  		arngName = "H8"
    52  	case ARNG_4W:
    53  		arngName = "W4"
    54  	case ARNG_2V:
    55  		arngName = "V2"
    56  	case ARNG_B:
    57  		arngName = "B"
    58  	case ARNG_H:
    59  		arngName = "H"
    60  	case ARNG_W:
    61  		arngName = "W"
    62  	case ARNG_V:
    63  		arngName = "V"
    64  	case ARNG_BU:
    65  		arngName = "BU"
    66  	case ARNG_HU:
    67  		arngName = "HU"
    68  	case ARNG_WU:
    69  		arngName = "WU"
    70  	case ARNG_VU:
    71  		arngName = "VU"
    72  	default:
    73  		arngName = "ARNG_???"
    74  	}
    75  
    76  	return fmt.Sprintf("%s%d.%s", regPrefix, simdReg, arngName)
    77  }
    78  
    79  func RegName(r int) string {
    80  	switch {
    81  	case r == 0:
    82  		return "NONE"
    83  	case r == REGG:
    84  		// Special case.
    85  		return "g"
    86  	case REG_R0 <= r && r <= REG_R31:
    87  		return fmt.Sprintf("R%d", r-REG_R0)
    88  	case REG_F0 <= r && r <= REG_F31:
    89  		return fmt.Sprintf("F%d", r-REG_F0)
    90  	case REG_FCSR0 <= r && r <= REG_FCSR31:
    91  		return fmt.Sprintf("FCSR%d", r-REG_FCSR0)
    92  	case REG_FCC0 <= r && r <= REG_FCC31:
    93  		return fmt.Sprintf("FCC%d", r-REG_FCC0)
    94  	case REG_V0 <= r && r <= REG_V31:
    95  		return fmt.Sprintf("V%d", r-REG_V0)
    96  	case REG_X0 <= r && r <= REG_X31:
    97  		return fmt.Sprintf("X%d", r-REG_X0)
    98  	case REG_ARNG <= r && r < REG_ELEM:
    99  		return arrange(int16(r - REG_ARNG))
   100  	case REG_ELEM <= r && r < REG_ELEM_END:
   101  		return arrange(int16(r - REG_ELEM))
   102  	}
   103  
   104  	return fmt.Sprintf("badreg(%d)", r-obj.RBaseLOONG64)
   105  }
   106  
   107  func DRconv(a int) string {
   108  	s := "C_??"
   109  	if a >= C_NONE && a <= C_NCLASS {
   110  		s = cnames0[a]
   111  	}
   112  	return s
   113  }
   114  

View as plain text