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