2004-10-16 16:37:42 +00:00
|
|
|
//===- SparcV9InstrForest.h - SparcV9 BURG Instruction Selector Trees -----===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-04 07:29:16 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-04 07:29:16 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// A forest of BURG instruction trees (class InstrForest) which represents
|
|
|
|
// a function to the BURG-based instruction selector, and a bunch of constants
|
|
|
|
// and declarations used by the generated BURG code.
|
2005-07-27 05:53:44 +00:00
|
|
|
//
|
2004-08-04 07:29:16 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef SPARCV9INSTRFOREST_H
|
|
|
|
#define SPARCV9INSTRFOREST_H
|
|
|
|
|
|
|
|
#include "llvm/Instruction.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
/// OpLabel values for special-case nodes created for instruction selection.
|
|
|
|
/// All op-labels not defined here are identical to the instruction
|
|
|
|
/// opcode returned by Instruction::getOpcode().
|
|
|
|
///
|
|
|
|
static const int
|
2005-07-27 05:53:44 +00:00
|
|
|
InvalidOp = -1,
|
2004-08-04 07:29:16 +00:00
|
|
|
VRegListOp = 97,
|
2005-07-27 05:53:44 +00:00
|
|
|
VRegNodeOp = 98,
|
2004-08-04 07:29:16 +00:00
|
|
|
ConstantNodeOp = 99,
|
2005-07-27 05:53:44 +00:00
|
|
|
LabelNodeOp = 100,
|
|
|
|
RetValueOp = 100 + Instruction::Ret, // 101
|
|
|
|
BrCondOp = 100 + Instruction::Br, // 102
|
2004-08-04 07:29:16 +00:00
|
|
|
BAndOp = 100 + Instruction::And, // 111
|
|
|
|
BOrOp = 100 + Instruction::Or, // 112
|
|
|
|
BXorOp = 100 + Instruction::Xor, // 113
|
|
|
|
BNotOp = 200 + Instruction::Xor, // 213
|
|
|
|
NotOp = 300 + Instruction::Xor, // 313
|
2005-07-27 05:53:44 +00:00
|
|
|
SetCCOp = 100 + Instruction::SetEQ, // 114
|
|
|
|
AllocaN = 100 + Instruction::Alloca, // 122
|
|
|
|
LoadIdx = 100 + Instruction::Load, // 123
|
|
|
|
GetElemPtrIdx = 100 + Instruction::GetElementPtr, // 125
|
|
|
|
ToBoolTy = 100 + Instruction::Cast; // 127
|
2004-08-04 07:29:16 +00:00
|
|
|
static const int
|
2005-07-27 05:53:44 +00:00
|
|
|
ToUByteTy = ToBoolTy + 1,
|
|
|
|
ToSByteTy = ToBoolTy + 2,
|
|
|
|
ToUShortTy = ToBoolTy + 3,
|
|
|
|
ToShortTy = ToBoolTy + 4,
|
|
|
|
ToUIntTy = ToBoolTy + 5,
|
|
|
|
ToIntTy = ToBoolTy + 6,
|
|
|
|
ToULongTy = ToBoolTy + 7,
|
|
|
|
ToLongTy = ToBoolTy + 8,
|
|
|
|
ToFloatTy = ToBoolTy + 9,
|
|
|
|
ToDoubleTy = ToBoolTy + 10,
|
|
|
|
ToArrayTy = ToBoolTy + 11,
|
|
|
|
ToPointerTy = ToBoolTy + 12;
|
2004-08-04 07:29:16 +00:00
|
|
|
|
|
|
|
/// Data types needed by BURG
|
|
|
|
///
|
|
|
|
typedef int OpLabel;
|
|
|
|
typedef int StateLabel;
|
|
|
|
|
|
|
|
/// Declarations of data and functions created by BURG
|
|
|
|
///
|
2005-04-21 23:30:14 +00:00
|
|
|
namespace llvm {
|
2004-08-04 07:29:16 +00:00
|
|
|
class InstrTreeNode;
|
|
|
|
};
|
2005-07-27 05:53:44 +00:00
|
|
|
extern short* burm_nts[];
|
|
|
|
extern StateLabel burm_label (InstrTreeNode* p);
|
|
|
|
extern StateLabel burm_state (OpLabel op, StateLabel leftState,
|
|
|
|
StateLabel rightState);
|
|
|
|
extern StateLabel burm_rule (StateLabel state, int goalNT);
|
|
|
|
extern InstrTreeNode** burm_kids (InstrTreeNode* p, int eruleno,
|
|
|
|
InstrTreeNode* kids[]);
|
|
|
|
extern void printcover (InstrTreeNode*, int, int);
|
|
|
|
extern void printtree (InstrTreeNode*);
|
|
|
|
extern int treecost (InstrTreeNode*, int, int);
|
|
|
|
extern void printMatches (InstrTreeNode*);
|
2004-08-04 07:29:16 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
/// InstrTreeNode - A single tree node in the instruction tree used for
|
|
|
|
/// instruction selection via BURG.
|
|
|
|
///
|
|
|
|
class InstrTreeNode {
|
|
|
|
InstrTreeNode(const InstrTreeNode &); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const InstrTreeNode &); // DO NOT IMPLEMENT
|
|
|
|
public:
|
|
|
|
enum InstrTreeNodeType { NTInstructionNode,
|
2005-07-27 05:53:44 +00:00
|
|
|
NTVRegListNode,
|
|
|
|
NTVRegNode,
|
|
|
|
NTConstNode,
|
|
|
|
NTLabelNode };
|
2004-08-04 07:29:16 +00:00
|
|
|
InstrTreeNode* LeftChild;
|
|
|
|
InstrTreeNode* RightChild;
|
|
|
|
InstrTreeNode* Parent;
|
|
|
|
OpLabel opLabel;
|
|
|
|
StateLabel state;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
InstrTreeNodeType treeNodeType;
|
2005-07-27 05:53:44 +00:00
|
|
|
Value* val;
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2004-08-04 07:29:16 +00:00
|
|
|
public:
|
|
|
|
InstrTreeNode(InstrTreeNodeType nodeType, Value* _val)
|
|
|
|
: treeNodeType(nodeType), val(_val) {
|
|
|
|
LeftChild = RightChild = Parent = 0;
|
|
|
|
opLabel = InvalidOp;
|
|
|
|
}
|
|
|
|
virtual ~InstrTreeNode() {
|
|
|
|
delete LeftChild;
|
|
|
|
delete RightChild;
|
|
|
|
}
|
2005-07-27 05:53:44 +00:00
|
|
|
InstrTreeNodeType getNodeType () const { return treeNodeType; }
|
|
|
|
Value* getValue () const { return val; }
|
|
|
|
inline OpLabel getOpLabel () const { return opLabel; }
|
2004-08-04 07:29:16 +00:00
|
|
|
inline InstrTreeNode *leftChild () const { return LeftChild; }
|
|
|
|
inline InstrTreeNode *parent () const { return Parent; }
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2004-08-04 07:29:16 +00:00
|
|
|
// If right child is a list node, recursively get its *left* child
|
|
|
|
inline InstrTreeNode* rightChild() const {
|
2005-04-21 23:30:14 +00:00
|
|
|
return (!RightChild ? 0 :
|
2005-07-27 05:53:44 +00:00
|
|
|
(RightChild->getOpLabel() == VRegListOp
|
|
|
|
? RightChild->LeftChild : RightChild));
|
2004-08-04 07:29:16 +00:00
|
|
|
}
|
|
|
|
void dump(int dumpChildren, int indent) const;
|
|
|
|
protected:
|
|
|
|
virtual void dumpNode(int indent) const = 0;
|
|
|
|
friend class InstrForest;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm.
|
|
|
|
|
|
|
|
#endif
|