Skip to content

Commit 3d4c59e

Browse files
committed
Merge branch 'master' into sync_from_rust_2023_06_11
2 parents 94e5c27 + ffb092d commit 3d4c59e

File tree

16 files changed

+230
-211
lines changed

16 files changed

+230
-211
lines changed

.github/workflows/stdarch.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
matrix:
2121
libgccjit_version:
2222
- { gcc: "libgccjit.so", artifacts_branch: "master" }
23-
commands: [
24-
"--test-successful-rustc --nb-parts 2 --current-part 0",
25-
"--test-successful-rustc --nb-parts 2 --current-part 1",
23+
cargo_runner: [
24+
"sde -future -rtm_mode full --",
25+
"",
2626
]
2727

2828
steps:
@@ -36,6 +36,20 @@ jobs:
3636
- name: Install packages
3737
run: sudo apt-get install ninja-build ripgrep
3838

39+
- name: Install Intel Software Development Emulator
40+
if: ${{ matrix.cargo_runner }}
41+
run: |
42+
mkdir intel-sde
43+
cd intel-sde
44+
dir=sde-external-9.14.0-2022-10-25-lin
45+
file=$dir.tar.xz
46+
wget https://downloadmirror.intel.com/751535/$file
47+
tar xvf $file
48+
sudo mkdir /usr/share/intel-sde
49+
sudo cp -r $dir/* /usr/share/intel-sde
50+
sudo ln -s /usr/share/intel-sde/sde /usr/bin/sde
51+
sudo ln -s /usr/share/intel-sde/sde64 /usr/bin/sde64
52+
3953
- name: Download artifact
4054
uses: dawidd6/action-download-artifact@v2
4155
with:
@@ -91,6 +105,10 @@ jobs:
91105
./prepare_build.sh
92106
./build.sh --release --release-sysroot
93107
cargo test
108+
109+
- name: Clean
110+
if: ${{ !matrix.cargo_runner }}
111+
run: |
94112
./clean_all.sh
95113
96114
- name: Prepare dependencies
@@ -107,10 +125,18 @@ jobs:
107125
args: --release
108126

109127
- name: Run tests
128+
if: ${{ !matrix.cargo_runner }}
110129
run: |
111130
./test.sh --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore
112131
113132
- name: Run stdarch tests
133+
if: ${{ !matrix.cargo_runner }}
114134
run: |
115135
cd build_sysroot/sysroot_src/library/stdarch/
116136
CHANNEL=release TARGET=x86_64-unknown-linux-gnu ../../../../cargo.sh test
137+
138+
- name: Run stdarch tests
139+
if: ${{ matrix.cargo_runner }}
140+
run: |
141+
cd build_sysroot/sysroot_src/library/stdarch/
142+
STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu ../../../../cargo.sh test -- --skip rtm --skip tbm --skip sse4a

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ benchmarks
2323
tools/llvm-project
2424
tools/llvmint
2525
tools/llvmint-2
26+
# The `llvm` folder is generated by the `tools/generate_intrinsics.py` script to update intrinsics.
27+
llvm

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ master = ["gccjit/master"]
2525
gccjit = { git = "https://github.com/antoyo/gccjit.rs" }
2626

2727
# Local copy.
28-
#gccjit = { path = "../gccjit.rs" }
28+
# gccjit = { path = "../gccjit.rs" }
2929

3030
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
3131

example/mini_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Uns
489489
#[lang = "owned_box"]
490490
pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A);
491491

492-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
492+
impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
493493

494494
impl<T> Box<T> {
495495
pub fn new(val: T) -> Box<T> {

example/mini_core_hello_world.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ fn main() {
168168
world as Box<dyn SomeTrait>;
169169

170170
assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8);
171+
assert_eq!(intrinsics::bitreverse(0xddccu16), 0x33bbu16);
172+
assert_eq!(intrinsics::bitreverse(0xffee_ddccu32), 0x33bb77ffu32);
173+
assert_eq!(intrinsics::bitreverse(0x1234_5678_ffee_ddccu64), 0x33bb77ff1e6a2c48u64);
171174

172175
assert_eq!(intrinsics::bswap(0xabu8), 0xabu8);
173176
assert_eq!(intrinsics::bswap(0xddccu16), 0xccddu16);

example/std_example.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fn main() {
5858

5959
assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26);
6060
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
61+
assert_eq!(0x1234_5678_ffee_ddcc_1234_5678_ffee_ddccu128.reverse_bits(), 0x33bb77ff1e6a2c4833bb77ff1e6a2c48u128);
6162

6263
let _d = 0i128.checked_div(2i128);
6364
let _d = 0u128.checked_div(2u128);

locales/en-US.ftl

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
codegen_gcc_unwinding_inline_asm =
2+
GCC backend does not support unwinding from inline asm
3+
4+
codegen_gcc_lto_not_supported =
5+
LTO is not supported. You may get a linker error.
6+
7+
codegen_gcc_invalid_monomorphization_basic_integer =
8+
invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
9+
10+
codegen_gcc_invalid_monomorphization_invalid_float_vector =
11+
invalid monomorphization of `{$name}` intrinsic: unsupported element type `{$elem_ty}` of floating-point vector `{$vec_ty}`
12+
13+
codegen_gcc_invalid_monomorphization_not_float =
14+
invalid monomorphization of `{$name}` intrinsic: `{$ty}` is not a floating-point type
15+
16+
codegen_gcc_invalid_monomorphization_unrecognized =
17+
invalid monomorphization of `{$name}` intrinsic: unrecognized intrinsic `{$name}`
18+
19+
codegen_gcc_invalid_monomorphization_expected_signed_unsigned =
20+
invalid monomorphization of `{$name}` intrinsic: expected element type `{$elem_ty}` of vector type `{$vec_ty}` to be a signed or unsigned integer type
21+
22+
codegen_gcc_invalid_monomorphization_unsupported_element =
23+
invalid monomorphization of `{$name}` intrinsic: unsupported {$name} from `{$in_ty}` with element `{$elem_ty}` to `{$ret_ty}`
24+
25+
codegen_gcc_invalid_monomorphization_invalid_bitmask =
26+
invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
27+
28+
codegen_gcc_invalid_monomorphization_simd_shuffle =
29+
invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be an array of `u32`, got `{$ty}`
30+
31+
codegen_gcc_invalid_monomorphization_expected_simd =
32+
invalid monomorphization of `{$name}` intrinsic: expected SIMD {$expected_ty} type, found non-SIMD `{$found_ty}`
33+
34+
codegen_gcc_invalid_monomorphization_mask_type =
35+
invalid monomorphization of `{$name}` intrinsic: mask element type is `{$ty}`, expected `i_`
36+
37+
codegen_gcc_invalid_monomorphization_return_length =
38+
invalid monomorphization of `{$name}` intrinsic: expected return type of length {$in_len}, found `{$ret_ty}` with length {$out_len}
39+
40+
codegen_gcc_invalid_monomorphization_return_length_input_type =
41+
invalid monomorphization of `{$name}` intrinsic: expected return type with length {$in_len} (same as input type `{$in_ty}`), found `{$ret_ty}` with length {$out_len}
42+
43+
codegen_gcc_invalid_monomorphization_return_element =
44+
invalid monomorphization of `{$name}` intrinsic: expected return element type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}` with element type `{$out_ty}`
45+
46+
codegen_gcc_invalid_monomorphization_return_type =
47+
invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}`
48+
49+
codegen_gcc_invalid_monomorphization_inserted_type =
50+
invalid monomorphization of `{$name}` intrinsic: expected inserted type `{$in_elem}` (element of input `{$in_ty}`), found `{$out_ty}`
51+
52+
codegen_gcc_invalid_monomorphization_return_integer_type =
53+
invalid monomorphization of `{$name}` intrinsic: expected return type with integer elements, found `{$ret_ty}` with non-integer `{$out_ty}`
54+
55+
codegen_gcc_invalid_monomorphization_mismatched_lengths =
56+
invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`
57+
58+
codegen_gcc_invalid_monomorphization_unsupported_cast =
59+
invalid monomorphization of `{$name}` intrinsic: unsupported cast from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}` with element `{$out_elem}`
60+
61+
codegen_gcc_invalid_monomorphization_unsupported_operation =
62+
invalid monomorphization of `{$name}` intrinsic: unsupported operation on `{$in_ty}` with element `{$in_elem}`
63+
64+
codegen_gcc_invalid_minimum_alignment =
65+
invalid minimum global alignment: {$err}

src/asm.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -502,49 +502,49 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
502502
let builtin_unreachable = self.context.get_builtin_function("__builtin_unreachable");
503503
let builtin_unreachable: RValue<'gcc> = unsafe { std::mem::transmute(builtin_unreachable) };
504504
self.call(self.type_void(), None, None, builtin_unreachable, &[], None);
505-
}
505+
}
506506

507-
// Write results to outputs.
508-
//
509-
// We need to do this because:
510-
// 1. Turning `PlaceRef` into `RValue` is error-prone and has nasty edge cases
511-
// (especially with current `rustc_backend_ssa` API).
512-
// 2. Not every output operand has an `out_place`, and it's required by `add_output_operand`.
513-
//
514-
// Instead, we generate a temporary output variable for each output operand, and then this loop,
515-
// generates `out_place = tmp_var;` assignments if out_place exists.
516-
for op in &outputs {
517-
if let Some(place) = op.out_place {
518-
OperandValue::Immediate(op.tmp_var.to_rvalue()).store(self, place);
519-
}
507+
// Write results to outputs.
508+
//
509+
// We need to do this because:
510+
// 1. Turning `PlaceRef` into `RValue` is error-prone and has nasty edge cases
511+
// (especially with current `rustc_backend_ssa` API).
512+
// 2. Not every output operand has an `out_place`, and it's required by `add_output_operand`.
513+
//
514+
// Instead, we generate a temporary output variable for each output operand, and then this loop,
515+
// generates `out_place = tmp_var;` assignments if out_place exists.
516+
for op in &outputs {
517+
if let Some(place) = op.out_place {
518+
OperandValue::Immediate(op.tmp_var.to_rvalue()).store(self, place);
520519
}
521-
522520
}
521+
522+
}
523523
}
524524

525525
fn estimate_template_length(template: &[InlineAsmTemplatePiece], constants_len: usize, att_dialect: bool) -> usize {
526-
let len: usize = template.iter().map(|piece| {
527-
match *piece {
528-
InlineAsmTemplatePiece::String(ref string) => {
529-
string.len()
530-
}
531-
InlineAsmTemplatePiece::Placeholder { .. } => {
532-
// '%' + 1 char modifier + 1 char index
533-
3
534-
}
526+
let len: usize = template.iter().map(|piece| {
527+
match *piece {
528+
InlineAsmTemplatePiece::String(ref string) => {
529+
string.len()
530+
}
531+
InlineAsmTemplatePiece::Placeholder { .. } => {
532+
// '%' + 1 char modifier + 1 char index
533+
3
535534
}
536-
})
537-
.sum();
535+
}
536+
})
537+
.sum();
538538

539-
// increase it by 5% to account for possible '%' signs that'll be duplicated
540-
// I pulled the number out of blue, but should be fair enough
541-
// as the upper bound
542-
let mut res = (len as f32 * 1.05) as usize + constants_len;
539+
// increase it by 5% to account for possible '%' signs that'll be duplicated
540+
// I pulled the number out of blue, but should be fair enough
541+
// as the upper bound
542+
let mut res = (len as f32 * 1.05) as usize + constants_len;
543543

544-
if att_dialect {
545-
res += INTEL_SYNTAX_INS.len() + ATT_SYNTAX_INS.len();
546-
}
547-
res
544+
if att_dialect {
545+
res += INTEL_SYNTAX_INS.len() + ATT_SYNTAX_INS.len();
546+
}
547+
res
548548
}
549549

550550
/// Converts a register class to a GCC constraint code.

src/attributes.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
use gccjit::FnAttribute;
33
use gccjit::Function;
44
use rustc_attr::InstructionSetAttr;
5+
#[cfg(feature="master")]
6+
use rustc_attr::InlineAttr;
57
use rustc_codegen_ssa::target_features::tied_target_features;
68
use rustc_data_structures::fx::FxHashMap;
79
use rustc_middle::ty;
10+
#[cfg(feature="master")]
11+
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
812
use rustc_session::Session;
913
use rustc_span::symbol::sym;
1014
use smallvec::{smallvec, SmallVec};
@@ -67,6 +71,24 @@ fn to_gcc_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> {
6771
}
6872
}
6973

74+
/// Get GCC attribute for the provided inline heuristic.
75+
#[cfg(feature="master")]
76+
#[inline]
77+
fn inline_attr<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, inline: InlineAttr) -> Option<FnAttribute<'gcc>> {
78+
match inline {
79+
InlineAttr::Hint => Some(FnAttribute::Inline),
80+
InlineAttr::Always => Some(FnAttribute::AlwaysInline),
81+
InlineAttr::Never => {
82+
if cx.sess().target.arch != "amdgpu" {
83+
Some(FnAttribute::NoInline)
84+
} else {
85+
None
86+
}
87+
}
88+
InlineAttr::None => None,
89+
}
90+
}
91+
7092
/// Composite function which sets GCC attributes for function depending on its AST (`#[attribute]`)
7193
/// attributes.
7294
pub fn from_fn_attrs<'gcc, 'tcx>(
@@ -77,6 +99,23 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
7799
) {
78100
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
79101

102+
#[cfg(feature="master")]
103+
{
104+
let inline =
105+
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
106+
InlineAttr::Never
107+
}
108+
else if codegen_fn_attrs.inline == InlineAttr::None && instance.def.requires_inline(cx.tcx) {
109+
InlineAttr::Hint
110+
}
111+
else {
112+
codegen_fn_attrs.inline
113+
};
114+
if let Some(attr) = inline_attr(cx, inline) {
115+
func.add_attribute(attr);
116+
}
117+
}
118+
80119
let function_features =
81120
codegen_fn_attrs.target_features.iter().map(|features| features.as_str()).collect::<Vec<&str>>();
82121

0 commit comments

Comments
 (0)