mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-28 22:20:43 +00:00
ARM refactor simple immediate asm operand render methods.
These immediate operands all use the same simple logic for rendering to MCInst, so have them share the method for doing so. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144439 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
501852423d
commit
9588c10b69
@ -174,7 +174,7 @@ def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
|
|||||||
|
|
||||||
// ARM special operands for disassembly only.
|
// ARM special operands for disassembly only.
|
||||||
//
|
//
|
||||||
def SetEndAsmOperand : AsmOperandClass {
|
def SetEndAsmOperand : ImmAsmOperand {
|
||||||
let Name = "SetEndImm";
|
let Name = "SetEndImm";
|
||||||
let ParserMethod = "parseSetEndImm";
|
let ParserMethod = "parseSetEndImm";
|
||||||
}
|
}
|
||||||
@ -820,7 +820,7 @@ class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PKH instructions
|
// PKH instructions
|
||||||
def PKHLSLAsmOperand : AsmOperandClass {
|
def PKHLSLAsmOperand : ImmAsmOperand {
|
||||||
let Name = "PKHLSLImm";
|
let Name = "PKHLSLImm";
|
||||||
let ParserMethod = "parsePKHLSLImm";
|
let ParserMethod = "parsePKHLSLImm";
|
||||||
}
|
}
|
||||||
|
@ -284,14 +284,6 @@ def lo16AllZero : PatLeaf<(i32 imm), [{
|
|||||||
return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
|
return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
|
||||||
}], hi16>;
|
}], hi16>;
|
||||||
|
|
||||||
/// imm0_65535 - An immediate is in the range [0.65535].
|
|
||||||
def Imm0_65535AsmOperand: AsmOperandClass { let Name = "Imm0_65535"; }
|
|
||||||
def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
|
|
||||||
return Imm >= 0 && Imm < 65536;
|
|
||||||
}]> {
|
|
||||||
let ParserMatchClass = Imm0_65535AsmOperand;
|
|
||||||
}
|
|
||||||
|
|
||||||
class BinOpWithFlagFrag<dag res> :
|
class BinOpWithFlagFrag<dag res> :
|
||||||
PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
|
PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
|
||||||
class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
|
class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
|
||||||
@ -326,6 +318,9 @@ def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
|
|||||||
// Operand Definitions.
|
// Operand Definitions.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// Immediate operands with a shared generic asm render method.
|
||||||
|
class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
|
||||||
|
|
||||||
// Branch target.
|
// Branch target.
|
||||||
// FIXME: rename brtarget to t2_brtarget
|
// FIXME: rename brtarget to t2_brtarget
|
||||||
def brtarget : Operand<OtherVT> {
|
def brtarget : Operand<OtherVT> {
|
||||||
@ -496,7 +491,7 @@ def shift_so_reg_imm : Operand<i32>, // reg reg imm
|
|||||||
|
|
||||||
// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
|
// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
|
||||||
// 8-bit immediate rotated by an arbitrary number of bits.
|
// 8-bit immediate rotated by an arbitrary number of bits.
|
||||||
def SOImmAsmOperand: AsmOperandClass { let Name = "ARMSOImm"; }
|
def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
|
||||||
def so_imm : Operand<i32>, ImmLeaf<i32, [{
|
def so_imm : Operand<i32>, ImmLeaf<i32, [{
|
||||||
return ARM_AM::getSOImmVal(Imm) != -1;
|
return ARM_AM::getSOImmVal(Imm) != -1;
|
||||||
}]> {
|
}]> {
|
||||||
@ -521,7 +516,7 @@ def arm_i32imm : PatLeaf<(imm), [{
|
|||||||
}]>;
|
}]>;
|
||||||
|
|
||||||
/// imm0_7 predicate - Immediate in the range [0,7].
|
/// imm0_7 predicate - Immediate in the range [0,7].
|
||||||
def Imm0_7AsmOperand: AsmOperandClass { let Name = "Imm0_7"; }
|
def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
|
||||||
def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
|
def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
|
||||||
return Imm >= 0 && Imm < 8;
|
return Imm >= 0 && Imm < 8;
|
||||||
}]> {
|
}]> {
|
||||||
@ -529,7 +524,7 @@ def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// imm0_15 predicate - Immediate in the range [0,15].
|
/// imm0_15 predicate - Immediate in the range [0,15].
|
||||||
def Imm0_15AsmOperand: AsmOperandClass { let Name = "Imm0_15"; }
|
def Imm0_15AsmOperand: ImmAsmOperand { let Name = "Imm0_15"; }
|
||||||
def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
|
def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
|
||||||
return Imm >= 0 && Imm < 16;
|
return Imm >= 0 && Imm < 16;
|
||||||
}]> {
|
}]> {
|
||||||
@ -537,7 +532,7 @@ def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
|
/// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
|
||||||
def Imm0_31AsmOperand: AsmOperandClass { let Name = "Imm0_31"; }
|
def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
|
||||||
def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
|
def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
|
||||||
return Imm >= 0 && Imm < 32;
|
return Imm >= 0 && Imm < 32;
|
||||||
}]> {
|
}]> {
|
||||||
@ -545,7 +540,7 @@ def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
|
/// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
|
||||||
def Imm0_32AsmOperand: AsmOperandClass { let Name = "Imm0_32"; }
|
def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
|
||||||
def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
|
def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
|
||||||
return Imm >= 0 && Imm < 32;
|
return Imm >= 0 && Imm < 32;
|
||||||
}]> {
|
}]> {
|
||||||
@ -553,25 +548,33 @@ def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// imm0_255 predicate - Immediate in the range [0,255].
|
/// imm0_255 predicate - Immediate in the range [0,255].
|
||||||
def Imm0_255AsmOperand : AsmOperandClass { let Name = "Imm0_255"; }
|
def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
|
||||||
def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
|
def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
|
||||||
let ParserMatchClass = Imm0_255AsmOperand;
|
let ParserMatchClass = Imm0_255AsmOperand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// imm0_65535 - An immediate is in the range [0.65535].
|
||||||
|
def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
|
||||||
|
def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
|
||||||
|
return Imm >= 0 && Imm < 65536;
|
||||||
|
}]> {
|
||||||
|
let ParserMatchClass = Imm0_65535AsmOperand;
|
||||||
|
}
|
||||||
|
|
||||||
// imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
|
// imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
|
||||||
// a relocatable expression.
|
// a relocatable expression.
|
||||||
//
|
//
|
||||||
// FIXME: This really needs a Thumb version separate from the ARM version.
|
// FIXME: This really needs a Thumb version separate from the ARM version.
|
||||||
// While the range is the same, and can thus use the same match class,
|
// While the range is the same, and can thus use the same match class,
|
||||||
// the encoding is different so it should have a different encoder method.
|
// the encoding is different so it should have a different encoder method.
|
||||||
def Imm0_65535ExprAsmOperand: AsmOperandClass { let Name = "Imm0_65535Expr"; }
|
def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
|
||||||
def imm0_65535_expr : Operand<i32> {
|
def imm0_65535_expr : Operand<i32> {
|
||||||
let EncoderMethod = "getHiLo16ImmOpValue";
|
let EncoderMethod = "getHiLo16ImmOpValue";
|
||||||
let ParserMatchClass = Imm0_65535ExprAsmOperand;
|
let ParserMatchClass = Imm0_65535ExprAsmOperand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// imm24b - True if the 32-bit immediate is encodable in 24 bits.
|
/// imm24b - True if the 32-bit immediate is encodable in 24 bits.
|
||||||
def Imm24bitAsmOperand: AsmOperandClass { let Name = "Imm24bit"; }
|
def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
|
||||||
def imm24b : Operand<i32>, ImmLeaf<i32, [{
|
def imm24b : Operand<i32>, ImmLeaf<i32, [{
|
||||||
return Imm >= 0 && Imm <= 0xffffff;
|
return Imm >= 0 && Imm <= 0xffffff;
|
||||||
}]> {
|
}]> {
|
||||||
|
@ -65,7 +65,7 @@ def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
|
|||||||
// t2_so_imm - Match a 32-bit immediate operand, which is an
|
// t2_so_imm - Match a 32-bit immediate operand, which is an
|
||||||
// 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
|
// 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
|
||||||
// immediate splatted into multiple bytes of the word.
|
// immediate splatted into multiple bytes of the word.
|
||||||
def t2_so_imm_asmoperand : AsmOperandClass { let Name = "T2SOImm"; }
|
def t2_so_imm_asmoperand : ImmAsmOperand { let Name = "T2SOImm"; }
|
||||||
def t2_so_imm : Operand<i32>, ImmLeaf<i32, [{
|
def t2_so_imm : Operand<i32>, ImmLeaf<i32, [{
|
||||||
return ARM_AM::getT2SOImmVal(Imm) != -1;
|
return ARM_AM::getT2SOImmVal(Imm) != -1;
|
||||||
}]> {
|
}]> {
|
||||||
|
@ -1189,26 +1189,6 @@ public:
|
|||||||
Inst.addOperand(MCOperand::CreateImm(CE->getValue() / 4));
|
Inst.addOperand(MCOperand::CreateImm(CE->getValue() / 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addImm0_255Operands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImm0_7Operands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImm0_15Operands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImm0_31Operands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImm1_16Operands(MCInst &Inst, unsigned N) const {
|
void addImm1_16Operands(MCInst &Inst, unsigned N) const {
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
assert(N == 1 && "Invalid number of operands!");
|
||||||
// The constant encodes as the immediate-1, and we store in the instruction
|
// The constant encodes as the immediate-1, and we store in the instruction
|
||||||
@ -1225,26 +1205,6 @@ public:
|
|||||||
Inst.addOperand(MCOperand::CreateImm(CE->getValue() - 1));
|
Inst.addOperand(MCOperand::CreateImm(CE->getValue() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addImm0_32Operands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImm0_65535Operands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImm0_65535ExprOperands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImm24bitOperands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addImmThumbSROperands(MCInst &Inst, unsigned N) const {
|
void addImmThumbSROperands(MCInst &Inst, unsigned N) const {
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
assert(N == 1 && "Invalid number of operands!");
|
||||||
// The constant encodes as the immediate, except for 32, which encodes as
|
// The constant encodes as the immediate, except for 32, which encodes as
|
||||||
@ -1254,11 +1214,6 @@ public:
|
|||||||
Inst.addOperand(MCOperand::CreateImm((Imm == 32 ? 0 : Imm)));
|
Inst.addOperand(MCOperand::CreateImm((Imm == 32 ? 0 : Imm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPKHLSLImmOperands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addPKHASRImmOperands(MCInst &Inst, unsigned N) const {
|
void addPKHASRImmOperands(MCInst &Inst, unsigned N) const {
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
assert(N == 1 && "Invalid number of operands!");
|
||||||
// An ASR value of 32 encodes as 0, so that's how we want to add it to
|
// An ASR value of 32 encodes as 0, so that's how we want to add it to
|
||||||
@ -1268,16 +1223,6 @@ public:
|
|||||||
Inst.addOperand(MCOperand::CreateImm(Val == 32 ? 0 : Val));
|
Inst.addOperand(MCOperand::CreateImm(Val == 32 ? 0 : Val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addARMSOImmOperands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addT2SOImmOperands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addT2SOImmNotOperands(MCInst &Inst, unsigned N) const {
|
void addT2SOImmNotOperands(MCInst &Inst, unsigned N) const {
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
assert(N == 1 && "Invalid number of operands!");
|
||||||
// The operand is actually a t2_so_imm, but we have its bitwise
|
// The operand is actually a t2_so_imm, but we have its bitwise
|
||||||
@ -1294,11 +1239,6 @@ public:
|
|||||||
Inst.addOperand(MCOperand::CreateImm(~CE->getValue()));
|
Inst.addOperand(MCOperand::CreateImm(~CE->getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSetEndImmOperands(MCInst &Inst, unsigned N) const {
|
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
|
||||||
addExpr(Inst, getImm());
|
|
||||||
}
|
|
||||||
|
|
||||||
void addMemBarrierOptOperands(MCInst &Inst, unsigned N) const {
|
void addMemBarrierOptOperands(MCInst &Inst, unsigned N) const {
|
||||||
assert(N == 1 && "Invalid number of operands!");
|
assert(N == 1 && "Invalid number of operands!");
|
||||||
Inst.addOperand(MCOperand::CreateImm(unsigned(getMemBarrierOpt())));
|
Inst.addOperand(MCOperand::CreateImm(unsigned(getMemBarrierOpt())));
|
||||||
|
Loading…
Reference in New Issue
Block a user