@@ -10,13 +10,15 @@ import (
10
10
// GlobalName encodes a global name to its LLVM IR assembly representation.
11
11
//
12
12
// Examples:
13
- // "foo" -> "@foo"
14
- // "a b" -> `@"a b"`
15
- // "世" -> `@"\E4\B8\96"`
16
- // "2" -> `@"2"`
13
+ //
14
+ // "foo" -> "@foo"
15
+ // "a b" -> `@"a b"`
16
+ // "世" -> `@"\E4\B8\96"`
17
+ // "2" -> `@"2"`
17
18
//
18
19
// References:
19
- // http://www.llvm.org/docs/LangRef.html#identifiers
20
+ //
21
+ // http://www.llvm.org/docs/LangRef.html#identifiers
20
22
func GlobalName (name string ) string {
21
23
// Positive numeric global names are quoted to distinguish global names from
22
24
// global IDs; e.g.
@@ -31,10 +33,12 @@ func GlobalName(name string) string {
31
33
// GlobalID encodes a global ID to its LLVM IR assembly representation.
32
34
//
33
35
// Examples:
34
- // "42" -> "@42"
36
+ //
37
+ // "42" -> "@42"
35
38
//
36
39
// References:
37
- // http://www.llvm.org/docs/LangRef.html#identifiers
40
+ //
41
+ // http://www.llvm.org/docs/LangRef.html#identifiers
38
42
func GlobalID (id int64 ) string {
39
43
if id < 0 {
40
44
panic (fmt .Errorf ("negative global ID (%d); should be represented as global name" , id ))
@@ -45,13 +49,15 @@ func GlobalID(id int64) string {
45
49
// LocalName encodes a local name to its LLVM IR assembly representation.
46
50
//
47
51
// Examples:
48
- // "foo" -> "%foo"
49
- // "a b" -> `%"a b"`
50
- // "世" -> `%"\E4\B8\96"`
51
- // "2" -> `%"2"`
52
+ //
53
+ // "foo" -> "%foo"
54
+ // "a b" -> `%"a b"`
55
+ // "世" -> `%"\E4\B8\96"`
56
+ // "2" -> `%"2"`
52
57
//
53
58
// References:
54
- // http://www.llvm.org/docs/LangRef.html#identifiers
59
+ //
60
+ // http://www.llvm.org/docs/LangRef.html#identifiers
55
61
func LocalName (name string ) string {
56
62
// Positive numeric local names are quoted to distinguish local names from
57
63
// local IDs; e.g.
@@ -66,10 +72,12 @@ func LocalName(name string) string {
66
72
// LocalID encodes a local ID to its LLVM IR assembly representation.
67
73
//
68
74
// Examples:
69
- // "42" -> "%42"
75
+ //
76
+ // "42" -> "%42"
70
77
//
71
78
// References:
72
- // http://www.llvm.org/docs/LangRef.html#identifiers
79
+ //
80
+ // http://www.llvm.org/docs/LangRef.html#identifiers
73
81
func LocalID (id int64 ) string {
74
82
if id < 0 {
75
83
panic (fmt .Errorf ("negative local ID (%d); should be represented as local name" , id ))
@@ -80,13 +88,15 @@ func LocalID(id int64) string {
80
88
// LabelName encodes a label name to its LLVM IR assembly representation.
81
89
//
82
90
// Examples:
83
- // "foo" -> "foo:"
84
- // "a b" -> `"a b":`
85
- // "世" -> `"\E4\B8\96":`
86
- // "2" -> `"2":`
91
+ //
92
+ // "foo" -> "foo:"
93
+ // "a b" -> `"a b":`
94
+ // "世" -> `"\E4\B8\96":`
95
+ // "2" -> `"2":`
87
96
//
88
97
// References:
89
- // http://www.llvm.org/docs/LangRef.html#identifiers
98
+ //
99
+ // http://www.llvm.org/docs/LangRef.html#identifiers
90
100
func LabelName (name string ) string {
91
101
// Positive numeric label names are quoted to distinguish label names from
92
102
// label IDs; e.g.
@@ -101,10 +111,12 @@ func LabelName(name string) string {
101
111
// LabelID encodes a label ID to its LLVM IR assembly representation.
102
112
//
103
113
// Examples:
104
- // "42" -> 42:
114
+ //
115
+ // "42" -> 42:
105
116
//
106
117
// References:
107
- // http://www.llvm.org/docs/LangRef.html#identifiers
118
+ //
119
+ // http://www.llvm.org/docs/LangRef.html#identifiers
108
120
func LabelID (id int64 ) string {
109
121
if id < 0 {
110
122
panic (fmt .Errorf ("negative label ID (%d); should be represented as label name" , id ))
@@ -115,13 +127,15 @@ func LabelID(id int64) string {
115
127
// TypeName encodes a type name to its LLVM IR assembly representation.
116
128
//
117
129
// Examples:
118
- // "foo" -> "%foo"
119
- // "a b" -> `%"a b"`
120
- // "世" -> `%"\E4\B8\96"`
121
- // "2" -> `%2`
130
+ //
131
+ // "foo" -> "%foo"
132
+ // "a b" -> `%"a b"`
133
+ // "世" -> `%"\E4\B8\96"`
134
+ // "2" -> `%2`
122
135
//
123
136
// References:
124
- // http://www.llvm.org/docs/LangRef.html#identifiers
137
+ //
138
+ // http://www.llvm.org/docs/LangRef.html#identifiers
125
139
func TypeName (name string ) string {
126
140
return "%" + EscapeIdent (name )
127
141
}
@@ -130,36 +144,42 @@ func TypeName(name string) string {
130
144
// representation.
131
145
//
132
146
// Examples:
133
- // "42" -> "#42"
147
+ //
148
+ // "42" -> "#42"
134
149
//
135
150
// References:
136
- // http://www.llvm.org/docs/LangRef.html#identifiers
151
+ //
152
+ // http://www.llvm.org/docs/LangRef.html#identifiers
137
153
func AttrGroupID (id int64 ) string {
138
154
return "#" + strconv .FormatInt (id , 10 )
139
155
}
140
156
141
157
// ComdatName encodes a comdat name to its LLVM IR assembly representation.
142
158
//
143
159
// Examples:
144
- // "foo" -> $%foo"
145
- // "a b" -> `$"a b"`
146
- // "世" -> `$"\E4\B8\96"`
160
+ //
161
+ // "foo" -> $%foo"
162
+ // "a b" -> `$"a b"`
163
+ // "世" -> `$"\E4\B8\96"`
147
164
//
148
165
// References:
149
- // http://www.llvm.org/docs/LangRef.html#identifiers
166
+ //
167
+ // http://www.llvm.org/docs/LangRef.html#identifiers
150
168
func ComdatName (name string ) string {
151
169
return "$" + EscapeIdent (name )
152
170
}
153
171
154
172
// MetadataName encodes a metadata name to its LLVM IR assembly representation.
155
173
//
156
174
// Examples:
157
- // "foo" -> "!foo"
158
- // "a b" -> `!a\20b`
159
- // "世" -> `!\E4\B8\96`
175
+ //
176
+ // "foo" -> "!foo"
177
+ // "a b" -> `!a\20b`
178
+ // "世" -> `!\E4\B8\96`
160
179
//
161
180
// References:
162
- // http://www.llvm.org/docs/LangRef.html#identifiers
181
+ //
182
+ // http://www.llvm.org/docs/LangRef.html#identifiers
163
183
func MetadataName (name string ) string {
164
184
valid := func (b byte ) bool {
165
185
return strings .IndexByte (tail , b ) != - 1
@@ -175,10 +195,12 @@ func MetadataName(name string) string {
175
195
// MetadataID encodes a metadata ID to its LLVM IR assembly representation.
176
196
//
177
197
// Examples:
178
- // "42" -> "!42"
198
+ //
199
+ // "42" -> "!42"
179
200
//
180
201
// References:
181
- // http://www.llvm.org/docs/LangRef.html#identifiers
202
+ //
203
+ // http://www.llvm.org/docs/LangRef.html#identifiers
182
204
func MetadataID (id int64 ) string {
183
205
return "!" + strconv .FormatInt (id , 10 )
184
206
}
0 commit comments