@@ -11,8 +11,7 @@ use crate::type_of::LayoutGccExt;
1111
1212impl < ' 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
8988pub 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
9894impl < ' 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}
0 commit comments