...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package ppc64
31
32 import (
33 "cmd/internal/obj"
34 "fmt"
35 )
36
37 func init() {
38 obj.RegisterRegister(obj.RBasePPC64, REG_SPR0+1024, rconv)
39
40 obj.RegisterOpcode(obj.ABasePPC64, Anames[:len(Anames)-1])
41 obj.RegisterOpcode(AFIRSTGEN, GenAnames)
42 }
43
44 func rconv(r int) string {
45 if r == 0 {
46 return "NONE"
47 }
48 if r == REGG {
49
50 return "g"
51 }
52 if REG_R0 <= r && r <= REG_R31 {
53 return fmt.Sprintf("R%d", r-REG_R0)
54 }
55 if REG_F0 <= r && r <= REG_F31 {
56 return fmt.Sprintf("F%d", r-REG_F0)
57 }
58 if REG_V0 <= r && r <= REG_V31 {
59 return fmt.Sprintf("V%d", r-REG_V0)
60 }
61 if REG_VS0 <= r && r <= REG_VS63 {
62 return fmt.Sprintf("VS%d", r-REG_VS0)
63 }
64 if REG_CR0 <= r && r <= REG_CR7 {
65 return fmt.Sprintf("CR%d", r-REG_CR0)
66 }
67 if REG_CR0LT <= r && r <= REG_CR7SO {
68 bits := [4]string{"LT", "GT", "EQ", "SO"}
69 crf := (r - REG_CR0LT) / 4
70 return fmt.Sprintf("CR%d%s", crf, bits[r%4])
71 }
72 if REG_A0 <= r && r <= REG_A7 {
73 return fmt.Sprintf("A%d", r-REG_A0)
74 }
75 if r == REG_CR {
76 return "CR"
77 }
78 if REG_SPR0 <= r && r <= REG_SPR0+1023 {
79 switch r {
80 case REG_XER:
81 return "XER"
82
83 case REG_LR:
84 return "LR"
85
86 case REG_CTR:
87 return "CTR"
88 }
89
90 return fmt.Sprintf("SPR(%d)", r-REG_SPR0)
91 }
92
93 if r == REG_FPSCR {
94 return "FPSCR"
95 }
96 if r == REG_MSR {
97 return "MSR"
98 }
99
100 return fmt.Sprintf("Rgok(%d)", r-obj.RBasePPC64)
101 }
102
103 func DRconv(a int) string {
104 s := "C_??"
105 if a >= C_NONE && a <= C_NCLASS {
106 s = cnames9[a]
107 }
108 var fp string
109 fp += s
110 return fp
111 }
112
113 func ConstantToCRbit(c int64) (int16, bool) {
114 reg64 := REG_CRBIT0 + c
115 success := reg64 >= REG_CR0LT && reg64 <= REG_CR7SO
116 return int16(reg64), success
117 }
118
View as plain text