Debian Codegraph @

internal/api/types.go

raw symbols SCIP
1 package apiscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/
2
3 import (
4 "pathscip-go gomod github.com/golang/go/src go1.18 path/"
5 "sortscip-go gomod github.com/golang/go/src go1.18 sort/"
6 "stringsscip-go gomod github.com/golang/go/src go1.18 strings/"
7 )
8
9 const (
10 // Package is the avo package import path.
11 Packagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/Package. = "github.com/mmcloughlin/avo"
12
13 // IRPackage is the package that defines intermediate representation types.
14 IRPackagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/IRPackage. = "ir"
15
16 // OperandPackage is the package for operand types.
17 OperandPackagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/OperandPackage. = "operand"
18
19 // OperandType is the type used for operands.
20 OperandTypescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/OperandType. = OperandPackagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/OperandPackage. + ".Op"
21
22 // RegisterPackage is the name of the package containing register types.
23 RegisterPackagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/RegisterPackage. = "reg"
24
25 // RegisterType is the type used for registers.
26 RegisterTypescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/RegisterType. = RegisterPackagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/RegisterPackage. + ".Register"
27 )
28
29 // ImportPath returns the full import path for an avo subpackage.
30 func ImportPathscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/ImportPath().(pkg string) string {
31 return pathscip-go gomod github.com/golang/go/src go1.18 path/.Joinscip-go gomod github.com/golang/go/src go1.18 path/Join().(Packagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/Package., pkg)
32 }
33
34 // ImplicitRegisterIdentifier maps an implicit register name to a string
35 // suitable for a related Go identifier.
36 func ImplicitRegisterIdentifierscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/ImplicitRegisterIdentifier().(r string) string {
37 r = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Replacescip-go gomod github.com/golang/go/src go1.18 strings/Replace().(r, "mm", "", 1) // handles the "xmm0" type
38 return stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.18 strings/ToUpper().(r)
39 }
40
41 // ImplicitRegister returns avo syntax for the given implicit register type (from Opcodes XML).
42 func ImplicitRegisterscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/ImplicitRegister().(r string) string {
43 return RegisterPackagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/RegisterPackage. + "." + ImplicitRegisterIdentifierscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/ImplicitRegisterIdentifier().(r)
44 }
45
46 // OperandTypeIdentifier maps an operand type to a string suitable for a related
47 // Go identifier.
48 func OperandTypeIdentifierscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/OperandTypeIdentifier().(t string) string {
49 return stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.18 strings/ToUpper().(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.18 strings/ReplaceAll().(t, "/", ""))
50 }
51
52 // CheckerName returns the name of the function that checks an operand of type t.
53 func CheckerNamescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/CheckerName().(t string) string {
54 return "operand.Is" + OperandTypeIdentifierscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/OperandTypeIdentifier().(t)
55 }
56
57 // ISAsIdentifier returns a string representation of an ISA list that suitable
58 // for use in a Go identifier.
59 func ISAsIdentifierscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/ISAsIdentifier().(isas []string) string {
60 if len(isas) == 0 {
61 return "Base"
62 }
63 sorted := append([]string(nil), isas...)
64 sortscip-go gomod github.com/golang/go/src go1.18 sort/.Stringsscip-go gomod github.com/golang/go/src go1.18 sort/Strings().(sorted)
65 ident := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Joinscip-go gomod github.com/golang/go/src go1.18 strings/Join().(sorted, "_")
66 ident = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.18 strings/ReplaceAll().(ident, ".", "") // SSE4.1
67 ident = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.18 strings/ReplaceAll().(ident, "+", "") // MMX+
68 return ident
69 }
70
71 // SuffixesClassIdentifier returns a string representation of a suffix class
72 // that's suitable for use in a Go identifier.
73 func SuffixesClassIdentifierscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/internal/api`/SuffixesClassIdentifier().(c string) string {
74 return stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.18 strings/ToUpper().(c)
75 }