mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-10 02:25:47 +00:00
Binary encoding for ARM tLDRspi and tSTRspi.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121186 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -247,6 +247,8 @@ namespace {
|
|||||||
const { return 0;}
|
const { return 0;}
|
||||||
uint32_t getAddrMode3OpValue(const MachineInstr &MI, unsigned Op)
|
uint32_t getAddrMode3OpValue(const MachineInstr &MI, unsigned Op)
|
||||||
const { return 0; }
|
const { return 0; }
|
||||||
|
uint32_t getAddrModeThumbSPOpValue(const MachineInstr &MI, unsigned Op)
|
||||||
|
const { return 0; }
|
||||||
uint32_t getAddrModeS4OpValue(const MachineInstr &MI, unsigned Op)
|
uint32_t getAddrModeS4OpValue(const MachineInstr &MI, unsigned Op)
|
||||||
const { return 0; }
|
const { return 0; }
|
||||||
uint32_t getAddrModeS2OpValue(const MachineInstr &MI, unsigned Op)
|
uint32_t getAddrModeS2OpValue(const MachineInstr &MI, unsigned Op)
|
||||||
|
@@ -128,6 +128,7 @@ def t_addrmode_s1 : Operand<i32>,
|
|||||||
//
|
//
|
||||||
def t_addrmode_sp : Operand<i32>,
|
def t_addrmode_sp : Operand<i32>,
|
||||||
ComplexPattern<i32, 2, "SelectThumbAddrModeSP", []> {
|
ComplexPattern<i32, 2, "SelectThumbAddrModeSP", []> {
|
||||||
|
let EncoderMethod = "getAddrModeThumbSPOpValue";
|
||||||
let PrintMethod = "printThumbAddrModeSPOperand";
|
let PrintMethod = "printThumbAddrModeSPOperand";
|
||||||
let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
|
let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
|
||||||
let ParserMatchClass = MemModeThumbAsmOperand;
|
let ParserMatchClass = MemModeThumbAsmOperand;
|
||||||
@@ -600,14 +601,20 @@ def tLDRSH : // A8.6.84
|
|||||||
[(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
|
[(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
|
||||||
|
|
||||||
let canFoldAsLoad = 1 in
|
let canFoldAsLoad = 1 in
|
||||||
def tLDRspi : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr), IIC_iLoad_i,
|
def tLDRspi : T1pIs<(outs tGPR:$Rt), (ins t_addrmode_sp:$addr), IIC_iLoad_i,
|
||||||
"ldr", "\t$dst, $addr",
|
"ldr", "\t$Rt, $addr",
|
||||||
[(set tGPR:$dst, (load t_addrmode_sp:$addr))]>,
|
[(set tGPR:$Rt, (load t_addrmode_sp:$addr))]>,
|
||||||
T1LdStSP<{1,?,?}>;
|
T1LdStSP<{1,?,?}> {
|
||||||
|
bits<3> Rt;
|
||||||
|
bits<8> addr;
|
||||||
|
let Inst{10-8} = Rt;
|
||||||
|
let Inst{7-0} = addr;
|
||||||
|
}
|
||||||
|
|
||||||
// Special instruction for restore. It cannot clobber condition register
|
// Special instruction for restore. It cannot clobber condition register
|
||||||
// when it's expanded by eliminateCallFramePseudoInstr().
|
// when it's expanded by eliminateCallFramePseudoInstr().
|
||||||
let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1 in
|
let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1 in
|
||||||
|
// FIXME: Pseudo for tLDRspi
|
||||||
def tRestore : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr), IIC_iLoad_i,
|
def tRestore : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr), IIC_iLoad_i,
|
||||||
"ldr", "\t$dst, $addr", []>,
|
"ldr", "\t$dst, $addr", []>,
|
||||||
T1LdStSP<{1,?,?}>;
|
T1LdStSP<{1,?,?}>;
|
||||||
@@ -668,14 +675,20 @@ def tSTRHi : // A8.6.205
|
|||||||
"strh", "\t$Rt, $addr",
|
"strh", "\t$Rt, $addr",
|
||||||
[]>;
|
[]>;
|
||||||
|
|
||||||
def tSTRspi : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr), IIC_iStore_i,
|
def tSTRspi : T1pIs<(outs), (ins tGPR:$Rt, t_addrmode_sp:$addr), IIC_iStore_i,
|
||||||
"str", "\t$src, $addr",
|
"str", "\t$Rt, $addr",
|
||||||
[(store tGPR:$src, t_addrmode_sp:$addr)]>,
|
[(store tGPR:$Rt, t_addrmode_sp:$addr)]>,
|
||||||
T1LdStSP<{0,?,?}>;
|
T1LdStSP<{0,?,?}> {
|
||||||
|
bits<3> Rt;
|
||||||
|
bits<8> addr;
|
||||||
|
let Inst{10-8} = Rt;
|
||||||
|
let Inst{7-0} = addr;
|
||||||
|
}
|
||||||
|
|
||||||
let mayStore = 1, neverHasSideEffects = 1 in
|
let mayStore = 1, neverHasSideEffects = 1 in
|
||||||
// Special instruction for spill. It cannot clobber condition register when it's
|
// Special instruction for spill. It cannot clobber condition register when it's
|
||||||
// expanded by eliminateCallFramePseudoInstr().
|
// expanded by eliminateCallFramePseudoInstr().
|
||||||
|
// FIXME: Pseudo for tSTRspi
|
||||||
def tSpill : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr), IIC_iStore_i,
|
def tSpill : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr), IIC_iStore_i,
|
||||||
"str", "\t$src, $addr", []>,
|
"str", "\t$src, $addr", []>,
|
||||||
T1LdStSP<{0,?,?}>;
|
T1LdStSP<{0,?,?}>;
|
||||||
|
@@ -156,6 +156,11 @@ public:
|
|||||||
uint32_t getAddrMode3OpValue(const MCInst &MI, unsigned OpIdx,
|
uint32_t getAddrMode3OpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||||
|
|
||||||
|
/// getAddrModeThumbSPOpValue - Return encoding info for 'reg +/- imm12'
|
||||||
|
/// operand.
|
||||||
|
uint32_t getAddrModeThumbSPOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
|
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||||
|
|
||||||
/// getAddrModeS4OpValue - Return encoding for t_addrmode_s4 operands.
|
/// getAddrModeS4OpValue - Return encoding for t_addrmode_s4 operands.
|
||||||
uint32_t getAddrModeS4OpValue(const MCInst &MI, unsigned OpIdx,
|
uint32_t getAddrModeS4OpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||||
@@ -656,6 +661,20 @@ getAddrMode3OpValue(const MCInst &MI, unsigned OpIdx,
|
|||||||
return (Rn << 9) | Imm8 | (isAdd << 8) | (isImm << 13);
|
return (Rn << 9) | Imm8 | (isAdd << 8) | (isImm << 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getAddrModeThumbSPOpValue- Encode the t_addrmode_sp operands.
|
||||||
|
uint32_t ARMMCCodeEmitter::
|
||||||
|
getAddrModeThumbSPOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
|
SmallVectorImpl<MCFixup> &Fixups) const {
|
||||||
|
// [SP, #imm]
|
||||||
|
// {7-0} = imm8
|
||||||
|
const MCOperand &MO = MI.getOperand(OpIdx);
|
||||||
|
const MCOperand &MO1 = MI.getOperand(OpIdx + 1);
|
||||||
|
assert (MO.getReg() == ARM::SP && "Unexpected base register!");
|
||||||
|
// The immediate is already shifted for the implicit zeroes, so no change
|
||||||
|
// here.
|
||||||
|
return MO1.getImm() & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
/// getAddrModeSOpValue - Encode the t_addrmode_s# operands.
|
/// getAddrModeSOpValue - Encode the t_addrmode_s# operands.
|
||||||
static unsigned getAddrModeSOpValue(const MCInst &MI, unsigned OpIdx,
|
static unsigned getAddrModeSOpValue(const MCInst &MI, unsigned OpIdx,
|
||||||
unsigned Scale) {
|
unsigned Scale) {
|
||||||
|
Reference in New Issue
Block a user