diff options
Diffstat (limited to 'llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp')
-rw-r--r-- | llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp b/llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp new file mode 100644 index 00000000000..31d04ebe447 --- /dev/null +++ b/llvm/lib/Target/Nios2/Nios2ISelDAGToDAG.cpp @@ -0,0 +1,79 @@ +//===-- Nios2ISelDAGToDAG.cpp - A Dag to Dag Inst Selector for Nios2 ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines an instruction selector for the NIOS2 target. +// +//===----------------------------------------------------------------------===// + +#include "Nios2.h" +#include "Nios2TargetMachine.h" +#include "llvm/CodeGen/SelectionDAGISel.h" +#include "llvm/Support/Debug.h" +using namespace llvm; + +#define DEBUG_TYPE "nios2-isel" + +//===----------------------------------------------------------------------===// +// Instruction Selector Implementation +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +// Nios2DAGToDAGISel - NIOS2 specific code to select NIOS2 machine +// instructions for SelectionDAG operations. +//===----------------------------------------------------------------------===// + +namespace { + +class Nios2DAGToDAGISel : public SelectionDAGISel { + /// Subtarget - Keep a pointer to the Nios2 Subtarget around so that we can + /// make the right decision when generating code for different targets. + const Nios2Subtarget *Subtarget; + +public: + explicit Nios2DAGToDAGISel(Nios2TargetMachine &TM, CodeGenOpt::Level OL) + : SelectionDAGISel(TM, OL) {} + + bool runOnMachineFunction(MachineFunction &MF) override { + Subtarget = &MF.getSubtarget<Nios2Subtarget>(); + return SelectionDAGISel::runOnMachineFunction(MF); + } + + void Select(SDNode *N) override; + + // Pass Name + StringRef getPassName() const override { + return "NIOS2 DAG->DAG Pattern Instruction Selection"; + } + +#include "Nios2GenDAGISel.inc" +}; +} // namespace + +// Select instructions not customized! Used for +// expanded, promoted and normal instructions +void Nios2DAGToDAGISel::Select(SDNode *Node) { + + // Dump information about the Node being selected + DEBUG(errs() << "Selecting: "; Node->dump(CurDAG); errs() << "\n"); + + // If we have a custom node, we already have selected! + if (Node->isMachineOpcode()) { + DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); + Node->setNodeId(-1); + return; + } + + // Select the default instruction + SelectCode(Node); +} + +FunctionPass *llvm::createNios2ISelDag(Nios2TargetMachine &TM, + CodeGenOpt::Level OptLevel) { + return new Nios2DAGToDAGISel(TM, OptLevel); +} |