From 71810ab7c0ecd6927dde1eee0c73169642f3764d Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Thu, 10 Nov 2011 16:44:55 +0000 Subject: [PATCH] ARM assembly parsing for ASR(immediate). Start of rdar://9704684 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144293 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMInstrFormats.td | 20 +++++++++++++------- lib/Target/ARM/ARMInstrInfo.td | 9 +++++++++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 15 +++++++++++++++ test/MC/ARM/basic-arm-instructions.s | 9 ++++++++- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/lib/Target/ARM/ARMInstrFormats.td b/lib/Target/ARM/ARMInstrFormats.td index f9969b9e6f3..c5bf607fd1c 100644 --- a/lib/Target/ARM/ARMInstrFormats.td +++ b/lib/Target/ARM/ARMInstrFormats.td @@ -293,21 +293,27 @@ class InstThumb +class AsmPseudoInst : InstTemplate { - let OutOperandList = (ops); + let OutOperandList = (outs); let InOperandList = iops; let Pattern = []; let isCodeGenOnly = 0; // So we get asm matcher for it. + let AsmString = asm; let isPseudo = 1; } -class ARMAsmPseudo : AsmPseudoInst, Requires<[IsARM]>; -class tAsmPseudo : AsmPseudoInst, Requires<[IsThumb]>; -class t2AsmPseudo : AsmPseudoInst, Requires<[IsThumb2]>; -class VFP2AsmPseudo : AsmPseudoInst, Requires<[HasVFP2]>; -class NEONAsmPseudo : AsmPseudoInst, Requires<[HasNEON]>; +class ARMAsmPseudo : AsmPseudoInst, + Requires<[IsARM]>; +class tAsmPseudo : AsmPseudoInst, + Requires<[IsThumb]>; +class t2AsmPseudo : AsmPseudoInst, + Requires<[IsThumb2]>; +class VFP2AsmPseudo : AsmPseudoInst, + Requires<[HasVFP2]>; +class NEONAsmPseudo : AsmPseudoInst, + Requires<[HasNEON]>; // Pseudo instructions for the code generator. class PseudoInst pattern> diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index af98af85bec..359053c1676 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -4994,3 +4994,12 @@ def : MnemonicAlias<"usubaddx", "usax">; // for isel. def : ARMInstAlias<"mov${s}${p} $Rd, $imm", (MVNi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>; + +// The shifter forms of the MOV instruction are aliased to the ASR, LSL, +// LSR, ROR, and RRX instructions. +// FIXME: We need C++ parser hooks to map the alias to the MOV +// encoding. It seems we should be able to do that sort of thing +// in tblgen, but it could get ugly. +def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm", + (ins GPR:$Rd, GPR:$Rm, imm1_32:$imm, pred:$p, + cc_out:$s)>; diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index cb0c97b4c63..e68ecec301a 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -4541,6 +4541,21 @@ void ARMAsmParser:: processInstruction(MCInst &Inst, const SmallVectorImpl &Operands) { switch (Inst.getOpcode()) { + // Handle the MOV complex aliases. + case ARM::ASRi: { + unsigned Amt = Inst.getOperand(2).getImm() + 1; + unsigned ShiftOp = ARM_AM::getSORegOpc(ARM_AM::asr, Amt); + MCInst TmpInst; + TmpInst.setOpcode(ARM::MOVsi); + TmpInst.addOperand(Inst.getOperand(0)); // Rd + TmpInst.addOperand(Inst.getOperand(1)); // Rn + TmpInst.addOperand(MCOperand::CreateImm(ShiftOp)); // Shift value and ty + TmpInst.addOperand(Inst.getOperand(3)); // CondCode + TmpInst.addOperand(Inst.getOperand(4)); + TmpInst.addOperand(Inst.getOperand(5)); // cc_out + Inst = TmpInst; + break; + } case ARM::LDMIA_UPD: // If this is a load of a single register via a 'pop', then we should use // a post-indexed LDR instruction instead, per the ARM ARM. diff --git a/test/MC/ARM/basic-arm-instructions.s b/test/MC/ARM/basic-arm-instructions.s index 55d9f026195..f2f6a94727b 100644 --- a/test/MC/ARM/basic-arm-instructions.s +++ b/test/MC/ARM/basic-arm-instructions.s @@ -257,8 +257,15 @@ Lforward: @ CHECK: and r10, r10, r1, rrx @ encoding: [0x61,0xa0,0x0a,0xe0] @------------------------------------------------------------------------------ -@ FIXME: ASR +@ ASR @------------------------------------------------------------------------------ + asr r2, r4, #32 + asr r2, r4, #2 + +@ CHECK: asr r2, r4, #32 @ encoding: [0x44,0x20,0xa0,0xe1] +@ CHECK: asr r2, r4, #2 @ encoding: [0x44,0x21,0xa0,0xe1] + + @------------------------------------------------------------------------------ @ B @------------------------------------------------------------------------------ -- 2.34.1