mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
Removal of the redundant CompileContext wrapper
llvm-svn: 274
This commit is contained in:
parent
90f8ecfda4
commit
d73669f4c6
@ -14,13 +14,13 @@
|
|||||||
|
|
||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
class CompileContext;
|
|
||||||
class Method;
|
class Method;
|
||||||
class InstrForest;
|
class InstrForest;
|
||||||
class MachineInstr;
|
class MachineInstr;
|
||||||
class InstructionNode;
|
class InstructionNode;
|
||||||
class TmpInstruction;
|
class TmpInstruction;
|
||||||
class ConstPoolVal;
|
class ConstPoolVal;
|
||||||
|
class TargetMachine;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// GLOBAL data and an external function that must be implemented
|
// GLOBAL data and an external function that must be implemented
|
||||||
@ -32,7 +32,7 @@ const unsigned MAX_INSTR_PER_VMINSTR = 8;
|
|||||||
extern unsigned GetInstructionsByRule (InstructionNode* subtreeRoot,
|
extern unsigned GetInstructionsByRule (InstructionNode* subtreeRoot,
|
||||||
int ruleForNode,
|
int ruleForNode,
|
||||||
short* nts,
|
short* nts,
|
||||||
CompileContext& ccontext,
|
TargetMachine &Target,
|
||||||
MachineInstr** minstrVec);
|
MachineInstr** minstrVec);
|
||||||
|
|
||||||
extern bool ThisIsAChainRule (int eruleno);
|
extern bool ThisIsAChainRule (int eruleno);
|
||||||
@ -51,7 +51,7 @@ extern bool ThisIsAChainRule (int eruleno);
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool SelectInstructionsForMethod (Method* method,
|
bool SelectInstructionsForMethod (Method* method,
|
||||||
CompileContext& ccontext);
|
TargetMachine &Target);
|
||||||
|
|
||||||
|
|
||||||
// Debugging function to print the generated instructions
|
// Debugging function to print the generated instructions
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
// $Id$ -*-c++-*-
|
|
||||||
//***************************************************************************
|
|
||||||
// class CompileContext
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
// Holds the common option and target information for a compilation run.
|
|
||||||
//
|
|
||||||
// History:
|
|
||||||
// 07/15/01 - vadve - Created
|
|
||||||
//
|
|
||||||
//**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef LLVM_LLC_COMPILECONTEXT_H
|
|
||||||
#define LLVM_LLC_COMPILECONTEXT_H
|
|
||||||
|
|
||||||
#include "llvm/Support/Unique.h"
|
|
||||||
class TargetMachine;
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// class CompileContext
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class CompileContext: public Unique {
|
|
||||||
private:
|
|
||||||
TargetMachine* targetMachine;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CompileContext(TargetMachine *Target) : targetMachine(Target) {}
|
|
||||||
~CompileContext();
|
|
||||||
|
|
||||||
const TargetMachine& getTarget () const { return *targetMachine; }
|
|
||||||
TargetMachine& getTarget () { return *targetMachine; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -16,7 +16,6 @@
|
|||||||
#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/LLC/CompileContext.h"
|
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/Tools/CommandLine.h"
|
#include "llvm/Tools/CommandLine.h"
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ cl::Enum<enum DebugLev> DebugLevel("debug_select", cl::NoFlags, // cl::Hidden
|
|||||||
//************************* Forward Declarations ***************************/
|
//************************* Forward Declarations ***************************/
|
||||||
|
|
||||||
static bool SelectInstructionsForTree(BasicTreeNode* treeRoot, int goalnt,
|
static bool SelectInstructionsForTree(BasicTreeNode* treeRoot, int goalnt,
|
||||||
CompileContext& ccontext);
|
TargetMachine &Target);
|
||||||
|
|
||||||
|
|
||||||
//******************* Externally Visible Functions *************************/
|
//******************* Externally Visible Functions *************************/
|
||||||
@ -47,7 +46,7 @@ static bool SelectInstructionsForTree(BasicTreeNode* treeRoot, int goalnt,
|
|||||||
// Returns true if instruction selection failed, false otherwise.
|
// Returns true if instruction selection failed, false otherwise.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool SelectInstructionsForMethod(Method* method, CompileContext& ccontext) {
|
bool SelectInstructionsForMethod(Method* method, TargetMachine &Target) {
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
InstrForest instrForest;
|
InstrForest instrForest;
|
||||||
@ -77,7 +76,7 @@ bool SelectInstructionsForMethod(Method* method, CompileContext& ccontext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then recursively walk the tree to select instructions
|
// Then recursively walk the tree to select instructions
|
||||||
if (SelectInstructionsForTree(basicNode, /*goalnt*/1, ccontext))
|
if (SelectInstructionsForTree(basicNode, /*goalnt*/1, Target))
|
||||||
{
|
{
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
@ -191,7 +190,7 @@ void PrintMachineInstructions(Method* method) {
|
|||||||
bool
|
bool
|
||||||
SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
||||||
int goalnt,
|
int goalnt,
|
||||||
CompileContext& ccontext)
|
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
|
||||||
static MachineInstr* minstrVec[MAX_INSTR_PER_VMINSTR];
|
static MachineInstr* minstrVec[MAX_INSTR_PER_VMINSTR];
|
||||||
@ -220,7 +219,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
InstructionNode* instrNode = (InstructionNode*) MainTreeNode(treeRoot);
|
InstructionNode* instrNode = (InstructionNode*) MainTreeNode(treeRoot);
|
||||||
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
|
assert(instrNode->getNodeType() == InstrTreeNode::NTInstructionNode);
|
||||||
|
|
||||||
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, ccontext,
|
unsigned N = GetInstructionsByRule(instrNode, ruleForNode, nts, Target,
|
||||||
minstrVec);
|
minstrVec);
|
||||||
assert(N <= MAX_INSTR_PER_VMINSTR);
|
assert(N <= MAX_INSTR_PER_VMINSTR);
|
||||||
for (unsigned i=0; i < N; i++)
|
for (unsigned i=0; i < N; i++)
|
||||||
@ -260,8 +259,7 @@ SelectInstructionsForTree(BasicTreeNode* treeRoot,
|
|||||||
if (nodeType == InstrTreeNode::NTVRegListNode ||
|
if (nodeType == InstrTreeNode::NTVRegListNode ||
|
||||||
nodeType == InstrTreeNode::NTInstructionNode)
|
nodeType == InstrTreeNode::NTInstructionNode)
|
||||||
{
|
{
|
||||||
bool failed= SelectInstructionsForTree(kids[i], nts[i],ccontext);
|
if (SelectInstructionsForTree(kids[i], nts[i], Target))
|
||||||
if (failed)
|
|
||||||
return true; // failure
|
return true; // failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
// 7/02/01 - Vikram Adve - Created
|
// 7/02/01 - Vikram Adve - Created
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
//*************************** User Include Files ***************************/
|
|
||||||
|
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/SymbolTable.h"
|
#include "llvm/SymbolTable.h"
|
||||||
@ -23,7 +21,6 @@
|
|||||||
#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/LLC/CompileContext.h"
|
|
||||||
#include "llvm/CodeGen/Sparc.h"
|
#include "llvm/CodeGen/Sparc.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/CodeGen/InstrForest.h"
|
#include "llvm/CodeGen/InstrForest.h"
|
||||||
@ -148,7 +145,7 @@ unsigned
|
|||||||
GetInstructionsByRule(InstructionNode* subtreeRoot,
|
GetInstructionsByRule(InstructionNode* subtreeRoot,
|
||||||
int ruleForNode,
|
int ruleForNode,
|
||||||
short* nts,
|
short* nts,
|
||||||
CompileContext& ccontext,
|
TargetMachine &Target,
|
||||||
MachineInstr** mvec)
|
MachineInstr** mvec)
|
||||||
{
|
{
|
||||||
int numInstr = 1; // initialize for common case
|
int numInstr = 1; // initialize for common case
|
||||||
@ -183,7 +180,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
case 3: // stmt: Store(reg,reg)
|
case 3: // stmt: Store(reg,reg)
|
||||||
case 4: // stmt: Store(reg,ptrreg)
|
case 4: // stmt: Store(reg,ptrreg)
|
||||||
mvec[0] = new MachineInstr(ChooseStoreInstruction(subtreeRoot->leftChild()->getValue()->getType()));
|
mvec[0] = new MachineInstr(ChooseStoreInstruction(subtreeRoot->leftChild()->getValue()->getType()));
|
||||||
SetOperandsForMemInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
SetOperandsForMemInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // stmt: BrUncond
|
case 5: // stmt: BrUncond
|
||||||
@ -307,7 +304,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mvec[0] =new MachineInstr(ChooseConvertToIntInstr(subtreeRoot,opType));
|
mvec[0] =new MachineInstr(ChooseConvertToIntInstr(subtreeRoot,opType));
|
||||||
Set2OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set2OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -329,7 +326,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
{
|
{
|
||||||
opType = subtreeRoot->leftChild()->getValue()->getType();
|
opType = subtreeRoot->leftChild()->getValue()->getType();
|
||||||
mvec[0] = new MachineInstr(ChooseConvertToFloatInstr(subtreeRoot, opType));
|
mvec[0] = new MachineInstr(ChooseConvertToFloatInstr(subtreeRoot, opType));
|
||||||
Set2OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set2OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -340,12 +337,12 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
|
|
||||||
case 33: // reg: Add(reg, reg)
|
case 33: // reg: Add(reg, reg)
|
||||||
mvec[0] = new MachineInstr(ChooseAddInstruction(subtreeRoot));
|
mvec[0] = new MachineInstr(ChooseAddInstruction(subtreeRoot));
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 34: // reg: Sub(reg, reg)
|
case 34: // reg: Sub(reg, reg)
|
||||||
mvec[0] = new MachineInstr(ChooseSubInstruction(subtreeRoot));
|
mvec[0] = new MachineInstr(ChooseSubInstruction(subtreeRoot));
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 135: // reg: Mul(todouble, todouble)
|
case 135: // reg: Mul(todouble, todouble)
|
||||||
@ -354,12 +351,12 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
|
|
||||||
case 35: // reg: Mul(reg, reg)
|
case 35: // reg: Mul(reg, reg)
|
||||||
mvec[0] = new MachineInstr(ChooseMulInstruction(subtreeRoot, checkCast));
|
mvec[0] = new MachineInstr(ChooseMulInstruction(subtreeRoot, checkCast));
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 36: // reg: Div(reg, reg)
|
case 36: // reg: Div(reg, reg)
|
||||||
mvec[0] = new MachineInstr(ChooseDivInstruction(subtreeRoot));
|
mvec[0] = new MachineInstr(ChooseDivInstruction(subtreeRoot));
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 37: // reg: Rem(reg, reg)
|
case 37: // reg: Rem(reg, reg)
|
||||||
@ -368,32 +365,32 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
|
|
||||||
case 38: // reg: And(reg, reg)
|
case 38: // reg: And(reg, reg)
|
||||||
mvec[0] = new MachineInstr(AND);
|
mvec[0] = new MachineInstr(AND);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 138: // reg: And(reg, not)
|
case 138: // reg: And(reg, not)
|
||||||
mvec[0] = new MachineInstr(ANDN);
|
mvec[0] = new MachineInstr(ANDN);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 39: // reg: Or(reg, reg)
|
case 39: // reg: Or(reg, reg)
|
||||||
mvec[0] = new MachineInstr(ORN);
|
mvec[0] = new MachineInstr(ORN);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 139: // reg: Or(reg, not)
|
case 139: // reg: Or(reg, not)
|
||||||
mvec[0] = new MachineInstr(ORN);
|
mvec[0] = new MachineInstr(ORN);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 40: // reg: Xor(reg, reg)
|
case 40: // reg: Xor(reg, reg)
|
||||||
mvec[0] = new MachineInstr(XOR);
|
mvec[0] = new MachineInstr(XOR);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 140: // reg: Xor(reg, not)
|
case 140: // reg: Xor(reg, not)
|
||||||
mvec[0] = new MachineInstr(XNOR);
|
mvec[0] = new MachineInstr(XNOR);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 41: // boolconst: SetCC(reg, Constant)
|
case 41: // boolconst: SetCC(reg, Constant)
|
||||||
@ -430,7 +427,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
{
|
{
|
||||||
// integer condition: destination should be %g0
|
// integer condition: destination should be %g0
|
||||||
mvec[0] = new MachineInstr(SUBcc);
|
mvec[0] = new MachineInstr(SUBcc);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget(),
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target,
|
||||||
/*canDiscardResult*/ true);
|
/*canDiscardResult*/ true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -456,7 +453,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
case 53: // reg: LoadIdx(reg,reg)
|
case 53: // reg: LoadIdx(reg,reg)
|
||||||
case 54: // reg: LoadIdx(ptrreg,reg)
|
case 54: // reg: LoadIdx(ptrreg,reg)
|
||||||
mvec[0] = new MachineInstr(ChooseLoadInstruction(subtreeRoot->getValue()->getType()));
|
mvec[0] = new MachineInstr(ChooseLoadInstruction(subtreeRoot->getValue()->getType()));
|
||||||
SetOperandsForMemInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
SetOperandsForMemInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 55: // reg: GetElemPtr(reg)
|
case 55: // reg: GetElemPtr(reg)
|
||||||
@ -476,7 +473,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
}
|
}
|
||||||
// else in all other cases we need to a separate ADD instruction
|
// else in all other cases we need to a separate ADD instruction
|
||||||
mvec[0] = new MachineInstr(ADD);
|
mvec[0] = new MachineInstr(ADD);
|
||||||
SetOperandsForMemInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
SetOperandsForMemInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 57: // reg: Alloca: Implement as 2 instructions:
|
case 57: // reg: Alloca: Implement as 2 instructions:
|
||||||
@ -485,8 +482,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
Instruction* instr = subtreeRoot->getInstruction();
|
Instruction* instr = subtreeRoot->getInstruction();
|
||||||
const PointerType* instrType = (const PointerType*) instr->getType();
|
const PointerType* instrType = (const PointerType*) instr->getType();
|
||||||
assert(instrType->isPointerType());
|
assert(instrType->isPointerType());
|
||||||
int tsize = (int) ccontext.getTarget().findOptimalStorageSize(
|
int tsize = (int) Target.findOptimalStorageSize(instrType->getValueType());
|
||||||
instrType->getValueType());
|
|
||||||
if (tsize == 0)
|
if (tsize == 0)
|
||||||
{
|
{
|
||||||
numInstr = 0;
|
numInstr = 0;
|
||||||
@ -528,7 +524,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
instrType->getValueType()->isArrayType());
|
instrType->getValueType()->isArrayType());
|
||||||
const Type* eltType =
|
const Type* eltType =
|
||||||
((ArrayType*) instrType->getValueType())->getElementType();
|
((ArrayType*) instrType->getValueType())->getElementType();
|
||||||
int tsize = (int) ccontext.getTarget().findOptimalStorageSize(eltType);
|
int tsize = (int) Target.findOptimalStorageSize(eltType);
|
||||||
|
|
||||||
if (tsize == 0)
|
if (tsize == 0)
|
||||||
{
|
{
|
||||||
@ -600,7 +596,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
opType = subtreeRoot->leftChild()->getValue()->getType();
|
opType = subtreeRoot->leftChild()->getValue()->getType();
|
||||||
assert(opType->isIntegral() || opType == Type::BoolTy);
|
assert(opType->isIntegral() || opType == Type::BoolTy);
|
||||||
mvec[0] = new MachineInstr((opType == Type::LongTy)? SLLX : SLL);
|
mvec[0] = new MachineInstr((opType == Type::LongTy)? SLLX : SLL);
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 63: // reg: Shr(reg, reg)
|
case 63: // reg: Shr(reg, reg)
|
||||||
@ -609,7 +605,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
mvec[0] = new MachineInstr((opType->isSigned()
|
mvec[0] = new MachineInstr((opType->isSigned()
|
||||||
? ((opType == Type::LongTy)? SRAX : SRA)
|
? ((opType == Type::LongTy)? SRAX : SRA)
|
||||||
: ((opType == Type::LongTy)? SRLX : SRL)));
|
: ((opType == Type::LongTy)? SRLX : SRL)));
|
||||||
Set3OperandsFromInstr(mvec[0], subtreeRoot, ccontext.getTarget());
|
Set3OperandsFromInstr(mvec[0], subtreeRoot, Target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 71: // reg: VReg
|
case 71: // reg: VReg
|
||||||
@ -642,7 +638,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
&& "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->getBasicNode()->state, nts[0]);
|
||||||
nts = burm_nts[nextRule];
|
nts = burm_nts[nextRule];
|
||||||
numInstr = GetInstructionsByRule(subtreeRoot, nextRule, nts,ccontext,mvec);
|
numInstr = GetInstructionsByRule(subtreeRoot, nextRule, nts,Target,mvec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -651,7 +647,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
numInstr =
|
numInstr =
|
||||||
FixConstantOperands(subtreeRoot, mvec, numInstr, ccontext.getTarget());
|
FixConstantOperands(subtreeRoot, mvec, numInstr, Target);
|
||||||
|
|
||||||
return numInstr;
|
return numInstr;
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,13 @@
|
|||||||
#include "llvm/Bytecode/Reader.h"
|
#include "llvm/Bytecode/Reader.h"
|
||||||
#include "llvm/Bytecode/Writer.h"
|
#include "llvm/Bytecode/Writer.h"
|
||||||
#include "llvm/CodeGen/InstrSelection.h"
|
#include "llvm/CodeGen/InstrSelection.h"
|
||||||
#include "llvm/LLC/CompileContext.h"
|
|
||||||
#include "llvm/CodeGen/Sparc.h"
|
#include "llvm/CodeGen/Sparc.h"
|
||||||
#include "llvm/Tools/CommandLine.h"
|
#include "llvm/Tools/CommandLine.h"
|
||||||
|
|
||||||
cl::String InputFilename ("", "Input filename", cl::NoFlags, "");
|
cl::String InputFilename ("", "Input filename", cl::NoFlags, "");
|
||||||
cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
|
cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
|
||||||
|
|
||||||
|
static bool CompileModule(Module *module, TargetMachine &Target) {
|
||||||
CompileContext::~CompileContext() { delete targetMachine; }
|
|
||||||
|
|
||||||
static bool CompileModule(Module *module, CompileContext& ccontext) {
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
for (Module::MethodListType::const_iterator
|
for (Module::MethodListType::const_iterator
|
||||||
@ -36,7 +32,7 @@ static bool CompileModule(Module *module, CompileContext& ccontext) {
|
|||||||
{
|
{
|
||||||
Method* method = *methodIter;
|
Method* method = *methodIter;
|
||||||
|
|
||||||
if (SelectInstructionsForMethod(method, ccontext))
|
if (SelectInstructionsForMethod(method, Target))
|
||||||
{
|
{
|
||||||
failed = true;
|
failed = true;
|
||||||
cerr << "Instruction selection failed for method "
|
cerr << "Instruction selection failed for method "
|
||||||
@ -56,7 +52,7 @@ static bool CompileModule(Module *module, CompileContext& ccontext) {
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
|
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
|
||||||
CompileContext compileContext(new UltraSparc());
|
UltraSparc Target;
|
||||||
|
|
||||||
Module *module = ParseBytecodeFile(InputFilename.getValue());
|
Module *module = ParseBytecodeFile(InputFilename.getValue());
|
||||||
if (module == 0) {
|
if (module == 0) {
|
||||||
@ -64,7 +60,7 @@ int main(int argc, char** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool failure = CompileModule(module, compileContext);
|
bool failure = CompileModule(module, Target);
|
||||||
|
|
||||||
if (failure) {
|
if (failure) {
|
||||||
cerr << "Error compiling "
|
cerr << "Error compiling "
|
||||||
|
Loading…
Reference in New Issue
Block a user