From 0f4b60d43a289671082deee3bd56a3a055afb16a Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Fri, 10 Dec 2010 22:11:13 +0000 Subject: [PATCH] Fix encoding of Thumb1 LDRB and STRB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121581 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMCodeEmitter.cpp | 2 ++ lib/Target/ARM/ARMInstrThumb.td | 1 + lib/Target/ARM/ARMMCCodeEmitter.cpp | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/lib/Target/ARM/ARMCodeEmitter.cpp b/lib/Target/ARM/ARMCodeEmitter.cpp index dc9f52488cf..823947395f2 100644 --- a/lib/Target/ARM/ARMCodeEmitter.cpp +++ b/lib/Target/ARM/ARMCodeEmitter.cpp @@ -191,6 +191,8 @@ namespace { const { return 0; } unsigned getSORegOpValue(const MachineInstr &MI, unsigned Op) const { return 0; } + unsigned getTAddrModeRegRegOpValue(const MachineInstr &MI, unsigned Op) + const { return 0; } unsigned getT2AddrModeImm12OpValue(const MachineInstr &MI, unsigned Op) const { return 0; } unsigned getT2AddrModeImm8OpValue(const MachineInstr &MI, unsigned Op) diff --git a/lib/Target/ARM/ARMInstrThumb.td b/lib/Target/ARM/ARMInstrThumb.td index e25e9cc9d90..c1192910113 100644 --- a/lib/Target/ARM/ARMInstrThumb.td +++ b/lib/Target/ARM/ARMInstrThumb.td @@ -103,6 +103,7 @@ def MemModeThumbAsmOperand : AsmOperandClass { // def t_addrmode_rr : Operand, ComplexPattern { + let EncoderMethod = "getTAddrModeRegRegOpValue"; let PrintMethod = "printThumbAddrModeRROperand"; let MIOperandInfo = (ops tGPR:$base, tGPR:$offsreg); } diff --git a/lib/Target/ARM/ARMMCCodeEmitter.cpp b/lib/Target/ARM/ARMMCCodeEmitter.cpp index f63d2f3be1e..e4f3288c82d 100644 --- a/lib/Target/ARM/ARMMCCodeEmitter.cpp +++ b/lib/Target/ARM/ARMMCCodeEmitter.cpp @@ -129,6 +129,10 @@ public: uint32_t getAddrModeImm12OpValue(const MCInst &MI, unsigned OpIdx, SmallVectorImpl &Fixups) const; + /// getTAddrModeRegRegOpValue - Return encoding for 'reg + reg' operand. + uint32_t getTAddrModeRegRegOpValue(const MCInst &MI, unsigned OpIdx, + SmallVectorImpl &Fixups) const; + /// getT2AddrModeImm8s4OpValue - Return encoding info for 'reg +/- imm8<<2' /// operand. uint32_t getT2AddrModeImm8s4OpValue(const MCInst &MI, unsigned OpIdx, @@ -504,6 +508,17 @@ getAdrLabelOpValue(const MCInst &MI, unsigned OpIdx, Fixups); } +/// getTAddrModeRegRegOpValue - Return encoding info for 'reg + reg' operand. +uint32_t ARMMCCodeEmitter:: +getTAddrModeRegRegOpValue(const MCInst &MI, unsigned OpIdx, + SmallVectorImpl &Fixups) const { + const MCOperand &MO1 = MI.getOperand(OpIdx); + const MCOperand &MO2 = MI.getOperand(OpIdx+1); + unsigned Rn = getARMRegisterNumbering(MO1.getReg()); + unsigned Rm = getARMRegisterNumbering(MO2.getReg()); + return (Rm << 3) | Rn; +} + /// getAddrModeImm12OpValue - Return encoding info for 'reg +/- imm12' operand. uint32_t ARMMCCodeEmitter:: getAddrModeImm12OpValue(const MCInst &MI, unsigned OpIdx, -- 2.34.1