From 3f0c495bbb4786cbf1ee48a006753be1fdc22ecf Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Wed, 12 Aug 2015 20:44:16 +0000 Subject: [PATCH] MIR Serialization: Serialize the stack pseudo source values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244806 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MIRParser/MILexer.cpp | 1 + lib/CodeGen/MIRParser/MILexer.h | 1 + lib/CodeGen/MIRParser/MIParser.cpp | 5 +++- lib/CodeGen/MIRPrinter.cpp | 3 ++ test/CodeGen/MIR/X86/memory-operands.mir | 35 ++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/MIRParser/MILexer.cpp b/lib/CodeGen/MIRParser/MILexer.cpp index c94c3981cc8..8a6a1ff817a 100644 --- a/lib/CodeGen/MIRParser/MILexer.cpp +++ b/lib/CodeGen/MIRParser/MILexer.cpp @@ -201,6 +201,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) { .Case("non-temporal", MIToken::kw_non_temporal) .Case("invariant", MIToken::kw_invariant) .Case("align", MIToken::kw_align) + .Case("stack", MIToken::kw_stack) .Case("constant-pool", MIToken::kw_constant_pool) .Case("liveout", MIToken::kw_liveout) .Default(MIToken::Identifier); diff --git a/lib/CodeGen/MIRParser/MILexer.h b/lib/CodeGen/MIRParser/MILexer.h index 75cf3f3463e..2c7a32cf508 100644 --- a/lib/CodeGen/MIRParser/MILexer.h +++ b/lib/CodeGen/MIRParser/MILexer.h @@ -70,6 +70,7 @@ struct MIToken { kw_non_temporal, kw_invariant, kw_align, + kw_stack, kw_constant_pool, kw_liveout, diff --git a/lib/CodeGen/MIRParser/MIParser.cpp b/lib/CodeGen/MIRParser/MIParser.cpp index afa6ffcc5e4..47a9eaf14c3 100644 --- a/lib/CodeGen/MIRParser/MIParser.cpp +++ b/lib/CodeGen/MIRParser/MIParser.cpp @@ -1121,6 +1121,9 @@ bool MIParser::parseMemoryOperandFlag(unsigned &Flags) { bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) { switch (Token.kind()) { + case MIToken::kw_stack: + PSV = MF.getPSVManager().getStack(); + break; case MIToken::kw_constant_pool: PSV = MF.getPSVManager().getConstantPool(); break; @@ -1133,7 +1136,7 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) { } bool MIParser::parseMachinePointerInfo(MachinePointerInfo &Dest) { - if (Token.is(MIToken::kw_constant_pool)) { + if (Token.is(MIToken::kw_constant_pool) || Token.is(MIToken::kw_stack)) { const PseudoSourceValue *PSV = nullptr; if (parseMemoryPseudoSourceValue(PSV)) return true; diff --git a/lib/CodeGen/MIRPrinter.cpp b/lib/CodeGen/MIRPrinter.cpp index d47ed979689..019383cc7cf 100644 --- a/lib/CodeGen/MIRPrinter.cpp +++ b/lib/CodeGen/MIRPrinter.cpp @@ -710,6 +710,9 @@ void MIPrinter::print(const MachineMemOperand &Op) { const PseudoSourceValue *PVal = Op.getPseudoValue(); assert(PVal && "Expected a pseudo source value"); switch (PVal->kind()) { + case PseudoSourceValue::Stack: + OS << "stack"; + break; case PseudoSourceValue::ConstantPool: OS << "constant-pool"; break; diff --git a/test/CodeGen/MIR/X86/memory-operands.mir b/test/CodeGen/MIR/X86/memory-operands.mir index f84ebfb003c..289a5f6267f 100644 --- a/test/CodeGen/MIR/X86/memory-operands.mir +++ b/test/CodeGen/MIR/X86/memory-operands.mir @@ -65,6 +65,16 @@ ret double %b } + declare x86_fp80 @cosl(x86_fp80) #0 + + define x86_fp80 @stack_psv(x86_fp80 %x) { + entry: + %y = call x86_fp80 @cosl(x86_fp80 %x) #0 + ret x86_fp80 %y + } + + attributes #0 = { readonly } + ... --- name: test @@ -211,3 +221,28 @@ body: - '%xmm0 = ADDSDrm killed %xmm0, %rip, 1, _, %const.0, _ :: (load 8 from constant-pool + 8)' - 'RETQ %xmm0' ... +--- +name: stack_psv +tracksRegLiveness: true +frameInfo: + stackSize: 24 + maxAlignment: 16 + adjustsStack: true + hasCalls: true + maxCallFrameSize: 16 +fixedStack: + - { id: 0, offset: 0, size: 10, alignment: 16, isImmutable: true, isAliased: false } +body: + - id: 0 + name: entry + instructions: + - '%rsp = frame-setup SUB64ri8 %rsp, 24, implicit-def dead %eflags' + - CFI_INSTRUCTION .cfi_def_cfa_offset 32 + - 'LD_F80m %rsp, 1, _, 32, _, implicit-def dead %fpsw' +# CHECK: name: stack_psv +# CHECK: ST_FP80m %rsp, 1, _, 0, _, implicit-def dead %fpsw :: (store 10 into stack, align 16) + - 'ST_FP80m %rsp, 1, _, 0, _, implicit-def dead %fpsw :: (store 10 into stack, align 16)' + - 'CALL64pcrel32 $cosl, csr_64, implicit %rsp, implicit-def %rsp, implicit-def %fp0' + - '%rsp = ADD64ri8 %rsp, 24, implicit-def dead %eflags' + - RETQ +... -- 2.34.1