diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2015-06-16 00:10:47 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2015-06-16 00:10:47 +0000 |
| commit | 5b5f97537f8b5865141d0bd827a1c271e6a90b0a (patch) | |
| tree | 1ff21f0bc5d8c9d3e9ae410c8581248ff1ff3f16 /llvm | |
| parent | 47972afd102f557553d7c6555240bd80982afdd1 (diff) | |
| download | bcm5719-llvm-5b5f97537f8b5865141d0bd827a1c271e6a90b0a.tar.gz bcm5719-llvm-5b5f97537f8b5865141d0bd827a1c271e6a90b0a.zip | |
MIR Serialization: Print and parse simple machine function attributes.
This commit serializes the simple, scalar attributes from the
'MachineFunction' class.
Reviewers: Duncan P. N. Exon Smith
Differential Revision: http://reviews.llvm.org/D10449
llvm-svn: 239790
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/CodeGen/MIRYamlMapping.h | 6 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 3 | ||||
| -rw-r--r-- | llvm/test/CodeGen/MIR/machine-function.mir | 34 |
4 files changed, 48 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h index f9d4c7471b9..c7489ba8bfd 100644 --- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h +++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h @@ -26,11 +26,17 @@ namespace yaml { struct MachineFunction { StringRef Name; + unsigned Alignment; + bool ExposesReturnsTwice; + bool HasInlineAsm; }; template <> struct MappingTraits<MachineFunction> { static void mapping(IO &YamlIO, MachineFunction &MF) { YamlIO.mapRequired("name", MF.Name); + YamlIO.mapOptional("alignment", MF.Alignment); + YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice); + YamlIO.mapOptional("hasInlineAsm", MF.HasInlineAsm); } }; diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index 689615b8b6e..acd3c1130a5 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -190,6 +190,11 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) { return error(Twine("no machine function information for function '") + MF.getName() + "' in the MIR file"); // TODO: Recreate the machine function. + const yaml::MachineFunction &YamlMF = *It->getValue(); + if (YamlMF.Alignment) + MF.setAlignment(YamlMF.Alignment); + MF.setExposesReturnsTwice(YamlMF.ExposesReturnsTwice); + MF.setHasInlineAsm(YamlMF.HasInlineAsm); return false; } diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 36bbaf94a15..b2bb2f9278d 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -58,6 +58,9 @@ template <> struct BlockScalarTraits<Module> { void MIRPrinter::print(const MachineFunction &MF) { yaml::MachineFunction YamlMF; YamlMF.Name = MF.getName(); + YamlMF.Alignment = MF.getAlignment(); + YamlMF.ExposesReturnsTwice = MF.exposesReturnsTwice(); + YamlMF.HasInlineAsm = MF.hasInlineAsm(); yaml::Output Out(OS); Out << YamlMF; } diff --git a/llvm/test/CodeGen/MIR/machine-function.mir b/llvm/test/CodeGen/MIR/machine-function.mir index 679bfd2d162..a3c1d1d7392 100644 --- a/llvm/test/CodeGen/MIR/machine-function.mir +++ b/llvm/test/CodeGen/MIR/machine-function.mir @@ -10,15 +10,49 @@ define i32 @bar() { ret i32 0 } + + define i32 @func() { + ret i32 0 + } + + define i32 @func2() { + ret i32 0 + } ... --- # CHECK: name: foo +# CHECK-NEXT: alignment: +# CHECK-NEXT: exposesReturnsTwice: false +# CHECK-NEXT: hasInlineAsm: false # CHECK-NEXT: ... name: foo ... --- # CHECK: name: bar +# CHECK-NEXT: alignment: +# CHECK-NEXT: exposesReturnsTwice: false +# CHECK-NEXT: hasInlineAsm: false # CHECK-NEXT: ... name: bar ... +--- +# CHECK: name: func +# CHECK-NEXT: alignment: 8 +# CHECK-NEXT: exposesReturnsTwice: false +# CHECK-NEXT: hasInlineAsm: false +# CHECK-NEXT: ... +name: func +alignment: 8 +... +--- +# CHECK: name: func2 +# CHECK-NEXT: alignment: 16 +# CHECK-NEXT: exposesReturnsTwice: true +# CHECK-NEXT: hasInlineAsm: true +# CHECK-NEXT: ... +name: func2 +alignment: 16 +exposesReturnsTwice: true +hasInlineAsm: true +... |

