mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
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
This commit is contained in:
parent
ee34987fd5
commit
8462b30548
@ -138,11 +138,17 @@ def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
|
|||||||
// ARM special operands.
|
// ARM special operands.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
def CondCodeOperand : AsmOperandClass {
|
||||||
|
let Name = "CondCode";
|
||||||
|
let SuperClasses = [];
|
||||||
|
}
|
||||||
|
|
||||||
// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
|
// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
|
||||||
// register whose default is 0 (no register).
|
// register whose default is 0 (no register).
|
||||||
def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
|
def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
|
||||||
(ops (i32 14), (i32 zero_reg))> {
|
(ops (i32 14), (i32 zero_reg))> {
|
||||||
let PrintMethod = "printPredicateOperand";
|
let PrintMethod = "printPredicateOperand";
|
||||||
|
let ParserMatchClass = CondCodeOperand;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conditional code result for instructions whose 's' bit is set, e.g. subs.
|
// Conditional code result for instructions whose 's' bit is set, e.g. subs.
|
||||||
|
@ -106,15 +106,20 @@ private:
|
|||||||
ARMOperand() {}
|
ARMOperand() {}
|
||||||
public:
|
public:
|
||||||
enum KindTy {
|
enum KindTy {
|
||||||
Token,
|
CondCode,
|
||||||
Register,
|
|
||||||
Immediate,
|
Immediate,
|
||||||
Memory
|
Memory,
|
||||||
|
Register,
|
||||||
|
Token
|
||||||
} Kind;
|
} Kind;
|
||||||
|
|
||||||
SMLoc StartLoc, EndLoc;
|
SMLoc StartLoc, EndLoc;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
struct {
|
||||||
|
ARMCC::CondCodes Val;
|
||||||
|
} CC;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char *Data;
|
const char *Data;
|
||||||
unsigned Length;
|
unsigned Length;
|
||||||
@ -155,8 +160,11 @@ public:
|
|||||||
StartLoc = o.StartLoc;
|
StartLoc = o.StartLoc;
|
||||||
EndLoc = o.EndLoc;
|
EndLoc = o.EndLoc;
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
|
case CondCode:
|
||||||
|
CC = o.CC;
|
||||||
|
break;
|
||||||
case Token:
|
case Token:
|
||||||
Tok = o.Tok;
|
Tok = o.Tok;
|
||||||
break;
|
break;
|
||||||
case Register:
|
case Register:
|
||||||
Reg = o.Reg;
|
Reg = o.Reg;
|
||||||
@ -175,6 +183,11 @@ public:
|
|||||||
/// getEndLoc - Get the location of the last token of this operand.
|
/// getEndLoc - Get the location of the last token of this operand.
|
||||||
SMLoc getEndLoc() const { return EndLoc; }
|
SMLoc getEndLoc() const { return EndLoc; }
|
||||||
|
|
||||||
|
ARMCC::CondCodes getCondCode() const {
|
||||||
|
assert(Kind == CondCode && "Invalid access!");
|
||||||
|
return CC.Val;
|
||||||
|
}
|
||||||
|
|
||||||
StringRef getToken() const {
|
StringRef getToken() const {
|
||||||
assert(Kind == Token && "Invalid access!");
|
assert(Kind == Token && "Invalid access!");
|
||||||
return StringRef(Tok.Data, Tok.Length);
|
return StringRef(Tok.Data, Tok.Length);
|
||||||
@ -190,6 +203,8 @@ public:
|
|||||||
return Imm.Val;
|
return Imm.Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isCondCode() const { return Kind == CondCode; }
|
||||||
|
|
||||||
bool isImm() const { return Kind == Immediate; }
|
bool isImm() const { return Kind == Immediate; }
|
||||||
|
|
||||||
bool isReg() const { return Kind == Register; }
|
bool isReg() const { return Kind == Register; }
|
||||||
@ -204,6 +219,11 @@ public:
|
|||||||
Inst.addOperand(MCOperand::CreateExpr(Expr));
|
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 {
|
void addRegOperands(MCInst &Inst, unsigned N) const {
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
assert(N == 1 && "Invalid number of operands!");
|
||||||
Inst.addOperand(MCOperand::CreateReg(getReg()));
|
Inst.addOperand(MCOperand::CreateReg(getReg()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user