diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-08-11 06:36:53 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-08-11 06:36:53 +0000 |
commit | 8462b30548fb5969250858036638c73c16b65b43 (patch) | |
tree | 6f3c764608ce304aff9bc525ba46a06c0efd691a /lib/Target/ARM/AsmParser/ARMAsmParser.cpp | |
parent | ee34987fd58ed98c6987ed46979ccb46e7420919 (diff) |
MC/ARM: Add an ARMOperand class for condition codes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110788 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/AsmParser/ARMAsmParser.cpp')
-rw-r--r-- | lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index b3d956e8cd..19d7d9aa47 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -106,16 +106,21 @@ private: ARMOperand() {} public: enum KindTy { - Token, - Register, + CondCode, Immediate, - Memory + Memory, + Register, + Token } Kind; SMLoc StartLoc, EndLoc; union { struct { + ARMCC::CondCodes Val; + } CC; + + struct { const char *Data; unsigned Length; } Tok; @@ -155,8 +160,11 @@ public: StartLoc = o.StartLoc; EndLoc = o.EndLoc; switch (Kind) { + case CondCode: + CC = o.CC; + break; case Token: - Tok = o.Tok; + Tok = o.Tok; break; case Register: Reg = o.Reg; @@ -175,6 +183,11 @@ public: /// getEndLoc - Get the location of the last token of this operand. SMLoc getEndLoc() const { return EndLoc; } + ARMCC::CondCodes getCondCode() const { + assert(Kind == CondCode && "Invalid access!"); + return CC.Val; + } + StringRef getToken() const { assert(Kind == Token && "Invalid access!"); return StringRef(Tok.Data, Tok.Length); @@ -190,6 +203,8 @@ public: return Imm.Val; } + bool isCondCode() const { return Kind == CondCode; } + bool isImm() const { return Kind == Immediate; } bool isReg() const { return Kind == Register; } @@ -204,6 +219,11 @@ public: Inst.addOperand(MCOperand::CreateExpr(Expr)); } + void addCondCodeOperands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateImm(unsigned(getCondCode()))); + } + void addRegOperands(MCInst &Inst, unsigned N) const { assert(N == 1 && "Invalid number of operands!"); Inst.addOperand(MCOperand::CreateReg(getReg())); |