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

Commit e3fdd64

Browse files
author
Dylan McKay
committed
[AVR] Add 16-bit STS instruction
1 parent e9d48fc commit e3fdd64

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

lib/Target/AVR/AVRInstrFormats.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,19 @@ class FIOBIT<bits<2> t, dag outs, dag ins, string asmstr, list<dag> pattern>
377377
let Inst{2-0} = b{2-0};
378378
}
379379

380+
class FIO16<bit type, dag outs, dag ins, string asmstr, list<dag> pattern>
381+
: AVRInst16<outs, ins, asmstr, pattern>
382+
{
383+
bits<7> k;
384+
bits<4> d;
385+
386+
let Inst{15-12} = 0b1010;
387+
let Inst{11} = type;
388+
let Inst{10-8} = k{6-4};
389+
let Inst{7-4} = d;
390+
let Inst{3-0} = k{3-0};
391+
}
392+
380393
//===----------------------------------------------------------------------===//
381394
// BST/BLD instruction.
382395
// <|1111|1ttd|dddd|0bbb>

lib/Target/AVR/AVRInstrInfo.td

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def imm0_63_neg : PatLeaf<(imm),
8787
}], imm16_neg_XFORM>;
8888

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

9192
def ioaddr_XFORM : SDNodeXForm<imm,
9293
[{
@@ -1135,6 +1136,19 @@ isReMaterializable = 1 in
11351136
Requires<[HasSRAM]>;
11361137
}
11371138

1139+
// Indirect load from data space to register.
1140+
// FIXME:
1141+
// - make this a physical instruction (not a pseudo)
1142+
// - map r0..r15 onto r16..r31 so that the numbers match up.
1143+
// - do weird MSB inversion as specified in datsheet
1144+
// encoding:
1145+
def LDS16KRr : FIO16<0,
1146+
(outs),
1147+
(ins uimm7:$k, GPR8hi:$rd),
1148+
"sts\t$k, $rd",
1149+
[store i8:$rd, imm:$k]>,
1150+
Requires<[HasTinyEncoding]>;
1151+
11381152
// Indirect loads.
11391153
let canFoldAsLoad = 1,
11401154
isReMaterializable = 1 in
@@ -1275,6 +1289,19 @@ def STSKRr : F32DM<0b1,
12751289
[(store i8:$rd, imm:$k)]>,
12761290
Requires<[HasSRAM]>;
12771291

1292+
// Indirect store from register to data space.
1293+
// FIXME:
1294+
// - make this a physical instruction (not a pseudo)
1295+
// - map r0..r15 onto r16..r31 so that the numbers match up.
1296+
// - do weird MSB inversion as specified in datsheet
1297+
// encoding:
1298+
def STS16KRr : FIO16<1,
1299+
(outs),
1300+
(ins uimm7:$k, GPR8hi:$rd),
1301+
"sts\t$k, $rd",
1302+
[store i8:$rd, imm:$k]>,
1303+
Requires<[HasTinyEncoding]>;
1304+
12781305
// STSW K+1:K, Rr+1:Rr
12791306
//
12801307
// Expands to:

lib/Target/AVR/AVRRegisterInfo.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def GPR8lo : RegisterClass<"AVR", [i8], 8,
130130
add R15, R14, R13, R12, R11, R10, R9, R8, R7, R6, R5, R4, R3, R2, R0, R1
131131
)>;
132132

133+
// Upper registers r0..r15
134+
def GPR8hi : RegisterClass<"AVR", [i8], 8,
135+
(
136+
add R16, R17, R18, R19, R20, R21, R22, R23,
137+
R24, R25, R26, R27, R28, R29, R30, R31
138+
)>;
139+
133140
// 8-bit register class for instructions which take immediates.
134141
def LD8 : RegisterClass<"AVR", [i8], 8,
135142
(

0 commit comments

Comments
 (0)