Cosmetic changes only.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@946 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vikram S. Adve 2001-10-22 13:51:09 +00:00
parent fb8c0533b4
commit 7ad1046065
2 changed files with 98 additions and 30 deletions

View File

@ -22,9 +22,12 @@
#include "llvm/BasicBlock.h" #include "llvm/BasicBlock.h"
#include "llvm/Method.h" #include "llvm/Method.h"
static bool SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
TargetMachine &target);
//******************** Internal Data Declarations ************************/
// Use a static vector to avoid allocating a new one per VM instruction
static MachineInstr* minstrVec[MAX_INSTR_PER_VMINSTR];
enum SelectDebugLevel_t { enum SelectDebugLevel_t {
Select_NoDebugInfo, Select_NoDebugInfo,
@ -42,6 +45,21 @@ cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags,
clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0); clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0);
//******************** Forward Function Declarations ***********************/
static bool SelectInstructionsForTree (InstrTreeNode* treeRoot,
int goalnt,
TargetMachine &target);
static void PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode,
short* nts,
TargetMachine &target);
//******************* Externally Visible Functions *************************/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Entry point for instruction selection using BURG. // Entry point for instruction selection using BURG.
@ -110,8 +128,9 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
if (SelectDebugLevel >= Select_PrintMachineCode) if (SelectDebugLevel >= Select_PrintMachineCode)
{ {
cout << endl << "*** Machine instructions after INSTRUCTION SELECTION" << endl; cout << endl
PrintMachineInstructions(method); << "*** Machine instructions after INSTRUCTION SELECTION" << endl;
method->getMachineCode().dump();
} }
return false; return false;
@ -121,6 +140,25 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
//*********************** Private Functions *****************************/ //*********************** Private Functions *****************************/
//---------------------------------------------------------------------------
// Function AppendMachineCodeForVMInstr
//
// Append machine instr sequence to the machine code vec for a VM instr
//---------------------------------------------------------------------------
inline void
AppendMachineCodeForVMInstr(MachineInstr** minstrVec,
unsigned int N,
Instruction* vmInstr)
{
if (N == 0)
return;
MachineCodeForVMInstr& mvec = vmInstr->getMachineInstrVec();
mvec.insert(mvec.end(), minstrVec, minstrVec+N);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Function PostprocessMachineCodeForTree // Function PostprocessMachineCodeForTree
// //
@ -128,7 +166,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
// after selection for all its children has been completed. // after selection for all its children has been completed.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void static void
PostprocessMachineCodeForTree(InstructionNode* instrNode, PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode, int ruleForNode,
short* nts, short* nts,
@ -170,9 +208,6 @@ bool
SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt, SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
TargetMachine &target) TargetMachine &target)
{ {
// Use a static vector to avoid allocating a new one per VM instruction
static MachineInstr* minstrVec[MAX_INSTR_PER_VMINSTR];
// Get the rule that matches this node. // Get the rule that matches this node.
// //
int ruleForNode = burm_rule(treeRoot->state, goalnt); int ruleForNode = burm_rule(treeRoot->state, goalnt);
@ -196,15 +231,14 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
{ {
InstructionNode* instrNode = (InstructionNode*)treeRoot; 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,
minstrVec); minstrVec);
assert(N <= MAX_INSTR_PER_VMINSTR); if (N > 0)
for (unsigned i=0; i < N; i++) {
{ assert(N <= MAX_INSTR_PER_VMINSTR);
assert(minstrVec[i] != NULL); AppendMachineCodeForVMInstr(minstrVec,N,instrNode->getInstruction());
instrNode->getInstruction()->addMachineInstruction(minstrVec[i]); }
}
} }
// Then, recursively compile the child nodes, if any. // Then, recursively compile the child nodes, if any.

View File

@ -22,9 +22,12 @@
#include "llvm/BasicBlock.h" #include "llvm/BasicBlock.h"
#include "llvm/Method.h" #include "llvm/Method.h"
static bool SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
TargetMachine &target);
//******************** Internal Data Declarations ************************/
// Use a static vector to avoid allocating a new one per VM instruction
static MachineInstr* minstrVec[MAX_INSTR_PER_VMINSTR];
enum SelectDebugLevel_t { enum SelectDebugLevel_t {
Select_NoDebugInfo, Select_NoDebugInfo,
@ -42,6 +45,21 @@ cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags,
clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0); clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), 0);
//******************** Forward Function Declarations ***********************/
static bool SelectInstructionsForTree (InstrTreeNode* treeRoot,
int goalnt,
TargetMachine &target);
static void PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode,
short* nts,
TargetMachine &target);
//******************* Externally Visible Functions *************************/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Entry point for instruction selection using BURG. // Entry point for instruction selection using BURG.
@ -110,8 +128,9 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
if (SelectDebugLevel >= Select_PrintMachineCode) if (SelectDebugLevel >= Select_PrintMachineCode)
{ {
cout << endl << "*** Machine instructions after INSTRUCTION SELECTION" << endl; cout << endl
PrintMachineInstructions(method); << "*** Machine instructions after INSTRUCTION SELECTION" << endl;
method->getMachineCode().dump();
} }
return false; return false;
@ -121,6 +140,25 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
//*********************** Private Functions *****************************/ //*********************** Private Functions *****************************/
//---------------------------------------------------------------------------
// Function AppendMachineCodeForVMInstr
//
// Append machine instr sequence to the machine code vec for a VM instr
//---------------------------------------------------------------------------
inline void
AppendMachineCodeForVMInstr(MachineInstr** minstrVec,
unsigned int N,
Instruction* vmInstr)
{
if (N == 0)
return;
MachineCodeForVMInstr& mvec = vmInstr->getMachineInstrVec();
mvec.insert(mvec.end(), minstrVec, minstrVec+N);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Function PostprocessMachineCodeForTree // Function PostprocessMachineCodeForTree
// //
@ -128,7 +166,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
// after selection for all its children has been completed. // after selection for all its children has been completed.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void static void
PostprocessMachineCodeForTree(InstructionNode* instrNode, PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode, int ruleForNode,
short* nts, short* nts,
@ -170,9 +208,6 @@ bool
SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt, SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
TargetMachine &target) TargetMachine &target)
{ {
// Use a static vector to avoid allocating a new one per VM instruction
static MachineInstr* minstrVec[MAX_INSTR_PER_VMINSTR];
// Get the rule that matches this node. // Get the rule that matches this node.
// //
int ruleForNode = burm_rule(treeRoot->state, goalnt); int ruleForNode = burm_rule(treeRoot->state, goalnt);
@ -196,15 +231,14 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
{ {
InstructionNode* instrNode = (InstructionNode*)treeRoot; 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,
minstrVec); minstrVec);
assert(N <= MAX_INSTR_PER_VMINSTR); if (N > 0)
for (unsigned i=0; i < N; i++) {
{ assert(N <= MAX_INSTR_PER_VMINSTR);
assert(minstrVec[i] != NULL); AppendMachineCodeForVMInstr(minstrVec,N,instrNode->getInstruction());
instrNode->getInstruction()->addMachineInstruction(minstrVec[i]); }
}
} }
// Then, recursively compile the child nodes, if any. // Then, recursively compile the child nodes, if any.