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

     1  // Copyright 2019 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 riscv
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"cmd/internal/obj"
    11  )
    12  
    13  func init() {
    14  	obj.RegisterRegister(obj.RBaseRISCV, REG_END, RegName)
    15  	obj.RegisterOpcode(obj.ABaseRISCV, Anames)
    16  }
    17  
    18  func RegName(r int) string {
    19  	switch {
    20  	case r == 0:
    21  		return "NONE"
    22  	case r == REG_G:
    23  		return "g"
    24  	case r == REG_SP:
    25  		return "SP"
    26  	case REG_X0 <= r && r <= REG_X31:
    27  		return fmt.Sprintf("X%d", r-REG_X0)
    28  	case REG_F0 <= r && r <= REG_F31:
    29  		return fmt.Sprintf("F%d", r-REG_F0)
    30  	default:
    31  		return fmt.Sprintf("Rgok(%d)", r-obj.RBaseRISCV)
    32  	}
    33  }
    34  

View as plain text