@@ -117,7 +117,10 @@ def __init__(self):
117
117
Type .__init__ (self , 0 )
118
118
119
119
def compiler_ctor (self ):
120
- return 'void()'
120
+ return '::VOID'
121
+
122
+ def compiler_ctor_ref (self ):
123
+ return '&' + self .compiler_ctor ()
121
124
122
125
def rust_name (self ):
123
126
return '()'
@@ -163,10 +166,12 @@ def __init__(self, bitwidth, llvm_bitwidth = None):
163
166
164
167
def compiler_ctor (self ):
165
168
if self ._llvm_bitwidth is None :
166
- return 'i({}) ' .format (self .bitwidth ())
169
+ return '::I{} ' .format (self .bitwidth ())
167
170
else :
168
- return 'i_({}, {})' .format (self .bitwidth (),
169
- self ._llvm_bitwidth )
171
+ return '::I{}_{}' .format (self .bitwidth (), self ._llvm_bitwidth )
172
+
173
+ def compiler_ctor_ref (self ):
174
+ return '&' + self .compiler_ctor ()
170
175
171
176
def llvm_name (self ):
172
177
bw = self ._llvm_bitwidth or self .bitwidth ()
@@ -182,10 +187,12 @@ def __init__(self, bitwidth, llvm_bitwidth = None):
182
187
183
188
def compiler_ctor (self ):
184
189
if self ._llvm_bitwidth is None :
185
- return 'u({}) ' .format (self .bitwidth ())
190
+ return '::U{} ' .format (self .bitwidth ())
186
191
else :
187
- return 'u_({}, {})' .format (self .bitwidth (),
188
- self ._llvm_bitwidth )
192
+ return '::U{}_{}' .format (self .bitwidth (), self ._llvm_bitwidth )
193
+
194
+ def compiler_ctor_ref (self ):
195
+ return '&' + self .compiler_ctor ()
189
196
190
197
def llvm_name (self ):
191
198
bw = self ._llvm_bitwidth or self .bitwidth ()
@@ -200,7 +207,10 @@ def __init__(self, bitwidth):
200
207
Number .__init__ (self , bitwidth )
201
208
202
209
def compiler_ctor (self ):
203
- return 'f({})' .format (self .bitwidth ())
210
+ return '::F{}' .format (self .bitwidth ())
211
+
212
+ def compiler_ctor_ref (self ):
213
+ return '&' + self .compiler_ctor ()
204
214
205
215
def llvm_name (self ):
206
216
return 'f{}' .format (self .bitwidth ())
@@ -244,12 +254,16 @@ def modify(self, spec, width, previous):
244
254
245
255
def compiler_ctor (self ):
246
256
if self ._bitcast is None :
247
- return 'v({}, {}) ' .format (self ._elem .compiler_ctor (),
248
- self ._length )
257
+ return '{}x{} ' .format (self ._elem .compiler_ctor (),
258
+ self ._length )
249
259
else :
250
- return 'v_({}, {}, {})' .format (self ._elem .compiler_ctor (),
251
- self ._bitcast .compiler_ctor (),
252
- self ._length )
260
+ return '{}x{}_{}' .format (self ._elem .compiler_ctor (),
261
+ self ._length ,
262
+ self ._bitcast .compiler_ctor ()
263
+ .replace ('::' , '' ))
264
+
265
+ def compiler_ctor_ref (self ):
266
+ return '&' + self .compiler_ctor ()
253
267
254
268
def rust_name (self ):
255
269
return '{}x{}' .format (self ._elem .rust_name (), self ._length )
@@ -284,10 +298,14 @@ def compiler_ctor(self):
284
298
if self ._llvm_elem is None :
285
299
llvm_elem = 'None'
286
300
else :
287
- llvm_elem = 'Some({})' .format (self ._llvm_elem .compiler_ctor ())
288
- return 'p({}, {}, {})' .format ('true' if self ._const else 'false' ,
289
- self ._elem .compiler_ctor (),
290
- llvm_elem )
301
+ llvm_elem = 'Some({})' .format (self ._llvm_elem .compiler_ctor_ref ())
302
+ return 'Type::Pointer({}, {}, {})' .format (self ._elem .compiler_ctor_ref (),
303
+ llvm_elem ,
304
+ 'true' if self ._const else 'false' )
305
+
306
+ def compiler_ctor_ref (self ):
307
+ return "{{ static PTR: Type = {}; &PTR }}" .format (self .compiler_ctor ())
308
+
291
309
292
310
def rust_name (self ):
293
311
return '*{} {}' .format ('const' if self ._const else 'mut' ,
@@ -322,8 +340,14 @@ def modify(self, spec, width, previous):
322
340
raise NotImplementedError ()
323
341
324
342
def compiler_ctor (self ):
325
- return 'agg({}, vec![{}])' .format ('true' if self ._flatten else 'false' ,
326
- ', ' .join (elem .compiler_ctor () for elem in self ._elems ))
343
+ parts = "{{ static PARTS: [&'static Type; {}] = [{}]; &PARTS }}"
344
+ elems = ', ' .join (elem .compiler_ctor_ref () for elem in self ._elems )
345
+ parts = parts .format (len (self ._elems ), elems )
346
+ return 'Type::Aggregate({}, {})' .format ('true' if self ._flatten else 'false' ,
347
+ parts )
348
+
349
+ def compiler_ctor_ref (self ):
350
+ return "{{ static AGG: Type = {}; &AGG }}" .format (self .compiler_ctor ())
327
351
328
352
def rust_name (self ):
329
353
return '({})' .format (', ' .join (elem .rust_name () for elem in self ._elems ))
@@ -518,10 +542,10 @@ def intrinsic_name(self):
518
542
return self ._platform .platform ().intrinsic_prefix () + self .intrinsic_suffix ()
519
543
520
544
def compiler_args (self ):
521
- return ', ' .join (arg .compiler_ctor () for arg in self ._args_raw )
545
+ return ', ' .join (arg .compiler_ctor_ref () for arg in self ._args_raw )
522
546
523
547
def compiler_ret (self ):
524
- return self ._ret_raw .compiler_ctor ()
548
+ return self ._ret_raw .compiler_ctor_ref ()
525
549
526
550
def compiler_signature (self ):
527
551
return '({}) -> {}' .format (self .compiler_args (), self .compiler_ret ())
@@ -733,7 +757,7 @@ def open(self, platform):
733
757
734
758
#![allow(unused_imports)]
735
759
736
- use {{Intrinsic, i, i_, u, u_, f, v, v_, agg, p, void }};
760
+ use {{Intrinsic, Type }};
737
761
use IntrinsicDef::Named;
738
762
use rustc::middle::ty::TyCtxt;
739
763
@@ -747,10 +771,11 @@ def open(self, platform):
747
771
def render (self , mono ):
748
772
return '''\
749
773
"{}" => Intrinsic {{
750
- inputs: vec![ {}],
774
+ inputs: {{ static INPUTS: [&'static Type; {}] = [{}]; &INPUTS }} ,
751
775
output: {},
752
776
definition: Named("{}")
753
777
}},''' .format (mono .intrinsic_suffix (),
778
+ len (mono ._args_raw ),
754
779
mono .compiler_args (),
755
780
mono .compiler_ret (),
756
781
mono .llvm_name ())
0 commit comments