2008-05-13 09:02:57 +00:00
|
|
|
//===-- PIC16ISelDAGToDAG.cpp - A dag to dag inst selector for PIC16 ------===//
|
|
|
|
//
|
|
|
|
// 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 PIC16 target.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "pic16-isel"
|
|
|
|
|
2009-07-08 20:53:28 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2008-11-19 11:00:54 +00:00
|
|
|
#include "PIC16ISelDAGToDAG.h"
|
2008-05-13 09:02:57 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
|
2008-11-19 11:00:54 +00:00
|
|
|
using namespace llvm;
|
2008-05-13 09:02:57 +00:00
|
|
|
|
2008-11-19 11:00:54 +00:00
|
|
|
/// createPIC16ISelDag - This pass converts a legalized DAG into a
|
|
|
|
/// PIC16-specific DAG, ready for instruction scheduling.
|
|
|
|
FunctionPass *llvm::createPIC16ISelDag(PIC16TargetMachine &TM) {
|
|
|
|
return new PIC16DAGToDAGISel(TM);
|
2008-05-13 09:02:57 +00:00
|
|
|
}
|
|
|
|
|
2008-11-19 11:00:54 +00:00
|
|
|
|
2008-06-30 20:45:06 +00:00
|
|
|
/// InstructionSelect - This callback is invoked by
|
2008-05-13 09:02:57 +00:00
|
|
|
/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
|
2008-11-19 11:00:54 +00:00
|
|
|
void PIC16DAGToDAGISel::InstructionSelect() {
|
2008-10-27 21:56:29 +00:00
|
|
|
SelectRoot(*CurDAG);
|
2008-08-23 02:25:05 +00:00
|
|
|
CurDAG->RemoveDeadNodes();
|
2008-05-13 09:02:57 +00:00
|
|
|
}
|
|
|
|
|
2008-05-14 11:31:39 +00:00
|
|
|
/// Select - Select instructions not customized! Used for
|
|
|
|
/// expanded, promoted and normal instructions.
|
2010-01-05 01:24:18 +00:00
|
|
|
SDNode* PIC16DAGToDAGISel::Select(SDNode *N) {
|
2008-05-13 09:02:57 +00:00
|
|
|
|
|
|
|
// Select the default instruction.
|
|
|
|
SDNode *ResNode = SelectCode(N);
|
|
|
|
|
|
|
|
return ResNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-19 11:00:54 +00:00
|
|
|
// SelectDirectAddr - Match a direct address for DAG.
|
|
|
|
// A direct address could be a globaladdress or externalsymbol.
|
2010-01-05 01:24:18 +00:00
|
|
|
bool PIC16DAGToDAGISel::SelectDirectAddr(SDNode *Op, SDValue N,
|
2008-11-19 11:00:54 +00:00
|
|
|
SDValue &Address) {
|
|
|
|
// Return true if TGA or ES.
|
|
|
|
if (N.getOpcode() == ISD::TargetGlobalAddress
|
|
|
|
|| N.getOpcode() == ISD::TargetExternalSymbol) {
|
|
|
|
Address = N;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|