Skip to content

Commit 9968d4f

Browse files
committed
---
yaml --- r: 234013 b: refs/heads/beta c: 62e346a h: refs/heads/master i: 234011: 559b6fc v: v3
1 parent f14de60 commit 9968d4f

File tree

6 files changed

+40
-6
lines changed

6 files changed

+40
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: add04307f9b627992914b31dca82530f7886ef9a
26+
refs/heads/beta: 62e346af4b7a1aac43db627f19d2511d5649e5d7
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/etc/platform-intrinsics/generator.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import itertools
1818

1919
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+)\)|'
2121
r'(?P<width>\d+)(:?/(?P<llvm_width>\d+))?)'
2222
r'|(?P<reference>\d+)(?P<modifiers>[vShdnwusDMC]*)(?P<force_width>x\d+)?)'
2323
r'(?:(?P<pointer>Pm|Pc)(?P<llvm_pointer>/.*)?)?$'
@@ -97,6 +97,19 @@ def bitwidth(self):
9797
def modify(self, spec, width):
9898
raise NotImplementedError()
9999

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+
100113
class Number(Type):
101114
def __init__(self, bitwidth):
102115
Type.__init__(self, bitwidth)
@@ -289,7 +302,10 @@ def enumerate(self, width, previous):
289302
id = match.group('id')
290303
reference = match.group('reference')
291304

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:
293309
is_vector = id.islower()
294310
type_ctors = TYPE_ID_LOOKUP[id.lower()]
295311

@@ -436,11 +452,15 @@ def parse_args():
436452
## Type specifier grammar
437453
438454
```
439-
type := ( vector | scalar | aggregate | reference ) pointer?
455+
type := core_type pointer?
456+
457+
core_type := void | vector | scalar | aggregate | reference
440458
441459
pointer := 'Pm' llvm_pointer? | 'Pc' llvm_pointer?
442460
llvm_pointer := '/' type
443461
462+
void := 'V'
463+
444464
vector := vector_elem width |
445465
vector_elem := 'i' | 'u' | 's' | 'f'
446466
@@ -472,6 +492,11 @@ def parse_args():
472492
in Rust, but is `i8*` in LLVM. (This defaults to the main
473493
type).
474494
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+
475500
## Vectors
476501
477502
The vector grammar is a pattern describing many possibilities
@@ -586,7 +611,7 @@ def open(self, platform):
586611
587612
#![allow(unused_imports)]
588613
589-
use {{Intrinsic, i, i_, u, u_, f, v, agg, p}};
614+
use {{Intrinsic, i, i_, u, u_, f, v, agg, p, void}};
590615
use IntrinsicDef::Named;
591616
use rustc::middle::ty;
592617

branches/beta/src/librustc_platform_intrinsics/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub struct Intrinsic {
3030

3131
#[derive(Clone, Hash, Eq, PartialEq)]
3232
pub enum Type {
33+
Void,
3334
Integer(/* signed */ bool, u8, /* llvm width */ u8),
3435
Float(u8),
3536
Pointer(Box<Type>, Option<Box<Type>>, /* const */ bool),
@@ -54,6 +55,9 @@ fn agg(flatten: bool, types: Vec<Type>) -> Type {
5455
fn p(const_: bool, elem: Type, llvm_elem: Option<Type>) -> Type {
5556
Type::Pointer(Box::new(elem), llvm_elem.map(Box::new), const_)
5657
}
58+
fn void() -> Type {
59+
Type::Void
60+
}
5761

5862
mod x86;
5963
mod arm;

branches/beta/src/librustc_platform_intrinsics/x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#![allow(unused_imports)]
1515

16-
use {Intrinsic, i, i_, u, u_, f, v, agg, p};
16+
use {Intrinsic, i, i_, u, u_, f, v, agg, p, void};
1717
use IntrinsicDef::Named;
1818
use rustc::middle::ty;
1919

branches/beta/src/librustc_trans/trans/intrinsic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
936936
any_changes_needed: &mut bool) -> Vec<Type> {
937937
use intrinsics::Type::*;
938938
match *t {
939+
Void => vec![Type::void(ccx)],
939940
Integer(_signed, width, llvm_width) => {
940941
*any_changes_needed |= width != llvm_width;
941942
vec![Type::ix(ccx, llvm_width as u64)]

branches/beta/src/librustc_typeck/check/intrinsic.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ fn match_intrinsic_type_to_type<'tcx, 'a>(
464464
};
465465

466466
match *expected {
467+
Void => match t.sty {
468+
ty::TyTuple(ref v) if v.is_empty() => {},
469+
_ => simple_error(&format!("`{}`", t), "()"),
470+
},
467471
// (The width we pass to LLVM doesn't concern the type checker.)
468472
Integer(signed, bits, _llvm_width) => match (signed, bits, &t.sty) {
469473
(true, 8, &ty::TyInt(hir::IntTy::TyI8)) |

0 commit comments

Comments
 (0)