mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239790 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -26,11 +26,17 @@ namespace yaml {
|
|||||||
|
|
||||||
struct MachineFunction {
|
struct MachineFunction {
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
|
unsigned Alignment;
|
||||||
|
bool ExposesReturnsTwice;
|
||||||
|
bool HasInlineAsm;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct MappingTraits<MachineFunction> {
|
template <> struct MappingTraits<MachineFunction> {
|
||||||
static void mapping(IO &YamlIO, MachineFunction &MF) {
|
static void mapping(IO &YamlIO, MachineFunction &MF) {
|
||||||
YamlIO.mapRequired("name", MF.Name);
|
YamlIO.mapRequired("name", MF.Name);
|
||||||
|
YamlIO.mapOptional("alignment", MF.Alignment);
|
||||||
|
YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice);
|
||||||
|
YamlIO.mapOptional("hasInlineAsm", MF.HasInlineAsm);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,6 +190,11 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
|
|||||||
return error(Twine("no machine function information for function '") +
|
return error(Twine("no machine function information for function '") +
|
||||||
MF.getName() + "' in the MIR file");
|
MF.getName() + "' in the MIR file");
|
||||||
// TODO: Recreate the machine function.
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ template <> struct BlockScalarTraits<Module> {
|
|||||||
void MIRPrinter::print(const MachineFunction &MF) {
|
void MIRPrinter::print(const MachineFunction &MF) {
|
||||||
yaml::MachineFunction YamlMF;
|
yaml::MachineFunction YamlMF;
|
||||||
YamlMF.Name = MF.getName();
|
YamlMF.Name = MF.getName();
|
||||||
|
YamlMF.Alignment = MF.getAlignment();
|
||||||
|
YamlMF.ExposesReturnsTwice = MF.exposesReturnsTwice();
|
||||||
|
YamlMF.HasInlineAsm = MF.hasInlineAsm();
|
||||||
yaml::Output Out(OS);
|
yaml::Output Out(OS);
|
||||||
Out << YamlMF;
|
Out << YamlMF;
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,48 @@
|
|||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define i32 @func() {
|
||||||
|
ret i32 0
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32 @func2() {
|
||||||
|
ret i32 0
|
||||||
|
}
|
||||||
|
|
||||||
...
|
...
|
||||||
---
|
---
|
||||||
# CHECK: name: foo
|
# CHECK: name: foo
|
||||||
|
# CHECK-NEXT: alignment:
|
||||||
|
# CHECK-NEXT: exposesReturnsTwice: false
|
||||||
|
# CHECK-NEXT: hasInlineAsm: false
|
||||||
# CHECK-NEXT: ...
|
# CHECK-NEXT: ...
|
||||||
name: foo
|
name: foo
|
||||||
...
|
...
|
||||||
---
|
---
|
||||||
# CHECK: name: bar
|
# CHECK: name: bar
|
||||||
|
# CHECK-NEXT: alignment:
|
||||||
|
# CHECK-NEXT: exposesReturnsTwice: false
|
||||||
|
# CHECK-NEXT: hasInlineAsm: false
|
||||||
# CHECK-NEXT: ...
|
# CHECK-NEXT: ...
|
||||||
name: bar
|
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
|
||||||
|
...
|
||||||
|
Reference in New Issue
Block a user