1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

Add a RegisterMaskSDNode class.

This SelectionDAG node will be attached to call nodes by LowerCall(),
and eventually becomes a MO_RegisterMask MachineOperand on the
MachineInstr representing the call instruction.

LowerCall() will attach a register mask that depends on the calling
convention.

llvm-svn: 148436
This commit is contained in:
Jakob Stoklund Olesen 2012-01-18 23:52:12 +00:00
parent 700f91def8
commit acb9eccef3
7 changed files with 41 additions and 3 deletions

View File

@ -57,7 +57,7 @@ namespace ISD {
AssertSext, AssertZext, AssertSext, AssertZext,
// Various leaf nodes. // Various leaf nodes.
BasicBlock, VALUETYPE, CONDCODE, Register, BasicBlock, VALUETYPE, CONDCODE, Register, RegisterMask,
Constant, ConstantFP, Constant, ConstantFP,
GlobalAddress, GlobalTLSAddress, FrameIndex, GlobalAddress, GlobalTLSAddress, FrameIndex,
JumpTable, ConstantPool, ExternalSymbol, BlockAddress, JumpTable, ConstantPool, ExternalSymbol, BlockAddress,

View File

@ -394,6 +394,7 @@ public:
unsigned char TargetFlags = 0); unsigned char TargetFlags = 0);
SDValue getValueType(EVT); SDValue getValueType(EVT);
SDValue getRegister(unsigned Reg, EVT VT); SDValue getRegister(unsigned Reg, EVT VT);
SDValue getRegisterMask(const uint32_t *RegMask);
SDValue getEHLabel(DebugLoc dl, SDValue Root, MCSymbol *Label); SDValue getEHLabel(DebugLoc dl, SDValue Root, MCSymbol *Label);
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, SDValue getBlockAddress(const BlockAddress *BA, EVT VT,
bool isTarget = false, unsigned char TargetFlags = 0); bool isTarget = false, unsigned char TargetFlags = 0);

View File

@ -1433,6 +1433,23 @@ public:
} }
}; };
class RegisterMaskSDNode : public SDNode {
// The memory for RegMask is not owned by the node.
const uint32_t *RegMask;
friend class SelectionDAG;
RegisterMaskSDNode(const uint32_t *mask)
: SDNode(ISD::RegisterMask, DebugLoc(), getSDVTList(MVT::Untyped)),
RegMask(mask) {}
public:
const uint32_t *getRegMask() const { return RegMask; }
static bool classof(const RegisterMaskSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::RegisterMask;
}
};
class BlockAddressSDNode : public SDNode { class BlockAddressSDNode : public SDNode {
const BlockAddress *BA; const BlockAddress *BA;
unsigned char TargetFlags; unsigned char TargetFlags;

View File

@ -351,6 +351,8 @@ void InstrEmitter::AddOperand(MachineInstr *MI, SDValue Op,
MI->addOperand(MachineOperand::CreateFPImm(CFP)); MI->addOperand(MachineOperand::CreateFPImm(CFP));
} else if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(Op)) { } else if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(Op)) {
MI->addOperand(MachineOperand::CreateReg(R->getReg(), false)); MI->addOperand(MachineOperand::CreateReg(R->getReg(), false));
} else if (RegisterMaskSDNode *RM = dyn_cast<RegisterMaskSDNode>(Op)) {
MI->addOperand(MachineOperand::CreateRegMask(RM->getRegMask()));
} else if (GlobalAddressSDNode *TGA = dyn_cast<GlobalAddressSDNode>(Op)) { } else if (GlobalAddressSDNode *TGA = dyn_cast<GlobalAddressSDNode>(Op)) {
MI->addOperand(MachineOperand::CreateGA(TGA->getGlobal(), TGA->getOffset(), MI->addOperand(MachineOperand::CreateGA(TGA->getGlobal(), TGA->getOffset(),
TGA->getTargetFlags())); TGA->getTargetFlags()));

View File

@ -53,6 +53,7 @@ namespace llvm {
if (isa<ConstantSDNode>(Node)) return true; if (isa<ConstantSDNode>(Node)) return true;
if (isa<ConstantFPSDNode>(Node)) return true; if (isa<ConstantFPSDNode>(Node)) return true;
if (isa<RegisterSDNode>(Node)) return true; if (isa<RegisterSDNode>(Node)) return true;
if (isa<RegisterMaskSDNode>(Node)) return true;
if (isa<GlobalAddressSDNode>(Node)) return true; if (isa<GlobalAddressSDNode>(Node)) return true;
if (isa<BasicBlockSDNode>(Node)) return true; if (isa<BasicBlockSDNode>(Node)) return true;
if (isa<FrameIndexSDNode>(Node)) return true; if (isa<FrameIndexSDNode>(Node)) return true;

View File

@ -383,7 +383,9 @@ static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
case ISD::Register: case ISD::Register:
ID.AddInteger(cast<RegisterSDNode>(N)->getReg()); ID.AddInteger(cast<RegisterSDNode>(N)->getReg());
break; break;
case ISD::RegisterMask:
ID.AddPointer(cast<RegisterMaskSDNode>(N)->getRegMask());
break;
case ISD::SRCVALUE: case ISD::SRCVALUE:
ID.AddPointer(cast<SrcValueSDNode>(N)->getValue()); ID.AddPointer(cast<SrcValueSDNode>(N)->getValue());
break; break;
@ -1375,6 +1377,20 @@ SDValue SelectionDAG::getRegister(unsigned RegNo, EVT VT) {
return SDValue(N, 0); return SDValue(N, 0);
} }
SDValue SelectionDAG::getRegisterMask(const uint32_t *RegMask) {
FoldingSetNodeID ID;
AddNodeIDNode(ID, ISD::RegisterMask, getVTList(MVT::Untyped), 0, 0);
ID.AddPointer(RegMask);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
SDNode *N = new (NodeAllocator) RegisterMaskSDNode(RegMask);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
return SDValue(N, 0);
}
SDValue SelectionDAG::getEHLabel(DebugLoc dl, SDValue Root, MCSymbol *Label) { SDValue SelectionDAG::getEHLabel(DebugLoc dl, SDValue Root, MCSymbol *Label) {
FoldingSetNodeID ID; FoldingSetNodeID ID;
SDValue Ops[] = { Root }; SDValue Ops[] = { Root };
@ -5946,7 +5962,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
case ISD::BasicBlock: return "BasicBlock"; case ISD::BasicBlock: return "BasicBlock";
case ISD::VALUETYPE: return "ValueType"; case ISD::VALUETYPE: return "ValueType";
case ISD::Register: return "Register"; case ISD::Register: return "Register";
case ISD::RegisterMask: return "RegisterMask";
case ISD::Constant: return "Constant"; case ISD::Constant: return "Constant";
case ISD::ConstantFP: return "ConstantFP"; case ISD::ConstantFP: return "ConstantFP";
case ISD::GlobalAddress: return "GlobalAddress"; case ISD::GlobalAddress: return "GlobalAddress";

View File

@ -2206,6 +2206,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
case ISD::EntryToken: // These nodes remain the same. case ISD::EntryToken: // These nodes remain the same.
case ISD::BasicBlock: case ISD::BasicBlock:
case ISD::Register: case ISD::Register:
case ISD::RegisterMask:
//case ISD::VALUETYPE: //case ISD::VALUETYPE:
//case ISD::CONDCODE: //case ISD::CONDCODE:
case ISD::HANDLENODE: case ISD::HANDLENODE: