blob: 058f85bb07574943044e11a30f97609f821013ec [file] [log] [blame]
Nate Begeman6cca84e2005-10-16 05:39:50 +00001//===-- PPCISelLowering.h - PPC32 DAG Lowering Interface --------*- C++ -*-===//
Chris Lattnerf22556d2005-08-16 17:14:42 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the interfaces that PPC uses to lower LLVM code into a
11// selection DAG.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TARGET_POWERPC_PPC32ISELLOWERING_H
16#define LLVM_TARGET_POWERPC_PPC32ISELLOWERING_H
17
18#include "llvm/Target/TargetLowering.h"
Chris Lattnerb2854fa2005-08-26 20:25:03 +000019#include "llvm/CodeGen/SelectionDAG.h"
Chris Lattnerbfca1ab2005-10-14 23:51:18 +000020#include "PPC.h"
Chris Lattnerf22556d2005-08-16 17:14:42 +000021
22namespace llvm {
Chris Lattnerb2854fa2005-08-26 20:25:03 +000023 namespace PPCISD {
24 enum NodeType {
25 // Start the numbering where the builting ops and target ops leave off.
26 FIRST_NUMBER = ISD::BUILTIN_OP_END+PPC::INSTRUCTION_LIST_END,
27
28 /// FSEL - Traditional three-operand fsel node.
29 ///
30 FSEL,
Chris Lattnerda2e04c2005-08-31 21:09:52 +000031
Nate Begeman60952142005-09-06 22:03:27 +000032 /// FCFID - The FCFID instruction, taking an f64 operand and producing
33 /// and f64 value containing the FP representation of the integer that
34 /// was temporarily in the f64 operand.
35 FCFID,
36
37 /// FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64
38 /// operand, producing an f64 value containing the integer representation
39 /// of that FP value.
40 FCTIDZ, FCTIWZ,
Chris Lattner595088a2005-11-17 07:30:41 +000041
Chris Lattner27f53452006-03-01 05:50:56 +000042 /// STFIWX - The STFIWX instruction. The first operand is an input token
43 /// chain, then an f64 value to store, then an address to store it to,
44 /// then a SRCVALUE for the address.
45 STFIWX,
46
Nate Begeman69caef22005-12-13 22:55:22 +000047 // VMADDFP, VNMSUBFP - The VMADDFP and VNMSUBFP instructions, taking
48 // three v4f32 operands and producing a v4f32 result.
49 VMADDFP, VNMSUBFP,
50
Chris Lattner7e9440a2006-03-19 06:55:52 +000051 /// LVE_X - The PPC LVE*X instructions. The size of the element loaded is
52 /// the size of the element type of the vector result. The element loaded
53 /// depends on the alignment of the input pointer.
54 ///
55 /// The first operand is a token chain, the second is the address to load
56 /// the third is the SRCVALUE node.
57 LVE_X,
58
Chris Lattner595088a2005-11-17 07:30:41 +000059 /// Hi/Lo - These represent the high and low 16-bit parts of a global
60 /// address respectively. These nodes have two operands, the first of
61 /// which must be a TargetGlobalAddress, and the second of which must be a
62 /// Constant. Selected naively, these turn into 'lis G+C' and 'li G+C',
63 /// though these are usually folded into other nodes.
64 Hi, Lo,
65
66 /// GlobalBaseReg - On Darwin, this node represents the result of the mflr
67 /// at function entry, used for PIC code.
68 GlobalBaseReg,
Chris Lattnerfea33f72005-12-06 02:10:38 +000069
Chris Lattnerfea33f72005-12-06 02:10:38 +000070 /// These nodes represent the 32-bit PPC shifts that operate on 6-bit
71 /// shift amounts. These nodes are generated by the multi-precision shift
72 /// code.
73 SRL, SRA, SHL,
Nate Begemanb11b8e42005-12-20 00:26:01 +000074
Chris Lattnerf424a662006-01-27 23:34:02 +000075 /// CALL - A function call.
76 CALL,
77
Nate Begemanb11b8e42005-12-20 00:26:01 +000078 /// Return with a flag operand, matched by 'blr'
79 RET_FLAG,
Chris Lattnerf424a662006-01-27 23:34:02 +000080 };
Chris Lattnerb2854fa2005-08-26 20:25:03 +000081 }
82
Nate Begeman6cca84e2005-10-16 05:39:50 +000083 class PPCTargetLowering : public TargetLowering {
Chris Lattnerf22556d2005-08-16 17:14:42 +000084 int VarArgsFrameIndex; // FrameIndex for start of varargs area.
85 int ReturnAddrIndex; // FrameIndex for return slot.
86 public:
Nate Begeman6cca84e2005-10-16 05:39:50 +000087 PPCTargetLowering(TargetMachine &TM);
Chris Lattnerf22556d2005-08-16 17:14:42 +000088
Chris Lattner347ed8a2006-01-09 23:52:17 +000089 /// getTargetNodeName() - This method returns the name of a target specific
90 /// DAG node.
91 virtual const char *getTargetNodeName(unsigned Opcode) const;
92
Chris Lattnerf3d06c62005-08-26 00:52:45 +000093 /// LowerOperation - Provide custom lowering hooks for some operations.
94 ///
95 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
96
Chris Lattnerf4184352006-03-01 04:57:39 +000097 virtual SDOperand PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
98
Chris Lattnerf22556d2005-08-16 17:14:42 +000099 /// LowerArguments - This hook must be implemented to indicate how we should
100 /// lower the arguments for the specified function, into the specified DAG.
101 virtual std::vector<SDOperand>
102 LowerArguments(Function &F, SelectionDAG &DAG);
103
104 /// LowerCallTo - This hook lowers an abstract call to a function into an
105 /// actual call.
106 virtual std::pair<SDOperand, SDOperand>
107 LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg,
108 unsigned CC,
109 bool isTailCall, SDOperand Callee, ArgListTy &Args,
110 SelectionDAG &DAG);
Nate Begeman78afac22005-10-18 23:23:37 +0000111
Chris Lattner9b577f12005-08-26 21:23:58 +0000112 virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
113 MachineBasicBlock *MBB);
Chris Lattner01513612006-01-31 19:20:21 +0000114
Chris Lattner203b2f12006-02-07 20:16:30 +0000115 ConstraintType getConstraintType(char ConstraintLetter) const;
Chris Lattner01513612006-01-31 19:20:21 +0000116 std::vector<unsigned>
Chris Lattner7ad77df2006-02-22 00:56:39 +0000117 getRegClassForInlineAsmConstraint(const std::string &Constraint,
118 MVT::ValueType VT) const;
Chris Lattner15a6c4c2006-02-07 00:47:13 +0000119 bool isOperandValidForConstraint(SDOperand Op, char ConstraintLetter);
Evan Cheng2dd2c652006-03-13 23:20:37 +0000120
121 /// isLegalAddressImmediate - Return true if the integer value can be used
122 /// as the offset of the target addressing mode.
123 virtual bool isLegalAddressImmediate(int64_t V) const;
Chris Lattnerf22556d2005-08-16 17:14:42 +0000124 };
125}
126
127#endif // LLVM_TARGET_POWERPC_PPC32ISELLOWERING_H