mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
Support for annul/pred and other future flags on op codes.
Support for recording the physical register for implcit references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6471 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
5cdb12f958
commit
9f495b54fa
1 file changed
+51
-14
@@ -13,6 +13,7 @@
|
|||||||
#include "Support/Annotation.h"
|
#include "Support/Annotation.h"
|
||||||
#include "Support/NonCopyable.h"
|
#include "Support/NonCopyable.h"
|
||||||
#include "Support/iterator"
|
#include "Support/iterator"
|
||||||
|
#include <set>
|
||||||
class Value;
|
class Value;
|
||||||
class Function;
|
class Function;
|
||||||
class MachineBasicBlock;
|
class MachineBasicBlock;
|
||||||
@@ -21,12 +22,27 @@ class GlobalValue;
|
|||||||
|
|
||||||
typedef int MachineOpCode;
|
typedef int MachineOpCode;
|
||||||
|
|
||||||
|
///---------------------------------------------------------------------------
|
||||||
|
/// Special flags on instructions that modify the opcode.
|
||||||
|
/// These flags are unused for now, but having them enforces that some
|
||||||
|
/// changes will be needed if they are used.
|
||||||
|
///---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
enum MachineOpCodeFlags {
|
||||||
|
AnnulFlag, /// 1 if annul bit is set on a branch
|
||||||
|
PredTakenFlag, /// 1 if branch should be predicted taken
|
||||||
|
PredNotTakenFlag /// 1 if branch should be predicted not taken
|
||||||
|
};
|
||||||
|
|
||||||
|
///---------------------------------------------------------------------------
|
||||||
/// MOTy - MachineOperandType - This namespace contains an enum that describes
|
/// MOTy - MachineOperandType - This namespace contains an enum that describes
|
||||||
/// how the machine operand is used by the instruction: is it read, defined, or
|
/// how the machine operand is used by the instruction: is it read, defined, or
|
||||||
/// both? Note that the MachineInstr/Operator class currently uses bool
|
/// both? Note that the MachineInstr/Operator class currently uses bool
|
||||||
/// arguments to represent this information instead of an enum. Eventually this
|
/// arguments to represent this information instead of an enum. Eventually this
|
||||||
/// should change over to use this _easier to read_ representation instead.
|
/// should change over to use this _easier to read_ representation instead.
|
||||||
///
|
///
|
||||||
|
///---------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace MOTy {
|
namespace MOTy {
|
||||||
enum UseType {
|
enum UseType {
|
||||||
Use, /// This machine operand is only read by the instruction
|
Use, /// This machine operand is only read by the instruction
|
||||||
@@ -275,16 +291,15 @@ public:
|
|||||||
|
|
||||||
// used to get the reg number if when one is allocated
|
// used to get the reg number if when one is allocated
|
||||||
int getAllocatedRegNum() const {
|
int getAllocatedRegNum() const {
|
||||||
assert(opType == MO_VirtualRegister || opType == MO_CCRegister ||
|
assert(hasAllocatedReg());
|
||||||
opType == MO_MachineRegister);
|
|
||||||
return regNum;
|
return regNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ********** TODO: get rid of this duplicate code! ***********
|
||||||
unsigned getReg() const {
|
unsigned getReg() const {
|
||||||
assert(hasAllocatedReg() && "Cannot call MachineOperand::getReg()!");
|
return getAllocatedRegNum();
|
||||||
return regNum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
|
friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -329,12 +344,13 @@ private:
|
|||||||
class MachineInstr: public NonCopyable { // Disable copy operations
|
class MachineInstr: public NonCopyable { // Disable copy operations
|
||||||
|
|
||||||
MachineOpCode opCode; // the opcode
|
MachineOpCode opCode; // the opcode
|
||||||
|
unsigned opCodeFlags; // flags modifying instrn behavior
|
||||||
std::vector<MachineOperand> operands; // the operands
|
std::vector<MachineOperand> operands; // the operands
|
||||||
unsigned numImplicitRefs; // number of implicit operands
|
unsigned numImplicitRefs; // number of implicit operands
|
||||||
|
|
||||||
// regsUsed - all machine registers used for this instruction, including regs
|
// regsUsed - all machine registers used for this instruction, including regs
|
||||||
// used to save values across the instruction. This is a bitset of registers.
|
// used to save values across the instruction. This is a bitset of registers.
|
||||||
std::vector<bool> regsUsed;
|
std::set<int> regsUsed;
|
||||||
|
|
||||||
// OperandComplete - Return true if it's illegal to add a new operand
|
// OperandComplete - Return true if it's illegal to add a new operand
|
||||||
bool OperandsComplete() const;
|
bool OperandsComplete() const;
|
||||||
@@ -361,6 +377,10 @@ public:
|
|||||||
const MachineOpCode getOpcode() const { return opCode; }
|
const MachineOpCode getOpcode() const { return opCode; }
|
||||||
const MachineOpCode getOpCode() const { return opCode; }
|
const MachineOpCode getOpCode() const { return opCode; }
|
||||||
|
|
||||||
|
// Opcode flags.
|
||||||
|
//
|
||||||
|
unsigned getOpCodeFlags() const { return opCodeFlags; }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Access to explicit operands of the instruction
|
// Access to explicit operands of the instruction
|
||||||
//
|
//
|
||||||
@@ -375,6 +395,18 @@ public:
|
|||||||
return operands[i];
|
return operands[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Access to explicit or implicit operands of the instruction
|
||||||
|
// This returns the i'th entry in the operand vector.
|
||||||
|
// That represents the i'th explicit operand or the (i-N)'th implicit operand,
|
||||||
|
// depending on whether i < N or i >= N.
|
||||||
|
//
|
||||||
|
const MachineOperand& getExplOrImplOperand(unsigned i) const {
|
||||||
|
assert(i < operands.size() && "getExplOrImplOperand() out of range!");
|
||||||
|
return (i < getNumOperands()? getOperand(i)
|
||||||
|
: getImplicitOp(i - getNumOperands()));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Access to implicit operands of the instruction
|
// Access to implicit operands of the instruction
|
||||||
//
|
//
|
||||||
@@ -402,15 +434,18 @@ public:
|
|||||||
bool isDef=false, bool isDefAndUse=false);
|
bool isDef=false, bool isDefAndUse=false);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Information about registers used in this instruction
|
// Information about registers used in this instruction.
|
||||||
//
|
//
|
||||||
const std::vector<bool> &getRegsUsed() const { return regsUsed; }
|
const std::set<int> &getRegsUsed() const {
|
||||||
|
return regsUsed;
|
||||||
|
}
|
||||||
|
bool isRegUsed(int regNum) const {
|
||||||
|
return regsUsed.find(regNum) != regsUsed.end();
|
||||||
|
}
|
||||||
|
|
||||||
// insertUsedReg - Add a register to the Used registers set...
|
// insertusedreg - Add a register to the Used registers set...
|
||||||
void insertUsedReg(unsigned Reg) {
|
void insertUsedReg(unsigned Reg) {
|
||||||
if (Reg >= regsUsed.size())
|
regsUsed.insert((int) Reg);
|
||||||
regsUsed.resize(Reg+1);
|
|
||||||
regsUsed[Reg] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -612,10 +647,12 @@ public:
|
|||||||
void setOperandLo64(unsigned i) { operands[i].markLo64(); }
|
void setOperandLo64(unsigned i) { operands[i].markLo64(); }
|
||||||
|
|
||||||
|
|
||||||
// SetRegForOperand - Replaces the Value for the operand with its allocated
|
// SetRegForOperand -
|
||||||
// physical register after register allocation is complete.
|
// SetRegForImplicitRef -
|
||||||
|
// Mark an explicit or implicit operand with its allocated physical register.
|
||||||
//
|
//
|
||||||
void SetRegForOperand(unsigned i, int regNum);
|
void SetRegForOperand(unsigned i, int regNum);
|
||||||
|
void SetRegForImplicitRef(unsigned i, int regNum);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Iterator to enumerate machine operands.
|
// Iterator to enumerate machine operands.
|
||||||
|
|||||||
Reference in new issue
Block a user