Skip to content

Commit

Permalink
Add addcarry/subborrow intrinsics to platform_intrinsics
Browse files Browse the repository at this point in the history
All of these LLVM intrinsics return aggregates, so they need to be
compiler defined!
  • Loading branch information
alexcrichton committed Dec 24, 2018
1 parent b890d51 commit 54cfe35
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 393 deletions.
Empty file.
20 changes: 20 additions & 0 deletions src/librustc_platform_intrinsics/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,25 @@ pub fn find(name: &str) -> Option<Intrinsic> {
output: &Type::Aggregate(false, &[&::U64, &::I32]),
definition: Named("llvm.x86.rdseed.64")
},
"_addcarry_u32" => Intrinsic {
inputs: &[&::I8, &::I32, &::I32],
output: &Type::Aggregate(false, &[&::I8, &::I32]),
definition: Named("llvm.x86.addcarry.32"),
},
"_addcarry_u64" => Intrinsic {
inputs: &[&::I8, &::I64, &::I64],
output: &Type::Aggregate(false, &[&::I8, &::I64]),
definition: Named("llvm.x86.addcarry.64"),
},
"_subborrow_u32" => Intrinsic {
inputs: &[&::I8, &::I32, &::I32],
output: &Type::Aggregate(false, &[&::I8, &::I32]),
definition: Named("llvm.x86.subborrow.32"),
},
"_subborrow_u64" => Intrinsic {
inputs: &[&::I8, &::I64, &::I64],
output: &Type::Aggregate(false, &[&::I8, &::I64]),
definition: Named("llvm.x86.subborrow.64"),
},
}
}
179 changes: 5 additions & 174 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3379,180 +3379,6 @@ extern "platform-intrinsic" {
```
"##,

E0440: r##"
A platform-specific intrinsic function has the wrong number of type
parameters. Erroneous code example:
```compile_fail,E0440
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct f64x2(f64, f64);
extern "platform-intrinsic" {
fn x86_mm_movemask_pd<T>(x: f64x2) -> i32;
// error: platform-specific intrinsic has wrong number of type
// parameters
}
```
Please refer to the function declaration to see if it corresponds
with yours. Example:
```
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct f64x2(f64, f64);
extern "platform-intrinsic" {
fn x86_mm_movemask_pd(x: f64x2) -> i32;
}
```
"##,

E0441: r##"
An unknown platform-specific intrinsic function was used. Erroneous
code example:
```compile_fail,E0441
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
extern "platform-intrinsic" {
fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8;
// error: unrecognized platform-specific intrinsic function
}
```
Please verify that the function name wasn't misspelled, and ensure
that it is declared in the rust source code (in the file
src/librustc_platform_intrinsics/x86.rs). Example:
```
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
extern "platform-intrinsic" {
fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok!
}
```
"##,

E0442: r##"
Intrinsic argument(s) and/or return value have the wrong type.
Erroneous code example:
```compile_fail,E0442
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
i8, i8, i8, i8, i8, i8, i8, i8);
#[repr(simd)]
struct i32x4(i32, i32, i32, i32);
#[repr(simd)]
struct i64x2(i64, i64);
extern "platform-intrinsic" {
fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
// error: intrinsic arguments/return value have wrong type
}
```
To fix this error, please refer to the function declaration to give
it the awaited types. Example:
```
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
extern "platform-intrinsic" {
fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok!
}
```
"##,

E0443: r##"
Intrinsic argument(s) and/or return value have the wrong type.
Erroneous code example:
```compile_fail,E0443
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
#[repr(simd)]
struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64);
extern "platform-intrinsic" {
fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8;
// error: intrinsic argument/return value has wrong type
}
```
To fix this error, please refer to the function declaration to give
it the awaited types. Example:
```
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
extern "platform-intrinsic" {
fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok!
}
```
"##,

E0444: r##"
A platform-specific intrinsic function has wrong number of arguments.
Erroneous code example:
```compile_fail,E0444
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct f64x2(f64, f64);
extern "platform-intrinsic" {
fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32;
// error: platform-specific intrinsic has invalid number of arguments
}
```
Please refer to the function declaration to see if it corresponds
with yours. Example:
```
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#[repr(simd)]
struct f64x2(f64, f64);
extern "platform-intrinsic" {
fn x86_mm_movemask_pd(x: f64x2) -> i32; // ok!
}
```
"##,

E0516: r##"
The `typeof` keyword is currently reserved but unimplemented.
Erroneous code example:
Expand Down Expand Up @@ -4891,6 +4717,11 @@ register_diagnostics! {
// E0372, // coherence not object safe
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
// between structures with the same definition
E0440, // errors associated with unstable platform intrinsics
E0441, // errors associated with unstable platform intrinsics
E0442, // errors associated with unstable platform intrinsics
E0443, // errors associated with unstable platform intrinsics
E0444, // errors associated with unstable platform intrinsics
E0533, // `{}` does not name a unit variant, unit struct or a constant
// E0563, // cannot determine a type for this `impl Trait`: {} // removed in 6383de15
E0564, // only named lifetimes are allowed in `impl Trait`,
Expand Down
34 changes: 0 additions & 34 deletions src/test/run-pass/simd/simd-upgraded.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0440.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
struct f64x2(f64, f64);

extern "platform-intrinsic" {
fn x86_mm_movemask_pd<T>(x: f64x2) -> i32; //~ ERROR E0440
fn x86_rdrand16_step<T>(x: f64x2) -> i32; //~ ERROR E0440
}

fn main () {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0440.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0440]: platform-specific intrinsic has wrong number of type parameters: found 1, expected 0
--> $DIR/E0440.rs:18:5
|
LL | fn x86_mm_movemask_pd<T>(x: f64x2) -> i32; //~ ERROR E0440
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn x86_rdrand16_step<T>(x: f64x2) -> i32; //~ ERROR E0440
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
8 changes: 1 addition & 7 deletions src/test/ui/error-codes/E0442.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@
#[repr(simd)]
struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
i8, i8, i8, i8, i8, i8, i8, i8);
#[repr(simd)]
struct i32x4(i32, i32, i32, i32);
#[repr(simd)]
struct i64x2(i64, i64);

extern "platform-intrinsic" {
fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
fn aarch64_vld2_s8(x: *const i8) -> (i8x16, i8x16);
//~^ ERROR E0442
//~| ERROR E0442
//~| ERROR E0442
}

fn main() {}
22 changes: 5 additions & 17 deletions src/test/ui/error-codes/E0442.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
error[E0442]: intrinsic argument 1 has wrong type: found vector with length 16, expected length 8
--> $DIR/E0442.rs:23:5
error[E0442]: intrinsic return value has wrong type: found vector with length 16, expected length 8
--> $DIR/E0442.rs:19:5
|
LL | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn aarch64_vld2_s8(x: *const i8) -> (i8x16, i8x16);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0442]: intrinsic argument 2 has wrong type: found vector with length 4, expected length 8
--> $DIR/E0442.rs:23:5
|
LL | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0442]: intrinsic return value has wrong type: found vector with length 2, expected length 8
--> $DIR/E0442.rs:23:5
|
LL | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors
error: aborting due to previous error

For more information about this error, try `rustc --explain E0442`.
5 changes: 3 additions & 2 deletions src/test/ui/error-codes/E0443.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
#![feature(platform_intrinsics)]

#[repr(simd)]
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
struct i8x8(i8, i8, i8, i8, i8, i8, i8, i8);
#[repr(simd)]
struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64);

extern "platform-intrinsic" {
fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443
fn aarch64_vld2_s8(x: *const i8) -> (i8x8, i64x8);
//~^ ERROR E0443
}

fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0443.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0443]: intrinsic return value has wrong type: found `i64x8`, expected `i16x8` which was used for this vector type previously in this signature
error[E0443]: intrinsic return value has wrong type: found `i64x8`, expected `i8x8` which was used for this vector type previously in this signature
--> $DIR/E0443.rs:20:5
|
LL | fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443
LL | fn aarch64_vld2_s8(x: *const i8) -> (i8x8, i64x8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0444.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
struct f64x2(f64, f64);

extern "platform-intrinsic" {
fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
fn x86_rdseed16_step(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
}

fn main() {}
6 changes: 3 additions & 3 deletions src/test/ui/error-codes/E0444.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0444]: platform-specific intrinsic has invalid number of arguments: found 3, expected 1
error[E0444]: platform-specific intrinsic has invalid number of arguments: found 3, expected 0
--> $DIR/E0444.rs:18:5
|
LL | fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn x86_rdseed16_step(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/intrinsic-invalid-number-of-arguments.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0444]: platform-specific intrinsic has invalid number of arguments: found 3, expected 1
error[E0441]: unrecognized platform-specific intrinsic function: `x86_mm_movemask_pd`
--> $DIR/intrinsic-invalid-number-of-arguments.rs:20:5
|
LL | fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ platform-specific intrinsic
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0444`.
For more information about this error, try `rustc --explain E0441`.
3 changes: 2 additions & 1 deletion src/test/ui/platform-intrinsic-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
// except according to those terms.

#![feature(platform_intrinsics)]

extern "platform-intrinsic" {
fn x86_mm_movemask_ps() -> i32; //~ERROR found 0, expected 1
fn aarch64_vld2_s8() -> i32; //~ERROR found 0, expected 1
}

fn main() { }
Loading

0 comments on commit 54cfe35

Please sign in to comment.