mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
ARM LDRH(immediate) assembly parsing and encoding support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137260 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c7de52fcff
commit
623a454b0f
@ -2007,16 +2007,18 @@ multiclass AI3_ldridx<bits<4> op, bit op20, string opc, InstrItinClass itin> {
|
||||
let Inst{19-16} = addr{12-9}; // Rn
|
||||
let Inst{11-8} = addr{7-4}; // imm7_4/zero
|
||||
let Inst{3-0} = addr{3-0}; // imm3_0/Rm
|
||||
let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
|
||||
}
|
||||
def _POST : AI3ldstidx<op, op20, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
|
||||
(ins GPR:$Rn, am3offset:$offset), IndexModePost,
|
||||
LdMiscFrm, itin,
|
||||
opc, "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb", []> {
|
||||
(ins addr_offset_none:$addr, am3offset:$offset),
|
||||
IndexModePost, LdMiscFrm, itin,
|
||||
opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
|
||||
[]> {
|
||||
bits<10> offset;
|
||||
bits<4> Rn;
|
||||
bits<4> addr;
|
||||
let Inst{23} = offset{8}; // U bit
|
||||
let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
|
||||
let Inst{19-16} = Rn;
|
||||
let Inst{19-16} = addr;
|
||||
let Inst{11-8} = offset{7-4}; // imm7_4/zero
|
||||
let Inst{3-0} = offset{3-0}; // imm3_0/Rm
|
||||
}
|
||||
|
@ -131,6 +131,8 @@ class ARMAsmParser : public MCTargetAsmParser {
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
bool cvtLdrdPre(MCInst &Inst, unsigned Opcode,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
bool cvtLdWriteBackRegAddrMode3(MCInst &Inst, unsigned Opcode,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
|
||||
bool validateInstruction(MCInst &Inst,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &Ops);
|
||||
@ -2202,6 +2204,21 @@ cvtLdrdPre(MCInst &Inst, unsigned Opcode,
|
||||
return true;
|
||||
}
|
||||
|
||||
/// cvtLdWriteBackRegAddrMode3 - Convert parsed operands to MCInst.
|
||||
/// Needed here because the Asm Gen Matcher can't handle properly tied operands
|
||||
/// when they refer multiple MIOperands inside a single one.
|
||||
bool ARMAsmParser::
|
||||
cvtLdWriteBackRegAddrMode3(MCInst &Inst, unsigned Opcode,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
((ARMOperand*)Operands[2])->addRegOperands(Inst, 1);
|
||||
// Create a writeback register dummy placeholder.
|
||||
Inst.addOperand(MCOperand::CreateImm(0));
|
||||
((ARMOperand*)Operands[3])->addAddrMode3Operands(Inst, 3);
|
||||
((ARMOperand*)Operands[1])->addCondCodeOperands(Inst, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// Parse an ARM memory expression, return false if successful else return true
|
||||
/// or an error. The first token must be a '[' when called.
|
||||
bool ARMAsmParser::
|
||||
|
@ -139,7 +139,23 @@ _func:
|
||||
ldrd r1, r2, [r8], r12
|
||||
ldrd r1, r2, [r8], -r12
|
||||
|
||||
ldrd r3, r4, [r1, r3] @ encoding: [0xd3,0x30,0x81,0xe1]
|
||||
ldrd r4, r5, [r7, r2]! @ encoding: [0xd2,0x40,0xa7,0xe1]
|
||||
ldrd r1, r2, [r8], r12 @ encoding: [0xdc,0x10,0x88,0xe0]
|
||||
ldrd r1, r2, [r8], -r12 @ encoding: [0xdc,0x10,0x08,0xe0]
|
||||
@ CHECK: ldrd r3, r4, [r1, r3] @ encoding: [0xd3,0x30,0x81,0xe1]
|
||||
@ CHECK: ldrd r4, r5, [r7, r2]! @ encoding: [0xd2,0x40,0xa7,0xe1]
|
||||
@ CHECK: ldrd r1, r2, [r8], r12 @ encoding: [0xdc,0x10,0x88,0xe0]
|
||||
@ CHECK: ldrd r1, r2, [r8], -r12 @ encoding: [0xdc,0x10,0x08,0xe0]
|
||||
|
||||
|
||||
@------------------------------------------------------------------------------
|
||||
@ LDRH (immediate)
|
||||
@------------------------------------------------------------------------------
|
||||
ldrh r3, [r4]
|
||||
ldrh r2, [r7, #4]
|
||||
ldrh r1, [r8, #64]!
|
||||
ldrh r12, [sp], #4
|
||||
|
||||
@ CHECK: ldrh r3, [r4] @ encoding: [0xb0,0x30,0xd4,0xe1]
|
||||
@ CHECK: ldrh r2, [r7, #4] @ encoding: [0xb4,0x20,0xd7,0xe1]
|
||||
@ CHECK: ldrh r1, [r8, #64]! @ encoding: [0xb0,0x14,0xf8,0xe1]
|
||||
@ CHECK: ldrh r12, [sp], #4 @ encoding: [0xb4,0xc0,0xdd,0xe0]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user