Skip to content

Commit a643bdc

Browse files
committed
Auto merge of #43419 - lu-zero:master, r=alexcrichton
Add support for the VSX and Altivec features on PowerPC
2 parents 5c126bd + 9ed8cf8 commit a643bdc

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"platform": "powerpc",
3+
"intrinsic_prefix": "_vec_",
4+
"llvm_prefix": "llvm.ppc.altivec.",
5+
"number_info": {
6+
"unsigned": {},
7+
"signed": {}
8+
},
9+
"width_info": {
10+
"128": { "width": "" }
11+
},
12+
"intrinsics": [
13+
{
14+
"intrinsic": "perm",
15+
"width": [128],
16+
"llvm": "vperm",
17+
"ret": "s32",
18+
"args": ["0", "0", "s8"]
19+
}
20+
]
21+
}

src/librustc_platform_intrinsics/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ mod arm;
113113
mod aarch64;
114114
mod nvptx;
115115
mod hexagon;
116+
mod powerpc;
116117

117118
impl Intrinsic {
118119
pub fn find(name: &str) -> Option<Intrinsic> {
@@ -126,6 +127,8 @@ impl Intrinsic {
126127
nvptx::find(name)
127128
} else if name.starts_with("Q6_") {
128129
hexagon::find(name)
130+
} else if name.starts_with("powerpc_") {
131+
powerpc::find(name)
129132
} else {
130133
None
131134
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// DO NOT EDIT: autogenerated by etc/platform-intrinsics/generator.py
12+
// ignore-tidy-linelength
13+
14+
#![allow(unused_imports)]
15+
16+
use {Intrinsic, Type};
17+
use IntrinsicDef::Named;
18+
19+
// The default inlining settings trigger a pathological behaviour in
20+
// LLVM, which causes makes compilation very slow. See #28273.
21+
#[inline(never)]
22+
pub fn find(name: &str) -> Option<Intrinsic> {
23+
if !name.starts_with("powerpc") { return None }
24+
Some(match &name["powerpc".len()..] {
25+
"_vec_perm" => Intrinsic {
26+
inputs: { static INPUTS: [&'static Type; 3] = [&::I32x4, &::I32x4, &::I8x16]; &INPUTS },
27+
output: &::I32x4,
28+
definition: Named("llvm.ppc.altivec.vperm")
29+
},
30+
_ => return None,
31+
})
32+
}

src/librustc_trans/llvm_util.rs

+3
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bm
8080

8181
const HEXAGON_WHITELIST: &'static [&'static str] = &["hvx\0", "hvx-double\0"];
8282

83+
const POWERPC_WHITELIST: &'static [&'static str] = &["altivec\0", "vsx\0"];
84+
8385
pub fn target_features(sess: &Session) -> Vec<Symbol> {
8486
let target_machine = create_target_machine(sess);
8587

8688
let whitelist = match &*sess.target.target.arch {
8789
"arm" => ARM_WHITELIST,
8890
"x86" | "x86_64" => X86_WHITELIST,
8991
"hexagon" => HEXAGON_WHITELIST,
92+
"powerpc" | "powerpc64" => POWERPC_WHITELIST,
9093
_ => &[],
9194
};
9295

0 commit comments

Comments
 (0)