bool HasPHI = false;
bool HasInlineAsm = false;
+ bool AllTiedOpsRewritten = true, HasTiedOps = false;
for (const MachineBasicBlock &MBB : MF) {
for (const MachineInstr &MI : MBB) {
if (MI.isPHI())
HasPHI = true;
if (MI.isInlineAsm())
HasInlineAsm = true;
+ for (unsigned I = 0; I < MI.getNumOperands(); ++I) {
+ const MachineOperand &MO = MI.getOperand(I);
+ if (!MO.isReg() || !MO.getReg())
+ continue;
+ unsigned DefIdx;
+ if (MO.isUse() && MI.isRegTiedToDefOperand(I, &DefIdx)) {
+ HasTiedOps = true;
+ if (MO.getReg() != MI.getOperand(DefIdx).getReg())
+ AllTiedOpsRewritten = false;
+ }
+ }
}
}
if (!HasPHI)
Properties.set(MachineFunctionProperties::Property::NoPHIs);
MF.setHasInlineAsm(HasInlineAsm);
+ if (HasTiedOps && AllTiedOpsRewritten)
+ Properties.set(MachineFunctionProperties::Property::TiedOpsRewritten);
+
if (isSSA(MF))
Properties.set(MachineFunctionProperties::Property::IsSSA);
else
)";
EXPECT_TRUE(checkOutput(CheckString, Output));
}
+
+TEST_F(MachineMetadataTest, TiedOpsRewritten) {
+ auto TM = createTargetMachine(Triple::normalize("powerpc64--"), "", "");
+ if (!TM)
+ GTEST_SKIP();
+ StringRef MIRString = R"MIR(
+---
+name: foo
+alignment: 16
+tracksRegLiveness: true
+frameInfo:
+ maxAlignment: 16
+machineFunctionInfo: {}
+body: |
+ bb.0:
+ liveins: $r3
+ %0:gprc = COPY $r3
+ %0 = RLWIMI killed %0, $r3, 1, 0, 30
+ $r3 = COPY %0
+ BLR8 implicit $r3, implicit $lr8, implicit $rm
+
+...
+)MIR";
+ MachineModuleInfo MMI(TM.get());
+ M = parseMIR(*TM, MIRString, "foo", MMI);
+ ASSERT_TRUE(M);
+ auto *MF = MMI.getMachineFunction(*M->getFunction("foo"));
+ MachineFunctionProperties &Properties = MF->getProperties();
+ ASSERT_TRUE(Properties.hasProperty(
+ MachineFunctionProperties::Property::TiedOpsRewritten));
+}
+
+TEST_F(MachineMetadataTest, NoTiedOpsRewritten) {
+ auto TM = createTargetMachine(Triple::normalize("powerpc64--"), "", "");
+ if (!TM)
+ GTEST_SKIP();
+ StringRef MIRString = R"MIR(
+---
+name: foo
+alignment: 16
+tracksRegLiveness: true
+frameInfo:
+ maxAlignment: 16
+machineFunctionInfo: {}
+body: |
+ bb.0:
+ liveins: $r3
+ %0:gprc = COPY $r3
+ %1:gprc = RLWIMI killed %0, $r3, 1, 0, 30
+ $r3 = COPY %1
+ BLR8 implicit $r3, implicit $lr8, implicit $rm
+
+...
+)MIR";
+ MachineModuleInfo MMI(TM.get());
+ M = parseMIR(*TM, MIRString, "foo", MMI);
+ ASSERT_TRUE(M);
+ auto *MF = MMI.getMachineFunction(*M->getFunction("foo"));
+ MachineFunctionProperties &Properties = MF->getProperties();
+ ASSERT_FALSE(Properties.hasProperty(
+ MachineFunctionProperties::Property::TiedOpsRewritten));
+}