Index: llvm/lib/Target/AVR/AVRInstrFormats.td =================================================================== --- llvm/lib/Target/AVR/AVRInstrFormats.td +++ llvm/lib/Target/AVR/AVRInstrFormats.td @@ -332,6 +332,8 @@ let Inst{10-9} = A{5-4}; let Inst{8-4} = d; let Inst{3-0} = A{3-0}; + + let DecoderMethod = "decodeFIORdA"; } //===----------------------------------------------------------------------===// @@ -350,6 +352,8 @@ let Inst{10-9} = A{5-4}; let Inst{8-4} = r; let Inst{3-0} = A{3-0}; + + let DecoderMethod = "decodeFIOARr"; } //===----------------------------------------------------------------------===// @@ -374,6 +378,8 @@ let Inst{3} = A{0}; let Inst{2-0} = b{2-0}; + + let DecoderMethod = "decodeFIOBIT"; } //===----------------------------------------------------------------------===// Index: llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp =================================================================== --- llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp +++ llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp @@ -95,8 +95,48 @@ return MCDisassembler::Success; } +static DecodeStatus decodeFIOARr(MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder); + +static DecodeStatus decodeFIORdA(MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder); + +static DecodeStatus decodeFIOBIT(MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder); + #include "AVRGenDisassemblerTables.inc" +static DecodeStatus decodeFIOARr(MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder) { + unsigned addr = 0; + addr |= fieldFromInstruction(Insn, 0, 4); + addr |= fieldFromInstruction(Insn, 9, 2) << 4; + unsigned reg = fieldFromInstruction(Insn, 4, 5); + Inst.addOperand(MCOperand::createImm(addr)); + if (DecodeGPR8RegisterClass(Inst, reg, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; } + return MCDisassembler::Success; +} + +static DecodeStatus decodeFIORdA(MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder) { + unsigned addr = 0; + addr |= fieldFromInstruction(Insn, 0, 4); + addr |= fieldFromInstruction(Insn, 9, 2) << 4; + unsigned reg = fieldFromInstruction(Insn, 4, 5); + if (DecodeGPR8RegisterClass(Inst, reg, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; } + Inst.addOperand(MCOperand::createImm(addr)); + return MCDisassembler::Success; +} + +static DecodeStatus decodeFIOBIT(MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder) { + unsigned addr = fieldFromInstruction(Insn, 3, 5); + unsigned b = fieldFromInstruction(Insn, 0, 3); + Inst.addOperand(MCOperand::createImm(addr)); + Inst.addOperand(MCOperand::createImm(b)); + return MCDisassembler::Success; +} + static DecodeStatus readInstruction16(ArrayRef Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn) { if (Bytes.size() < 2) { Index: llvm/test/MC/AVR/inst-cbi.s =================================================================== --- llvm/test/MC/AVR/inst-cbi.s +++ llvm/test/MC/AVR/inst-cbi.s @@ -1,4 +1,5 @@ ; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s +; RUN: llvm-mc -filetype=obj -triple avr < %s | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s foo: @@ -18,3 +19,9 @@ ; CHECK: cbi bar-2, 2 ; encoding: [0bAAAAA010,0x98] ; CHECK: ; fixup A - offset: 0, value: bar-2, kind: fixup_port5 +; CHECK-INST: cbi 3, 5 +; CHECK-INST: cbi 1, 1 +; CHECK-INST: cbi 0, 0 +; CHECK-INST: cbi 7, 2 + +; CHECK-INST: cbi 0, 2 Index: llvm/test/MC/AVR/inst-in.s =================================================================== --- llvm/test/MC/AVR/inst-in.s +++ llvm/test/MC/AVR/inst-in.s @@ -1,4 +1,5 @@ ; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s +; RUN: llvm-mc -filetype=obj -triple avr < %s | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s foo: @@ -18,3 +19,8 @@ ; CHECK: in r20, foo+1 ; encoding: [0x40'A',0xb1'A'] ; CHECK: ; fixup A - offset: 0, value: foo+1, kind: fixup_port6 +; CHECK-INST: in r2, 4 +; CHECK-INST: in r9, 6 +; CHECK-INST: in r5, 32 +; CHECK-INST: in r0, 0 +; CHECK-INST: in r20, 0 Index: llvm/test/MC/AVR/inst-out.s =================================================================== --- llvm/test/MC/AVR/inst-out.s +++ llvm/test/MC/AVR/inst-out.s @@ -1,4 +1,5 @@ ; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s +; RUN: llvm-mc -filetype=obj -triple avr < %s | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s foo: @@ -18,3 +19,9 @@ ; CHECK: out bar-8, r29 ; encoding: [0xd0'A',0xb9'A'] ; CHECK: ; fixup A - offset: 0, value: bar-8, kind: fixup_port6 +; CHECK-INST: out 4, r2 +; CHECK-INST: out 6, r9 +; CHECK-INST: out 32, r5 +; CHECK-INST: out 0, r0 + +; CHECK-INST: out 0, r29 Index: llvm/test/MC/AVR/inst-sbi.s =================================================================== --- llvm/test/MC/AVR/inst-sbi.s +++ llvm/test/MC/AVR/inst-sbi.s @@ -1,4 +1,5 @@ ; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s +; RUN: llvm-mc -filetype=obj -triple avr < %s | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s foo: @@ -18,3 +19,8 @@ ; CHECK: sbi main, 0 ; encoding: [0bAAAAA000,0x9a] ; CHECK: ; fixup A - offset: 0, value: main, kind: fixup_port5 +; CHECK-INST: sbi 3, 5 +; CHECK-INST: sbi 1, 1 +; CHECK-INST: sbi 0, 0 +; CHECK-INST: sbi 7, 2 +; CHECK-INST: sbi 0, 0 Index: llvm/test/MC/AVR/inst-sbic.s =================================================================== --- llvm/test/MC/AVR/inst-sbic.s +++ llvm/test/MC/AVR/inst-sbic.s @@ -1,4 +1,5 @@ ; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s +; RUN: llvm-mc -filetype=obj -triple avr < %s | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s foo: @@ -17,3 +18,9 @@ ; CHECK: sbic foo+1, 1 ; encoding: [0bAAAAA001,0x99] ; CHECK: ; fixup A - offset: 0, value: foo+1, kind: fixup_port5 + +; CHECK-INST: sbic 4, 3 +; CHECK-INST: sbic 6, 2 +; CHECK-INST: sbic 16, 5 +; CHECK-INST: sbic 0, 0 +; CHECK-INST: sbic 0, 1 Index: llvm/test/MC/AVR/inst-sbis.s =================================================================== --- llvm/test/MC/AVR/inst-sbis.s +++ llvm/test/MC/AVR/inst-sbis.s @@ -1,4 +1,5 @@ ; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s +; RUN: llvm-mc -filetype=obj -triple avr < %s | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s foo: @@ -16,3 +17,9 @@ ; CHECK: sbis FOO+4, 7 ; encoding: [0bAAAAA111,0x9b] ; CHECK: ; fixup A - offset: 0, value: FOO+4, kind: fixup_port5 + +; CHECK-INST: sbis 4, 3 +; CHECK-INST: sbis 6, 2 +; CHECK-INST: sbis 16, 5 +; CHECK-INST: sbis 0, 0 +; CHECK-INST: sbis 0, 7