mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-02 16:56:50 +00:00
MIR Serialization: Serialize the frame info's save and restore points.
This commit serializes the save and restore machine basic block references from the machine frame information class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243575 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3b4ca38ce1
commit
81474d36a0
@ -326,7 +326,8 @@ struct MachineFrameInfo {
|
||||
bool HasOpaqueSPAdjustment = false;
|
||||
bool HasVAStart = false;
|
||||
bool HasMustTailInVarArgFunc = false;
|
||||
// TODO: Serialize save and restore MBB references.
|
||||
StringValue SavePoint;
|
||||
StringValue RestorePoint;
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<MachineFrameInfo> {
|
||||
@ -344,6 +345,10 @@ template <> struct MappingTraits<MachineFrameInfo> {
|
||||
YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment);
|
||||
YamlIO.mapOptional("hasVAStart", MFI.HasVAStart);
|
||||
YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc);
|
||||
YamlIO.mapOptional("savePoint", MFI.SavePoint,
|
||||
StringValue()); // Don't print it out when it's empty.
|
||||
YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
|
||||
StringValue()); // Don't print it out when it's empty.
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -282,8 +282,6 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
|
||||
PerFunctionMIParsingState PFS;
|
||||
if (initializeRegisterInfo(MF, YamlMF, PFS))
|
||||
return true;
|
||||
if (initializeFrameInfo(MF, YamlMF, PFS))
|
||||
return true;
|
||||
if (!YamlMF.Constants.empty()) {
|
||||
auto *ConstantPool = MF.getConstantPool();
|
||||
assert(ConstantPool && "Constant pool must be created");
|
||||
@ -324,6 +322,10 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
|
||||
if (YamlMF.BasicBlocks.empty())
|
||||
return error(Twine("machine function '") + Twine(MF.getName()) +
|
||||
"' requires at least one machine basic block in its body");
|
||||
// Initialize the frame information after creating all the MBBs so that the
|
||||
// MBB references in the frame information can be resolved.
|
||||
if (initializeFrameInfo(MF, YamlMF, PFS))
|
||||
return true;
|
||||
// Initialize the jump table after creating all the MBBs so that the MBB
|
||||
// references can be resolved.
|
||||
if (!YamlMF.JumpTableInfo.Entries.empty() &&
|
||||
@ -450,6 +452,18 @@ bool MIRParserImpl::initializeFrameInfo(MachineFunction &MF,
|
||||
MFI.setHasOpaqueSPAdjustment(YamlMFI.HasOpaqueSPAdjustment);
|
||||
MFI.setHasVAStart(YamlMFI.HasVAStart);
|
||||
MFI.setHasMustTailInVarArgFunc(YamlMFI.HasMustTailInVarArgFunc);
|
||||
if (!YamlMFI.SavePoint.Value.empty()) {
|
||||
MachineBasicBlock *MBB = nullptr;
|
||||
if (parseMBBReference(MBB, YamlMFI.SavePoint, MF, PFS))
|
||||
return true;
|
||||
MFI.setSavePoint(MBB);
|
||||
}
|
||||
if (!YamlMFI.RestorePoint.Value.empty()) {
|
||||
MachineBasicBlock *MBB = nullptr;
|
||||
if (parseMBBReference(MBB, YamlMFI.RestorePoint, MF, PFS))
|
||||
return true;
|
||||
MFI.setRestorePoint(MBB);
|
||||
}
|
||||
|
||||
std::vector<CalleeSavedInfo> CSIInfo;
|
||||
// Initialize the fixed frame objects.
|
||||
|
@ -72,7 +72,8 @@ public:
|
||||
|
||||
void convert(yaml::MachineFunction &MF, const MachineRegisterInfo &RegInfo,
|
||||
const TargetRegisterInfo *TRI);
|
||||
void convert(yaml::MachineFrameInfo &YamlMFI, const MachineFrameInfo &MFI);
|
||||
void convert(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
|
||||
const MachineFrameInfo &MFI);
|
||||
void convert(yaml::MachineFunction &MF,
|
||||
const MachineConstantPool &ConstantPool);
|
||||
void convert(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
|
||||
@ -158,14 +159,13 @@ void MIRPrinter::print(const MachineFunction &MF) {
|
||||
YamlMF.ExposesReturnsTwice = MF.exposesReturnsTwice();
|
||||
YamlMF.HasInlineAsm = MF.hasInlineAsm();
|
||||
convert(YamlMF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo());
|
||||
convert(YamlMF.FrameInfo, *MF.getFrameInfo());
|
||||
ModuleSlotTracker MST(MF.getFunction()->getParent());
|
||||
MST.incorporateFunction(*MF.getFunction());
|
||||
convert(MST, YamlMF.FrameInfo, *MF.getFrameInfo());
|
||||
convertStackObjects(YamlMF, *MF.getFrameInfo(),
|
||||
MF.getSubtarget().getRegisterInfo());
|
||||
if (const auto *ConstantPool = MF.getConstantPool())
|
||||
convert(YamlMF, *ConstantPool);
|
||||
|
||||
ModuleSlotTracker MST(MF.getFunction()->getParent());
|
||||
MST.incorporateFunction(*MF.getFunction());
|
||||
if (const auto *JumpTableInfo = MF.getJumpTableInfo())
|
||||
convert(MST, YamlMF.JumpTableInfo, *JumpTableInfo);
|
||||
for (const auto &MBB : MF) {
|
||||
@ -207,7 +207,8 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
|
||||
}
|
||||
}
|
||||
|
||||
void MIRPrinter::convert(yaml::MachineFrameInfo &YamlMFI,
|
||||
void MIRPrinter::convert(ModuleSlotTracker &MST,
|
||||
yaml::MachineFrameInfo &YamlMFI,
|
||||
const MachineFrameInfo &MFI) {
|
||||
YamlMFI.IsFrameAddressTaken = MFI.isFrameAddressTaken();
|
||||
YamlMFI.IsReturnAddressTaken = MFI.isReturnAddressTaken();
|
||||
@ -222,6 +223,16 @@ void MIRPrinter::convert(yaml::MachineFrameInfo &YamlMFI,
|
||||
YamlMFI.HasOpaqueSPAdjustment = MFI.hasOpaqueSPAdjustment();
|
||||
YamlMFI.HasVAStart = MFI.hasVAStart();
|
||||
YamlMFI.HasMustTailInVarArgFunc = MFI.hasMustTailInVarArgFunc();
|
||||
if (MFI.getSavePoint()) {
|
||||
raw_string_ostream StrOS(YamlMFI.SavePoint.Value);
|
||||
MIPrinter(StrOS, MST, RegisterMaskIds, StackObjectOperandMapping)
|
||||
.printMBBReference(*MFI.getSavePoint());
|
||||
}
|
||||
if (MFI.getRestorePoint()) {
|
||||
raw_string_ostream StrOS(YamlMFI.RestorePoint.Value);
|
||||
MIPrinter(StrOS, MST, RegisterMaskIds, StackObjectOperandMapping)
|
||||
.printMBBReference(*MFI.getRestorePoint());
|
||||
}
|
||||
}
|
||||
|
||||
void MIRPrinter::convertStackObjects(yaml::MachineFunction &MF,
|
||||
|
72
test/CodeGen/MIR/X86/frame-info-save-restore-points.mir
Normal file
72
test/CodeGen/MIR/X86/frame-info-save-restore-points.mir
Normal file
@ -0,0 +1,72 @@
|
||||
# RUN: llc -march=x86-64 -enable-shrink-wrap=true -start-after shrink-wrap -stop-after shrink-wrap -o /dev/null %s | FileCheck %s
|
||||
# This test ensures that the MIR parser parses the save and restore points in
|
||||
# the machine frame info correctly.
|
||||
|
||||
--- |
|
||||
|
||||
define i32 @foo(i32 %a, i32 %b) {
|
||||
entry:
|
||||
%tmp = alloca i32, align 4
|
||||
%tmp2 = icmp slt i32 %a, %b
|
||||
br i1 %tmp2, label %true, label %false
|
||||
|
||||
true:
|
||||
store i32 %a, i32* %tmp, align 4
|
||||
%tmp4 = call i32 @doSomething(i32 0, i32* %tmp)
|
||||
br label %false
|
||||
|
||||
false:
|
||||
%tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %entry ]
|
||||
ret i32 %tmp.0
|
||||
}
|
||||
|
||||
declare i32 @doSomething(i32, i32*)
|
||||
|
||||
...
|
||||
---
|
||||
name: foo
|
||||
tracksRegLiveness: true
|
||||
liveins:
|
||||
- { reg: '%edi' }
|
||||
- { reg: '%esi' }
|
||||
# CHECK: frameInfo:
|
||||
# CHECK: savePoint: '%bb.2.true'
|
||||
# CHECK-NEXT: restorePoint: '%bb.2.true'
|
||||
# CHECK: stack
|
||||
frameInfo:
|
||||
maxAlignment: 4
|
||||
hasCalls: true
|
||||
savePoint: '%bb.2.true'
|
||||
restorePoint: '%bb.2.true'
|
||||
stack:
|
||||
- { id: 0, name: tmp, offset: 0, size: 4, alignment: 4 }
|
||||
body:
|
||||
- id: 0
|
||||
successors: [ '%bb.2.true', '%bb.1' ]
|
||||
liveins: [ '%edi', '%esi' ]
|
||||
instructions:
|
||||
- '%eax = COPY %edi'
|
||||
- 'CMP32rr %eax, killed %esi, implicit-def %eflags'
|
||||
- 'JL_1 %bb.2.true, implicit killed %eflags'
|
||||
- id: 1
|
||||
successors: [ '%bb.3.false' ]
|
||||
liveins: [ '%eax' ]
|
||||
instructions:
|
||||
- 'JMP_1 %bb.3.false'
|
||||
- id: 2
|
||||
name: 'true'
|
||||
successors: [ '%bb.3.false' ]
|
||||
liveins: [ '%eax' ]
|
||||
instructions:
|
||||
- 'MOV32mr %stack.0.tmp, 1, _, 0, _, killed %eax'
|
||||
- 'ADJCALLSTACKDOWN64 0, 0, implicit-def %rsp, implicit-def dead %eflags, implicit %rsp'
|
||||
- '%rsi = LEA64r %stack.0.tmp, 1, _, 0, _'
|
||||
- '%edi = MOV32r0 implicit-def dead %eflags'
|
||||
- 'CALL64pcrel32 @doSomething, csr_64, implicit %rsp, implicit %edi, implicit %rsi, implicit-def %rsp, implicit-def %eax'
|
||||
- 'ADJCALLSTACKUP64 0, 0, implicit-def %rsp, implicit-def dead %eflags, implicit %rsp'
|
||||
- id: 3
|
||||
name: 'false'
|
||||
liveins: [ '%eax' ]
|
||||
instructions:
|
||||
- 'RETQ %eax'
|
||||
...
|
Loading…
Reference in New Issue
Block a user