mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-29 08:16:51 +00:00
Moved code generation support routines to InstrSelectionSupport.{h,cpp}.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@718 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -4,10 +4,11 @@
|
|||||||
// InstrSelection.h
|
// InstrSelection.h
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
|
// External interface to instruction selection.
|
||||||
//
|
//
|
||||||
// History:
|
// History:
|
||||||
// 7/02/01 - Vikram Adve - Created
|
// 7/02/01 - Vikram Adve - Created
|
||||||
//***************************************************************************
|
//**************************************************************************/
|
||||||
|
|
||||||
#ifndef LLVM_CODEGEN_INSTR_SELECTION_H
|
#ifndef LLVM_CODEGEN_INSTR_SELECTION_H
|
||||||
#define LLVM_CODEGEN_INSTR_SELECTION_H
|
#define LLVM_CODEGEN_INSTR_SELECTION_H
|
||||||
@@ -21,10 +22,10 @@ class TmpInstruction;
|
|||||||
class ConstPoolVal;
|
class ConstPoolVal;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// GLOBAL data and an external function that must be implemented
|
/************************* Required Functions *******************************
|
||||||
// for each architecture.
|
* Target-dependent functions that MUST be implemented for each target.
|
||||||
//---------------------------------------------------------------------------
|
***************************************************************************/
|
||||||
|
|
||||||
const unsigned MAX_INSTR_PER_VMINSTR = 8;
|
const unsigned MAX_INSTR_PER_VMINSTR = 8;
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ extern unsigned GetInstructionsByRule (InstructionNode* subtreeRoot,
|
|||||||
extern bool ThisIsAChainRule (int eruleno);
|
extern bool ThisIsAChainRule (int eruleno);
|
||||||
|
|
||||||
|
|
||||||
//************************ Exported Data Types *****************************/
|
//************************ Exported Functions ******************************/
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -52,17 +53,8 @@ extern bool ThisIsAChainRule (int eruleno);
|
|||||||
bool SelectInstructionsForMethod (Method* method,
|
bool SelectInstructionsForMethod (Method* method,
|
||||||
TargetMachine &Target);
|
TargetMachine &Target);
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// Function: FoldGetElemChain
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
// Fold a chain of GetElementPtr instructions into an equivalent
|
|
||||||
// (Pointer, IndexVector) pair. Returns the pointer Value, and
|
|
||||||
// stores the resulting IndexVector in argument chainIdxVec.
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
|
//************************ Exported Data Types *****************************/
|
||||||
vector<ConstPoolVal*>& chainIdxVec);
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -381,17 +381,20 @@ class MachineCodeForVMInstr: public vector<MachineInstr*>
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
vector<Value*> tempVec; // used by m/c instr but not VM instr
|
vector<Value*> tempVec; // used by m/c instr but not VM instr
|
||||||
vector<const Value*> implicitUses; // used by VM instr but not m/c instr
|
vector<Value*> implicitUses; // used by VM instr but not m/c instr
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*ctor*/ MachineCodeForVMInstr () {}
|
/*ctor*/ MachineCodeForVMInstr () {}
|
||||||
/*ctor*/ ~MachineCodeForVMInstr ();
|
/*ctor*/ ~MachineCodeForVMInstr ();
|
||||||
|
|
||||||
const vector<Value*>& getTempValues () const { return tempVec; }
|
const vector<Value*>& getTempValues () const { return tempVec; }
|
||||||
const vector<const Value*>& getImplicitUses() const { return implicitUses; }
|
vector<Value*>& getTempValues () { return tempVec; }
|
||||||
|
|
||||||
|
const vector<Value*>& getImplicitUses() const { return implicitUses; }
|
||||||
|
vector<Value*>& getImplicitUses() { return implicitUses; }
|
||||||
|
|
||||||
void addTempValue (Value* val) { tempVec.push_back(val); }
|
void addTempValue (Value* val) { tempVec.push_back(val); }
|
||||||
void addImplicitUse(const Value* val) { implicitUses.push_back(val);}
|
void addImplicitUse(Value* val) { implicitUses.push_back(val);}
|
||||||
|
|
||||||
// dropAllReferences() - This function drops all references within
|
// dropAllReferences() - This function drops all references within
|
||||||
// temporary (hidden) instructions created in implementing the original
|
// temporary (hidden) instructions created in implementing the original
|
||||||
@@ -437,58 +440,10 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Target-independent utility routines for creating machine instructions
|
// Debugging Support
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
// Function Set2OperandsFromInstr
|
|
||||||
// Function Set3OperandsFromInstr
|
|
||||||
//
|
|
||||||
// For the common case of 2- and 3-operand arithmetic/logical instructions,
|
|
||||||
// set the m/c instr. operands directly from the VM instruction's operands.
|
|
||||||
// Check whether the first or second operand is 0 and can use a dedicated
|
|
||||||
// "0" register.
|
|
||||||
// Check whether the second operand should use an immediate field or register.
|
|
||||||
// (First and third operands are never immediates for such instructions.)
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// canDiscardResult: Specifies that the result operand can be discarded
|
|
||||||
// by using the dedicated "0"
|
|
||||||
//
|
|
||||||
// op1position, op2position and resultPosition: Specify in which position
|
|
||||||
// in the machine instruction the 3 operands (arg1, arg2
|
|
||||||
// and result) should go.
|
|
||||||
//
|
|
||||||
// RETURN VALUE: unsigned int flags, where
|
|
||||||
// flags & 0x01 => operand 1 is constant and needs a register
|
|
||||||
// flags & 0x02 => operand 2 is constant and needs a register
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void Set2OperandsFromInstr (MachineInstr* minstr,
|
|
||||||
InstructionNode* vmInstrNode,
|
|
||||||
const TargetMachine& targetMachine,
|
|
||||||
bool canDiscardResult = false,
|
|
||||||
int op1Position = 0,
|
|
||||||
int resultPosition = 1);
|
|
||||||
|
|
||||||
void Set3OperandsFromInstr (MachineInstr* minstr,
|
|
||||||
InstructionNode* vmInstrNode,
|
|
||||||
const TargetMachine& targetMachine,
|
|
||||||
bool canDiscardResult = false,
|
|
||||||
int op1Position = 0,
|
|
||||||
int op2Position = 1,
|
|
||||||
int resultPosition = 2);
|
|
||||||
|
|
||||||
MachineOperand::MachineOperandType
|
|
||||||
ChooseRegOrImmed(Value* val,
|
|
||||||
MachineOpCode opCode,
|
|
||||||
const TargetMachine& targetMachine,
|
|
||||||
bool canUseImmed,
|
|
||||||
unsigned int& getMachineRegNum,
|
|
||||||
int64_t& getImmedValue);
|
|
||||||
|
|
||||||
|
|
||||||
ostream& operator<< (ostream& os, const MachineInstr& minstr);
|
ostream& operator<< (ostream& os, const MachineInstr& minstr);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user