diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2022-06-04 11:58:51 +0000 |
commit | 4b6eb0e63c698094db5506763df44cc83c19f643 (patch) | |
tree | f1d30b8c10bc6db323b91538745ae8ab8b593910 /contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp | |
parent | 76886853f03395abb680824bcc74e98f83bd477a (diff) | |
download | src-4b6eb0e63c698094db5506763df44cc83c19f643.tar.gz src-4b6eb0e63c698094db5506763df44cc83c19f643.zip |
Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-10186-gff7f2cfa959b.
PR: 261742
MFC after: 2 weeks
(cherry picked from commit 349cc55c9796c4596a5b9904cd3281af295f878f)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp b/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp new file mode 100644 index 000000000000..fc9ef8bfd9d9 --- /dev/null +++ b/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp @@ -0,0 +1,75 @@ +//===-- CSKYISelDAGToDAG.cpp - A dag to dag inst selector for CSKY---------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines an instruction selector for the CSKY target. +// +//===----------------------------------------------------------------------===// + +#include "CSKY.h" +#include "CSKYSubtarget.h" +#include "CSKYTargetMachine.h" +#include "MCTargetDesc/CSKYMCTargetDesc.h" +#include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/CodeGen/SelectionDAGISel.h" + +using namespace llvm; + +#define DEBUG_TYPE "csky-isel" + +namespace { +class CSKYDAGToDAGISel : public SelectionDAGISel { + const CSKYSubtarget *Subtarget; + +public: + explicit CSKYDAGToDAGISel(CSKYTargetMachine &TM) : SelectionDAGISel(TM) {} + + StringRef getPassName() const override { + return "CSKY DAG->DAG Pattern Instruction Selection"; + } + + bool runOnMachineFunction(MachineFunction &MF) override { + // Reset the subtarget each time through. + Subtarget = &MF.getSubtarget<CSKYSubtarget>(); + SelectionDAGISel::runOnMachineFunction(MF); + return true; + } + + void Select(SDNode *N) override; + +#include "CSKYGenDAGISel.inc" +}; +} // namespace + +void CSKYDAGToDAGISel::Select(SDNode *N) { + // If we have a custom node, we have already selected + if (N->isMachineOpcode()) { + LLVM_DEBUG(dbgs() << "== "; N->dump(CurDAG); dbgs() << "\n"); + N->setNodeId(-1); + return; + } + + SDLoc Dl(N); + unsigned Opcode = N->getOpcode(); + bool IsSelected = false; + + switch (Opcode) { + default: + break; + // FIXME: Add selection nodes needed later. + } + + if (IsSelected) + return; + + // Select the default instruction. + SelectCode(N); +} + +FunctionPass *llvm::createCSKYISelDag(CSKYTargetMachine &TM) { + return new CSKYDAGToDAGISel(TM); +} |