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 "PIC16ISelDAGToDAG.h" 00017 #include "llvm/Support/Debug.h" 00018 00019 using namespace llvm; 00020 00021 /// createPIC16ISelDag - This pass converts a legalized DAG into a 00022 /// PIC16-specific DAG, ready for instruction scheduling. 00023 FunctionPass *llvm::createPIC16ISelDag(PIC16TargetMachine &TM) { 00024 return new PIC16DAGToDAGISel(TM); 00025 } 00026 00027 00028 /// InstructionSelect - This callback is invoked by 00029 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. 00030 void PIC16DAGToDAGISel::InstructionSelect() { 00031 DEBUG(BB->dump()); 00032 SelectRoot(*CurDAG); 00033 CurDAG->RemoveDeadNodes(); 00034 } 00035 00036 /// Select - Select instructions not customized! Used for 00037 /// expanded, promoted and normal instructions. 00038 SDNode* PIC16DAGToDAGISel::Select(SDValue N) { 00039 00040 // Select the default instruction. 00041 SDNode *ResNode = SelectCode(N); 00042 00043 return ResNode; 00044 } 00045 00046 00047 // SelectDirectAddr - Match a direct address for DAG. 00048 // A direct address could be a globaladdress or externalsymbol. 00049 bool PIC16DAGToDAGISel::SelectDirectAddr(SDValue Op, SDValue N, 00050 SDValue &Address) { 00051 // Return true if TGA or ES. 00052 if (N.getOpcode() == ISD::TargetGlobalAddress 00053 || N.getOpcode() == ISD::TargetExternalSymbol) { 00054 Address = N; 00055 return true; 00056 } 00057 00058 return false; 00059 }