mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Encode register class constreaints in inline asm instructions.
The inline asm operand constraint is initially encoded in the virtual register for the operand, but that register class may change during coalescing, and the original constraint is lost. Encode the original register class as part of the flag word for each inline asm operand. This makes it possible to recover the actual constraint required by inline asm, just like we can for normal instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141833 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1422,18 +1422,27 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
||||
OS << '$' << AsmOpCount++;
|
||||
unsigned Flag = MO.getImm();
|
||||
switch (InlineAsm::getKind(Flag)) {
|
||||
case InlineAsm::Kind_RegUse: OS << ":[reguse]"; break;
|
||||
case InlineAsm::Kind_RegDef: OS << ":[regdef]"; break;
|
||||
case InlineAsm::Kind_RegDefEarlyClobber: OS << ":[regdef-ec]"; break;
|
||||
case InlineAsm::Kind_Clobber: OS << ":[clobber]"; break;
|
||||
case InlineAsm::Kind_Imm: OS << ":[imm]"; break;
|
||||
case InlineAsm::Kind_Mem: OS << ":[mem]"; break;
|
||||
default: OS << ":[??" << InlineAsm::getKind(Flag) << ']'; break;
|
||||
case InlineAsm::Kind_RegUse: OS << ":[reguse"; break;
|
||||
case InlineAsm::Kind_RegDef: OS << ":[regdef"; break;
|
||||
case InlineAsm::Kind_RegDefEarlyClobber: OS << ":[regdef-ec"; break;
|
||||
case InlineAsm::Kind_Clobber: OS << ":[clobber"; break;
|
||||
case InlineAsm::Kind_Imm: OS << ":[imm"; break;
|
||||
case InlineAsm::Kind_Mem: OS << ":[mem"; break;
|
||||
default: OS << ":[??" << InlineAsm::getKind(Flag); break;
|
||||
}
|
||||
|
||||
unsigned RCID = 0;
|
||||
if (InlineAsm::hasRegClassConstraint(Flag, RCID))
|
||||
if (TM)
|
||||
OS << ':' << TM->getRegisterInfo()->getRegClass(RCID)->getName();
|
||||
else
|
||||
OS << ":RC" << RCID;
|
||||
|
||||
unsigned TiedTo = 0;
|
||||
if (InlineAsm::isUseOperandTiedToDef(Flag, TiedTo))
|
||||
OS << " [tiedto:$" << TiedTo << ']';
|
||||
OS << " tiedto:$" << TiedTo;
|
||||
|
||||
OS << ']';
|
||||
|
||||
// Compute the index of the next operand descriptor.
|
||||
AsmDescOp += 1 + InlineAsm::getNumOperandRegisters(Flag);
|
||||
|
@@ -788,6 +788,18 @@ void RegsForValue::AddInlineAsmOperands(unsigned Code, bool HasMatching,
|
||||
unsigned Flag = InlineAsm::getFlagWord(Code, Regs.size());
|
||||
if (HasMatching)
|
||||
Flag = InlineAsm::getFlagWordForMatchingOp(Flag, MatchingIdx);
|
||||
else if (!Regs.empty() &&
|
||||
TargetRegisterInfo::isVirtualRegister(Regs.front())) {
|
||||
// Put the register class of the virtual registers in the flag word. That
|
||||
// way, later passes can recompute register class constraints for inline
|
||||
// assembly as well as normal instructions.
|
||||
// Don't do this for tied operands that can use the regclass information
|
||||
// from the def.
|
||||
const MachineRegisterInfo &MRI = DAG.getMachineFunction().getRegInfo();
|
||||
const TargetRegisterClass *RC = MRI.getRegClass(Regs.front());
|
||||
Flag = InlineAsm::getFlagWordForRegClass(Flag, RC->getID());
|
||||
}
|
||||
|
||||
SDValue Res = DAG.getTargetConstant(Flag, MVT::i32);
|
||||
Ops.push_back(Res);
|
||||
|
||||
|
Reference in New Issue
Block a user