Skip to content

Commit 559b6fc

Browse files
committed
---
yaml --- r: 234011 b: refs/heads/beta c: d12135a h: refs/heads/master i: 234009: f4c3523 234007: cd5b00f v: v3
1 parent d1bd747 commit 559b6fc

File tree

15 files changed

+310
-169
lines changed

15 files changed

+310
-169
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: 779b2a9847319106647dcad12fc6dc472bc0cf4d
26+
refs/heads/beta: d12135a70de99e1cf86e3147379f4eb0678cd97c
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/configure

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,27 +1180,16 @@ do
11801180
# MSVC requires cmake because that's how we're going to build LLVM
11811181
probe_need CFG_CMAKE cmake
11821182

1183-
# There are three builds of cmake on windows: MSVC, MinGW and Cygwin
1184-
# The Cygwin build does not have generators for Visual Studio, so
1185-
# detect that here and error.
1186-
if ! "$CFG_CMAKE" --help | sed -n '/^Generators/,$p' | grep 'Visual Studio' > /dev/null
1187-
then
1188-
err "cmake does not support Visual Studio generators.\n\n \
1189-
This is likely due to it being an msys/cygwin build of cmake, \
1190-
rather than the required windows version, built using MinGW \
1191-
or Visual Studio."
1192-
fi
1193-
11941183
# Use the REG program to figure out where VS is installed
11951184
# We need to figure out where cl.exe and link.exe are, so we do some
11961185
# munging and some probing here. We also look for the default
11971186
# INCLUDE and LIB variables for MSVC so we can set those in the
11981187
# build system as well.
1199-
install=$(cmd //c reg QUERY \
1188+
install=$(reg QUERY \
12001189
'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0' \
12011190
-v InstallDir)
12021191
if [ -z "$install" ]; then
1203-
install=$(cmd //c reg QUERY \
1192+
install=$(reg QUERY \
12041193
'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0' \
12051194
-v InstallDir)
12061195
fi
@@ -1233,9 +1222,9 @@ do
12331222
eval CFG_MSVC_LINK_$bits="\"$bindir/link.exe\""
12341223

12351224
vcvarsall="${CFG_MSVC_ROOT}/VC/vcvarsall.bat"
1236-
include_path=$(cmd //V:ON //c "$vcvarsall" $msvc_part \& echo !INCLUDE!)
1225+
include_path=$(cmd /c "\"$vcvarsall\" $msvc_part && cmd /c echo %INCLUDE%")
12371226
need_ok "failed to learn about MSVC's INCLUDE"
1238-
lib_path=$(cmd //V:ON //c "$vcvarsall" $msvc_part \& echo !LIB!)
1227+
lib_path=$(cmd /c "\"$vcvarsall\" $msvc_part && cmd /c echo %LIB%")
12391228
need_ok "failed to learn about MSVC's LIB"
12401229

12411230
eval CFG_MSVC_INCLUDE_PATH_${bits}="\"$include_path\""

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

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
SPEC = re.compile(
1919
r'^(?:(?P<id>[iusfIUSF])(?:\((?P<start>\d+)-(?P<end>\d+)\)|'
2020
r'(?P<width>\d+)(:?/(?P<llvm_width>\d+))?)'
21-
r'|(?P<reference>\d+)(?P<modifiers>[vShdnwus]*)(?P<force_width>x\d+)?)$'
21+
r'|(?P<reference>\d+)(?P<modifiers>[vShdnwusDMC]*)(?P<force_width>x\d+)?)'
22+
r'(?:(?P<pointer>Pm|Pc)(?P<llvm_pointer>/.*)?)?$'
2223
)
2324

2425
class PlatformInfo(object):
@@ -80,6 +81,11 @@ def vectorize(self, length, width_info):
8081
props.update(width_info)
8182
return PlatformTypeInfo('v{}{}'.format(length, self.llvm_name), props)
8283

84+
def pointer(self):
85+
return PlatformTypeInfo('p0{}'.format(self.llvm_name), self.properties)
86+
87+
BITWIDTH_POINTER = '<pointer>'
88+
8389
class Type(object):
8490
def __init__(self, bitwidth):
8591
self._bitwidth = bitwidth
@@ -193,6 +199,39 @@ def type_info(self, platform_info):
193199
return elem_info.vectorize(self._length,
194200
platform_info.width_info(self.bitwidth()))
195201

202+
class Pointer(Type):
203+
def __init__(self, elem, llvm_elem, const):
204+
self._elem = elem;
205+
self._llvm_elem = llvm_elem
206+
self._const = const
207+
Type.__init__(self, BITWIDTH_POINTER)
208+
209+
def modify(self, spec, width):
210+
if spec == 'D':
211+
return self._elem
212+
elif spec == 'M':
213+
return Pointer(self._elem, self._llvm_elem, False)
214+
elif spec == 'C':
215+
return Pointer(self._elem, self._llvm_elem, True)
216+
else:
217+
return Pointer(self._elem.modify(spec, width), self._llvm_elem, self._const)
218+
219+
def compiler_ctor(self):
220+
if self._llvm_elem is None:
221+
llvm_elem = 'None'
222+
else:
223+
llvm_elem = 'Some({})'.format(self._llvm_elem.compiler_ctor())
224+
return 'p({}, {}, {})'.format('true' if self._const else 'false',
225+
self._elem.compiler_ctor(),
226+
llvm_elem)
227+
228+
def rust_name(self):
229+
return '*{} {}'.format('const' if self._const else 'mut',
230+
self._elem.rust_name())
231+
232+
def type_info(self, platform_info):
233+
return self._elem.type_info(platform_info).pointer()
234+
196235
class Aggregate(Type):
197236
def __init__(self, flatten, elems):
198237
self._flatten = flatten
@@ -219,6 +258,22 @@ def type_info(self, platform_info):
219258
'u': [Unsigned],
220259
'f': [Float]}
221260

261+
def ptrify(match, elem, width):
262+
ptr = match.group('pointer')
263+
if ptr is None:
264+
return elem
265+
else:
266+
llvm_ptr = match.group('llvm_pointer')
267+
if llvm_ptr is None:
268+
llvm_elem = None
269+
else:
270+
assert llvm_ptr.startswith('/')
271+
options = list(TypeSpec(llvm_ptr[1:]).enumerate(width))
272+
assert len(options) == 1
273+
llvm_elem = options[0]
274+
assert ptr in ('Pc', 'Pm')
275+
return Pointer(elem, llvm_elem, ptr == 'Pc')
276+
222277
class TypeSpec(object):
223278
def __init__(self, spec):
224279
if not isinstance(spec, list):
@@ -229,8 +284,10 @@ def __init__(self, spec):
229284
def enumerate(self, width):
230285
for spec in self.spec:
231286
match = SPEC.match(spec)
232-
if match:
287+
assert match is not None
288+
if True:
233289
id = match.group('id')
290+
assert id is not None
234291
is_vector = id.islower()
235292
type_ctors = TYPE_ID_LOOKUP[id.lower()]
236293

@@ -256,19 +313,21 @@ def enumerate(self, width):
256313
scalar = ctor(bitwidth)
257314

258315
if is_vector:
259-
yield Vector(scalar, width // bitwidth)
316+
elem = Vector(scalar, width // bitwidth)
260317
else:
261-
yield scalar
318+
elem = scalar
319+
yield ptrify(match, elem, width)
262320
bitwidth *= 2
263321
else:
264-
print('Failed to parse: `{}`'.format(spec), file=sys.stderr)
322+
pass
323+
#print('Failed to parse: `{}`'.format(spec), file=sys.stderr)
265324

266325
def resolve(self, width, zero):
267326
assert len(self.spec) == 1
268327
spec = self.spec[0]
269328
match = SPEC.match(spec)
270329
if match:
271-
id = match.group('id')
330+
id = match.group('id')
272331
if id is not None:
273332
options = list(self.enumerate(width))
274333
assert len(options) == 1
@@ -282,7 +341,7 @@ def resolve(self, width, zero):
282341
force = match.group('force_width')
283342
if force is not None:
284343
ret = ret.modify(force, width)
285-
return ret
344+
return ptrify(match, ret, width)
286345
elif spec.startswith('('):
287346
if spec.endswith(')'):
288347
raise NotImplementedError()
@@ -291,6 +350,8 @@ def resolve(self, width, zero):
291350
flatten = True
292351
elems = [TypeSpec(subspec).resolve(width, zero) for subspec in true_spec.split(',')]
293352
return Aggregate(flatten, elems)
353+
else:
354+
assert False, 'Failed to resolve: {}'.format(spec)
294355

295356
class GenericIntrinsic(object):
296357
def __init__(self, platform, intrinsic, widths, llvm_name, ret, args):
@@ -369,7 +430,10 @@ def parse_args():
369430
## Type specifier grammar
370431
371432
```
372-
type := vector | scalar | aggregate | reference
433+
type := ( vector | scalar | aggregate | reference ) pointer?
434+
435+
pointer := 'Pm' llvm_pointer? | 'Pc' llvm_pointer?
436+
llvm_pointer := '/' type
373437
374438
vector := vector_elem width |
375439
vector_elem := 'i' | 'u' | 's' | 'f'
@@ -390,6 +454,18 @@ def parse_args():
390454
number = [0-9]+
391455
```
392456
457+
## Pointers
458+
459+
Pointers can be created to any type. The `m` vs. `c` chooses
460+
mut vs. const. e.g. `S32Pm` corresponds to `*mut i32`, and
461+
`i32Pc` corresponds (with width 128) to `*const i8x16`,
462+
`*const u32x4`, etc.
463+
464+
The type after the `/` (optional) represents the type used
465+
internally to LLVM, e.g. `S32pm/S8` is exposed as `*mut i32`
466+
in Rust, but is `i8*` in LLVM. (This defaults to the main
467+
type).
468+
393469
## Vectors
394470
395471
The vector grammar is a pattern describing many possibilities
@@ -454,6 +530,9 @@ def parse_args():
454530
- 'u': force an integer (vector or scalar) to be unsigned (i32x4 -> u32x4)
455531
- 's': force an integer (vector or scalar) to be signed (u32x4 -> i32x4)
456532
- 'x' number: force the type to be a vector of bitwidth `number`.
533+
- 'D': dereference a pointer (*mut u32 -> u32)
534+
- 'C': make a pointer const (*mut u32 -> *const u32)
535+
- 'M': make a pointer mut (*const u32 -> *mut u32)
457536
'''))
458537
parser.add_argument('--format', choices=FORMATS, required=True,
459538
help = 'Output format.')
@@ -502,7 +581,7 @@ def open(self, platform):
502581
503582
#![allow(unused_imports)]
504583
505-
use {{Intrinsic, i, i_, u, u_, f, v, agg}};
584+
use {{Intrinsic, i, i_, u, u_, f, v, agg, p}};
506585
use IntrinsicDef::Named;
507586
use rustc::middle::ty;
508587

branches/beta/src/libcore/array.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
integer constants",
2020
issue = "27778")]
2121

22-
use borrow::{Borrow, BorrowMut};
2322
use clone::Clone;
2423
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
2524
use convert::{AsRef, AsMut};
@@ -71,20 +70,6 @@ macro_rules! array_impls {
7170
}
7271
}
7372

74-
#[stable(feature = "array_borrow", since = "1.4.0")]
75-
impl<T> Borrow<[T]> for [T; $N] {
76-
fn borrow(&self) -> &[T] {
77-
self
78-
}
79-
}
80-
81-
#[stable(feature = "array_borrow", since = "1.4.0")]
82-
impl<T> BorrowMut<[T]> for [T; $N] {
83-
fn borrow_mut(&mut self) -> &mut [T] {
84-
self
85-
}
86-
}
87-
8873
#[stable(feature = "rust1", since = "1.0.0")]
8974
impl<T:Copy> Clone for [T; $N] {
9075
fn clone(&self) -> [T; $N] {

branches/beta/src/librustc/middle/traits/object_safety.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
9292
// Check methods for violations.
9393
let mut violations: Vec<_> =
9494
tcx.trait_items(trait_def_id).iter()
95-
.filter_map(|item| {
95+
.flat_map(|item| {
9696
match *item {
9797
ty::MethodTraitItem(ref m) => {
9898
object_safety_violation_for_method(tcx, trait_def_id, &**m)
9999
.map(|code| ObjectSafetyViolation::Method(m.clone(), code))
100+
.into_iter()
100101
}
101-
_ => None,
102+
_ => None.into_iter(),
102103
}
103104
})
104105
.collect();

branches/beta/src/librustc_platform_intrinsics/aarch64.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, u, f, v, agg};
16+
use {Intrinsic, i, i_, u, u_, f, v, agg, p};
1717
use IntrinsicDef::Named;
1818
use rustc::middle::ty;
1919

branches/beta/src/librustc_platform_intrinsics/arm.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, u, f, v, agg};
16+
use {Intrinsic, i, i_, u, u_, f, v, agg, p};
1717
use IntrinsicDef::Named;
1818
use rustc::middle::ty;
1919

branches/beta/src/librustc_platform_intrinsics/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct Intrinsic {
3232
pub enum Type {
3333
Integer(/* signed */ bool, u8, /* llvm width */ u8),
3434
Float(u8),
35-
Pointer(Box<Type>),
35+
Pointer(Box<Type>, Option<Box<Type>>, /* const */ bool),
3636
Vector(Box<Type>, u8),
3737
Aggregate(bool, Vec<Type>),
3838
}
@@ -51,6 +51,9 @@ fn v(x: Type, length: u8) -> Type { Type::Vector(Box::new(x), length) }
5151
fn agg(flatten: bool, types: Vec<Type>) -> Type {
5252
Type::Aggregate(flatten, types)
5353
}
54+
fn p(const_: bool, elem: Type, llvm_elem: Option<Type>) -> Type {
55+
Type::Pointer(Box::new(elem), llvm_elem.map(Box::new), const_)
56+
}
5457

5558
mod x86;
5659
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};
16+
use {Intrinsic, i, i_, u, u_, f, v, agg, p};
1717
use IntrinsicDef::Named;
1818
use rustc::middle::ty;
1919

0 commit comments

Comments
 (0)