aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PIC16/PIC16ISelLowering.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/PIC16/PIC16ISelLowering.h')
-rw-r--r--lib/Target/PIC16/PIC16ISelLowering.h123
1 files changed, 73 insertions, 50 deletions
diff --git a/lib/Target/PIC16/PIC16ISelLowering.h b/lib/Target/PIC16/PIC16ISelLowering.h
index e14a0c2..dfe5b5f 100644
--- a/lib/Target/PIC16/PIC16ISelLowering.h
+++ b/lib/Target/PIC16/PIC16ISelLowering.h
@@ -26,66 +26,89 @@ namespace llvm {
// Start the numbering from where ISD NodeType finishes.
FIRST_NUMBER = ISD::BUILTIN_OP_END,
- // used for encapsulating the expanded nodes into one node.
- Package,
-
- // Get the Higher 16 bits from a 32-bit immediate
- Hi,
-
- // Get the Lower 16 bits from a 32-bit immediate
- Lo,
-
- Cmp, // PIC16 Generic Comparison instruction.
- Branch, // PIC16 Generic Branch Instruction.
- BTFSS, // PIC16 BitTest Instruction (Skip if set).
- BTFSC, // PIC16 BitTest Instruction (Skip if clear).
-
- // PIC16 comparison to be converted to either XOR or SUB
- // Following instructions cater to those convertions.
- XORCC,
- SUBCC,
-
- // Get the Global Address wrapped into a wrapper that also captures
- // the bank or page.
- Wrapper,
- SetBank,
- SetPage
+ Lo, // Low 8-bits of GlobalAddress.
+ Hi, // High 8-bits of GlobalAddress.
+ PIC16Load,
+ PIC16Store,
+ Banksel,
+ MTLO,
+ MTHI,
+ BCF,
+ LSLF, // PIC16 Logical shift left
+ LRLF, // PIC16 Logical shift right
+ RLF, // Rotate left through carry
+ RRF, // Rotate right through carry
+ Dummy
+ };
+
+ // Keep track of different address spaces.
+ enum AddressSpace {
+ RAM_SPACE = 0, // RAM address space
+ ROM_SPACE = 1 // ROM address space number is 1
};
}
//===--------------------------------------------------------------------===//
// TargetLowering Implementation
//===--------------------------------------------------------------------===//
- class PIC16TargetLowering : public TargetLowering
- {
+ class PIC16TargetLowering : public TargetLowering {
public:
- typedef std::map<SDNode *, SDNode *> NodeMap_t;
-
explicit PIC16TargetLowering(PIC16TargetMachine &TM);
- /// LowerOperation - Provide custom lowering hooks for some operations.
- virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
-
- SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
- SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG);
- SDValue LowerRET(SDValue Op, SelectionDAG &DAG);
- SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG);
- SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG);
-
- SDValue RemoveHiLo(SDNode *, SelectionDAG &DAG,
- DAGCombinerInfo &DCI) const;
- SDValue LowerADDSUB(SDNode *, SelectionDAG &DAG,
- DAGCombinerInfo &DCI) const;
- SDValue LowerLOAD(SDNode *, SelectionDAG &DAG,
- DAGCombinerInfo &DCI) const;
-
- /// getTargetNodeName - This method returns the name of a target specific
- // DAG node.
+ /// getTargetNodeName - This method returns the name of a target specific
+ /// DAG node.
virtual const char *getTargetNodeName(unsigned Opcode) const;
- virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
-
- // utility function.
- const SDValue *findLoadi8(const SDValue &Src, SelectionDAG &DAG) const;
+ SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
+ SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG);
+ SDValue LowerADDE(SDValue Op, SelectionDAG &DAG);
+ SDValue LowerADDC(SDValue Op, SelectionDAG &DAG);
+ SDValue LowerSUBE(SDValue Op, SelectionDAG &DAG);
+ SDValue LowerSUBC(SDValue Op, SelectionDAG &DAG);
+
+ SDNode *ReplaceNodeResults(SDNode *N, SelectionDAG &DAG);
+ SDNode *ExpandStore(SDNode *N, SelectionDAG &DAG);
+ SDNode *ExpandLoad(SDNode *N, SelectionDAG &DAG);
+ SDNode *ExpandAdd(SDNode *N, SelectionDAG &DAG);
+ SDNode *ExpandGlobalAddress(SDNode *N, SelectionDAG &DAG);
+ SDNode *ExpandShift(SDNode *N, SelectionDAG &DAG);
+
+ SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
+ SDValue PerformPIC16LoadCombine(SDNode *N, DAGCombinerInfo &DCI) const;
+
+ private:
+ // If the Node is a BUILD_PAIR representing representing an Address
+ // then this function will return true
+ bool isDirectAddress(const SDValue &Op);
+
+ // If the Node is a DirectAddress in ROM_SPACE then this
+ // function will return true
+ bool isRomAddress(const SDValue &Op);
+
+ // To extract chain value from the SDValue Nodes
+ // This function will help to maintain the chain extracting
+ // code at one place. In case of any change in future it will
+ // help maintain the code
+ SDValue getChain(SDValue &Op);
+
+
+ // Extract the Lo and Hi component of Op.
+ void GetExpandedParts(SDValue Op, SelectionDAG &DAG, SDValue &Lo,
+ SDValue &Hi);
+
+
+ // Load pointer can be a direct or indirect address. In PIC16 direct
+ // addresses need Banksel and Indirect addresses need to be loaded to
+ // FSR first. Handle address specific cases here.
+ void LegalizeAddress(SDValue Ptr, SelectionDAG &DAG, SDValue &Chain,
+ SDValue &NewPtr, unsigned &Offset);
+
+ // We can not have both operands of a binary operation in W.
+ // This function is used to put one operand on stack and generate a load.
+ SDValue ConvertToMemOperand(SDValue Op, SelectionDAG &DAG);
+
+ /// Subtarget - Keep a pointer to the PIC16Subtarget around so that we can
+ /// make the right decision when generating code for different targets.
+ const PIC16Subtarget *Subtarget;
};
} // namespace llvm