summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/CodeGen/MIRYamlMapping.h3
-rw-r--r--llvm/include/llvm/CodeGen/MachineFunction.h6
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIRParser.cpp4
-rw-r--r--llvm/lib/CodeGen/MIRPrinter.cpp3
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp3
-rw-r--r--llvm/test/CodeGen/MIR/Generic/global-isel-properties.mir34
6 files changed, 53 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 7f9c4483333..1653e9a8ef4 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -384,6 +384,8 @@ struct MachineFunction {
bool HasInlineAsm = false;
// MachineFunctionProperties
bool AllVRegsAllocated = false;
+ // GISel MachineFunctionProperties.
+ bool Legalized = false;
// Register information
bool IsSSA = false;
bool TracksRegLiveness = false;
@@ -408,6 +410,7 @@ template <> struct MappingTraits<MachineFunction> {
YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice);
YamlIO.mapOptional("hasInlineAsm", MF.HasInlineAsm);
YamlIO.mapOptional("allVRegsAllocated", MF.AllVRegsAllocated);
+ YamlIO.mapOptional("legalized", MF.Legalized);
YamlIO.mapOptional("isSSA", MF.IsSSA);
YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness);
YamlIO.mapOptional("tracksSubRegLiveness", MF.TracksSubRegLiveness);
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index fadc05f1c08..5830af3416f 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -117,10 +117,16 @@ public:
// When this property is clear, liveness is no longer reliable.
// AllVRegsAllocated: All virtual registers have been allocated; i.e. all
// register operands are physical registers.
+ // Legalized: In GlobalISel: the MachineLegalizer ran and all pre-isel generic
+ // instructions have been legalized; i.e., all instructions are now one of:
+ // - generic and always legal (e.g., COPY)
+ // - target-specific
+ // - legal pre-isel generic instructions.
enum class Property : unsigned {
IsSSA,
TracksLiveness,
AllVRegsAllocated,
+ Legalized,
LastProperty,
};
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 4d8e4a90d1d..035b0ae5246 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -292,6 +292,10 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
MF.setHasInlineAsm(YamlMF.HasInlineAsm);
if (YamlMF.AllVRegsAllocated)
MF.getProperties().set(MachineFunctionProperties::Property::AllVRegsAllocated);
+
+ if (YamlMF.Legalized)
+ MF.getProperties().set(MachineFunctionProperties::Property::Legalized);
+
PerFunctionMIParsingState PFS(MF, SM, IRSlots);
if (initializeRegisterInfo(PFS, YamlMF))
return true;
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index b42d45b5b5f..fdd7a42ac62 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -178,6 +178,9 @@ void MIRPrinter::print(const MachineFunction &MF) {
YamlMF.AllVRegsAllocated = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::AllVRegsAllocated);
+ YamlMF.Legalized = MF.getProperties().hasProperty(
+ MachineFunctionProperties::Property::Legalized);
+
convert(YamlMF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo());
ModuleSlotTracker MST(MF.getFunction()->getParent());
MST.incorporateFunction(*MF.getFunction());
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index a4c4ea4bb95..202cf3cdf03 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -76,6 +76,9 @@ void MachineFunctionProperties::print(raw_ostream &ROS, bool OnlySet) const {
case Property::AllVRegsAllocated:
ROS << (HasProperty ? "AllVRegsAllocated" : "HasVRegs");
break;
+ case Property::Legalized:
+ ROS << (HasProperty ? "" : "not ") << "legalized";
+ break;
default:
break;
}
diff --git a/llvm/test/CodeGen/MIR/Generic/global-isel-properties.mir b/llvm/test/CodeGen/MIR/Generic/global-isel-properties.mir
new file mode 100644
index 00000000000..44854153060
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/Generic/global-isel-properties.mir
@@ -0,0 +1,34 @@
+# RUN: llc -run-pass none -o - %s | FileCheck %s
+# This test ensures that the MIR parser parses GlobalISel MachineFunction
+# properties correctly.
+# This doesn't require GlobalISel to be built, as the properties are always
+# available in CodeGen.
+
+--- |
+
+ define i32 @test_defaults() {
+ entry:
+ ret i32 0
+ }
+
+ define i32 @test() {
+ start:
+ ret i32 0
+ }
+
+...
+---
+# CHECK-LABEL: name: test_defaults
+# CHECK: legalized: false
+name: test_defaults
+body: |
+ bb.0:
+...
+---
+# CHECK-LABEL: name: test
+# CHECK: legalized: true
+name: test
+legalized: true
+body: |
+ bb.0:
+...
OpenPOWER on IntegriCloud