mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
add support for MCSymbols as operands to MachineInstrs.
llvm-svn: 98433
This commit is contained in:
parent
f26e0336c2
commit
533e5c8ffd
@ -28,6 +28,7 @@ class MachineRegisterInfo;
|
||||
class MDNode;
|
||||
class TargetMachine;
|
||||
class raw_ostream;
|
||||
class MCSymbol;
|
||||
|
||||
/// MachineOperand class - Representation of each machine instruction operand.
|
||||
///
|
||||
@ -44,7 +45,8 @@ public:
|
||||
MO_ExternalSymbol, ///< Name of external global symbol
|
||||
MO_GlobalAddress, ///< Address of a global value
|
||||
MO_BlockAddress, ///< Address of a basic block
|
||||
MO_Metadata ///< Metadata reference (for debug info)
|
||||
MO_Metadata, ///< Metadata reference (for debug info)
|
||||
MO_MCSymbol ///< MCSymbol reference (for debug/eh info)
|
||||
};
|
||||
|
||||
private:
|
||||
@ -101,6 +103,7 @@ private:
|
||||
const ConstantFP *CFP; // For MO_FPImmediate.
|
||||
int64_t ImmVal; // For MO_Immediate.
|
||||
const MDNode *MD; // For MO_Metadata.
|
||||
MCSymbol *Sym; // For MO_MCSymbol
|
||||
|
||||
struct { // For MO_Register.
|
||||
unsigned RegNo;
|
||||
@ -167,6 +170,7 @@ public:
|
||||
bool isBlockAddress() const { return OpKind == MO_BlockAddress; }
|
||||
/// isMetadata - Tests if this is a MO_Metadata operand.
|
||||
bool isMetadata() const { return OpKind == MO_Metadata; }
|
||||
bool isMCSymbol() const { return OpKind == MO_MCSymbol; }
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Accessors for Register Operands
|
||||
@ -315,6 +319,11 @@ public:
|
||||
assert(isBlockAddress() && "Wrong MachineOperand accessor");
|
||||
return Contents.OffsetedInfo.Val.BA;
|
||||
}
|
||||
|
||||
MCSymbol *getMCSymbol() const {
|
||||
assert(isMCSymbol() && "Wrong MachineOperand accessor");
|
||||
return Contents.Sym;
|
||||
}
|
||||
|
||||
/// getOffset - Return the offset from the symbol in this operand. This always
|
||||
/// returns 0 for ExternalSymbol operands.
|
||||
@ -473,6 +482,12 @@ public:
|
||||
return Op;
|
||||
}
|
||||
|
||||
static MachineOperand CreateMCSymbol(MCSymbol *Sym) {
|
||||
MachineOperand Op(MachineOperand::MO_MCSymbol);
|
||||
Op.Contents.Sym = Sym;
|
||||
return Op;
|
||||
}
|
||||
|
||||
friend class MachineInstr;
|
||||
friend class MachineRegisterInfo;
|
||||
private:
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Metadata.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/Value.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
@ -23,6 +24,7 @@
|
||||
#include "llvm/CodeGen/MachineMemOperand.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/PseudoSourceValue.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/Target/TargetInstrDesc.h"
|
||||
@ -35,7 +37,6 @@
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/Metadata.h"
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -189,6 +190,8 @@ bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
|
||||
getOffset() == Other.getOffset();
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
return getBlockAddress() == Other.getBlockAddress();
|
||||
case MachineOperand::MO_MCSymbol:
|
||||
return getMCSymbol() == Other.getMCSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,6 +294,9 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
|
||||
WriteAsOperand(OS, getMetadata(), /*PrintType=*/false);
|
||||
OS << '>';
|
||||
break;
|
||||
case MachineOperand::MO_MCSymbol:
|
||||
OS << "<MCSym=" << *getMCSymbol() << '>';
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unrecognized operand type");
|
||||
}
|
||||
@ -1363,30 +1369,33 @@ MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) {
|
||||
const MachineOperand &MO = MI->getOperand(i);
|
||||
uint64_t Key = (uint64_t)MO.getType() << 32;
|
||||
switch (MO.getType()) {
|
||||
default: break;
|
||||
case MachineOperand::MO_Register:
|
||||
if (MO.isDef() && MO.getReg() &&
|
||||
TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||
continue; // Skip virtual register defs.
|
||||
Key |= MO.getReg();
|
||||
break;
|
||||
case MachineOperand::MO_Immediate:
|
||||
Key |= MO.getImm();
|
||||
break;
|
||||
case MachineOperand::MO_FrameIndex:
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
Key |= MO.getIndex();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
Key |= DenseMapInfo<void*>::getHashValue(MO.getMBB());
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
Key |= DenseMapInfo<void*>::getHashValue(MO.getGlobal());
|
||||
break;
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
Key |= DenseMapInfo<void*>::getHashValue(MO.getBlockAddress());
|
||||
break;
|
||||
default: break;
|
||||
case MachineOperand::MO_Register:
|
||||
if (MO.isDef() && MO.getReg() &&
|
||||
TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||
continue; // Skip virtual register defs.
|
||||
Key |= MO.getReg();
|
||||
break;
|
||||
case MachineOperand::MO_Immediate:
|
||||
Key |= MO.getImm();
|
||||
break;
|
||||
case MachineOperand::MO_FrameIndex:
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
Key |= MO.getIndex();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
Key |= DenseMapInfo<void*>::getHashValue(MO.getMBB());
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
Key |= DenseMapInfo<void*>::getHashValue(MO.getGlobal());
|
||||
break;
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
Key |= DenseMapInfo<void*>::getHashValue(MO.getBlockAddress());
|
||||
break;
|
||||
case MachineOperand::MO_MCSymbol:
|
||||
Key |= DenseMapInfo<void*>::getHashValue(MO.getMCSymbol());
|
||||
break;
|
||||
}
|
||||
Key += ~(Key << 32);
|
||||
Key ^= (Key >> 22);
|
||||
|
Loading…
Reference in New Issue
Block a user