-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GlobalISel infrastructure up to the point where we can select a ret void. Patch by Petar Avramovic. Differential Revision: https://reviews.llvm.org/D43583 llvm-svn: 325888
- Loading branch information
1 parent
db1a062
commit fac93e2
Showing
15 changed files
with
378 additions
and
0 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,4 +43,5 @@ required_libraries = | |
| SelectionDAG | ||
| Support | ||
| Target | ||
| GlobalISel | ||
| add_to_library_groups = Mips | ||
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,47 @@ | ||
| //===- MipsCallLowering.cpp -------------------------------------*- C++ -*-===// | ||
| // | ||
| // 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 "MipsCallLowering.h" | ||
| #include "MipsISelLowering.h" | ||
| #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| MipsCallLowering::MipsCallLowering(const MipsTargetLowering &TLI) | ||
| : CallLowering(&TLI) {} | ||
|
|
||
| bool MipsCallLowering::lowerReturn(MachineIRBuilder &MIRBuilder, | ||
| const Value *Val, unsigned VReg) const { | ||
|
|
||
| MachineInstrBuilder Ret = MIRBuilder.buildInstrNoInsert(Mips::RetRA); | ||
|
|
||
| if (Val != nullptr) { | ||
| return false; | ||
| } | ||
| MIRBuilder.insertInstr(Ret); | ||
| return true; | ||
| } | ||
|
|
||
| bool MipsCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder, | ||
| const Function &F, | ||
| ArrayRef<unsigned> VRegs) const { | ||
|
|
||
| // Quick exit if there aren't any args. | ||
| if (F.arg_empty()) | ||
| return true; | ||
|
|
||
| // Function had args, but we didn't lower them. | ||
| return false; | ||
| } |
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,40 @@ | ||
| //===- MipsCallLowering.h ---------------------------------------*- C++ -*-===// | ||
| // | ||
| // 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_MIPS_MIPSCALLLOWERING_H | ||
| #define LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H | ||
|
|
||
| #include "llvm/CodeGen/CallingConvLower.h" | ||
| #include "llvm/CodeGen/GlobalISel/CallLowering.h" | ||
| #include "llvm/CodeGen/ValueTypes.h" | ||
|
|
||
| namespace llvm { | ||
|
|
||
| class MipsTargetLowering; | ||
|
|
||
| class MipsCallLowering : public CallLowering { | ||
|
|
||
| public: | ||
| MipsCallLowering(const MipsTargetLowering &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 namespace llvm | ||
|
|
||
| #endif // LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H |
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,66 @@ | ||
| //===- MipsInstructionSelector.cpp ------------------------------*- C++ -*-===// | ||
| // | ||
| // 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 targeting of the InstructionSelector class for | ||
| /// Mips. | ||
| /// \todo This should be generated by TableGen. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "MipsRegisterBankInfo.h" | ||
| #include "MipsSubtarget.h" | ||
| #include "MipsTargetMachine.h" | ||
| #include "llvm/Support/Debug.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| namespace { | ||
|
|
||
| class MipsInstructionSelector : public InstructionSelector { | ||
| public: | ||
| MipsInstructionSelector(const MipsTargetMachine &TM, const MipsSubtarget &STI, | ||
| const MipsRegisterBankInfo &RBI); | ||
|
|
||
| bool select(MachineInstr &I, CodeGenCoverage &CoverageInfo) const override; | ||
|
|
||
| private: | ||
| const MipsTargetMachine &TM; | ||
| const MipsSubtarget &STI; | ||
| const MipsInstrInfo &TII; | ||
| const MipsRegisterInfo &TRI; | ||
| const MipsRegisterBankInfo &RBI; | ||
| }; | ||
|
|
||
| } // end anonymous namespace | ||
|
|
||
| MipsInstructionSelector::MipsInstructionSelector( | ||
| const MipsTargetMachine &TM, const MipsSubtarget &STI, | ||
| const MipsRegisterBankInfo &RBI) | ||
| : InstructionSelector(), TM(TM), STI(STI), TII(*STI.getInstrInfo()), | ||
| TRI(*STI.getRegisterInfo()), RBI(RBI) {} | ||
|
|
||
| bool MipsInstructionSelector::select(MachineInstr &I, | ||
| CodeGenCoverage &CoverageInfo) const { | ||
|
|
||
| if (!isPreISelGenericOpcode(I.getOpcode())) { | ||
| // Not global isel generic opcode. | ||
| // TODO: select copy | ||
| return true; | ||
| } | ||
|
|
||
| // We didn't select anything. | ||
| return false; | ||
| } | ||
|
|
||
| namespace llvm { | ||
| InstructionSelector *createMipsInstructionSelector(const MipsTargetMachine &TM, | ||
| MipsSubtarget &Subtarget, | ||
| MipsRegisterBankInfo &RBI) { | ||
| return new MipsInstructionSelector(TM, Subtarget, RBI); | ||
| } | ||
| } // end namespace llvm |
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,24 @@ | ||
| //===- MipsLegalizerInfo.cpp ------------------------------------*- C++ -*-===// | ||
| // | ||
| // 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 targeting of the Machinelegalizer class for Mips. | ||
| /// \todo This should be generated by TableGen. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "MipsLegalizerInfo.h" | ||
| #include "llvm/CodeGen/TargetOpcodes.h" | ||
| #include "llvm/CodeGen/ValueTypes.h" | ||
| #include "llvm/IR/DerivedTypes.h" | ||
| #include "llvm/IR/Type.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) { | ||
| computeTables(); | ||
| } |
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,29 @@ | ||
| //===- MipsLegalizerInfo ----------------------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// \file | ||
| /// This file declares the targeting of the Machinelegalizer class for Mips. | ||
| /// \todo This should be generated by TableGen. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINELEGALIZER_H | ||
| #define LLVM_LIB_TARGET_MIPS_MIPSMACHINELEGALIZER_H | ||
|
|
||
| #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" | ||
|
|
||
| namespace llvm { | ||
|
|
||
| class MipsSubtarget; | ||
|
|
||
| /// This class provides legalization strategies. | ||
| class MipsLegalizerInfo : public LegalizerInfo { | ||
| public: | ||
| MipsLegalizerInfo(const MipsSubtarget &ST); | ||
| }; | ||
| } // end 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //===- MipsRegisterBankInfo.cpp ---------------------------------*- C++ -*-===// | ||
| // | ||
| // 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 targeting of the RegisterBankInfo class for Mips. | ||
| /// \todo This should be generated by TableGen. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "MipsRegisterBankInfo.h" | ||
| #include "llvm/CodeGen/GlobalISel/RegisterBank.h" | ||
| #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h" | ||
| #include "llvm/CodeGen/MachineRegisterInfo.h" | ||
| #include "llvm/CodeGen/TargetRegisterInfo.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| MipsGenRegisterBankInfo::MipsGenRegisterBankInfo() | ||
| : RegisterBankInfo(nullptr, 0) {} | ||
|
|
||
| MipsRegisterBankInfo::MipsRegisterBankInfo(const TargetRegisterInfo &TRI) | ||
| : MipsGenRegisterBankInfo() {} |
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,35 @@ | ||
| //===- MipsRegisterBankInfo.h -----------------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// \file | ||
| /// This file declares the targeting of the RegisterBankInfo class for Mips. | ||
| /// \todo This should be generated by TableGen. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIB_TARGET_MIPS_MIPSREGISTERBANKINFO_H | ||
| #define LLVM_LIB_TARGET_MIPS_MIPSREGISTERBANKINFO_H | ||
|
|
||
| #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h" | ||
|
|
||
| namespace llvm { | ||
|
|
||
| class TargetRegisterInfo; | ||
|
|
||
| class MipsGenRegisterBankInfo : public RegisterBankInfo { | ||
| // TODO: This should be auto-generated by TableGen. | ||
| public: | ||
| MipsGenRegisterBankInfo(); | ||
| }; | ||
|
|
||
| /// This class provides the information for the target register banks. | ||
| class MipsRegisterBankInfo final : public MipsGenRegisterBankInfo { | ||
| public: | ||
| MipsRegisterBankInfo(const TargetRegisterInfo &TRI); | ||
| }; | ||
| } // end 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
Oops, something went wrong.