Remove dead generics-related code from OccName
[ghc.git] / compiler / nativeGen / CPrim.hs
1 -- | Generating C symbol names emitted by the compiler.
2 module CPrim
3 ( atomicReadLabel
4 , atomicWriteLabel
5 , atomicRMWLabel
6 , cmpxchgLabel
7 , popCntLabel
8 , bSwapLabel
9 , clzLabel
10 , ctzLabel
11 , word2FloatLabel
12 ) where
13
14 import CmmType
15 import CmmMachOp
16 import Outputable
17
18 popCntLabel :: Width -> String
19 popCntLabel w = "hs_popcnt" ++ pprWidth w
20 where
21 pprWidth W8 = "8"
22 pprWidth W16 = "16"
23 pprWidth W32 = "32"
24 pprWidth W64 = "64"
25 pprWidth w = pprPanic "popCntLabel: Unsupported word width " (ppr w)
26
27 bSwapLabel :: Width -> String
28 bSwapLabel w = "hs_bswap" ++ pprWidth w
29 where
30 pprWidth W16 = "16"
31 pprWidth W32 = "32"
32 pprWidth W64 = "64"
33 pprWidth w = pprPanic "bSwapLabel: Unsupported word width " (ppr w)
34
35 clzLabel :: Width -> String
36 clzLabel w = "hs_clz" ++ pprWidth w
37 where
38 pprWidth W8 = "8"
39 pprWidth W16 = "16"
40 pprWidth W32 = "32"
41 pprWidth W64 = "64"
42 pprWidth w = pprPanic "clzLabel: Unsupported word width " (ppr w)
43
44 ctzLabel :: Width -> String
45 ctzLabel w = "hs_ctz" ++ pprWidth w
46 where
47 pprWidth W8 = "8"
48 pprWidth W16 = "16"
49 pprWidth W32 = "32"
50 pprWidth W64 = "64"
51 pprWidth w = pprPanic "ctzLabel: Unsupported word width " (ppr w)
52
53 word2FloatLabel :: Width -> String
54 word2FloatLabel w = "hs_word2float" ++ pprWidth w
55 where
56 pprWidth W32 = "32"
57 pprWidth W64 = "64"
58 pprWidth w = pprPanic "word2FloatLabel: Unsupported word width " (ppr w)
59
60 atomicRMWLabel :: Width -> AtomicMachOp -> String
61 atomicRMWLabel w amop = "hs_atomic_" ++ pprFunName amop ++ pprWidth w
62 where
63 pprWidth W8 = "8"
64 pprWidth W16 = "16"
65 pprWidth W32 = "32"
66 pprWidth W64 = "64"
67 pprWidth w = pprPanic "atomicRMWLabel: Unsupported word width " (ppr w)
68
69 pprFunName AMO_Add = "add"
70 pprFunName AMO_Sub = "sub"
71 pprFunName AMO_And = "and"
72 pprFunName AMO_Nand = "nand"
73 pprFunName AMO_Or = "or"
74 pprFunName AMO_Xor = "xor"
75
76 cmpxchgLabel :: Width -> String
77 cmpxchgLabel w = "hs_cmpxchg" ++ pprWidth w
78 where
79 pprWidth W8 = "8"
80 pprWidth W16 = "16"
81 pprWidth W32 = "32"
82 pprWidth W64 = "64"
83 pprWidth w = pprPanic "cmpxchgLabel: Unsupported word width " (ppr w)
84
85 atomicReadLabel :: Width -> String
86 atomicReadLabel w = "hs_atomicread" ++ pprWidth w
87 where
88 pprWidth W8 = "8"
89 pprWidth W16 = "16"
90 pprWidth W32 = "32"
91 pprWidth W64 = "64"
92 pprWidth w = pprPanic "atomicReadLabel: Unsupported word width " (ppr w)
93
94 atomicWriteLabel :: Width -> String
95 atomicWriteLabel w = "hs_atomicwrite" ++ pprWidth w
96 where
97 pprWidth W8 = "8"
98 pprWidth W16 = "16"
99 pprWidth W32 = "32"
100 pprWidth W64 = "64"
101 pprWidth w = pprPanic "atomicWriteLabel: Unsupported word width " (ppr w)