mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 02:31:09 +00:00
Eliminate 'BasicNode' from InstrForest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@551 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c2a2396e17
commit
d268ad6e2e
@ -78,36 +78,26 @@ const int ToPointerTy = ToBoolTy + 12;
|
|||||||
typedef int OpLabel;
|
typedef int OpLabel;
|
||||||
typedef int StateLabel;
|
typedef int StateLabel;
|
||||||
|
|
||||||
struct BasicTreeNode {
|
|
||||||
BasicTreeNode* leftChild;
|
|
||||||
BasicTreeNode* rightChild;
|
|
||||||
BasicTreeNode* parent;
|
|
||||||
OpLabel opLabel;
|
|
||||||
StateLabel state;
|
|
||||||
InstrTreeNode *treeNodePtr; // points to the C++ tree node object
|
|
||||||
// that "contains" this node
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Declarations of data and functions created by BURG
|
// Declarations of data and functions created by BURG
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
extern short* burm_nts[];
|
extern short* burm_nts[];
|
||||||
|
|
||||||
extern StateLabel burm_label (BasicTreeNode* p);
|
extern StateLabel burm_label (InstrTreeNode* p);
|
||||||
|
|
||||||
extern StateLabel burm_state (OpLabel op, StateLabel leftState,
|
extern StateLabel burm_state (OpLabel op, StateLabel leftState,
|
||||||
StateLabel rightState);
|
StateLabel rightState);
|
||||||
|
|
||||||
extern StateLabel burm_rule (StateLabel state, int goalNT);
|
extern StateLabel burm_rule (StateLabel state, int goalNT);
|
||||||
|
|
||||||
extern BasicTreeNode** burm_kids (BasicTreeNode* p, int eruleno,
|
extern InstrTreeNode** burm_kids (InstrTreeNode* p, int eruleno,
|
||||||
BasicTreeNode* kids[]);
|
InstrTreeNode* kids[]);
|
||||||
|
|
||||||
extern void printcover (BasicTreeNode*, int, int);
|
extern void printcover (InstrTreeNode*, int, int);
|
||||||
extern void printtree (BasicTreeNode*);
|
extern void printtree (InstrTreeNode*);
|
||||||
extern int treecost (BasicTreeNode*, int, int);
|
extern int treecost (InstrTreeNode*, int, int);
|
||||||
extern void printMatches (BasicTreeNode*);
|
extern void printMatches (InstrTreeNode*);
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -125,8 +115,15 @@ public:
|
|||||||
NTConstNode,
|
NTConstNode,
|
||||||
NTLabelNode };
|
NTLabelNode };
|
||||||
|
|
||||||
|
// BASIC TREE NODE START
|
||||||
|
InstrTreeNode* LeftChild;
|
||||||
|
InstrTreeNode* RightChild;
|
||||||
|
InstrTreeNode* Parent;
|
||||||
|
OpLabel opLabel;
|
||||||
|
StateLabel state;
|
||||||
|
// BASIC TREE NODE END
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BasicTreeNode basicNode;
|
|
||||||
InstrTreeNodeType treeNodeType;
|
InstrTreeNodeType treeNodeType;
|
||||||
Value* val;
|
Value* val;
|
||||||
|
|
||||||
@ -135,30 +132,25 @@ public:
|
|||||||
Value* _val);
|
Value* _val);
|
||||||
/*dtor*/ virtual ~InstrTreeNode () {}
|
/*dtor*/ virtual ~InstrTreeNode () {}
|
||||||
|
|
||||||
BasicTreeNode* getBasicNode () { return &basicNode; }
|
|
||||||
|
|
||||||
InstrTreeNodeType getNodeType () const { return treeNodeType; }
|
InstrTreeNodeType getNodeType () const { return treeNodeType; }
|
||||||
|
|
||||||
Value* getValue () const { return val; }
|
Value* getValue () const { return val; }
|
||||||
|
|
||||||
inline OpLabel getOpLabel () const { return basicNode.opLabel; }
|
inline OpLabel getOpLabel () const { return opLabel; }
|
||||||
|
|
||||||
inline InstrTreeNode* leftChild () const {
|
inline InstrTreeNode* leftChild () const {
|
||||||
return (basicNode.leftChild? basicNode.leftChild->treeNodePtr : NULL);
|
return LeftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If right child is a list node, recursively get its *left* child
|
// If right child is a list node, recursively get its *left* child
|
||||||
inline InstrTreeNode* rightChild () const {
|
inline InstrTreeNode* rightChild() const {
|
||||||
return (InstrTreeNode*)
|
return (!RightChild ? 0 :
|
||||||
(basicNode.rightChild
|
(RightChild->getOpLabel() == VRegListOp
|
||||||
? (basicNode.rightChild->treeNodePtr->getOpLabel() == VRegListOp
|
? RightChild->LeftChild : RightChild));
|
||||||
? basicNode.rightChild->treeNodePtr->leftChild()
|
|
||||||
: basicNode.rightChild->treeNodePtr)
|
|
||||||
: NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline InstrTreeNode* parent () const {
|
inline InstrTreeNode *parent() const {
|
||||||
return (basicNode.parent? basicNode.parent->treeNodePtr : NULL);
|
return Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump (int dumpChildren,
|
void dump (int dumpChildren,
|
||||||
|
@ -38,23 +38,16 @@
|
|||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
InstrTreeNode::InstrTreeNode(InstrTreeNodeType nodeType,
|
InstrTreeNode::InstrTreeNode(InstrTreeNodeType nodeType, Value* _val)
|
||||||
Value* _val)
|
: treeNodeType(nodeType), val(_val) {
|
||||||
: treeNodeType(nodeType),
|
LeftChild = 0;
|
||||||
val(_val)
|
RightChild = 0;
|
||||||
{
|
Parent = 0;
|
||||||
basicNode.leftChild = NULL;
|
opLabel = InvalidOp;
|
||||||
basicNode.rightChild = NULL;
|
|
||||||
basicNode.parent = NULL;
|
|
||||||
basicNode.opLabel = InvalidOp;
|
|
||||||
basicNode.treeNodePtr = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void InstrTreeNode::dump(int dumpChildren, int indent) const {
|
||||||
InstrTreeNode::dump(int dumpChildren,
|
dumpNode(indent);
|
||||||
int indent) const
|
|
||||||
{
|
|
||||||
this->dumpNode(indent);
|
|
||||||
|
|
||||||
if (dumpChildren)
|
if (dumpChildren)
|
||||||
{
|
{
|
||||||
@ -122,7 +115,7 @@ InstructionNode::InstructionNode(Instruction* _instr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
basicNode.opLabel = opLabel;
|
this->opLabel = opLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,10 +141,8 @@ InstructionNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VRegListNode::VRegListNode()
|
VRegListNode::VRegListNode() : InstrTreeNode(NTVRegListNode, 0) {
|
||||||
: InstrTreeNode(NTVRegListNode, NULL)
|
opLabel = VRegListOp;
|
||||||
{
|
|
||||||
basicNode.opLabel = VRegListOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -164,10 +155,8 @@ VRegListNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VRegNode::VRegNode(Value* _val)
|
VRegNode::VRegNode(Value* _val) : InstrTreeNode(NTVRegNode, _val) {
|
||||||
: InstrTreeNode(NTVRegNode, _val)
|
opLabel = VRegNodeOp;
|
||||||
{
|
|
||||||
basicNode.opLabel = VRegNodeOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -181,10 +170,9 @@ VRegNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ConstantNode::ConstantNode(ConstPoolVal* constVal)
|
ConstantNode::ConstantNode(ConstPoolVal *constVal)
|
||||||
: InstrTreeNode(NTConstNode, constVal)
|
: InstrTreeNode(NTConstNode, constVal) {
|
||||||
{
|
opLabel = ConstantNodeOp;
|
||||||
basicNode.opLabel = ConstantNodeOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -198,10 +186,8 @@ ConstantNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LabelNode::LabelNode(BasicBlock* _bblock)
|
LabelNode::LabelNode(BasicBlock *BB) : InstrTreeNode(NTLabelNode, BB) {
|
||||||
: InstrTreeNode(NTLabelNode, _bblock)
|
opLabel = LabelNodeOp;
|
||||||
{
|
|
||||||
basicNode.opLabel = LabelNodeOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -255,10 +241,9 @@ InstrForest::noteTreeNodeForInstr(Instruction* instr,
|
|||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child)
|
InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child) {
|
||||||
{
|
parent->LeftChild = child;
|
||||||
parent->basicNode.leftChild = & child->basicNode;
|
child->Parent = parent;
|
||||||
child->basicNode.parent = & parent->basicNode;
|
|
||||||
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
||||||
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
||||||
}
|
}
|
||||||
@ -267,8 +252,8 @@ InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child)
|
|||||||
inline void
|
inline void
|
||||||
InstrForest::setRightChild(InstrTreeNode* parent, InstrTreeNode* child)
|
InstrForest::setRightChild(InstrTreeNode* parent, InstrTreeNode* child)
|
||||||
{
|
{
|
||||||
parent->basicNode.rightChild = & child->basicNode;
|
parent->RightChild = child;
|
||||||
child->basicNode.parent = & parent->basicNode;
|
child->Parent = parent;
|
||||||
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
||||||
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
||||||
}
|
}
|
||||||
|
@ -10,30 +10,19 @@
|
|||||||
//**************************************************************************/
|
//**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//************************** System Include Files ***************************/
|
|
||||||
|
|
||||||
|
|
||||||
//*************************** User Include Files ***************************/
|
|
||||||
|
|
||||||
#include "llvm/CodeGen/InstrSelection.h"
|
#include "llvm/CodeGen/InstrSelection.h"
|
||||||
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/iMemory.h"
|
#include "llvm/iMemory.h"
|
||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Method.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
|
||||||
|
|
||||||
|
static bool SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
|
||||||
//************************* Forward Declarations ***************************/
|
|
||||||
|
|
||||||
static bool SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|
||||||
int goalnt,
|
|
||||||
TargetMachine &Target);
|
TargetMachine &Target);
|
||||||
|
|
||||||
|
|
||||||
//************************* Internal Data Types *****************************/
|
|
||||||
|
|
||||||
enum SelectDebugLevel_t {
|
enum SelectDebugLevel_t {
|
||||||
Select_NoDebugInfo,
|
Select_NoDebugInfo,
|
||||||
Select_PrintMachineCode,
|
Select_PrintMachineCode,
|
||||||
@ -50,8 +39,6 @@ cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags, // cl
|
|||||||
clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0);
|
clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0);
|
||||||
|
|
||||||
|
|
||||||
//************************** External Functions ****************************/
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Entry point for instruction selection using BURG.
|
// Entry point for instruction selection using BURG.
|
||||||
@ -87,7 +74,7 @@ SelectInstructionsForMethod(Method* method,
|
|||||||
treeRootIter != treeRoots.end();
|
treeRootIter != treeRoots.end();
|
||||||
++treeRootIter)
|
++treeRootIter)
|
||||||
{
|
{
|
||||||
BasicTreeNode* basicNode = (*treeRootIter)->getBasicNode();
|
InstrTreeNode* basicNode = *treeRootIter;
|
||||||
|
|
||||||
// Invoke BURM to label each tree node with a state
|
// Invoke BURM to label each tree node with a state
|
||||||
(void) burm_label(basicNode);
|
(void) burm_label(basicNode);
|
||||||
@ -192,8 +179,7 @@ FoldGetElemChain(const InstructionNode* getElemInstrNode,
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
|
||||||
int goalnt,
|
|
||||||
TargetMachine &Target)
|
TargetMachine &Target)
|
||||||
{
|
{
|
||||||
// Use a static vector to avoid allocating a new one per VM instruction
|
// Use a static vector to avoid allocating a new one per VM instruction
|
||||||
@ -220,7 +206,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
//
|
//
|
||||||
if (treeRoot->opLabel != VRegListOp)
|
if (treeRoot->opLabel != VRegListOp)
|
||||||
{
|
{
|
||||||
InstructionNode* instrNode = (InstructionNode*)treeRoot->treeNodePtr;
|
InstructionNode* instrNode = (InstructionNode*)treeRoot;
|
||||||
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
|
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
|
||||||
|
|
||||||
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, Target,
|
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, Target,
|
||||||
@ -238,7 +224,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
if (nts[0])
|
if (nts[0])
|
||||||
{ // i.e., there is at least one kid
|
{ // i.e., there is at least one kid
|
||||||
|
|
||||||
BasicTreeNode* kids[2];
|
InstrTreeNode* kids[2];
|
||||||
int currentRule = ruleForNode;
|
int currentRule = ruleForNode;
|
||||||
burm_kids(treeRoot, currentRule, kids);
|
burm_kids(treeRoot, currentRule, kids);
|
||||||
|
|
||||||
@ -258,8 +244,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
for (int i = 0; nts[i]; i++)
|
for (int i = 0; nts[i]; i++)
|
||||||
{
|
{
|
||||||
assert(i < 2);
|
assert(i < 2);
|
||||||
InstrTreeNode::InstrTreeNodeType
|
InstrTreeNode::InstrTreeNodeType nodeType = kids[i]->getNodeType();
|
||||||
nodeType = kids[i]->treeNodePtr->getNodeType();
|
|
||||||
if (nodeType == InstrTreeNode::NTVRegListNode ||
|
if (nodeType == InstrTreeNode::NTVRegListNode ||
|
||||||
nodeType == InstrTreeNode::NTInstructionNode)
|
nodeType == InstrTreeNode::NTInstructionNode)
|
||||||
{
|
{
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <llvm/CodeGen/InstrForest.h>
|
#include <llvm/CodeGen/InstrForest.h>
|
||||||
|
|
||||||
typedef BasicTreeNode* NODEPTR_TYPE;
|
typedef InstrTreeNode* NODEPTR_TYPE;
|
||||||
#define OP_LABEL(p) ((p)->opLabel)
|
#define OP_LABEL(p) ((p)->opLabel)
|
||||||
#define LEFT_CHILD(p) ((p)->leftChild)
|
#define LEFT_CHILD(p) ((p)->LeftChild)
|
||||||
#define RIGHT_CHILD(p) ((p)->rightChild)
|
#define RIGHT_CHILD(p) ((p)->RightChild)
|
||||||
#define STATE_LABEL(p) ((p)->state)
|
#define STATE_LABEL(p) ((p)->state)
|
||||||
#define PANIC printf
|
#define PANIC printf
|
||||||
%}
|
%}
|
||||||
|
@ -9,23 +9,18 @@
|
|||||||
// 7/02/01 - Vikram Adve - Created
|
// 7/02/01 - Vikram Adve - Created
|
||||||
//**************************************************************************/
|
//**************************************************************************/
|
||||||
|
|
||||||
|
#include "llvm/CodeGen/Sparc.h"
|
||||||
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
|
#include "llvm/CodeGen/InstrForest.h"
|
||||||
|
#include "llvm/CodeGen/InstrSelection.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Type.h"
|
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/SymbolTable.h"
|
|
||||||
#include "llvm/Value.h"
|
|
||||||
#include "llvm/Instruction.h"
|
|
||||||
#include "llvm/InstrTypes.h"
|
|
||||||
#include "llvm/iTerminators.h"
|
#include "llvm/iTerminators.h"
|
||||||
#include "llvm/iMemory.h"
|
#include "llvm/iMemory.h"
|
||||||
#include "llvm/iOther.h"
|
#include "llvm/iOther.h"
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Method.h"
|
||||||
#include "llvm/ConstPoolVals.h"
|
#include "llvm/ConstPoolVals.h"
|
||||||
#include "llvm/CodeGen/Sparc.h"
|
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
|
||||||
#include "llvm/CodeGen/InstrForest.h"
|
|
||||||
#include "llvm/CodeGen/InstrSelection.h"
|
|
||||||
|
|
||||||
|
|
||||||
//******************** Internal Data Declarations ************************/
|
//******************** Internal Data Declarations ************************/
|
||||||
@ -1982,7 +1977,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
assert(ThisIsAChainRule(ruleForNode));
|
assert(ThisIsAChainRule(ruleForNode));
|
||||||
assert(nts[0] && ! nts[1]
|
assert(nts[0] && ! nts[1]
|
||||||
&& "A chain rule should have only one RHS non-terminal!");
|
&& "A chain rule should have only one RHS non-terminal!");
|
||||||
nextRule = burm_rule(subtreeRoot->getBasicNode()->state, nts[0]);
|
nextRule = burm_rule(subtreeRoot->state, nts[0]);
|
||||||
nts = burm_nts[nextRule];
|
nts = burm_nts[nextRule];
|
||||||
numInstr = GetInstructionsByRule(subtreeRoot, nextRule, nts,target,mvec);
|
numInstr = GetInstructionsByRule(subtreeRoot, nextRule, nts,target,mvec);
|
||||||
break;
|
break;
|
||||||
|
@ -38,23 +38,16 @@
|
|||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
InstrTreeNode::InstrTreeNode(InstrTreeNodeType nodeType,
|
InstrTreeNode::InstrTreeNode(InstrTreeNodeType nodeType, Value* _val)
|
||||||
Value* _val)
|
: treeNodeType(nodeType), val(_val) {
|
||||||
: treeNodeType(nodeType),
|
LeftChild = 0;
|
||||||
val(_val)
|
RightChild = 0;
|
||||||
{
|
Parent = 0;
|
||||||
basicNode.leftChild = NULL;
|
opLabel = InvalidOp;
|
||||||
basicNode.rightChild = NULL;
|
|
||||||
basicNode.parent = NULL;
|
|
||||||
basicNode.opLabel = InvalidOp;
|
|
||||||
basicNode.treeNodePtr = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void InstrTreeNode::dump(int dumpChildren, int indent) const {
|
||||||
InstrTreeNode::dump(int dumpChildren,
|
dumpNode(indent);
|
||||||
int indent) const
|
|
||||||
{
|
|
||||||
this->dumpNode(indent);
|
|
||||||
|
|
||||||
if (dumpChildren)
|
if (dumpChildren)
|
||||||
{
|
{
|
||||||
@ -122,7 +115,7 @@ InstructionNode::InstructionNode(Instruction* _instr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
basicNode.opLabel = opLabel;
|
this->opLabel = opLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,10 +141,8 @@ InstructionNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VRegListNode::VRegListNode()
|
VRegListNode::VRegListNode() : InstrTreeNode(NTVRegListNode, 0) {
|
||||||
: InstrTreeNode(NTVRegListNode, NULL)
|
opLabel = VRegListOp;
|
||||||
{
|
|
||||||
basicNode.opLabel = VRegListOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -164,10 +155,8 @@ VRegListNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VRegNode::VRegNode(Value* _val)
|
VRegNode::VRegNode(Value* _val) : InstrTreeNode(NTVRegNode, _val) {
|
||||||
: InstrTreeNode(NTVRegNode, _val)
|
opLabel = VRegNodeOp;
|
||||||
{
|
|
||||||
basicNode.opLabel = VRegNodeOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -181,10 +170,9 @@ VRegNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ConstantNode::ConstantNode(ConstPoolVal* constVal)
|
ConstantNode::ConstantNode(ConstPoolVal *constVal)
|
||||||
: InstrTreeNode(NTConstNode, constVal)
|
: InstrTreeNode(NTConstNode, constVal) {
|
||||||
{
|
opLabel = ConstantNodeOp;
|
||||||
basicNode.opLabel = ConstantNodeOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -198,10 +186,8 @@ ConstantNode::dumpNode(int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LabelNode::LabelNode(BasicBlock* _bblock)
|
LabelNode::LabelNode(BasicBlock *BB) : InstrTreeNode(NTLabelNode, BB) {
|
||||||
: InstrTreeNode(NTLabelNode, _bblock)
|
opLabel = LabelNodeOp;
|
||||||
{
|
|
||||||
basicNode.opLabel = LabelNodeOp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -255,10 +241,9 @@ InstrForest::noteTreeNodeForInstr(Instruction* instr,
|
|||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child)
|
InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child) {
|
||||||
{
|
parent->LeftChild = child;
|
||||||
parent->basicNode.leftChild = & child->basicNode;
|
child->Parent = parent;
|
||||||
child->basicNode.parent = & parent->basicNode;
|
|
||||||
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
||||||
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
||||||
}
|
}
|
||||||
@ -267,8 +252,8 @@ InstrForest::setLeftChild(InstrTreeNode* parent, InstrTreeNode* child)
|
|||||||
inline void
|
inline void
|
||||||
InstrForest::setRightChild(InstrTreeNode* parent, InstrTreeNode* child)
|
InstrForest::setRightChild(InstrTreeNode* parent, InstrTreeNode* child)
|
||||||
{
|
{
|
||||||
parent->basicNode.rightChild = & child->basicNode;
|
parent->RightChild = child;
|
||||||
child->basicNode.parent = & parent->basicNode;
|
child->Parent = parent;
|
||||||
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
if (child->getNodeType() == InstrTreeNode::NTInstructionNode)
|
||||||
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
treeRoots.erase((InstructionNode*) child); // no longer a tree root
|
||||||
}
|
}
|
||||||
|
@ -10,30 +10,19 @@
|
|||||||
//**************************************************************************/
|
//**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//************************** System Include Files ***************************/
|
|
||||||
|
|
||||||
|
|
||||||
//*************************** User Include Files ***************************/
|
|
||||||
|
|
||||||
#include "llvm/CodeGen/InstrSelection.h"
|
#include "llvm/CodeGen/InstrSelection.h"
|
||||||
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/iMemory.h"
|
#include "llvm/iMemory.h"
|
||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Method.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
|
||||||
|
|
||||||
|
static bool SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
|
||||||
//************************* Forward Declarations ***************************/
|
|
||||||
|
|
||||||
static bool SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|
||||||
int goalnt,
|
|
||||||
TargetMachine &Target);
|
TargetMachine &Target);
|
||||||
|
|
||||||
|
|
||||||
//************************* Internal Data Types *****************************/
|
|
||||||
|
|
||||||
enum SelectDebugLevel_t {
|
enum SelectDebugLevel_t {
|
||||||
Select_NoDebugInfo,
|
Select_NoDebugInfo,
|
||||||
Select_PrintMachineCode,
|
Select_PrintMachineCode,
|
||||||
@ -50,8 +39,6 @@ cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags, // cl
|
|||||||
clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0);
|
clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0);
|
||||||
|
|
||||||
|
|
||||||
//************************** External Functions ****************************/
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Entry point for instruction selection using BURG.
|
// Entry point for instruction selection using BURG.
|
||||||
@ -87,7 +74,7 @@ SelectInstructionsForMethod(Method* method,
|
|||||||
treeRootIter != treeRoots.end();
|
treeRootIter != treeRoots.end();
|
||||||
++treeRootIter)
|
++treeRootIter)
|
||||||
{
|
{
|
||||||
BasicTreeNode* basicNode = (*treeRootIter)->getBasicNode();
|
InstrTreeNode* basicNode = *treeRootIter;
|
||||||
|
|
||||||
// Invoke BURM to label each tree node with a state
|
// Invoke BURM to label each tree node with a state
|
||||||
(void) burm_label(basicNode);
|
(void) burm_label(basicNode);
|
||||||
@ -192,8 +179,7 @@ FoldGetElemChain(const InstructionNode* getElemInstrNode,
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
|
||||||
int goalnt,
|
|
||||||
TargetMachine &Target)
|
TargetMachine &Target)
|
||||||
{
|
{
|
||||||
// Use a static vector to avoid allocating a new one per VM instruction
|
// Use a static vector to avoid allocating a new one per VM instruction
|
||||||
@ -220,7 +206,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
//
|
//
|
||||||
if (treeRoot->opLabel != VRegListOp)
|
if (treeRoot->opLabel != VRegListOp)
|
||||||
{
|
{
|
||||||
InstructionNode* instrNode = (InstructionNode*)treeRoot->treeNodePtr;
|
InstructionNode* instrNode = (InstructionNode*)treeRoot;
|
||||||
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
|
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
|
||||||
|
|
||||||
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, Target,
|
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, Target,
|
||||||
@ -238,7 +224,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
if (nts[0])
|
if (nts[0])
|
||||||
{ // i.e., there is at least one kid
|
{ // i.e., there is at least one kid
|
||||||
|
|
||||||
BasicTreeNode* kids[2];
|
InstrTreeNode* kids[2];
|
||||||
int currentRule = ruleForNode;
|
int currentRule = ruleForNode;
|
||||||
burm_kids(treeRoot, currentRule, kids);
|
burm_kids(treeRoot, currentRule, kids);
|
||||||
|
|
||||||
@ -258,8 +244,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
for (int i = 0; nts[i]; i++)
|
for (int i = 0; nts[i]; i++)
|
||||||
{
|
{
|
||||||
assert(i < 2);
|
assert(i < 2);
|
||||||
InstrTreeNode::InstrTreeNodeType
|
InstrTreeNode::InstrTreeNodeType nodeType = kids[i]->getNodeType();
|
||||||
nodeType = kids[i]->treeNodePtr->getNodeType();
|
|
||||||
if (nodeType == InstrTreeNode::NTVRegListNode ||
|
if (nodeType == InstrTreeNode::NTVRegListNode ||
|
||||||
nodeType == InstrTreeNode::NTInstructionNode)
|
nodeType == InstrTreeNode::NTInstructionNode)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user