[llvm] r244803 - MIR Serialization: Serialize the constant pool pseudo source values.

Alex L via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 14:34:01 PDT 2015


Sorry about that. I usually try to keep moves and other refactorings in
separate NFC pre-commits, but I wasn't sure if the move justified its own
commit in this case.

Alex

2015-08-12 14:27 GMT-07:00 Duncan P. N. Exon Smith <dexonsmith at apple.com>:

>
> > On 2015-Aug-12, at 13:33, Alex Lorenz via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
> >
> > Author: arphaman
> > Date: Wed Aug 12 15:33:26 2015
> > New Revision: 244803
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=244803&view=rev
> > Log:
> > MIR Serialization: Serialize the constant pool pseudo source values.
> >
> > Modified:
> >    llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp
> >    llvm/trunk/lib/CodeGen/MIRParser/MILexer.h
> >    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
> >    llvm/trunk/lib/CodeGen/MIRPrinter.cpp
> >    llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir
> >
> > Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp?rev=244803&r1=244802&r2=244803&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
> > +++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Wed Aug 12 15:33:26 2015
> > @@ -201,6 +201,7 @@ static MIToken::TokenKind getIdentifierK
> >       .Case("non-temporal", MIToken::kw_non_temporal)
> >       .Case("invariant", MIToken::kw_invariant)
> >       .Case("align", MIToken::kw_align)
> > +      .Case("constant-pool", MIToken::kw_constant_pool)
> >       .Case("liveout", MIToken::kw_liveout)
> >       .Default(MIToken::Identifier);
> > }
> >
> > Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.h
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.h?rev=244803&r1=244802&r2=244803&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/CodeGen/MIRParser/MILexer.h (original)
> > +++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.h Wed Aug 12 15:33:26 2015
> > @@ -70,6 +70,7 @@ struct MIToken {
> >     kw_non_temporal,
> >     kw_invariant,
> >     kw_align,
> > +    kw_constant_pool,
> >     kw_liveout,
> >
> >     // Identifier tokens
> >
> > Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=244803&r1=244802&r2=244803&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
> > +++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Aug 12 15:33:26
> 2015
> > @@ -128,6 +128,8 @@ public:
> >   bool parseOperandsOffset(MachineOperand &Op);
> >   bool parseIRValue(Value *&V);
> >   bool parseMemoryOperandFlag(unsigned &Flags);
> > +  bool parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV);
> > +  bool parseMachinePointerInfo(MachinePointerInfo &Dest);
> >   bool parseMachineMemoryOperand(MachineMemOperand *&Dest);
> >
> > private:
> > @@ -1117,6 +1119,45 @@ bool MIParser::parseMemoryOperandFlag(un
> >   return false;
> > }
> >
> > +bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue
> *&PSV) {
> > +  switch (Token.kind()) {
> > +  case MIToken::kw_constant_pool:
> > +    PSV = MF.getPSVManager().getConstantPool();
> > +    break;
> > +  // TODO: Parse the other pseudo source values.
> > +  default:
> > +    llvm_unreachable("The current token should be pseudo source value");
> > +  }
> > +  lex();
> > +  return false;
> > +}
> > +
> > +bool MIParser::parseMachinePointerInfo(MachinePointerInfo &Dest) {
> > +  if (Token.is(MIToken::kw_constant_pool)) {
> > +    const PseudoSourceValue *PSV = nullptr;
> > +    if (parseMemoryPseudoSourceValue(PSV))
> > +      return true;
> > +    int64_t Offset = 0;
> > +    if (parseOffset(Offset))
> > +      return true;
> > +    Dest = MachinePointerInfo(PSV, Offset);
> > +    return false;
> > +  }
> > +  if (Token.isNot(MIToken::NamedIRValue))
> > +    return error("expected an IR value reference");
> > +  Value *V = nullptr;
> > +  if (parseIRValue(V))
> > +    return true;
> > +  if (!V->getType()->isPointerTy())
> > +    return error("expected a pointer IR value");
> > +  lex();
> > +  int64_t Offset = 0;
> > +  if (parseOffset(Offset))
> > +    return true;
> > +  Dest = MachinePointerInfo(V, Offset);
> > +  return false;
> > +}
> > +
> > bool MIParser::parseMachineMemoryOperand(MachineMemOperand *&Dest) {
> >   if (expectAndConsume(MIToken::lparen))
> >     return true;
> > @@ -1146,17 +1187,8 @@ bool MIParser::parseMachineMemoryOperand
> >     return error(Twine("expected '") + Word + "'");
> >   lex();
> >
> > -  // TODO: Parse pseudo source values.
> > -  if (Token.isNot(MIToken::NamedIRValue))
> > -    return error("expected an IR value reference");
> > -  Value *V = nullptr;
> > -  if (parseIRValue(V))
> > -    return true;
> > -  if (!V->getType()->isPointerTy())
> > -    return error("expected a pointer IR value");
> > -  lex();
> > -  int64_t Offset = 0;
> > -  if (parseOffset(Offset))
> > +  MachinePointerInfo Ptr = MachinePointerInfo();
> > +  if (parseMachinePointerInfo(Ptr))
>
> For next time: it'd be easier to read this patch -- to see what's
> changed -- if you'd moved the code to a helper function in a
> preparatory NFC commit.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150812/74fb4e0d/attachment.html>


More information about the llvm-commits mailing list