1
2
3
4
5 package rewriteppc64latelower
6
7 import (
8 "cmd/compile/internal/ssa"
9 "cmd/compile/internal/ssa/ssaop"
10 "cmd/compile/internal/types"
11 )
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 func convertPPC64OpToOpCC(op *ssa.Value) *ssa.Value {
39 ccOpMap := map[ssaop.Op]ssaop.Op{
40 ssaop.OpPPC64ADD: ssaop.OpPPC64ADDCC,
41 ssaop.OpPPC64ADDconst: ssaop.OpPPC64ADDCCconst,
42 ssaop.OpPPC64AND: ssaop.OpPPC64ANDCC,
43 ssaop.OpPPC64ANDN: ssaop.OpPPC64ANDNCC,
44 ssaop.OpPPC64ANDconst: ssaop.OpPPC64ANDCCconst,
45 ssaop.OpPPC64CNTLZD: ssaop.OpPPC64CNTLZDCC,
46 ssaop.OpPPC64MULHDU: ssaop.OpPPC64MULHDUCC,
47 ssaop.OpPPC64NEG: ssaop.OpPPC64NEGCC,
48 ssaop.OpPPC64NOR: ssaop.OpPPC64NORCC,
49 ssaop.OpPPC64OR: ssaop.OpPPC64ORCC,
50 ssaop.OpPPC64RLDICL: ssaop.OpPPC64RLDICLCC,
51 ssaop.OpPPC64SUB: ssaop.OpPPC64SUBCC,
52 ssaop.OpPPC64XOR: ssaop.OpPPC64XORCC,
53 }
54 b := op.Block
55 opCC := b.NewValue0I(op.Pos, ccOpMap[op.Op], types.NewTuple(op.Type, types.TypeFlags), op.AuxInt)
56 opCC.AddArgs(op.Args...)
57 op.Reset(ssaop.OpSelect0)
58 op.AddArgs(opCC)
59 return op
60 }
61
62
63 func convertPPC64RldiclAndccconst(sauxint int64) int64 {
64 r, _, _, mask := ssa.DecodePPC64RotateMask(sauxint)
65 if r != 0 || mask&0xFFFF != mask {
66 return 0
67 }
68 return int64(mask)
69 }
70
71
72
73
74
75
76 func mergePPC64RLDICLandSRDconst(encoded, s int64) int64 {
77 mb := s
78 r := 64 - s
79
80 if (encoded>>8)&0xFF < mb {
81 encoded = (encoded &^ 0xFF00) | mb<<8
82 }
83
84 if (encoded & 0xFF0000) != 0 {
85 panic("non-zero rotate")
86 }
87 return encoded | r<<16
88 }
89
View as plain text