summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGeoff Berry <gberry@codeaurora.org>2017-12-12 17:53:59 +0000
committerGeoff Berry <gberry@codeaurora.org>2017-12-12 17:53:59 +0000
commit3b391fe80e65f144d9e2e31a09e24f00ac7bb230 (patch)
tree2e73cc0bf11d06fa2c54f3d8b37e17a40fda4cf8 /include
parent9cc4cf09cace7a496734dfcfb5fd3227290e6cdf (diff)
[MachineOperand][MIR] Add isRenamable to MachineOperand.
Summary: Add isRenamable() predicate to MachineOperand. This predicate can be used by machine passes after register allocation to determine whether it is safe to rename a given register operand. Register operands that aren't marked as renamable may be required to be assigned their current register to satisfy constraints that are not captured by the machine IR (e.g. ABI or ISA constraints). Reviewers: qcolombet, MatzeB, hfinkel Subscribers: nemanjai, mcrosier, javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D39400 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320503 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h13
-rw-r--r--include/llvm/CodeGen/MachineOperand.h49
2 files changed, 43 insertions, 19 deletions
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index 9e0f19a5aea..e4f3976ec95 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -25,6 +25,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineOperand.h"
+#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/Support/ErrorHandling.h"
@@ -48,6 +49,7 @@ namespace RegState {
EarlyClobber = 0x40,
Debug = 0x80,
InternalRead = 0x100,
+ Renamable = 0x200,
DefineNoRead = Define | Undef,
ImplicitDefine = Implicit | Define,
ImplicitKill = Implicit | Kill
@@ -91,7 +93,8 @@ public:
flags & RegState::EarlyClobber,
SubReg,
flags & RegState::Debug,
- flags & RegState::InternalRead));
+ flags & RegState::InternalRead,
+ flags & RegState::Renamable));
return *this;
}
@@ -443,6 +446,9 @@ inline unsigned getInternalReadRegState(bool B) {
inline unsigned getDebugRegState(bool B) {
return B ? RegState::Debug : 0;
}
+inline unsigned getRenamableRegState(bool B) {
+ return B ? RegState::Renamable : 0;
+}
/// Get all register state flags from machine operand \p RegOp.
inline unsigned getRegState(const MachineOperand &RegOp) {
@@ -453,7 +459,10 @@ inline unsigned getRegState(const MachineOperand &RegOp) {
getDeadRegState(RegOp.isDead()) |
getUndefRegState(RegOp.isUndef()) |
getInternalReadRegState(RegOp.isInternalRead()) |
- getDebugRegState(RegOp.isDebug());
+ getDebugRegState(RegOp.isDebug()) |
+ getRenamableRegState(
+ TargetRegisterInfo::isPhysicalRegister(RegOp.getReg()) &&
+ RegOp.isRenamable());
}
/// Helper class for constructing bundles of MachineInstrs.
diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h
index a7043ea90e3..c235649c009 100644
--- a/include/llvm/CodeGen/MachineOperand.h
+++ b/include/llvm/CodeGen/MachineOperand.h
@@ -86,24 +86,30 @@ private:
/// before MachineInstr::tieOperands().
unsigned char TiedTo : 4;
- /// IsDef/IsImp/IsKill/IsDead flags - These are only valid for MO_Register
- /// operands.
-
/// IsDef - True if this is a def, false if this is a use of the register.
+ /// This is only valid on register operands.
///
bool IsDef : 1;
/// IsImp - True if this is an implicit def or use, false if it is explicit.
+ /// This is only valid on register opderands.
///
bool IsImp : 1;
- /// IsKill - True if this instruction is the last use of the register on this
- /// path through the function. This is only valid on uses of registers.
- bool IsKill : 1;
-
- /// IsDead - True if this register is never used by a subsequent instruction.
- /// This is only valid on definitions of registers.
- bool IsDead : 1;
+ /// IsDeadOrKill
+ /// For uses: IsKill - True if this instruction is the last use of the
+ /// register on this path through the function.
+ /// For defs: IsDead - True if this register is never used by a subsequent
+ /// instruction.
+ /// This is only valid on register operands.
+ bool IsDeadOrKill : 1;
+
+ /// IsRenamable - True if this register may be renamed, i.e. it does not
+ /// generate a value that is somehow read in a way that is not represented by
+ /// the Machine IR (e.g. to meet an ABI or ISA requirement). This is only
+ /// valid on physical register operands. Virtual registers are assumed to
+ /// always be renamable regardless of the value of this field.
+ bool IsRenamable : 1;
/// IsUndef - True if this register operand reads an "undef" value, i.e. the
/// read value doesn't matter. This flag can be set on both use and def
@@ -333,12 +339,12 @@ public:
bool isDead() const {
assert(isReg() && "Wrong MachineOperand accessor");
- return IsDead;
+ return IsDeadOrKill & IsDef;
}
bool isKill() const {
assert(isReg() && "Wrong MachineOperand accessor");
- return IsKill;
+ return IsDeadOrKill & !IsDef;
}
bool isUndef() const {
@@ -346,6 +352,8 @@ public:
return IsUndef;
}
+ bool isRenamable() const;
+
bool isInternalRead() const {
assert(isReg() && "Wrong MachineOperand accessor");
return IsInternalRead;
@@ -418,12 +426,12 @@ public:
void setIsKill(bool Val = true) {
assert(isReg() && !IsDef && "Wrong MachineOperand mutator");
assert((!Val || !isDebug()) && "Marking a debug operation as kill");
- IsKill = Val;
+ IsDeadOrKill = Val;
}
void setIsDead(bool Val = true) {
assert(isReg() && IsDef && "Wrong MachineOperand mutator");
- IsDead = Val;
+ IsDeadOrKill = Val;
}
void setIsUndef(bool Val = true) {
@@ -431,6 +439,12 @@ public:
IsUndef = Val;
}
+ void setIsRenamable(bool Val = true);
+
+ /// Set IsRenamable to true if there are no extra register allocation
+ /// requirements placed on this operand by the parent instruction's opcode.
+ void setIsRenamableIfNoExtraRegAllocReq();
+
void setIsInternalRead(bool Val = true) {
assert(isReg() && "Wrong MachineOperand mutator");
IsInternalRead = Val;
@@ -675,14 +689,15 @@ public:
bool isUndef = false,
bool isEarlyClobber = false,
unsigned SubReg = 0, bool isDebug = false,
- bool isInternalRead = false) {
+ bool isInternalRead = false,
+ bool isRenamable = false) {
assert(!(isDead && !isDef) && "Dead flag on non-def");
assert(!(isKill && isDef) && "Kill flag on def");
MachineOperand Op(MachineOperand::MO_Register);
Op.IsDef = isDef;
Op.IsImp = isImp;
- Op.IsKill = isKill;
- Op.IsDead = isDead;
+ Op.IsDeadOrKill = isKill | isDead;
+ Op.IsRenamable = isRenamable;
Op.IsUndef = isUndef;
Op.IsInternalRead = isInternalRead;
Op.IsEarlyClobber = isEarlyClobber;