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

Commit 2861e1c

Browse files
author
Dylan McKay
committed
[AVR] Rewrote subtarget feature support
Closes #57.
1 parent 56c7aa9 commit 2861e1c

35 files changed

+390
-332
lines changed

lib/Target/AVR/AVR.td

+148-157
Large diffs are not rendered by default.

lib/Target/AVR/AVRInstrInfo.td

+151-78
Large diffs are not rendered by default.

lib/Target/AVR/AVRSubtarget.cpp

+6-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,12 @@ AVRSubtarget::AVRSubtarget(const std::string &TT, const std::string &CPU,
3333
TLInfo(TM),
3434
TSInfo(TM),
3535

36-
// Supported instructions
37-
HasLPM(false), HasLPMX(false), HasELPM(false), HasELPMX(false),
38-
HasSPM(false), HasSPMX(false),
39-
HasMUL(false), HasFMUL(false),
40-
HasMOVW(false),
41-
HasDES(false),
42-
HasBREAK(false),
43-
SupportsRMW(false),
44-
45-
// Other features
46-
HasSRAM(false),
47-
HasEIND(false),
48-
IsTiny(false),
49-
IsMega(false)
36+
// Subtarget features
37+
m_hasSRAM(false), m_hasJMPCALL(false), m_hasIJMPCALL(false), m_hasEIJMPCALL(false),
38+
m_hasADDSUBIW(false), m_hasSmallStack(false), m_hasMOVW(false), m_hasLPM(false),
39+
m_hasLPMX(false), m_hasELPM(false), m_hasELPMX(false), m_hasSPM(false), m_hasSPMX(false),
40+
m_hasDES(false), m_supportsRMW(false), m_supportsMultiplication(false),
41+
m_hasBREAK(false), m_hasTinyEncoding(false), m_DummyFeature(false)
5042
{
5143
// Parse features string.
5244
ParseSubtargetFeatures(CPU, FS);

lib/Target/AVR/AVRSubtarget.h

+54-52
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@
3030

3131
namespace llvm
3232
{
33-
34-
class StringRef;
35-
33+
//! \brief Holds information about an AVR subtarget.
3634
class AVRSubtarget : public AVRGenSubtargetInfo
3735
{
3836
virtual void anchor();
37+
3938
public:
40-
/// This constructor initializes the data members to match that
41-
/// of the specified triple.
42-
///
39+
//! \brief Creates an AVR subtarget.
40+
//! \param TT The target triple.
41+
//! \param CPU The CPU to target.
42+
//! \param FS The feature string.
43+
//! \param TM The target machine.
4344
AVRSubtarget(const std::string &TT, const std::string &CPU,
4445
const std::string &FS, AVRTargetMachine &TM);
4546

@@ -49,62 +50,63 @@ class AVRSubtarget : public AVRGenSubtargetInfo
4950
const AVRSelectionDAGInfo *getSelectionDAGInfo() const override { return &TSInfo; }
5051
const AVRRegisterInfo *getRegisterInfo() const override { return &InstrInfo.getRegisterInfo(); }
5152

52-
/// ParseSubtargetFeatures - Parses features string setting specified
53-
/// subtarget options. Definition of function is auto generated by tblgen.
53+
/// \brief Parses a subtarget feature string, setting appropriate options.
54+
/// \note Definition of function is auto generated by `tblgen`.
5455
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
5556

56-
bool hasLPM() const { return this->HasLPM; }
57-
bool hasLPMX() const { return this->HasLPMX; }
58-
59-
bool hasELPM() const { return this->HasELPM; }
60-
bool hasELPMX() const { return this->HasELPMX; }
61-
62-
bool hasSPM() const { return this->HasSPM; }
63-
bool hasSPMX() const { return this->HasSPMX; }
64-
65-
bool hasMUL() const { return this->HasMUL; }
66-
bool hasFMUL() const { return this->HasFMUL; }
67-
68-
bool hasMOVW() const { return this->HasMOVW; }
69-
bool hasDES() const { return this->HasDES; }
70-
bool hasBREAK() const { return this->HasBREAK; }
71-
bool supportsRMW() const { return this->SupportsRMW; }
72-
73-
bool hasSRAM() const { return this->HasSRAM; }
74-
bool hasEIND() const { return this->HasEIND; }
75-
76-
bool isTiny() const { return this->IsTiny; }
77-
bool isMega() const { return this->IsMega; }
57+
// Subtarget feature getters.
58+
// See AVR.td for details.
59+
bool hasSRAM() const { return this->m_hasSRAM; }
60+
bool hasJMPCALL() const { return this->m_hasJMPCALL; }
61+
bool hasIJMPCALL() const { return this->m_hasIJMPCALL; }
62+
bool hasEIJMPCALL() const { return this->m_hasEIJMPCALL; }
63+
bool hasADDSUBIW() const { return this->m_hasADDSUBIW; }
64+
bool hasSmallStack() const { return m_hasSmallStack; }
65+
bool hasMOVW() const { return this->m_hasMOVW; }
66+
bool hasLPM() const { return this->m_hasLPM; }
67+
bool hasLPMX() const { return this->m_hasLPMX; }
68+
bool hasELPM() const { return this->m_hasELPM; }
69+
bool hasELPMX() const { return this->m_hasELPMX; }
70+
bool hasSPM() const { return this->m_hasSPM; }
71+
bool hasSPMX() const { return this->m_hasSPMX; }
72+
bool hasDES() const { return this->m_hasDES; }
73+
bool supportsRMW() const { return this->m_supportsRMW; }
74+
bool supportsMultiplication() const { return this->m_supportsMultiplication; }
75+
bool hasBREAK() const { return this->m_hasBREAK; }
76+
bool hasTinyEncoding() const { return this->m_hasTinyEncoding; }
7877

7978
private:
8079

8180
AVRInstrInfo InstrInfo;
8281
AVRFrameLowering FrameLowering;
8382
AVRTargetLowering TLInfo;
8483
AVRSelectionDAGInfo TSInfo;
85-
86-
// Supported instructions
87-
bool HasLPM;
88-
bool HasLPMX;
89-
bool HasELPM;
90-
bool HasELPMX;
91-
bool HasSPM;
92-
bool HasSPMX;
93-
bool HasMUL;
94-
bool HasFMUL;
95-
bool HasMOVW;
96-
bool HasDES;
97-
bool HasBREAK;
98-
bool SupportsRMW;
99-
100-
// Other features
101-
bool HasSRAM;
102-
bool HasEIND;
103-
bool IsTiny;
104-
bool IsMega;
105-
84+
85+
// Subtarget feature settings
86+
// See AVR.td for details.
87+
bool m_hasSRAM;
88+
bool m_hasJMPCALL;
89+
bool m_hasIJMPCALL;
90+
bool m_hasEIJMPCALL;
91+
bool m_hasADDSUBIW;
92+
bool m_hasSmallStack;
93+
bool m_hasMOVW;
94+
bool m_hasLPM;
95+
bool m_hasLPMX;
96+
bool m_hasELPM;
97+
bool m_hasELPMX;
98+
bool m_hasSPM;
99+
bool m_hasSPMX;
100+
bool m_hasDES;
101+
bool m_supportsRMW;
102+
bool m_supportsMultiplication;
103+
bool m_hasBREAK;
104+
bool m_hasTinyEncoding;
105+
106106
// Dummy feature value, used by PseudoSubtargetFeature.
107-
bool DummyFeature;
107+
// We cannot have a SubtargetFeature with no variable, so
108+
// we instead bind pseudo features to this variable.
109+
bool m_DummyFeature;
108110
};
109111

110112
} // end namespace llvm

test/MC/AVR/inst-adiw.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=addsubiw -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-call.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=jmpcall -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-des.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=des -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-eicall.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=eijmpcall -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-eijmp.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=eijmpcall -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-elpm.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=elpm,elpmx -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-fmul.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=mul -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-fmuls.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=mul -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-fmulsu.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=mul -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-icall.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=ijmpcall -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-ijmp.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=ijmpcall -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-jmp.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=jmpcall -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-lac.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=rmw -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-las.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=rmw -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-lat.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=rmw -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-ld.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-ldd.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-lds.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-lpm.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -mattr=lpm -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=lpm,lpmx -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-movw.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=movw -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-mul.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=mul -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-muls.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=mul -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-mulsu.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=mul -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-pop.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-push.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-sbiw.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=addsubiw -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-spm.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=spm,spmx -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-st.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-std.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-sts.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=sram -show-encoding < %s | FileCheck %s
22

33

44
foo:

test/MC/AVR/inst-xch.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llvm-mc -triple avr-none -show-encoding < %s | FileCheck %s
1+
; RUN: llvm-mc -triple avr-none -mattr=rmw -show-encoding < %s | FileCheck %s
22

33

44
foo:

0 commit comments

Comments
 (0)