Skip to content

Commit 3d5d4e3

Browse files
committed
Merge commit 'e228f0c16ea8c34794a6285bf57aab627c26b147' into libgccjit-codegen
2 parents 6fc0696 + e228f0c commit 3d5d4e3

27 files changed

+265
-3053
lines changed

compiler/rustc_codegen_gcc/build_sysroot/prepare_sysroot_src.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo "[GIT] add"
2121
git add .
2222
echo "[GIT] commit"
2323

24-
# This is needed on virgin system where nothing is configured.
24+
# This is needed on systems where nothing is configured.
2525
# git really needs something here, or it will fail.
2626
# Even using --author is not enough.
2727
git config user.email || git config user.email "[email protected]"

compiler/rustc_codegen_gcc/config.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
3131
fi
3232

3333
export RUSTFLAGS=$linker' -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_gcc.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
34-
#export RUSTFLAGS=$linker' -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_gcc.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot -Clto=fat -Cembed-bitcode=yes'
3534

36-
# FIXME remove once the atomic shim is gone
35+
# FIXME(antoyo): remove once the atomic shim is gone
3736
if [[ `uname` == 'Darwin' ]]; then
3837
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
3938
fi
@@ -43,6 +42,3 @@ export RUSTC_LOG=warn # display metadata load errors
4342

4443
export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib:$GCC_PATH"
4544
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
46-
47-
export CG_CLIF_DISPLAY_CG_TIME=1
48-
export CG_CLIF_INCR_CACHE_DISABLED=1

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ fn main() {
253253
}
254254
}
255255

256-
// TODO: not sure about this assert. ABC is not defined, so should it be really 0?
256+
// TODO(antoyo): to make this work, support weak linkage.
257257
//unsafe { assert_eq!(ABC as usize, 0); }
258258

259259
&mut (|| Some(0 as *const ())) as &mut dyn FnMut() -> Option<*const ()>;

compiler/rustc_codegen_gcc/example/std_example.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ fn main() {
1616
let stderr = ::std::io::stderr();
1717
let mut stderr = stderr.lock();
1818

19-
// FIXME: this thread panics.
2019
std::thread::spawn(move || {
2120
println!("Hello from another thread!");
2221
});
@@ -56,7 +55,7 @@ fn main() {
5655
assert_eq!(-32768i16, (-32768i16).saturating_add(-32768));
5756
assert_eq!(32767i16, 32767i16.saturating_add(1));
5857

59-
/*assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26);
58+
assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26);
6059
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
6160

6261
let _d = 0i128.checked_div(2i128);
@@ -85,7 +84,7 @@ fn main() {
8584
assert_eq!(houndred_i128 as f32, 100.0);
8685
assert_eq!(houndred_i128 as f64, 100.0);
8786
assert_eq!(houndred_f32 as i128, 100);
88-
assert_eq!(houndred_f64 as i128, 100);*/
87+
assert_eq!(houndred_f64 as i128, 100);
8988

9089
let _a = 1u32 << 2u8;
9190

compiler/rustc_codegen_gcc/gcc_path

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/bouanto/Ordinateur/Programmation/Projets/gcc-build/build/gcc

compiler/rustc_codegen_gcc/src/abi.rs

+2-128
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use crate::type_of::LayoutGccExt;
1111

1212
impl<'a, 'gcc, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
1313
fn apply_attrs_callsite(&mut self, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _callsite: Self::Value) {
14-
// TODO
15-
//fn_abi.apply_attrs_callsite(self, callsite)
14+
// TODO(antoyo)
1615
}
1716

1817
fn get_param(&self, index: usize) -> Self::Value {
@@ -87,12 +86,9 @@ impl GccType for Reg {
8786
}
8887

8988
pub trait FnAbiGccExt<'gcc, 'tcx> {
90-
// TODO: return a function pointer type instead?
89+
// TODO(antoyo): return a function pointer type instead?
9190
fn gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> (Type<'gcc>, Vec<Type<'gcc>>, bool);
9291
fn ptr_to_gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
93-
/*fn llvm_cconv(&self) -> llvm::CallConv;
94-
fn apply_attrs_llfn(&self, cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value);
95-
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value);*/
9692
}
9793

9894
impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
@@ -145,12 +141,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
145141
continue;
146142
}
147143
PassMode::Indirect { extra_attrs: Some(_), .. } => {
148-
/*let ptr_ty = cx.tcx.mk_mut_ptr(arg.layout.ty);
149-
let ptr_layout = cx.layout_of(ptr_ty);
150-
argument_tys.push(ptr_layout.scalar_pair_element_gcc_type(cx, 0, true));
151-
argument_tys.push(ptr_layout.scalar_pair_element_gcc_type(cx, 1, true));*/
152144
unimplemented!();
153-
//continue;
154145
}
155146
PassMode::Cast(cast) => cast.gcc_type(cx),
156147
PassMode::Indirect { extra_attrs: None, .. } => cx.type_ptr_to(arg.memory_ty(cx)),
@@ -166,121 +157,4 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
166157
let pointer_type = cx.context.new_function_pointer_type(None, return_type, &params, variadic);
167158
pointer_type
168159
}
169-
170-
/*fn llvm_cconv(&self) -> llvm::CallConv {
171-
match self.conv {
172-
Conv::C | Conv::Rust => llvm::CCallConv,
173-
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
174-
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
175-
Conv::Msp430Intr => llvm::Msp430Intr,
176-
Conv::PtxKernel => llvm::PtxKernel,
177-
Conv::X86Fastcall => llvm::X86FastcallCallConv,
178-
Conv::X86Intr => llvm::X86_Intr,
179-
Conv::X86Stdcall => llvm::X86StdcallCallConv,
180-
Conv::X86ThisCall => llvm::X86_ThisCall,
181-
Conv::X86VectorCall => llvm::X86_VectorCall,
182-
Conv::X86_64SysV => llvm::X86_64_SysV,
183-
Conv::X86_64Win64 => llvm::X86_64_Win64,
184-
}
185-
}
186-
187-
fn apply_attrs_llfn(&self, cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value) {
188-
// FIXME(eddyb) can this also be applied to callsites?
189-
if self.ret.layout.abi.is_uninhabited() {
190-
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);
191-
}
192-
193-
// FIXME(eddyb, wesleywiser): apply this to callsites as well?
194-
if !self.can_unwind {
195-
llvm::Attribute::NoUnwind.apply_llfn(llvm::AttributePlace::Function, llfn);
196-
}
197-
198-
let mut i = 0;
199-
let mut apply = |attrs: &ArgAttributes, ty: Option<&Type>| {
200-
attrs.apply_llfn(llvm::AttributePlace::Argument(i), llfn, ty);
201-
i += 1;
202-
};
203-
match self.ret.mode {
204-
PassMode::Direct(ref attrs) => {
205-
attrs.apply_llfn(llvm::AttributePlace::ReturnValue, llfn, None);
206-
}
207-
PassMode::Indirect(ref attrs, _) => apply(attrs, Some(self.ret.layout.gcc_type(cx))),
208-
_ => {}
209-
}
210-
for arg in &self.args {
211-
if arg.pad.is_some() {
212-
apply(&ArgAttributes::new(), None);
213-
}
214-
match arg.mode {
215-
PassMode::Ignore => {}
216-
PassMode::Direct(ref attrs) | PassMode::Indirect(ref attrs, None) => {
217-
apply(attrs, Some(arg.layout.gcc_type(cx)))
218-
}
219-
PassMode::Indirect(ref attrs, Some(ref extra_attrs)) => {
220-
apply(attrs, None);
221-
apply(extra_attrs, None);
222-
}
223-
PassMode::Pair(ref a, ref b) => {
224-
apply(a, None);
225-
apply(b, None);
226-
}
227-
PassMode::Cast(_) => apply(&ArgAttributes::new(), None),
228-
}
229-
}
230-
}
231-
232-
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value) {
233-
// FIXME(wesleywiser, eddyb): We should apply `nounwind` and `noreturn` as appropriate to this callsite.
234-
235-
let mut i = 0;
236-
let mut apply = |attrs: &ArgAttributes, ty: Option<&Type>| {
237-
attrs.apply_callsite(llvm::AttributePlace::Argument(i), callsite, ty);
238-
i += 1;
239-
};
240-
match self.ret.mode {
241-
PassMode::Direct(ref attrs) => {
242-
attrs.apply_callsite(llvm::AttributePlace::ReturnValue, callsite, None);
243-
}
244-
PassMode::Indirect(ref attrs, _) => apply(attrs, Some(self.ret.layout.gcc_type(bx))),
245-
_ => {}
246-
}
247-
if let abi::Abi::Scalar(ref scalar) = self.ret.layout.abi {
248-
// If the value is a boolean, the range is 0..2 and that ultimately
249-
// become 0..0 when the type becomes i1, which would be rejected
250-
// by the LLVM verifier.
251-
if let Int(..) = scalar.value {
252-
if !scalar.is_bool() {
253-
let range = scalar.valid_range_exclusive(bx);
254-
if range.start != range.end {
255-
bx.range_metadata(callsite, range);
256-
}
257-
}
258-
}
259-
}
260-
for arg in &self.args {
261-
if arg.pad.is_some() {
262-
apply(&ArgAttributes::new(), None);
263-
}
264-
match arg.mode {
265-
PassMode::Ignore => {}
266-
PassMode::Direct(ref attrs) | PassMode::Indirect(ref attrs, None) => {
267-
apply(attrs, Some(arg.layout.gcc_type(bx)))
268-
}
269-
PassMode::Indirect(ref attrs, Some(ref extra_attrs)) => {
270-
apply(attrs, None);
271-
apply(extra_attrs, None);
272-
}
273-
PassMode::Pair(ref a, ref b) => {
274-
apply(a, None);
275-
apply(b, None);
276-
}
277-
PassMode::Cast(_) => apply(&ArgAttributes::new(), None),
278-
}
279-
}
280-
281-
let cconv = self.llvm_cconv();
282-
if cconv != llvm::CCallConv {
283-
llvm::SetInstructionCallConv(callsite, cconv);
284-
}
285-
}*/
286160
}

compiler/rustc_codegen_gcc/src/allocator.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//use crate::attributes;
21
use gccjit::{FunctionType, ToRValue};
32
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
43
use rustc_middle::bug;
@@ -50,19 +49,18 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, kind: Alloc
5049
let func = context.new_function(None, FunctionType::Exported, output.unwrap_or(void), &args, name, false);
5150

5251
if tcx.sess.target.options.default_hidden_visibility {
53-
//llvm::LLVMRustSetVisibility(func, llvm::Visibility::Hidden);
52+
// TODO(antoyo): set visibility.
5453
}
5554
if tcx.sess.must_emit_unwind_tables() {
56-
// TODO
57-
//attributes::emit_uwtable(func, true);
55+
// TODO(antoyo): emit unwind tables.
5856
}
5957

6058
let callee = kind.fn_name(method.name);
6159
let args: Vec<_> = types.iter().enumerate()
6260
.map(|(index, typ)| context.new_parameter(None, *typ, &format!("param{}", index)))
6361
.collect();
6462
let callee = context.new_function(None, FunctionType::Extern, output.unwrap_or(void), &args, callee, false);
65-
//llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);
63+
// TODO(antoyo): set visibility.
6664

6765
let block = func.new_block("entry");
6866

0 commit comments

Comments
 (0)