aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2001-10-22 13:51:09 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2001-10-22 13:51:09 +0000
commit7ad104606557f7b46035556da4d912ad87792290 (patch)
treed6dd641b2eb1b901357702c2b677c442ba165d52 /lib
parentfb8c0533b46309296a3c404d58f6b5d7c337f0f1 (diff)
downloadexternal_llvm-7ad104606557f7b46035556da4d912ad87792290.tar.gz
external_llvm-7ad104606557f7b46035556da4d912ad87792290.tar.bz2
external_llvm-7ad104606557f7b46035556da4d912ad87792290.zip
Cosmetic changes only.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/InstrSelection/InstrSelection.cpp64
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrSelection.cpp64
2 files changed, 98 insertions, 30 deletions
diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp
index df9098f219..abbd2f94f7 100644
--- a/lib/CodeGen/InstrSelection/InstrSelection.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp
@@ -22,9 +22,12 @@
#include "llvm/BasicBlock.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 {
Select_NoDebugInfo,
@@ -42,6 +45,21 @@ cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags,
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.
@@ -110,8 +128,9 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
if (SelectDebugLevel >= Select_PrintMachineCode)
{
- cout << endl << "*** Machine instructions after INSTRUCTION SELECTION" << endl;
- PrintMachineInstructions(method);
+ cout << endl
+ << "*** Machine instructions after INSTRUCTION SELECTION" << endl;
+ method->getMachineCode().dump();
}
return false;
@@ -122,13 +141,32 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
//---------------------------------------------------------------------------
+// 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
//
// Apply any final cleanups to machine code for the root of a subtree
// after selection for all its children has been completed.
//---------------------------------------------------------------------------
-void
+static void
PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode,
short* nts,
@@ -170,9 +208,6 @@ bool
SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
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.
//
int ruleForNode = burm_rule(treeRoot->state, goalnt);
@@ -196,15 +231,14 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
{
InstructionNode* instrNode = (InstructionNode*)treeRoot;
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
-
+
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, target,
minstrVec);
- assert(N <= MAX_INSTR_PER_VMINSTR);
- for (unsigned i=0; i < N; i++)
- {
- assert(minstrVec[i] != NULL);
- instrNode->getInstruction()->addMachineInstruction(minstrVec[i]);
- }
+ if (N > 0)
+ {
+ assert(N <= MAX_INSTR_PER_VMINSTR);
+ AppendMachineCodeForVMInstr(minstrVec,N,instrNode->getInstruction());
+ }
}
// Then, recursively compile the child nodes, if any.
diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
index df9098f219..abbd2f94f7 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
@@ -22,9 +22,12 @@
#include "llvm/BasicBlock.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 {
Select_NoDebugInfo,
@@ -42,6 +45,21 @@ cl::Enum<enum SelectDebugLevel_t> SelectDebugLevel("dselect", cl::NoFlags,
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.
@@ -110,8 +128,9 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
if (SelectDebugLevel >= Select_PrintMachineCode)
{
- cout << endl << "*** Machine instructions after INSTRUCTION SELECTION" << endl;
- PrintMachineInstructions(method);
+ cout << endl
+ << "*** Machine instructions after INSTRUCTION SELECTION" << endl;
+ method->getMachineCode().dump();
}
return false;
@@ -122,13 +141,32 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
//---------------------------------------------------------------------------
+// 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
//
// Apply any final cleanups to machine code for the root of a subtree
// after selection for all its children has been completed.
//---------------------------------------------------------------------------
-void
+static void
PostprocessMachineCodeForTree(InstructionNode* instrNode,
int ruleForNode,
short* nts,
@@ -170,9 +208,6 @@ bool
SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
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.
//
int ruleForNode = burm_rule(treeRoot->state, goalnt);
@@ -196,15 +231,14 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
{
InstructionNode* instrNode = (InstructionNode*)treeRoot;
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
-
+
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, target,
minstrVec);
- assert(N <= MAX_INSTR_PER_VMINSTR);
- for (unsigned i=0; i < N; i++)
- {
- assert(minstrVec[i] != NULL);
- instrNode->getInstruction()->addMachineInstruction(minstrVec[i]);
- }
+ if (N > 0)
+ {
+ assert(N <= MAX_INSTR_PER_VMINSTR);
+ AppendMachineCodeForVMInstr(minstrVec,N,instrNode->getInstruction());
+ }
}
// Then, recursively compile the child nodes, if any.