forked from jeremyhu/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86][GlobalISel] Add minimal call lowering support to the IRTranslator
Summary: Add basic functionality to support call lowering for X86. Currently only supports functions which return void and take zero arguments. Inspired by commit 286573. Reviewers: ab, qcolombet, t.p.northover Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26593 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286935 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Zvi Rackover
committed
Nov 15, 2016
1 parent
4edb3e4
commit 1ccb8e7
Showing
9 changed files
with
229 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===-- llvm/lib/Target/X86/X86CallLowering.cpp - Call lowering -----------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// \file | ||
/// This file implements the lowering of LLVM calls to machine code calls for | ||
/// GlobalISel. | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "X86CallLowering.h" | ||
#include "X86ISelLowering.h" | ||
#include "X86InstrInfo.h" | ||
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" | ||
|
||
using namespace llvm; | ||
|
||
#ifndef LLVM_BUILD_GLOBAL_ISEL | ||
#error "This shouldn't be built without GISel" | ||
#endif | ||
|
||
X86CallLowering::X86CallLowering(const X86TargetLowering &TLI) | ||
: CallLowering(&TLI) {} | ||
|
||
bool X86CallLowering::lowerReturn(MachineIRBuilder &MIRBuilder, | ||
const Value *Val, unsigned VReg) const { | ||
// TODO: handle functions returning non-void values. | ||
if (Val) | ||
return false; | ||
|
||
MIRBuilder.buildInstr(X86::RET).addImm(0); | ||
|
||
return true; | ||
} | ||
|
||
bool X86CallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder, | ||
const Function &F, | ||
ArrayRef<unsigned> VRegs) const { | ||
// TODO: handle functions with one or more arguments. | ||
return F.arg_empty(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===-- llvm/lib/Target/X86/X86CallLowering.h - Call lowering -----===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// \file | ||
/// This file describes how to lower LLVM calls to machine code calls. | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIB_TARGET_X86_X86CALLLOWERING | ||
#define LLVM_LIB_TARGET_X86_X86CALLLOWERING | ||
|
||
#include "llvm/ADT/ArrayRef.h" | ||
#include "llvm/CodeGen/GlobalISel/CallLowering.h" | ||
|
||
namespace llvm { | ||
|
||
class Function; | ||
class MachineIRBuilder; | ||
class X86TargetLowering; | ||
class Value; | ||
|
||
class X86CallLowering : public CallLowering { | ||
public: | ||
X86CallLowering(const X86TargetLowering &TLI); | ||
|
||
bool lowerReturn(MachineIRBuilder &MIRBuiler, const Value *Val, | ||
unsigned VReg) const override; | ||
|
||
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, | ||
ArrayRef<unsigned> VRegs) const override; | ||
}; | ||
} // End of namespace llvm; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
; RUN: llc -mtriple i386 -global-isel -stop-after=irtranslator %s -o - | FileCheck %s | ||
; RUN: llc -mtriple x86_64 -global-isel -stop-after=irtranslator %s -o - | FileCheck %s | ||
|
||
define void @test_void_return() { | ||
; CHECK-LABEL: name: test_void_return | ||
; CHECK: alignment: 4 | ||
; CHECK-NEXT: exposesReturnsTwice: false | ||
; CHECK-NEXT: legalized: false | ||
; CHECK-NEXT: regBankSelected: false | ||
; CHECK-NEXT: selected: false | ||
; CHECK-NEXT: tracksRegLiveness: true | ||
; CHECK-NEXT: frameInfo: | ||
; CHECK-NEXT: isFrameAddressTaken: false | ||
; CHECK-NEXT: isReturnAddressTaken: false | ||
; CHECK-NEXT: hasStackMap: false | ||
; CHECK-NEXT: hasPatchPoint: false | ||
; CHECK-NEXT: stackSize: 0 | ||
; CHECK-NEXT: offsetAdjustment: 0 | ||
; CHECK-NEXT: maxAlignment: 0 | ||
; CHECK-NEXT: adjustsStack: false | ||
; CHECK-NEXT: hasCalls: false | ||
; CHECK-NEXT: maxCallFrameSize: 0 | ||
; CHECK-NEXT: hasOpaqueSPAdjustment: false | ||
; CHECK-NEXT: hasVAStart: false | ||
; CHECK-NEXT: hasMustTailInVarArgFunc: false | ||
; CHECK-NEXT: body: | ||
; CHECK-NEXT: bb.0: | ||
; CHECK-NEXT: RET 0 | ||
entry: | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
if not 'global-isel' in config.root.available_features: | ||
config.unsupported = True |