Skip to content
This repository has been archived by the owner on Sep 2, 2018. It is now read-only.

WIP: Add 16-bit STS instruction #227

Open
wants to merge 1 commit into
base: avr-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/Target/AVR/AVRInstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,19 @@ class FIOBIT<bits<2> t, dag outs, dag ins, string asmstr, list<dag> pattern>
let Inst{2-0} = b{2-0};
}

class FIO16<bit type, dag outs, dag ins, string asmstr, list<dag> pattern>
: AVRInst16<outs, ins, asmstr, pattern>
{
bits<7> k;
bits<4> d;

let Inst{15-12} = 0b1010;
let Inst{11} = type;
let Inst{10-8} = k{6-4};
let Inst{7-4} = d;
let Inst{3-0} = k{3-0};
}

//===----------------------------------------------------------------------===//
// BST/BLD instruction.
// <|1111|1ttd|dddd|0bbb>
Expand Down
27 changes: 27 additions & 0 deletions lib/Target/AVR/AVRInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def imm0_63_neg : PatLeaf<(imm),
}], imm16_neg_XFORM>;

def uimm6 : PatLeaf<(imm), [{ return isUInt<6>(N->getZExtValue()); }]>;
def uimm7 : PatLeaf<(imm), [{ return isUInt<7>(N->getZExtValue()); }]>;

def ioaddr_XFORM : SDNodeXForm<imm,
[{
Expand Down Expand Up @@ -1135,6 +1136,19 @@ isReMaterializable = 1 in
Requires<[HasSRAM]>;
}

// Indirect load from data space to register.
// FIXME:
// - make this a physical instruction (not a pseudo)
// - map r0..r15 onto r16..r31 so that the numbers match up.
// - do weird MSB inversion as specified in datsheet
// encoding:
def LDS16KRr : FIO16<0,
(outs),
(ins uimm7:$k, GPR8hi:$rd),
"sts\t$k, $rd",
[store i8:$rd, imm:$k]>,
Requires<[HasTinyEncoding]>;

// Indirect loads.
let canFoldAsLoad = 1,
isReMaterializable = 1 in
Expand Down Expand Up @@ -1275,6 +1289,19 @@ def STSKRr : F32DM<0b1,
[(store i8:$rd, imm:$k)]>,
Requires<[HasSRAM]>;

// Indirect store from register to data space.
// FIXME:
// - make this a physical instruction (not a pseudo)
// - map r0..r15 onto r16..r31 so that the numbers match up.
// - do weird MSB inversion as specified in datsheet
// encoding:
def STS16KRr : FIO16<1,
(outs),
(ins uimm7:$k, GPR8hi:$rd),
"sts\t$k, $rd",
[store i8:$rd, imm:$k]>,
Requires<[HasTinyEncoding]>;

// STSW K+1:K, Rr+1:Rr
//
// Expands to:
Expand Down
7 changes: 7 additions & 0 deletions lib/Target/AVR/AVRRegisterInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def GPR8lo : RegisterClass<"AVR", [i8], 8,
add R15, R14, R13, R12, R11, R10, R9, R8, R7, R6, R5, R4, R3, R2, R0, R1
)>;

// Upper registers r0..r15
def GPR8hi : RegisterClass<"AVR", [i8], 8,
(
add R16, R17, R18, R19, R20, R21, R22, R23,
R24, R25, R26, R27, R28, R29, R30, R31
)>;

// 8-bit register class for instructions which take immediates.
def LD8 : RegisterClass<"AVR", [i8], 8,
(
Expand Down