mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-17 18:31:04 +00:00
Thumb conditional branch binary encodings. rdar://8745367
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121493 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c8cfbcb99a
commit
0108645139
@ -200,6 +200,9 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
|
|||||||
uint32_t Binary = (Value - 4) >> 1;
|
uint32_t Binary = (Value - 4) >> 1;
|
||||||
return ((Binary & 0x20) << 9) | ((Binary & 0x1f) << 3);
|
return ((Binary & 0x20) << 9) | ((Binary & 0x1f) << 3);
|
||||||
}
|
}
|
||||||
|
case ARM::fixup_arm_thumb_bcc:
|
||||||
|
// Offset by 4 and don't encode the lower bit, which is always 0.
|
||||||
|
return ((Value - 4) >> 1) & 0xff;
|
||||||
case ARM::fixup_arm_pcrel_10:
|
case ARM::fixup_arm_pcrel_10:
|
||||||
Value = Value - 6; // ARM fixups offset by an additional word and don't
|
Value = Value - 6; // ARM fixups offset by an additional word and don't
|
||||||
// need to adjust for the half-word ordering.
|
// need to adjust for the half-word ordering.
|
||||||
@ -310,6 +313,7 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
|
|||||||
default:
|
default:
|
||||||
llvm_unreachable("Unknown fixup kind!");
|
llvm_unreachable("Unknown fixup kind!");
|
||||||
|
|
||||||
|
case ARM::fixup_arm_thumb_bcc:
|
||||||
case ARM::fixup_arm_thumb_cp:
|
case ARM::fixup_arm_thumb_cp:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -175,6 +175,8 @@ namespace {
|
|||||||
const { return 0; }
|
const { return 0; }
|
||||||
unsigned getThumbBLXTargetOpValue(const MachineInstr &MI, unsigned Op)
|
unsigned getThumbBLXTargetOpValue(const MachineInstr &MI, unsigned Op)
|
||||||
const { return 0; }
|
const { return 0; }
|
||||||
|
unsigned getThumbBCCTargetOpValue(const MachineInstr &MI, unsigned Op)
|
||||||
|
const { return 0; }
|
||||||
unsigned getThumbCBTargetOpValue(const MachineInstr &MI, unsigned Op)
|
unsigned getThumbCBTargetOpValue(const MachineInstr &MI, unsigned Op)
|
||||||
const { return 0; }
|
const { return 0; }
|
||||||
unsigned getBranchTargetOpValue(const MachineInstr &MI, unsigned Op)
|
unsigned getBranchTargetOpValue(const MachineInstr &MI, unsigned Op)
|
||||||
|
@ -52,6 +52,9 @@ enum Fixups {
|
|||||||
// fixup_arm_thumb_cp - Fixup for Thumb load/store from constant pool instrs.
|
// fixup_arm_thumb_cp - Fixup for Thumb load/store from constant pool instrs.
|
||||||
fixup_arm_thumb_cp,
|
fixup_arm_thumb_cp,
|
||||||
|
|
||||||
|
// fixup_arm_thumb_bcc - Fixup for Thumb load/store from constant pool instrs.
|
||||||
|
fixup_arm_thumb_bcc,
|
||||||
|
|
||||||
// The next two are for the movt/movw pair
|
// The next two are for the movt/movw pair
|
||||||
// the 16bit imm field are split into imm{15-12} and imm{11-0}
|
// the 16bit imm field are split into imm{15-12} and imm{11-0}
|
||||||
// Fixme: We need new ones for Thumb.
|
// Fixme: We need new ones for Thumb.
|
||||||
|
@ -74,6 +74,10 @@ def t_imm_s4 : Operand<i32> {
|
|||||||
|
|
||||||
// Define Thumb specific addressing modes.
|
// Define Thumb specific addressing modes.
|
||||||
|
|
||||||
|
def t_bcctarget : Operand<i32> {
|
||||||
|
let EncoderMethod = "getThumbBCCTargetOpValue";
|
||||||
|
}
|
||||||
|
|
||||||
def t_cbtarget : Operand<i32> {
|
def t_cbtarget : Operand<i32> {
|
||||||
let EncoderMethod = "getThumbCBTargetOpValue";
|
let EncoderMethod = "getThumbCBTargetOpValue";
|
||||||
}
|
}
|
||||||
@ -508,12 +512,14 @@ let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
|
|||||||
// FIXME: should be able to write a pattern for ARMBrcond, but can't use
|
// FIXME: should be able to write a pattern for ARMBrcond, but can't use
|
||||||
// a two-value operand where a dag node expects two operands. :(
|
// a two-value operand where a dag node expects two operands. :(
|
||||||
let isBranch = 1, isTerminator = 1 in
|
let isBranch = 1, isTerminator = 1 in
|
||||||
def tBcc : T1I<(outs), (ins brtarget:$target, pred:$p), IIC_Br,
|
def tBcc : T1I<(outs), (ins t_bcctarget:$target, pred:$p), IIC_Br,
|
||||||
"b${p}\t$target",
|
"b${p}\t$target",
|
||||||
[/*(ARMbrcond bb:$target, imm:$cc)*/]>,
|
[/*(ARMbrcond bb:$target, imm:$cc)*/]>,
|
||||||
T1Encoding<{1,1,0,1,?,?}> {
|
T1Encoding<{1,1,0,1,?,?}> {
|
||||||
bits<4> p;
|
bits<4> p;
|
||||||
|
bits<8> target;
|
||||||
let Inst{11-8} = p;
|
let Inst{11-8} = p;
|
||||||
|
let Inst{7-0} = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare and branch on zero / non-zero
|
// Compare and branch on zero / non-zero
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
{ "fixup_arm_thumb_blx", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_arm_thumb_blx", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_arm_thumb_cb", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_arm_thumb_cb", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_arm_thumb_cp", 1, 8, MCFixupKindInfo::FKF_IsPCRel },
|
{ "fixup_arm_thumb_cp", 1, 8, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
|
{ "fixup_arm_thumb_bcc", 1, 8, MCFixupKindInfo::FKF_IsPCRel },
|
||||||
{ "fixup_arm_movt_hi16", 0, 16, 0 },
|
{ "fixup_arm_movt_hi16", 0, 16, 0 },
|
||||||
{ "fixup_arm_movw_lo16", 0, 16, 0 },
|
{ "fixup_arm_movw_lo16", 0, 16, 0 },
|
||||||
};
|
};
|
||||||
@ -100,6 +101,10 @@ public:
|
|||||||
uint32_t getThumbBLXTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
uint32_t getThumbBLXTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||||
|
|
||||||
|
/// getThumbBCCTargetOpValue - Return encoding info for Thumb branch target.
|
||||||
|
uint32_t getThumbBCCTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
|
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||||
|
|
||||||
/// getThumbCBTargetOpValue - Return encoding info for Thumb branch target.
|
/// getThumbCBTargetOpValue - Return encoding info for Thumb branch target.
|
||||||
uint32_t getThumbCBTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
uint32_t getThumbCBTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||||
@ -452,6 +457,13 @@ getThumbBLXTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
|||||||
return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_blx, Fixups);
|
return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_blx, Fixups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getThumbBCCTargetOpValue - Return encoding info for Thumb branch target.
|
||||||
|
uint32_t ARMMCCodeEmitter::
|
||||||
|
getThumbBCCTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
|
SmallVectorImpl<MCFixup> &Fixups) const {
|
||||||
|
return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_bcc, Fixups);
|
||||||
|
}
|
||||||
|
|
||||||
/// getThumbCBTargetOpValue - Return encoding info for Thumb branch target.
|
/// getThumbCBTargetOpValue - Return encoding info for Thumb branch target.
|
||||||
uint32_t ARMMCCodeEmitter::
|
uint32_t ARMMCCodeEmitter::
|
||||||
getThumbCBTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
getThumbCBTargetOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
|
@ -587,6 +587,7 @@ static int ARMFlagFromOpName(LiteralConstantEmitter *type,
|
|||||||
IMM("neon_vcvt_imm32");
|
IMM("neon_vcvt_imm32");
|
||||||
|
|
||||||
MISC("brtarget", "kOperandTypeARMBranchTarget"); // ?
|
MISC("brtarget", "kOperandTypeARMBranchTarget"); // ?
|
||||||
|
MISC("t_bcctarget", "kOperandTypeARMBranchTarget"); // ?
|
||||||
MISC("t_cbtarget", "kOperandTypeARMBranchTarget"); // ?
|
MISC("t_cbtarget", "kOperandTypeARMBranchTarget"); // ?
|
||||||
MISC("bltarget", "kOperandTypeARMBranchTarget"); // ?
|
MISC("bltarget", "kOperandTypeARMBranchTarget"); // ?
|
||||||
MISC("t_bltarget", "kOperandTypeARMBranchTarget"); // ?
|
MISC("t_bltarget", "kOperandTypeARMBranchTarget"); // ?
|
||||||
|
Loading…
Reference in New Issue
Block a user