|
17 | 17 | import itertools
|
18 | 18 |
|
19 | 19 | SPEC = re.compile(
|
20 |
| - r'^(?:(?P<id>[iusfIUSF])(?:\((?P<start>\d+)-(?P<end>\d+)\)|' |
| 20 | + r'^(?:(?P<void>V)|(?P<id>[iusfIUSF])(?:\((?P<start>\d+)-(?P<end>\d+)\)|' |
21 | 21 | r'(?P<width>\d+)(:?/(?P<llvm_width>\d+))?)'
|
22 | 22 | r'|(?P<reference>\d+)(?P<modifiers>[vShdnwusDMC]*)(?P<force_width>x\d+)?)'
|
23 | 23 | r'(?:(?P<pointer>Pm|Pc)(?P<llvm_pointer>/.*)?)?$'
|
@@ -97,6 +97,19 @@ def bitwidth(self):
|
97 | 97 | def modify(self, spec, width):
|
98 | 98 | raise NotImplementedError()
|
99 | 99 |
|
| 100 | +class Void(Type): |
| 101 | + def __init__(self): |
| 102 | + Type.__init__(self, 0) |
| 103 | + |
| 104 | + def compiler_ctor(self): |
| 105 | + return 'void()' |
| 106 | + |
| 107 | + def rust_name(self): |
| 108 | + return '()' |
| 109 | + |
| 110 | + def type_info(self, platform_info): |
| 111 | + return None |
| 112 | + |
100 | 113 | class Number(Type):
|
101 | 114 | def __init__(self, bitwidth):
|
102 | 115 | Type.__init__(self, bitwidth)
|
@@ -289,7 +302,10 @@ def enumerate(self, width, previous):
|
289 | 302 | id = match.group('id')
|
290 | 303 | reference = match.group('reference')
|
291 | 304 |
|
292 |
| - if id is not None: |
| 305 | + if match.group('void') is not None: |
| 306 | + assert spec == 'V' |
| 307 | + yield Void() |
| 308 | + elif id is not None: |
293 | 309 | is_vector = id.islower()
|
294 | 310 | type_ctors = TYPE_ID_LOOKUP[id.lower()]
|
295 | 311 |
|
@@ -436,11 +452,15 @@ def parse_args():
|
436 | 452 | ## Type specifier grammar
|
437 | 453 |
|
438 | 454 | ```
|
439 |
| - type := ( vector | scalar | aggregate | reference ) pointer? |
| 455 | + type := core_type pointer? |
| 456 | +
|
| 457 | + core_type := void | vector | scalar | aggregate | reference |
440 | 458 |
|
441 | 459 | pointer := 'Pm' llvm_pointer? | 'Pc' llvm_pointer?
|
442 | 460 | llvm_pointer := '/' type
|
443 | 461 |
|
| 462 | + void := 'V' |
| 463 | +
|
444 | 464 | vector := vector_elem width |
|
445 | 465 | vector_elem := 'i' | 'u' | 's' | 'f'
|
446 | 466 |
|
@@ -472,6 +492,11 @@ def parse_args():
|
472 | 492 | in Rust, but is `i8*` in LLVM. (This defaults to the main
|
473 | 493 | type).
|
474 | 494 |
|
| 495 | + ## Void |
| 496 | +
|
| 497 | + The `V` type corresponds to `void` in LLVM (`()` in |
| 498 | + Rust). It's likely to only work in return position. |
| 499 | +
|
475 | 500 | ## Vectors
|
476 | 501 |
|
477 | 502 | The vector grammar is a pattern describing many possibilities
|
@@ -586,7 +611,7 @@ def open(self, platform):
|
586 | 611 |
|
587 | 612 | #![allow(unused_imports)]
|
588 | 613 |
|
589 |
| -use {{Intrinsic, i, i_, u, u_, f, v, agg, p}}; |
| 614 | +use {{Intrinsic, i, i_, u, u_, f, v, agg, p, void}}; |
590 | 615 | use IntrinsicDef::Named;
|
591 | 616 | use rustc::middle::ty;
|
592 | 617 |
|
|
0 commit comments