LLVM API Documentation
00001 //===-- PIC16ISelDAGToDAG.cpp - A dag to dag inst selector for PIC16 ------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines an instruction selector for the PIC16 target. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #define DEBUG_TYPE "pic16-isel" 00015 00016 #include "llvm/Support/ErrorHandling.h" 00017 #include "llvm/Support/raw_ostream.h" 00018 #include "PIC16ISelDAGToDAG.h" 00019 #include "llvm/Support/Debug.h" 00020 00021 using namespace llvm; 00022 00023 /// createPIC16ISelDag - This pass converts a legalized DAG into a 00024 /// PIC16-specific DAG, ready for instruction scheduling. 00025 FunctionPass *llvm::createPIC16ISelDag(PIC16TargetMachine &TM) { 00026 return new PIC16DAGToDAGISel(TM); 00027 } 00028 00029 00030 /// InstructionSelect - This callback is invoked by 00031 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. 00032 void PIC16DAGToDAGISel::InstructionSelect() { 00033 DEBUG(BB->dump()); 00034 SelectRoot(*CurDAG); 00035 CurDAG->RemoveDeadNodes(); 00036 } 00037 00038 /// Select - Select instructions not customized! Used for 00039 /// expanded, promoted and normal instructions. 00040 SDNode* PIC16DAGToDAGISel::Select(SDValue N) { 00041 00042 // Select the default instruction. 00043 SDNode *ResNode = SelectCode(N); 00044 00045 return ResNode; 00046 } 00047 00048 00049 // SelectDirectAddr - Match a direct address for DAG. 00050 // A direct address could be a globaladdress or externalsymbol. 00051 bool PIC16DAGToDAGISel::SelectDirectAddr(SDValue Op, SDValue N, 00052 SDValue &Address) { 00053 // Return true if TGA or ES. 00054 if (N.getOpcode() == ISD::TargetGlobalAddress 00055 || N.getOpcode() == ISD::TargetExternalSymbol) { 00056 Address = N; 00057 return true; 00058 } 00059 00060 return false; 00061 }