list.go 702 B

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