diff options
| author | Jim Grosbach <grosbach@apple.com> | 2011-10-07 23:56:00 +0000 | 
|---|---|---|
| committer | Jim Grosbach <grosbach@apple.com> | 2011-10-07 23:56:00 +0000 | 
| commit | d0637bfc68dd1b4901a0a7dc0f4ad9da78a84cfc (patch) | |
| tree | a4bb0bee270105f1522096b7fb0a0a3411262842 /llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | |
| parent | b5a46edf352706dca3342ab5c7b26bb16ca7fc7d (diff) | |
| download | bcm5719-llvm-d0637bfc68dd1b4901a0a7dc0f4ad9da78a84cfc.tar.gz bcm5719-llvm-d0637bfc68dd1b4901a0a7dc0f4ad9da78a84cfc.zip | |
ARM NEON assembly parsing and encoding for VDUP(scalar).
llvm-svn: 141446
Diffstat (limited to 'llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp')
| -rw-r--r-- | llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 119 | 
1 files changed, 119 insertions, 0 deletions
| diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index f56f45577d4..1d6a05cff95 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -254,6 +254,7 @@ class ARMOperand : public MCParsedAsmOperand {      k_PostIndexRegister,      k_MSRMask,      k_ProcIFlags, +    k_VectorIndex,      k_Register,      k_RegisterList,      k_DPRRegisterList, @@ -304,6 +305,10 @@ class ARMOperand : public MCParsedAsmOperand {      } Reg;      struct { +      unsigned Val; +    } VectorIndex; + +    struct {        const MCExpr *Val;      } Imm; @@ -419,6 +424,9 @@ public:      case k_BitfieldDescriptor:        Bitfield = o.Bitfield;        break; +    case k_VectorIndex: +      VectorIndex = o.VectorIndex; +      break;      }    } @@ -463,6 +471,11 @@ public:      return FPImm.Val;    } +  unsigned getVectorIndex() const { +    assert(Kind == k_VectorIndex && "Invalid access!"); +    return VectorIndex.Val; +  } +    ARM_MB::MemBOpt getMemBarrierOpt() const {      assert(Kind == k_MemBarrierOpt && "Invalid access!");      return MBOpt.Val; @@ -859,6 +872,21 @@ public:    bool isMSRMask() const { return Kind == k_MSRMask; }    bool isProcIFlags() const { return Kind == k_ProcIFlags; } +  bool isVectorIndex8() const { +    if (Kind != k_VectorIndex) return false; +    return VectorIndex.Val < 8; +  } +  bool isVectorIndex16() const { +    if (Kind != k_VectorIndex) return false; +    return VectorIndex.Val < 4; +  } +  bool isVectorIndex32() const { +    if (Kind != k_VectorIndex) return false; +    return VectorIndex.Val < 2; +  } + + +    void addExpr(MCInst &Inst, const MCExpr *Expr) const {      // Add as immediates when possible.  Null MCExpr = 0.      if (Expr == 0) @@ -1343,6 +1371,21 @@ public:      Inst.addOperand(MCOperand::CreateImm(unsigned(getProcIFlags())));    } +  void addVectorIndex8Operands(MCInst &Inst, unsigned N) const { +    assert(N == 1 && "Invalid number of operands!"); +    Inst.addOperand(MCOperand::CreateImm(getVectorIndex())); +  } + +  void addVectorIndex16Operands(MCInst &Inst, unsigned N) const { +    assert(N == 1 && "Invalid number of operands!"); +    Inst.addOperand(MCOperand::CreateImm(getVectorIndex())); +  } + +  void addVectorIndex32Operands(MCInst &Inst, unsigned N) const { +    assert(N == 1 && "Invalid number of operands!"); +    Inst.addOperand(MCOperand::CreateImm(getVectorIndex())); +  } +    virtual void print(raw_ostream &OS) const;    static ARMOperand *CreateITMask(unsigned Mask, SMLoc S) { @@ -1479,6 +1522,15 @@ public:      return Op;    } +  static ARMOperand *CreateVectorIndex(unsigned Idx, SMLoc S, SMLoc E, +                                       MCContext &Ctx) { +    ARMOperand *Op = new ARMOperand(k_VectorIndex); +    Op->VectorIndex.Val = Idx; +    Op->StartLoc = S; +    Op->EndLoc = E; +    return Op; +  } +    static ARMOperand *CreateImm(const MCExpr *Val, SMLoc S, SMLoc E) {      ARMOperand *Op = new ARMOperand(k_Immediate);      Op->Imm.Val = Val; @@ -1659,6 +1711,9 @@ void ARMOperand::print(raw_ostream &OS) const {    case k_Token:      OS << "'" << getToken() << "'";      break; +  case k_VectorIndex: +    OS << "<vectorindex " << getVectorIndex() << ">"; +    break;    }  } @@ -1700,6 +1755,39 @@ int ARMAsmParser::tryParseRegister() {    if (!RegNum) return -1;    Parser.Lex(); // Eat identifier token. + +#if 0 +  // Also check for an index operand. This is only legal for vector registers, +  // but that'll get caught OK in operand matching, so we don't need to +  // explicitly filter everything else out here. +  if (Parser.getTok().is(AsmToken::LBrac)) { +    SMLoc SIdx = Parser.getTok().getLoc(); +    Parser.Lex(); // Eat left bracket token. + +    const MCExpr *ImmVal; +    SMLoc ExprLoc = Parser.getTok().getLoc(); +    if (getParser().ParseExpression(ImmVal)) +      return MatchOperand_ParseFail; +    const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(ImmVal); +    if (!MCE) { +      TokError("immediate value expected for vector index"); +      return MatchOperand_ParseFail; +    } + +    SMLoc E = Parser.getTok().getLoc(); +    if (Parser.getTok().isNot(AsmToken::RBrac)) { +      Error(E, "']' expected"); +      return MatchOperand_ParseFail; +    } + +    Parser.Lex(); // Eat right bracket token. + +    Operands.push_back(ARMOperand::CreateVectorIndex(MCE->getValue(), +                                                     SIdx, E, +                                                     getContext())); +  } +#endif +    return RegNum;  } @@ -1815,6 +1903,37 @@ tryParseRegisterWithWriteBack(SmallVectorImpl<MCParsedAsmOperand*> &Operands) {      Operands.push_back(ARMOperand::CreateToken(ExclaimTok.getString(),                                                 ExclaimTok.getLoc()));      Parser.Lex(); // Eat exclaim token +    return false; +  } + +  // Also check for an index operand. This is only legal for vector registers, +  // but that'll get caught OK in operand matching, so we don't need to +  // explicitly filter everything else out here. +  if (Parser.getTok().is(AsmToken::LBrac)) { +    SMLoc SIdx = Parser.getTok().getLoc(); +    Parser.Lex(); // Eat left bracket token. + +    const MCExpr *ImmVal; +    SMLoc ExprLoc = Parser.getTok().getLoc(); +    if (getParser().ParseExpression(ImmVal)) +      return MatchOperand_ParseFail; +    const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(ImmVal); +    if (!MCE) { +      TokError("immediate value expected for vector index"); +      return MatchOperand_ParseFail; +    } + +    SMLoc E = Parser.getTok().getLoc(); +    if (Parser.getTok().isNot(AsmToken::RBrac)) { +      Error(E, "']' expected"); +      return MatchOperand_ParseFail; +    } + +    Parser.Lex(); // Eat right bracket token. + +    Operands.push_back(ARMOperand::CreateVectorIndex(MCE->getValue(), +                                                     SIdx, E, +                                                     getContext()));    }    return false; | 

