1 //===-- llvm/lib/Target/X86/X86CallLowering.cpp - Call lowering -----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file implements the lowering of LLVM calls to machine code calls for
12 /// GlobalISel.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #include "X86CallLowering.h"
17 #include "X86ISelLowering.h"
18 #include "X86InstrInfo.h"
19 #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
20 
21 using namespace llvm;
22 
23 #ifndef LLVM_BUILD_GLOBAL_ISEL
24 #error "This shouldn't be built without GISel"
25 #endif
26 
27 X86CallLowering::X86CallLowering(const X86TargetLowering &TLI)
28     : CallLowering(&TLI) {}
29 
30 bool X86CallLowering::lowerReturn(MachineIRBuilder &MIRBuilder,
31                                   const Value *Val, unsigned VReg) const {
32   // TODO: handle functions returning non-void values.
33   if (Val)
34     return false;
35 
36   MIRBuilder.buildInstr(X86::RET).addImm(0);
37 
38   return true;
39 }
40 
41 bool X86CallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
42                                            const Function &F,
43                                            ArrayRef<unsigned> VRegs) const {
44   // TODO: handle functions with one or more arguments.
45   return F.arg_empty();
46 }
47